Fix ThreadedListing for new TUI API

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/312/head
Manos Pitsidianakis 2023-12-02 00:36:33 +02:00
parent 3b4acc15a5
commit 28fa66cc2a
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
3 changed files with 587 additions and 558 deletions

View File

@ -236,8 +236,8 @@ impl<T> RowsState<T> {
mod compact;
pub use self::compact::*;
//mod thread;
//pub use self::thread::*;
mod thread;
pub use self::thread::*;
mod plain;
pub use self::plain::*;
@ -411,7 +411,7 @@ macro_rules! address_list {
let mut ret: String =
$name
.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.push_str(", ");
s
@ -930,7 +930,7 @@ pub enum ListingComponent {
//Conversations(Box<ConversationsListing>),
Offline(Box<OfflineListing>),
Plain(Box<PlainListing>),
//Threaded(Box<ThreadListing>),
Threaded(Box<ThreadListing>),
}
use crate::ListingComponent::*;
@ -943,7 +943,7 @@ impl std::ops::Deref for ListingComponent {
//Conversations(ref l) => l.as_ref(),
Offline(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(),
Offline(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(),
Offline(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),
Offline(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(),
Offline(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(),
Offline(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) {
let old = match new_style {
IndexStyle::Conversations | IndexStyle::Threaded | IndexStyle::Plain => {
IndexStyle::Conversations | IndexStyle::Plain => {
if matches!(self.component, Plain(_)) {
return;
}
@ -3134,17 +3134,16 @@ impl Listing {
Plain(PlainListing::new(self.id, coordinates)),
)
}
//IndexStyle::Threaded => {
// return;
// //if matches!(self.component, Threaded(_)) {
// // return;
// //}
// //let coordinates = self.component.coordinates();
// //std::mem::replace(
// // &mut self.component,
// // Threaded(ThreadListing::new(self.id, coordinates,
// // context)), //)
//}
IndexStyle::Threaded => {
if matches!(self.component, Threaded(_)) {
return;
}
let coordinates = self.component.coordinates();
std::mem::replace(
&mut self.component,
Threaded(ThreadListing::new(self.id, coordinates, context)),
)
}
IndexStyle::Compact => {
if matches!(self.component, Compact(_)) {
return;

View File

@ -21,7 +21,7 @@
use std::iter::FromIterator;
use melib::{Address, SortField, SortOrder, ThreadNode};
use melib::{SortField, SortOrder, ThreadNode};
use super::{EntryStrings, *};
use crate::{components::PageMovement, jobs::JoinHandle};
@ -339,8 +339,6 @@ impl ListingTrait for PlainListing {
self.cursor_pos.2 += 1;
self.new_cursor_pos.2 += 1;
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.new_cursor_pos.2 -= 1;
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;
/* If cursor position has changed, remove the highlight from the previous
* position and apply it in the new one. */
// If cursor position has changed, remove the highlight from the previous
// position and apply it in the new one.
if self.cursor_pos.2 != self.new_cursor_pos.2 && prev_page_no == page_no {
let old_cursor_pos = self.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) {
match new_value {
Focus::None => {
//self.view .process_event(&mut UIEvent::VisibilityChange(false), context);
self.dirty = true;
/* 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.
* So force a draw in any case.
*/
// 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.
// So force a draw in any case.
self.force_draw = true;
}
Focus::Entry => {

File diff suppressed because it is too large Load Diff