Skip to content

Commit

Permalink
Merge pull request #274 from B-LechCode/wide_paths
Browse files Browse the repository at this point in the history
Truncating path label width for consistent left panel width
  • Loading branch information
woelper authored Feb 11, 2024
2 parents 69fd121 + e46ed3a commit e58b068
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,18 +280,19 @@ pub fn info_ui(ctx: &Context, state: &mut OculanteState, gfx: &mut Graphics) {

if let Some(path) = &state.current_path {
// make sure we truncate filenames
let max_chars = 20;
let max_chars = 18;
let file_name = path.file_name().unwrap_or_default().to_string_lossy();
let skip_symbol = if file_name.chars().count() > max_chars {".."} else {""};

ui.label_i(&format!("{} File", IMAGE_SQUARE));
ui.label(
let path_label = egui::Label::new(
RichText::new(format!(
"{skip_symbol}{}",
file_name.chars().rev().take(max_chars).collect::<String>().chars().rev().collect::<String>()
))
// .monospace(),
)
).truncate(true);

ui.add(path_label)
.on_hover_text(format!("{}", path.display()));
ui.end_row();
}
Expand Down

0 comments on commit e58b068

Please sign in to comment.