Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/log level filter #11

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: Fix filter issue with table selection after filtering, update d…
…oc. with video
  • Loading branch information
hackinghieser committed Feb 20, 2024
commit bd5ff7aeb55d4b929b5b4b8b7955dc4a3954d979
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# clever
Clever is a simple cli application to view *.clef logs. Written in Rust & powered by Ratatui

![clever](./images/clever.png)
![clever](./images/clever.gif)

# Installation

Expand Down
Binary file added images/clever.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> App<'a> {

pub fn move_row_up(&mut self, range: usize) {
if let Some(selected) = self.event_table_state.selected() {
if selected >= range {
if selected >= range +1 {
self.event_table_state.select(Some(selected - range));
} else {
self.event_table_state.select(Some(self.lines.len() - 1));
Expand Down
13 changes: 10 additions & 3 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ratatui::{
style::{Color, Modifier, Style, Stylize},
widgets::{
block::{self, Title},
Block, Borders, Clear, List, ListDirection, Paragraph, Row, Table, TableState, Wrap,
Block, Borders, Clear, List, ListDirection, Paragraph, Row, Table, Wrap,
},
Frame,
};
Expand Down Expand Up @@ -57,8 +57,15 @@ pub fn render(app: &mut App, f: &mut Frame) {
}
}

let selected_row_index = app.event_table_state.selected().unwrap();
let selected_row: &ClefLine = clef_rows.get(selected_row_index).unwrap().0;
let mut selected_row_index = app.event_table_state.selected().unwrap();
let selected_row: &ClefLine = match clef_rows.get(selected_row_index) {
None => {
app.event_table_state.select(Some(0));
selected_row_index = 0;
clef_rows.get(0).unwrap().0
}
Some(val) => val.0,
};
let selection_text = format!("{}|{}", selected_row_index, clef_rows.len() - 1);

let detail: Detail = Detail {
Expand Down
Loading