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.
This commit is contained in:
2026-07-07 15:05:30 +03:00
parent 5fe49527be
commit ffc4b3cc6e
+35 -6
View File
@@ -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 {