diff --git a/local/recipes/tui/tlc/source/src/filemanager/dialog_ops.rs b/local/recipes/tui/tlc/source/src/filemanager/dialog_ops.rs index 78bd545480..83566e4baa 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/dialog_ops.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/dialog_ops.rs @@ -356,6 +356,29 @@ impl FileManager { Ok(()) } + /// Open the viewer in raw mode (no magic/binary detection). MC + /// parity for Shift-F3. The viewer forces Text mode regardless of + /// file content. + pub fn open_viewer_raw_for_cursor(&mut self) -> Result<()> { + let p = self.active_panel().cursor_path(); + if p.as_os_str().is_empty() { + self.status.set_message("view: no path selected"); + return Ok(()); + } + match crate::viewer::Viewer::open(&p) { + Ok(mut v) => { + v.magic_mode = false; + let _ = v.restore_cursor_position(); + self.viewer = Some(v); + self.status.set_message(format!("Viewing {} (raw)", p.display())); + } + Err(e) => { + self.status.set_message(format!("view: {e}")); + } + } + Ok(()) + } + /// Open the M-? Find dialog. The pattern input is pre-filled with /// the cursor entry's name (so searching for the selected file's /// pattern is the default); falls back to the default placeholder diff --git a/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs b/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs index a7993365c6..92df65553c 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/dispatch.rs @@ -109,6 +109,10 @@ impl FileManager { self.open_viewer_for_cursor()?; Ok(true) } + Cmd::ViewRaw => { + self.open_viewer_raw_for_cursor()?; + Ok(true) + } Cmd::UserMenu => { self.open_user_menu_dialog()?; Ok(true) diff --git a/local/recipes/tui/tlc/source/src/keymap/mod.rs b/local/recipes/tui/tlc/source/src/keymap/mod.rs index c832d32b86..413eb7b96e 100644 --- a/local/recipes/tui/tlc/source/src/keymap/mod.rs +++ b/local/recipes/tui/tlc/source/src/keymap/mod.rs @@ -11,6 +11,8 @@ pub enum Cmd { Edit, /// F3 — open the file under the cursor in the viewer. View, + /// Shift-F3 — view the cursor file in raw mode (no magic detection). + ViewRaw, /// Descend into the directory under the cursor (or open a file). /// If the cursor is on a directory, change into it. If on a /// regular file, route to Edit. This is the historical "ENTER @@ -315,6 +317,7 @@ impl Cmd { Cmd::EditMenuFile => "Edit menu file", Cmd::EditHighlightFile => "Edit highlighting file", Cmd::ViewFile => "View file", + Cmd::ViewRaw => "View raw file", Cmd::DisplayBits => "Display bits", Cmd::LearnKeysDialog => "Learn keys", Cmd::VfsSettings => "Virtual FS", @@ -441,6 +444,10 @@ pub fn default_keymap() -> Keymap { km.bind(F1, Cmd::Help); km.bind(F2, Cmd::UserMenu); km.bind(F3, Cmd::View); + km.bind(Key { + code: F3.code, + mods: crate::key::Modifiers::SHIFT, + }, Cmd::ViewRaw); km.bind(F4, Cmd::Edit); km.bind(F5, Cmd::Copy); km.bind(F6, Cmd::Move);