diff options
| author | lukeflo | 2024-10-21 12:27:15 +0200 |
|---|---|---|
| committer | lukeflo | 2024-10-21 12:27:15 +0200 |
| commit | 2aae195f2ebb3e970ae44b725f46e28ff3a26a63 (patch) | |
| tree | 482ae156d760354c9ddebe2d2ab6a9833ae53e84 /src/frontend/ui.rs | |
| parent | 23461438ad1ef51cfabf76e1530574e8bac28faa (diff) | |
| parent | 4337f1c8524b3774a9b10ea41543cc89ae7fb5a9 (diff) | |
| download | bibiman-2aae195f2ebb3e970ae44b725f46e28ff3a26a63.tar.gz bibiman-2aae195f2ebb3e970ae44b725f46e28ff3a26a63.zip | |
Merge branch 'bugfixes'
- Separate selecting column and sorting column
- No auto sort after selecting other column
-> Sort only when pressing `s`
- Keep state of sorting when searching
Diffstat (limited to 'src/frontend/ui.rs')
| -rw-r--r-- | src/frontend/ui.rs | 165 |
1 files changed, 99 insertions, 66 deletions
diff --git a/src/frontend/ui.rs b/src/frontend/ui.rs index d4fbba1..59a07f3 100644 --- a/src/frontend/ui.rs +++ b/src/frontend/ui.rs @@ -228,11 +228,8 @@ impl App { .right_aligned() .bg(HEADER_FOOTER_BG) .render(count_area, buf); - // Paragraph::new(Line::from(vec![Span::raw( - // self.main_bibfile.display().to_string(), - // )])) - // .block(block) - // .render(area, buf); + + // Render that stuff Widget::render(block, area, buf) } @@ -266,67 +263,103 @@ impl App { .fg(TEXT_FG_COLOR) .bg(HEADER_FOOTER_BG); + let header_selected_col = Style::default().underlined(); + let header = Row::new(vec![ - if let EntryTableColumn::Authors = self.entry_table.entry_table_selected_column { - Cell::from(Line::from(vec![ - Span::raw("Author").underlined(), - Span::raw(format!( - " {}", - if self.entry_table.entry_table_reversed_sort { - SORTED_ENTRIES_REVERSED - } else { - SORTED_ENTRIES - } - )), - ])) - } else { - Cell::from("Author".to_string()) - }, - if let EntryTableColumn::Title = self.entry_table.entry_table_selected_column { - Cell::from(Line::from(vec![ - Span::raw("Title").underlined(), - Span::raw(format!( - " {}", - if self.entry_table.entry_table_reversed_sort { - SORTED_ENTRIES_REVERSED - } else { - SORTED_ENTRIES - } - )), - ])) - } else { - Cell::from("Title".to_string()) - }, - if let EntryTableColumn::Year = self.entry_table.entry_table_selected_column { - Cell::from(Line::from(vec![ - Span::raw("Year").underlined(), - Span::raw(format!( - " {}", - if self.entry_table.entry_table_reversed_sort { - SORTED_ENTRIES_REVERSED - } else { - SORTED_ENTRIES - } - )), - ])) - } else { - Cell::from("Year".to_string()) - }, - if let EntryTableColumn::Pubtype = self.entry_table.entry_table_selected_column { - Cell::from(Line::from(vec![ - Span::raw("Pubtype").underlined(), - Span::raw(format!( - " {}", - if self.entry_table.entry_table_reversed_sort { - SORTED_ENTRIES_REVERSED - } else { - SORTED_ENTRIES - } - )), - ])) - } else { - Cell::from("Pubtype".to_string()) - }, + Cell::from(Line::from(vec![ + { + if let EntryTableColumn::Authors = self.entry_table.entry_table_selected_column + { + Span::styled("Author", header_selected_col) + } else { + Span::raw("Author") + } + }, + { + if let EntryTableColumn::Authors = self.entry_table.entry_table_sorted_by_col { + Span::raw(format!( + " {}", + if self.entry_table.entry_table_reversed_sort { + SORTED_ENTRIES_REVERSED + } else { + SORTED_ENTRIES + } + )) + } else { + Span::raw("") + } + }, + ])), + Cell::from(Line::from(vec![ + { + if let EntryTableColumn::Title = self.entry_table.entry_table_selected_column { + Span::styled("Title", header_selected_col) + } else { + Span::raw("Title") + } + }, + { + if let EntryTableColumn::Title = self.entry_table.entry_table_sorted_by_col { + Span::raw(format!( + " {}", + if self.entry_table.entry_table_reversed_sort { + SORTED_ENTRIES_REVERSED + } else { + SORTED_ENTRIES + } + )) + } else { + Span::raw("") + } + }, + ])), + Cell::from(Line::from(vec![ + { + if let EntryTableColumn::Year = self.entry_table.entry_table_selected_column { + Span::styled("Year", header_selected_col) + } else { + Span::raw("Year") + } + }, + { + if let EntryTableColumn::Year = self.entry_table.entry_table_sorted_by_col { + Span::raw(format!( + " {}", + if self.entry_table.entry_table_reversed_sort { + SORTED_ENTRIES_REVERSED + } else { + SORTED_ENTRIES + } + )) + } else { + Span::raw("") + } + }, + ])), + Cell::from(Line::from(vec![ + { + if let EntryTableColumn::Pubtype = self.entry_table.entry_table_selected_column + { + Span::styled("Pubtype", header_selected_col) + } else { + Span::raw("Pubtype") + } + }, + { + if let EntryTableColumn::Pubtype = self.entry_table.entry_table_sorted_by_col { + Span::raw(format!( + " {}", + if self.entry_table.entry_table_reversed_sort { + SORTED_ENTRIES_REVERSED + } else { + SORTED_ENTRIES + } + )) + } else { + Span::raw("") + } + }, + ])), ]) .style(header_style) .height(1); @@ -351,7 +384,7 @@ impl App { Constraint::Percentage(20), Constraint::Fill(1), Constraint::Length( - if let EntryTableColumn::Year = self.entry_table.entry_table_selected_column { + if let EntryTableColumn::Year = self.entry_table.entry_table_sorted_by_col { 6 } else { 4 |
