mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-23 05:19:48 -04:00
feat: show the currently selected sheet in top of the table
This commit is contained in:
parent
a70a1451c1
commit
ba504a88c7
@ -448,8 +448,9 @@ impl<'ws> Workspace<'ws> {
|
||||
let mut rs: Vec<Box<dyn Fn(Rect, &mut Buffer, &mut Self)>> = vec![
|
||||
Box::new(|rect: Rect, buf: &mut Buffer, ws: &mut Self| ws.text_area.render(rect, buf)),
|
||||
Box::new(move |rect: Rect, buf: &mut Buffer, ws: &mut Self| {
|
||||
let sheet_name = ws.book.get_sheet_name().unwrap_or("Unknown");
|
||||
// Table widget display
|
||||
let table_block = Block::bordered();
|
||||
let table_block = Block::bordered().title_top(sheet_name);
|
||||
let table_inner: Table = TryFrom::try_from(&ws.book).expect("");
|
||||
let table = table_inner.block(table_block);
|
||||
// https://docs.rs/ratatui/latest/ratatui/widgets/struct.TableState.html
|
||||
|
@ -60,6 +60,7 @@ impl<'t, 'book: 't> TryFrom<&'book Book> for Table<'t> {
|
||||
// TODO(zaphar): This is apparently expensive. Maybe we can cache it somehow?
|
||||
// We should do the correct thing here if this fails
|
||||
let (row_count, col_count) = value.get_size()?;
|
||||
let sheet_name = value.get_sheet_name()?;
|
||||
let rows: Vec<Row> = (1..=row_count)
|
||||
.into_iter()
|
||||
.map(|ri| {
|
||||
@ -99,7 +100,7 @@ impl<'t, 'book: 't> TryFrom<&'book Book> for Table<'t> {
|
||||
Cell::new(COLNAMES[i % 26].repeat(count))
|
||||
}));
|
||||
Ok(Table::new(rows, constraints)
|
||||
.block(Block::bordered())
|
||||
.block(Block::bordered().title_top(sheet_name))
|
||||
.header(Row::new(header).underlined())
|
||||
.column_spacing(1)
|
||||
.flex(Flex::SpaceAround))
|
||||
|
Loading…
x
Reference in New Issue
Block a user