listing/plain: move flags to subject column
parent
ad2a10478e
commit
9d7e877510
|
@ -384,7 +384,7 @@ impl ListingTrait for PlainListing {
|
||||||
pos_dec(self.data_columns.columns[3].size(), (1, 1)),
|
pos_dec(self.data_columns.columns[3].size(), (1, 1)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
for c in grid.row_iter(x..(x + self.data_columns.widths[3]), get_y(upper_left)) {
|
for c in grid.row_iter(x..get_x(bottom_right), get_y(upper_left)) {
|
||||||
grid[c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
grid[c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,31 +482,25 @@ impl ListingTrait for PlainListing {
|
||||||
self.data_columns.widths[0] = self.data_columns.columns[0].size().0;
|
self.data_columns.widths[0] = self.data_columns.columns[0].size().0;
|
||||||
self.data_columns.widths[1] = self.data_columns.columns[1].size().0; /* date*/
|
self.data_columns.widths[1] = self.data_columns.columns[1].size().0; /* date*/
|
||||||
self.data_columns.widths[2] = self.data_columns.columns[2].size().0; /* from */
|
self.data_columns.widths[2] = self.data_columns.columns[2].size().0; /* from */
|
||||||
self.data_columns.widths[3] = self.data_columns.columns[3].size().0; /* flags */
|
self.data_columns.widths[3] = self.data_columns.columns[3].size().0; /* subject */
|
||||||
self.data_columns.widths[4] = self.data_columns.columns[4].size().0; /* subject */
|
|
||||||
|
|
||||||
let min_col_width = std::cmp::min(
|
let min_col_width = std::cmp::min(
|
||||||
15,
|
15,
|
||||||
std::cmp::min(self.data_columns.widths[4], self.data_columns.widths[2]),
|
std::cmp::min(self.data_columns.widths[3], self.data_columns.widths[2]),
|
||||||
);
|
);
|
||||||
if self.data_columns.widths[0] + self.data_columns.widths[1] + 3 * min_col_width + 8 > width
|
if self.data_columns.widths[0] + self.data_columns.widths[1] + 2 * min_col_width + 4 > width
|
||||||
{
|
{
|
||||||
let remainder = width
|
let remainder = width
|
||||||
.saturating_sub(self.data_columns.widths[0])
|
.saturating_sub(self.data_columns.widths[0])
|
||||||
.saturating_sub(self.data_columns.widths[1])
|
.saturating_sub(self.data_columns.widths[1])
|
||||||
.saturating_sub(4);
|
.saturating_sub(2 * 2);
|
||||||
self.data_columns.widths[2] = remainder / 6;
|
self.data_columns.widths[2] = remainder / 6;
|
||||||
self.data_columns.widths[4] =
|
|
||||||
((2 * remainder) / 3).saturating_sub(self.data_columns.widths[3]);
|
|
||||||
} else {
|
} else {
|
||||||
let remainder = width
|
let remainder = width
|
||||||
.saturating_sub(self.data_columns.widths[0])
|
.saturating_sub(self.data_columns.widths[0])
|
||||||
.saturating_sub(self.data_columns.widths[1])
|
.saturating_sub(self.data_columns.widths[1])
|
||||||
.saturating_sub(8);
|
.saturating_sub(3 * 2);
|
||||||
if min_col_width + self.data_columns.widths[4] > remainder {
|
if min_col_width + self.data_columns.widths[3] > remainder {
|
||||||
self.data_columns.widths[4] = remainder
|
|
||||||
.saturating_sub(min_col_width)
|
|
||||||
.saturating_sub(self.data_columns.widths[3]);
|
|
||||||
self.data_columns.widths[2] = min_col_width;
|
self.data_columns.widths[2] = min_col_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,30 +508,24 @@ impl ListingTrait for PlainListing {
|
||||||
/* Page_no has changed, so draw new page */
|
/* Page_no has changed, so draw new page */
|
||||||
let mut x = get_x(upper_left);
|
let mut x = get_x(upper_left);
|
||||||
let mut flag_x = 0;
|
let mut flag_x = 0;
|
||||||
for i in 0..self.data_columns.columns.len() {
|
for i in 0..4 {
|
||||||
let column_width = self.data_columns.columns[i].size().0;
|
let column_width = self.data_columns.widths[i];
|
||||||
if i == 3 {
|
if i == 3 {
|
||||||
flag_x = x;
|
flag_x = x;
|
||||||
}
|
}
|
||||||
if self.data_columns.widths[i] == 0 {
|
if column_width == 0 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
copy_area(
|
copy_area(
|
||||||
grid,
|
grid,
|
||||||
&self.data_columns.columns[i],
|
&self.data_columns.columns[i],
|
||||||
(
|
(set_x(upper_left, x), bottom_right),
|
||||||
set_x(upper_left, x),
|
|
||||||
set_x(
|
|
||||||
bottom_right,
|
|
||||||
std::cmp::min(get_x(bottom_right), x + (self.data_columns.widths[i])),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
(0, top_idx),
|
(0, top_idx),
|
||||||
(column_width.saturating_sub(1), self.length - 1),
|
(column_width.saturating_sub(1), self.length - 1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
x += self.data_columns.widths[i] + 2; // + SEPARATOR
|
x += column_width + 2; // + SEPARATOR
|
||||||
if x > get_x(bottom_right) {
|
if x > get_x(bottom_right) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +760,53 @@ impl PlainListing {
|
||||||
EntryStrings {
|
EntryStrings {
|
||||||
date: DateString(PlainListing::format_date(&e)),
|
date: DateString(PlainListing::format_date(&e)),
|
||||||
subject: SubjectString(subject),
|
subject: SubjectString(subject),
|
||||||
flag: FlagString(format!("{}", if e.has_attachments() { "📎" } else { "" },)),
|
flag: FlagString(format!(
|
||||||
|
"{selected}{unseen}{attachments}{whitespace}",
|
||||||
|
selected = if self.selection.get(&e.hash()).cloned().unwrap_or(false) {
|
||||||
|
mailbox_settings!(
|
||||||
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
|
.listing
|
||||||
|
.selected_flag
|
||||||
|
)
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.as_str())
|
||||||
|
.unwrap_or(super::DEFAULT_SELECTED_FLAG)
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
},
|
||||||
|
unseen = if !e.is_seen() {
|
||||||
|
mailbox_settings!(
|
||||||
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
|
.listing
|
||||||
|
.unseen_flag
|
||||||
|
)
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.as_str())
|
||||||
|
.unwrap_or(super::DEFAULT_UNSEEN_FLAG)
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
},
|
||||||
|
attachments = if e.has_attachments() {
|
||||||
|
mailbox_settings!(
|
||||||
|
context[self.cursor_pos.0][&self.cursor_pos.1]
|
||||||
|
.listing
|
||||||
|
.attachment_flag
|
||||||
|
)
|
||||||
|
.as_ref()
|
||||||
|
.map(|s| s.as_str())
|
||||||
|
.unwrap_or(super::DEFAULT_ATTACHMENT_FLAG)
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
},
|
||||||
|
whitespace = if self.selection.get(&e.hash()).cloned().unwrap_or(false)
|
||||||
|
|| !e.is_seen()
|
||||||
|
|| e.has_attachments()
|
||||||
|
{
|
||||||
|
" "
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
},
|
||||||
|
)),
|
||||||
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
from: FromString(address_list!((e.from()) as comma_sep_list)),
|
||||||
tags: TagString(tags, colors),
|
tags: TagString(tags, colors),
|
||||||
}
|
}
|
||||||
|
@ -817,10 +851,12 @@ impl PlainListing {
|
||||||
let entry_strings = self.make_entry_string(envelope, context);
|
let entry_strings = self.make_entry_string(envelope, context);
|
||||||
min_width.1 = cmp::max(min_width.1, entry_strings.date.grapheme_width()); /* date */
|
min_width.1 = cmp::max(min_width.1, entry_strings.date.grapheme_width()); /* date */
|
||||||
min_width.2 = cmp::max(min_width.2, entry_strings.from.grapheme_width()); /* from */
|
min_width.2 = cmp::max(min_width.2, entry_strings.from.grapheme_width()); /* from */
|
||||||
min_width.3 = cmp::max(min_width.3, entry_strings.flag.grapheme_width()); /* flags */
|
min_width.3 = cmp::max(
|
||||||
min_width.4 = cmp::max(
|
min_width.3,
|
||||||
min_width.4,
|
entry_strings.flag.grapheme_width()
|
||||||
entry_strings.subject.grapheme_width() + 1 + entry_strings.tags.grapheme_width(),
|
+ entry_strings.subject.grapheme_width()
|
||||||
|
+ 1
|
||||||
|
+ entry_strings.tags.grapheme_width(),
|
||||||
); /* tags + subject */
|
); /* tags + subject */
|
||||||
rows.push(entry_strings);
|
rows.push(entry_strings);
|
||||||
|
|
||||||
|
@ -840,12 +876,9 @@ impl PlainListing {
|
||||||
/* from column */
|
/* from column */
|
||||||
self.data_columns.columns[2] =
|
self.data_columns.columns[2] =
|
||||||
CellBuffer::new_with_context(min_width.2, rows.len(), None, context);
|
CellBuffer::new_with_context(min_width.2, rows.len(), None, context);
|
||||||
/* flags column */
|
/* subject column */
|
||||||
self.data_columns.columns[3] =
|
self.data_columns.columns[3] =
|
||||||
CellBuffer::new_with_context(min_width.3, rows.len(), None, context);
|
CellBuffer::new_with_context(min_width.3, rows.len(), None, context);
|
||||||
/* subject column */
|
|
||||||
self.data_columns.columns[4] =
|
|
||||||
CellBuffer::new_with_context(min_width.4, rows.len(), None, context);
|
|
||||||
|
|
||||||
let iter = if self.filter_term.is_empty() {
|
let iter = if self.filter_term.is_empty() {
|
||||||
Box::new(self.local_collection.iter().cloned())
|
Box::new(self.local_collection.iter().cloned())
|
||||||
|
@ -923,16 +956,13 @@ impl PlainListing {
|
||||||
((0, idx), (min_width.3, idx)),
|
((0, idx), (min_width.3, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[3].row_iter(x..min_width.3, idx) {
|
|
||||||
columns[3][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
|
||||||
}
|
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.subject,
|
&strings.subject,
|
||||||
&mut columns[4],
|
&mut columns[3],
|
||||||
row_attr.fg,
|
row_attr.fg,
|
||||||
row_attr.bg,
|
row_attr.bg,
|
||||||
row_attr.attrs,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.4, idx)),
|
((x, idx), (min_width.3, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let x = {
|
let x = {
|
||||||
|
@ -941,38 +971,42 @@ impl PlainListing {
|
||||||
let color = color.unwrap_or(self.color_cache.tag_default.bg);
|
let color = color.unwrap_or(self.color_cache.tag_default.bg);
|
||||||
let (_x, _) = write_string_to_grid(
|
let (_x, _) = write_string_to_grid(
|
||||||
t,
|
t,
|
||||||
&mut columns[4],
|
&mut columns[3],
|
||||||
self.color_cache.tag_default.fg,
|
self.color_cache.tag_default.fg,
|
||||||
color,
|
color,
|
||||||
self.color_cache.tag_default.attrs,
|
self.color_cache.tag_default.attrs,
|
||||||
((x + 1, idx), (min_width.4, idx)),
|
((x + 1, idx), (min_width.3, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[4].row_iter(x..(x + 1), idx) {
|
for c in columns[3].row_iter(x..(x + 1), idx) {
|
||||||
columns[4][c].set_bg(color);
|
columns[3][c].set_bg(color);
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter(_x..(_x + 1), idx) {
|
for c in columns[3].row_iter(_x..(_x + 1), idx) {
|
||||||
columns[4][c].set_bg(color).set_keep_bg(true);
|
columns[3][c].set_bg(color).set_keep_bg(true);
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter((x + 1)..(_x + 1), idx) {
|
for c in columns[3].row_iter((x + 1)..(_x + 1), idx) {
|
||||||
columns[4][c].set_keep_fg(true).set_keep_bg(true);
|
columns[3][c].set_keep_fg(true).set_keep_bg(true);
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter(x..(x + 1), idx) {
|
for c in columns[3].row_iter(x..(x + 1), idx) {
|
||||||
columns[4][c].set_keep_bg(true);
|
columns[3][c].set_keep_bg(true);
|
||||||
}
|
}
|
||||||
x = _x + 1;
|
x = _x + 1;
|
||||||
}
|
}
|
||||||
x
|
x
|
||||||
};
|
};
|
||||||
for c in columns[4].row_iter(x..min_width.4, idx) {
|
for c in columns[3].row_iter(x..min_width.3, idx) {
|
||||||
columns[4][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
columns[3][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
if context.accounts[&self.cursor_pos.0]
|
/* Set fg color for flags */
|
||||||
.collection
|
let mut x = 0;
|
||||||
.get_env(i)
|
if self.selection.get(&i).cloned().unwrap_or(false) {
|
||||||
.has_attachments()
|
x += 1;
|
||||||
{
|
}
|
||||||
columns[3][(0, idx)].set_fg(Color::Byte(103));
|
if !envelope.is_seen() {
|
||||||
|
x += 1;
|
||||||
|
}
|
||||||
|
if envelope.has_attachments() {
|
||||||
|
columns[3][(x, idx)].set_fg(self.color_cache.attachment_flag.fg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.length == 0 && self.filter_term.is_empty() {
|
if self.length == 0 && self.filter_term.is_empty() {
|
||||||
|
|
Loading…
Reference in New Issue