Fix ThreadedListing for new TUI API

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/312/head
Manos Pitsidianakis 6 months ago
parent 3b4acc15a5
commit 28fa66cc2a
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -236,8 +236,8 @@ impl<T> RowsState<T> {
mod compact; mod compact;
pub use self::compact::*; pub use self::compact::*;
//mod thread; mod thread;
//pub use self::thread::*; pub use self::thread::*;
mod plain; mod plain;
pub use self::plain::*; pub use self::plain::*;
@ -411,7 +411,7 @@ macro_rules! address_list {
let mut ret: String = let mut ret: String =
$name $name
.into_iter() .into_iter()
.fold(String::new(), |mut s: String, n: &Address| { .fold(String::new(), |mut s: String, n: &melib::Address| {
s.extend(n.display().to_string().chars()); s.extend(n.display().to_string().chars());
s.push_str(", "); s.push_str(", ");
s s
@ -930,7 +930,7 @@ pub enum ListingComponent {
//Conversations(Box<ConversationsListing>), //Conversations(Box<ConversationsListing>),
Offline(Box<OfflineListing>), Offline(Box<OfflineListing>),
Plain(Box<PlainListing>), Plain(Box<PlainListing>),
//Threaded(Box<ThreadListing>), Threaded(Box<ThreadListing>),
} }
use crate::ListingComponent::*; use crate::ListingComponent::*;
@ -943,7 +943,7 @@ impl std::ops::Deref for ListingComponent {
//Conversations(ref l) => l.as_ref(), //Conversations(ref l) => l.as_ref(),
Offline(ref l) => l.as_ref(), Offline(ref l) => l.as_ref(),
Plain(ref l) => l.as_ref(), Plain(ref l) => l.as_ref(),
//Threaded(ref l) => l.as_ref(), Threaded(ref l) => l.as_ref(),
} }
} }
} }
@ -955,7 +955,7 @@ impl std::ops::DerefMut for ListingComponent {
//Conversations(l) => l.as_mut(), //Conversations(l) => l.as_mut(),
Offline(l) => l.as_mut(), Offline(l) => l.as_mut(),
Plain(l) => l.as_mut(), Plain(l) => l.as_mut(),
//Threaded(l) => l.as_mut(), Threaded(l) => l.as_mut(),
} }
} }
} }
@ -967,7 +967,7 @@ impl ListingComponent {
//Conversations(l) => l.as_component().id(), //Conversations(l) => l.as_component().id(),
Offline(l) => l.as_component().id(), Offline(l) => l.as_component().id(),
Plain(l) => l.as_component().id(), Plain(l) => l.as_component().id(),
//Threaded(l) => l.as_component().id(), Threaded(l) => l.as_component().id(),
} }
} }
} }
@ -1044,7 +1044,7 @@ impl std::fmt::Display for Listing {
//Conversations(ref l) => write!(f, "{}", l), //Conversations(ref l) => write!(f, "{}", l),
Offline(ref l) => write!(f, "{}", l), Offline(ref l) => write!(f, "{}", l),
Plain(ref l) => write!(f, "{}", l), Plain(ref l) => write!(f, "{}", l),
//Threaded(ref l) => write!(f, "{}", l), Threaded(ref l) => write!(f, "{}", l),
} }
} }
} }
@ -2461,7 +2461,7 @@ impl Component for Listing {
//Conversations(l) => l.as_component(), //Conversations(l) => l.as_component(),
Offline(l) => l.as_component(), Offline(l) => l.as_component(),
Plain(l) => l.as_component(), Plain(l) => l.as_component(),
//Threaded(l) => l.as_component(), Threaded(l) => l.as_component(),
}, },
); );
@ -2477,7 +2477,7 @@ impl Component for Listing {
//Conversations(l) => l.as_component_mut(), //Conversations(l) => l.as_component_mut(),
Offline(l) => l.as_component_mut(), Offline(l) => l.as_component_mut(),
Plain(l) => l.as_component_mut(), Plain(l) => l.as_component_mut(),
//Threaded(l) => l.as_component_mut(), Threaded(l) => l.as_component_mut(),
}, },
); );
@ -3124,7 +3124,7 @@ impl Listing {
fn set_index_style(&mut self, new_style: IndexStyle, context: &mut Context) { fn set_index_style(&mut self, new_style: IndexStyle, context: &mut Context) {
let old = match new_style { let old = match new_style {
IndexStyle::Conversations | IndexStyle::Threaded | IndexStyle::Plain => { IndexStyle::Conversations | IndexStyle::Plain => {
if matches!(self.component, Plain(_)) { if matches!(self.component, Plain(_)) {
return; return;
} }
@ -3134,17 +3134,16 @@ impl Listing {
Plain(PlainListing::new(self.id, coordinates)), Plain(PlainListing::new(self.id, coordinates)),
) )
} }
//IndexStyle::Threaded => { IndexStyle::Threaded => {
// return; if matches!(self.component, Threaded(_)) {
// //if matches!(self.component, Threaded(_)) { return;
// // return; }
// //} let coordinates = self.component.coordinates();
// //let coordinates = self.component.coordinates(); std::mem::replace(
// //std::mem::replace( &mut self.component,
// // &mut self.component, Threaded(ThreadListing::new(self.id, coordinates, context)),
// // Threaded(ThreadListing::new(self.id, coordinates, )
// // context)), //) }
//}
IndexStyle::Compact => { IndexStyle::Compact => {
if matches!(self.component, Compact(_)) { if matches!(self.component, Compact(_)) {
return; return;

@ -21,7 +21,7 @@
use std::iter::FromIterator; use std::iter::FromIterator;
use melib::{Address, SortField, SortOrder, ThreadNode}; use melib::{SortField, SortOrder, ThreadNode};
use super::{EntryStrings, *}; use super::{EntryStrings, *};
use crate::{components::PageMovement, jobs::JoinHandle}; use crate::{components::PageMovement, jobs::JoinHandle};
@ -339,8 +339,6 @@ impl ListingTrait for PlainListing {
self.cursor_pos.2 += 1; self.cursor_pos.2 += 1;
self.new_cursor_pos.2 += 1; self.new_cursor_pos.2 += 1;
self.set_focus(Focus::Entry, context); self.set_focus(Focus::Entry, context);
self.cursor_pos.2 -= 1;
self.new_cursor_pos.2 -= 1;
} }
} }
@ -356,8 +354,6 @@ impl ListingTrait for PlainListing {
self.cursor_pos.2 -= 1; self.cursor_pos.2 -= 1;
self.new_cursor_pos.2 -= 1; self.new_cursor_pos.2 -= 1;
self.set_focus(Focus::Entry, context); self.set_focus(Focus::Entry, context);
self.cursor_pos.2 += 1;
self.new_cursor_pos.2 += 1;
} }
} }
@ -478,8 +474,8 @@ impl ListingTrait for PlainListing {
let top_idx = page_no * rows; let top_idx = page_no * rows;
/* If cursor position has changed, remove the highlight from the previous // If cursor position has changed, remove the highlight from the previous
* position and apply it in the new one. */ // position and apply it in the new one.
if self.cursor_pos.2 != self.new_cursor_pos.2 && prev_page_no == page_no { if self.cursor_pos.2 != self.new_cursor_pos.2 && prev_page_no == page_no {
let old_cursor_pos = self.cursor_pos; let old_cursor_pos = self.cursor_pos;
self.cursor_pos = self.new_cursor_pos; self.cursor_pos = self.new_cursor_pos;
@ -619,12 +615,10 @@ impl ListingTrait for PlainListing {
fn set_focus(&mut self, new_value: Focus, context: &mut Context) { fn set_focus(&mut self, new_value: Focus, context: &mut Context) {
match new_value { match new_value {
Focus::None => { Focus::None => {
//self.view .process_event(&mut UIEvent::VisibilityChange(false), context);
self.dirty = true; self.dirty = true;
/* If self.rows.row_updates is not empty and we exit a thread, the row_update // If self.rows.row_updates is not empty and we exit a thread, the row_update
* events will be performed but the list will not be drawn. // events will be performed but the list will not be drawn.
* So force a draw in any case. // So force a draw in any case.
*/
self.force_draw = true; self.force_draw = true;
} }
Focus::Entry => { Focus::Entry => {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save