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 {