Skip to content

Commit 32880e4

Browse files
committed
feat: add display of line count
1 parent da9e523 commit 32880e4

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/app.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,18 @@ impl LogViewerApp {
605605
ui.label(format!("Filename: {}", filename.display()));
606606
}
607607
}
608-
// TODO 1: Show number of lines
608+
if let Some(data) = self.data.as_ref() {
609+
let row_count_text =
610+
match (data.is_filtered(), data.len(), data.total_len_unfiltered()) {
611+
(true, filtered_len, total_len) => format!(
612+
"{} of {}",
613+
with_separators(filtered_len),
614+
with_separators(total_len)
615+
),
616+
(false, _, total_len) => with_separators(total_len),
617+
};
618+
ui.label(format!("# Rows: {row_count_text}"));
619+
}
609620
});
610621
}
611622

@@ -758,3 +769,15 @@ fn shortcut_hint_text(ui: &mut egui::Ui, hint_msg: &str, shortcut: &KeyboardShor
758769
let space = if hint_msg.is_empty() { "" } else { " " };
759770
format!("{hint_msg}{space}({})", ui.ctx().format_shortcut(shortcut))
760771
}
772+
773+
fn with_separators(value: usize) -> String {
774+
value
775+
.to_string()
776+
.as_bytes()
777+
.rchunks(3)
778+
.rev()
779+
.map(std::str::from_utf8)
780+
.collect::<Result<Vec<&str>, _>>()
781+
.unwrap()
782+
.join(",")
783+
}

src/app/data.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ impl Data {
137137
}
138138
}
139139

140+
pub fn total_len_unfiltered(&self) -> usize {
141+
self.rows.len()
142+
}
143+
140144
/// If the points are not filtered returns the input otherwise translates it from the filtered array
141145
fn get_real_index(&self, index: usize) -> usize {
142146
if let Some(filtered) = self.filtered_rows.as_ref() {

0 commit comments

Comments
 (0)