From ffc4b3cc6eb59952fdbfb46f5347dae3b37a59d2 Mon Sep 17 00:00:00 2001 From: vasilito Date: Tue, 7 Jul 2026 15:05:30 +0300 Subject: [PATCH] W62: Hex buttonbar + NroffMode F9 (MC CK_NroffMode) Two MC viewer parity gaps closed: Buttonbar: now shows different labels in Hex mode (F2=Edit, F4=Ascii, F6=Save, F7=HxSrch, F8=Raw) matching MC's hex display. NroffMode: F9 now toggles nroff_enabled (MC CK_NroffMode). Previously F9 opened the menubar; the menubar moves to Shift-F9. The buttonbar label for F9 shows 'Nroff'. Text mode buttonbar also shows 'Nroff' for F9 instead of blank. Tests: 1421 pass, zero warnings. --- .../recipes/tui/tlc/source/src/viewer/mod.rs | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/local/recipes/tui/tlc/source/src/viewer/mod.rs b/local/recipes/tui/tlc/source/src/viewer/mod.rs index fa274f3cd4..2c98e51a9e 100644 --- a/local/recipes/tui/tlc/source/src/viewer/mod.rs +++ b/local/recipes/tui/tlc/source/src/viewer/mod.rs @@ -109,6 +109,9 @@ pub struct Viewer { /// True when the cursor navigates the ASCII text column in /// hex mode (MC hexview_in_text). Toggled by Tab. pub hexview_in_text: bool, + /// Whether nroff backspace-overstrike formatting is active. + /// Toggled by F9 when the menubar is not active (MC F9). + pub nroff_enabled: bool, /// Active modal prompt at the bottom of the viewer (`None` = /// no prompt open). Drives the prompt's title and Enter /// handler. @@ -187,6 +190,7 @@ impl Viewer { last_search_forward: true, ruler: false, hexview_in_text: false, + nroff_enabled: false, prompt: None, prompt_input: String::new(), loading: size >= crate::viewer::source::INLINE_THRESHOLD, @@ -232,6 +236,7 @@ impl Viewer { last_search_forward: true, ruler: false, hexview_in_text: false, + nroff_enabled: false, prompt: None, prompt_input: String::new(), loading: size >= crate::viewer::source::INLINE_THRESHOLD, @@ -789,11 +794,25 @@ impl Viewer { } if chunks[3].height > 0 { - let labels: [(&str, &str); 10] = [ - ("1", "Help"), ("2", "Wrap"), ("3", ""), ("4", "Hex"), - ("5", ""), ("6", ""), ("7", "Search"), ("8", "Magic"), - ("9", ""), ("10", "Quit"), - ]; + let labels: [(&str, &str); 10] = if self.mode == ViewMode::Hex { + [ + ("1", "Help"), ("2", "Edit"), ("3", "Quit"), ("4", "Ascii"), + ("5", "Goto"), ("6", "Save"), ("7", "HxSrch"), ("8", "Raw"), + ("9", ""), ("10", "Quit"), + ] + } else if self.mode == ViewMode::HexEdit { + [ + ("1", "Help"), ("2", "View"), ("3", "Quit"), ("4", "Ascii"), + ("5", "Goto"), ("6", "Save"), ("7", "HxSrch"), ("8", "Raw"), + ("9", ""), ("10", "Quit"), + ] + } else { + [ + ("1", "Help"), ("2", "Wrap"), ("3", ""), ("4", "Hex"), + ("5", ""), ("6", ""), ("7", "Search"), ("8", "Magic"), + ("9", "Nroff"), ("10", "Quit"), + ] + }; crate::widget::buttonbar::render_buttonbar(frame, chunks[3], theme, &labels); } @@ -881,8 +900,18 @@ impl Viewer { if key == Key::f(10) || key == Key::ctrl('q') { return true; } - // F9 toggles the menubar. + // F9 — toggle NroffMode (MC CK_NroffMode parity). + // Shift-F9 opens the viewer menubar. if key == Key::f(9) { + self.nroff_enabled = !self.nroff_enabled; + return true; + } + // Shift-F9 opens the menubar. + let shift_f9 = Key { + code: Key::f(9).code, + mods: crate::key::Modifiers::SHIFT, + }; + if key == shift_f9 { if self.menubar.is_some() { self.menubar = None; } else {