From c3676e7b6278f5103f23f35abfc3a0d8308009d9 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Mon, 10 Mar 2025 12:15:14 +0200 Subject: [PATCH] allow columns to be resized --- src/keys.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/keys.rs b/src/keys.rs index 46f64ee..4b5d6e4 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -26,6 +26,20 @@ impl Handle for Taggart { let x_max = self.offset + self.size.h().saturating_sub(1); let event = &*input.event(); match &self.editing { + None => match event { + press!(Up) => { self.cursor = self.cursor.saturating_sub(1); }, + press!(Down) => { self.cursor = self.cursor + 1; }, + press!(PageUp) => { self.cursor = self.cursor.saturating_sub(PAGE_SIZE); }, + press!(PageDown) => { self.cursor += PAGE_SIZE; }, + press!(Left) => { self.column = self.column.saturating_sub(1); }, + press!(Right) => { self.column = self.column + 1; }, + press!(Enter) => { self.edit_begin() }, + press!(Char(' ')) => { open(&self.paths[self.cursor].path)?; } + press!(Char(']')) => { self.columns.0[self.column].width += 1; } + press!(Char('[')) => { self.columns.0[self.column].width = + self.columns.0[self.column].width.saturating_sub(1).max(5); } + _ => {} + }, Some(_value) => match event { press!(Char(c)) => self.edit_insert(*c), press!(Shift-Char(c)) => self.edit_insert(c.to_uppercase().next().unwrap()), @@ -35,17 +49,6 @@ impl Handle for Taggart { press!(Esc) => self.edit_confirm(), _ => {} }, - None => match event { - press!(Up) => { self.cursor = self.cursor.saturating_sub(1); }, - press!(Down) => { self.cursor = self.cursor + 1; }, - press!(PageUp) => { self.cursor = self.cursor.saturating_sub(PAGE_SIZE); }, - press!(PageDown) => { self.cursor += PAGE_SIZE; }, - press!(Left) => { self.column = self.column.saturating_sub(1); }, - press!(Right) => { self.column = self.column + 1; }, - press!(Char(' ')) => { open(&self.paths[self.cursor].path)?; } - press!(Enter) => self.edit_begin(), - _ => {} - } } if self.cursor < x_min { self.offset = self.cursor;