diff --git a/build/linux/config.json b/build/linux/config.json index e49577b..c23788b 100644 --- a/build/linux/config.json +++ b/build/linux/config.json @@ -7,13 +7,8 @@ "text_editor": "msedit", "custom_menu_items": [ { - "name": "Nytt kommando", - "command": "echo $[path]", - "applies_to": "Both" - }, - { - "name": "Nytt kommando", - "command": "echo $[path]", + "name": "Open In VS Code", + "command": "code $[path]", "applies_to": "Both" } ] diff --git a/build/linux/tui-fm b/build/linux/tui-fm index 22c1280..86e8923 100755 Binary files a/build/linux/tui-fm and b/build/linux/tui-fm differ diff --git a/src/app.rs b/src/app.rs index 0cb36ba..e0c49c4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -103,6 +103,8 @@ pub struct App { pub settings_editing_field: Option, // which field is being edited pub settings_editing_buf: String, // current text in the edited field pub settings_custom_selected: usize, // which custom item row is selected + /// Which button on the action-button row is hovered: 0 = [+ Ny], 1 = [Ta bort], None = neither + pub settings_hover_button: Option, // Terminal capabilities pub unicode_support: bool, } @@ -177,6 +179,7 @@ impl App { settings_editing_field: None, settings_editing_buf: String::new(), settings_custom_selected: 0, + settings_hover_button: None, unicode_support: detect_unicode_support(), } } diff --git a/src/events.rs b/src/events.rs index e7e0e37..8751f2d 100644 --- a/src/events.rs +++ b/src/events.rs @@ -542,6 +542,17 @@ fn settings_activate(app: &mut App) { pub fn settings_click(app: &mut App, col: u16, row: u16, dlg: ratatui::layout::Rect) { if col < dlg.x || col >= dlg.x + dlg.width { return; } if row < dlg.y || row >= dlg.y + dlg.height { return; } + + // [X] close button on the top border row + if row == dlg.y { + let close_x = dlg.x + dlg.width.saturating_sub(5); + if col >= close_x && col < close_x + 3 { + app.dialog = DialogMode::None; + return; + } + return; + } + let inner_y = dlg.y + 1; // top border let inner_x = dlg.x + 1; let inner_w = dlg.width.saturating_sub(2); @@ -914,19 +925,36 @@ fn handle_mouse_move(app: &mut App, col: u16, row: u16) { && row > dlg.y && row < dlg.y + dlg.height.saturating_sub(1) { let inner_y = dlg.y + 1; + let inner_x = dlg.x + 1; let list_row = (row - inner_y) as usize; let custom_count = app.config.custom_menu_items.len(); let btn_lr = if custom_count == 0 { 7 } else { 6 + custom_count }; let save_lr = btn_lr + 1; if list_row == 1 { app.settings_selected_row = 1; + app.settings_hover_button = None; } else if list_row >= 5 && custom_count > 0 && list_row < 5 + custom_count { app.settings_selected_row = 4 + (list_row - 5); + app.settings_hover_button = None; } else if list_row == btn_lr { app.settings_selected_row = 4 + custom_count; + // Determine which button the mouse is over + let col_rel = col.saturating_sub(inner_x) as usize; + if col_rel < 10 { + app.settings_hover_button = Some(0); // [+ Ny] + } else if col_rel < 22 { + app.settings_hover_button = Some(1); // [Ta bort] + } else { + app.settings_hover_button = None; + } } else if list_row == save_lr { app.settings_selected_row = 5 + custom_count; + app.settings_hover_button = None; + } else { + app.settings_hover_button = None; } + } else { + app.settings_hover_button = None; } return; } diff --git a/src/ui.rs b/src/ui.rs index 5078027..39d5f5b 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -678,6 +678,16 @@ fn draw_settings(f: &mut Frame, app: &App, right_edge: u16) { let inner = block.inner(area); f.render_widget(block, area); + // ── [X] close button in top-right corner of the border ─────────────────── + let close_label = "[X]"; + let close_x = area.x + area.width.saturating_sub(close_label.len() as u16 + 2); + f.render_widget( + Paragraph::new(close_label).style( + Style::default().fg(Color::Red).add_modifier(Modifier::BOLD) + ), + Rect::new(close_x, area.y, close_label.len() as u16, 1), + ); + let sel = app.settings_selected_row; let editing = &app.settings_editing_field; let buf = &app.settings_editing_buf; @@ -815,14 +825,16 @@ fn draw_settings(f: &mut Frame, app: &App, right_edge: u16) { // ── Action buttons row ──────────────────────────────────────────────────── if row_y < inner.y + inner.height.saturating_sub(2) { - let is_btn_sel = sel == 4 + custom_count; + let is_btn_row = sel == 4 + custom_count; + let hover_add = is_btn_row && app.settings_hover_button == Some(0); + let hover_del = is_btn_row && app.settings_hover_button == Some(1); - let btn_add_s = if is_btn_sel { + let btn_add_s = if hover_add { Style::default().fg(Color::Black).bg(Color::Green).add_modifier(Modifier::BOLD) } else { Style::default().fg(Color::Green).add_modifier(Modifier::BOLD) }; - let btn_del_s = if is_btn_sel { + let btn_del_s = if hover_del { Style::default().fg(Color::White).bg(Color::Red).add_modifier(Modifier::BOLD) } else { Style::default().fg(Color::Red)