fix: handle overlapping columns in listview
This commit is contained in:
@@ -29,6 +29,7 @@ use clipboard::{ClipboardContext, ClipboardProvider};
|
|||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
pub type Paginator<I> = Box<dyn Fn(Arc<RwLock<Vec<I>>>) + Send + Sync>;
|
pub type Paginator<I> = Box<dyn Fn(Arc<RwLock<Vec<I>>>) + Send + Sync>;
|
||||||
|
|
||||||
pub struct Pagination<I: ListItem> {
|
pub struct Pagination<I: ListItem> {
|
||||||
max_content: Arc<RwLock<Option<usize>>>,
|
max_content: Arc<RwLock<Option<usize>>>,
|
||||||
callback: Arc<RwLock<Option<Paginator<I>>>>,
|
callback: Arc<RwLock<Option<Paginator<I>>>>,
|
||||||
@@ -230,8 +231,7 @@ impl<I: ListItem> View for ListView<I> {
|
|||||||
let left = item.display_left();
|
let left = item.display_left();
|
||||||
let center = item.display_center();
|
let center = item.display_center();
|
||||||
let right = item.display_right(self.library.clone());
|
let right = item.display_right(self.library.clone());
|
||||||
|
let draw_center = !center.is_empty();
|
||||||
let center_offset = printer.size.x / 2;
|
|
||||||
|
|
||||||
// draw left string
|
// draw left string
|
||||||
printer.with_color(style, |printer| {
|
printer.with_color(style, |printer| {
|
||||||
@@ -259,25 +259,35 @@ impl<I: ListItem> View for ListView<I> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// left string cut off indicator
|
// left string cut off indicator
|
||||||
let max_length = center_offset.saturating_sub(1);
|
let center_offset = printer.size.x / 2;
|
||||||
if max_length < left.width() {
|
let left_max_length = if draw_center {
|
||||||
let offset = max_length.saturating_sub(1);
|
center_offset.saturating_sub(1)
|
||||||
|
} else {
|
||||||
|
printer.size.x.saturating_sub(right.width() + 1)
|
||||||
|
};
|
||||||
|
|
||||||
|
if left_max_length < left.width() {
|
||||||
|
let offset = left_max_length.saturating_sub(1);
|
||||||
printer.with_color(style, |printer| {
|
printer.with_color(style, |printer| {
|
||||||
|
printer.print_hline((offset, 0), printer.size.x, " ");
|
||||||
printer.print((offset, 0), "..");
|
printer.print((offset, 0), "..");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
printer.with_color(style, |printer| {
|
// draw center string
|
||||||
printer.print((center_offset, 0), ¢er);
|
if draw_center {
|
||||||
});
|
|
||||||
|
|
||||||
// center string cut off indicator
|
|
||||||
let max_length = printer.size.x.saturating_sub(right.width() + 1);
|
|
||||||
if max_length < center_offset + center.width() {
|
|
||||||
let offset = max_length.saturating_sub(1);
|
|
||||||
printer.with_color(style, |printer| {
|
printer.with_color(style, |printer| {
|
||||||
printer.print((offset, 0), "..");
|
printer.print((center_offset, 0), ¢er);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// center string cut off indicator
|
||||||
|
let max_length = printer.size.x.saturating_sub(right.width() + 1);
|
||||||
|
if max_length < center_offset + center.width() {
|
||||||
|
let offset = max_length.saturating_sub(1);
|
||||||
|
printer.with_color(style, |printer| {
|
||||||
|
printer.print((offset, 0), "..");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw right string
|
// draw right string
|
||||||
|
|||||||
Reference in New Issue
Block a user