aboutsummaryrefslogtreecommitdiff
path: root/helix-tui/src/widgets
diff options
context:
space:
mode:
authormWalrus2023-03-22 14:38:34 +0000
committerBlaž Hrastnik2023-03-31 06:19:17 +0000
commite72be529968071abcd5fce1d9a06e8e2e2bbaacf (patch)
tree8c0f12984f736c8fce0b0241e541073218f318a4 /helix-tui/src/widgets
parenta863fd89e149ae698f1c7d1d493cc4197abd430a (diff)
Truncate paths in the file picker (#6410)
Diffstat (limited to 'helix-tui/src/widgets')
-rw-r--r--helix-tui/src/widgets/table.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/helix-tui/src/widgets/table.rs b/helix-tui/src/widgets/table.rs
index 400f65e0..97762167 100644
--- a/helix-tui/src/widgets/table.rs
+++ b/helix-tui/src/widgets/table.rs
@@ -354,7 +354,13 @@ impl TableState {
impl<'a> Table<'a> {
// type State = TableState;
- pub fn render_table(mut self, area: Rect, buf: &mut Buffer, state: &mut TableState) {
+ pub fn render_table(
+ mut self,
+ area: Rect,
+ buf: &mut Buffer,
+ state: &mut TableState,
+ truncate: bool,
+ ) {
if area.area() == 0 {
return;
}
@@ -401,6 +407,7 @@ impl<'a> Table<'a> {
width: *width,
height: max_header_height,
},
+ truncate,
);
col += *width + self.column_spacing;
}
@@ -457,6 +464,7 @@ impl<'a> Table<'a> {
width: *width,
height: table_row.height,
},
+ truncate,
);
col += *width + self.column_spacing;
}
@@ -464,20 +472,24 @@ impl<'a> Table<'a> {
}
}
-fn render_cell(buf: &mut Buffer, cell: &Cell, area: Rect) {
+fn render_cell(buf: &mut Buffer, cell: &Cell, area: Rect, truncate: bool) {
buf.set_style(area, cell.style);
for (i, spans) in cell.content.lines.iter().enumerate() {
if i as u16 >= area.height {
break;
}
- buf.set_spans(area.x, area.y + i as u16, spans, area.width);
+ if truncate {
+ buf.set_spans_truncated(area.x, area.y + i as u16, spans, area.width);
+ } else {
+ buf.set_spans(area.x, area.y + i as u16, spans, area.width);
+ }
}
}
impl<'a> Widget for Table<'a> {
fn render(self, area: Rect, buf: &mut Buffer) {
let mut state = TableState::default();
- Table::render_table(self, area, buf, &mut state);
+ Table::render_table(self, area, buf, &mut state, false);
}
}