Skip to content

fbwhiptail: implement missing whiptail-compatible features#2075

Open
tlaurion wants to merge 1 commit intolinuxboot:masterfrom
tlaurion:fbwiptail-full-featureset
Open

fbwhiptail: implement missing whiptail-compatible features#2075
tlaurion wants to merge 1 commit intolinuxboot:masterfrom
tlaurion:fbwiptail-full-featureset

Conversation

@tlaurion
Copy link
Collaborator

Add a patch against fbwhiptail 1.3 that brings it to feature parity with newt's whiptail for the options used by Heads scripts:

Bugs fixed:

  • --output-fd: output was always hardcoded to stderr; now uses fdopen() on the specified fd (default 2 keeps existing behaviour)
  • backtitle: parsed but never passed to the draw layer (parse preserved, rendering to follow in a future patch)

New modes:

  • --infobox: renders once and exits immediately (no interaction)
  • --inputbox: live text entry with printable char / backspace handling; Enter confirms, Escape cancels (unless --nocancel)
  • --passwordbox: same as inputbox, characters masked as '*'
  • --textbox: loads file content into scrollable text surface; Page Up / Page Down scroll, Enter / Escape close
  • --radiolist: single-selection list with [*]/[ ] markers; Space selects
  • --checklist: multi-selection list with [X]/[ ] markers; Space toggles

New flags:

  • --nocancel: suppresses double-Escape cancel in all modes
  • --defaultno: yesno dialog starts with No selected
  • --separate-output: checklist emits one tag per line instead of "a" "b"

Previously-silenced but accepted options:

  • --scrolltext, --fullbuttons / --fb: no longer trigger "unknown argument"

Internal changes to fbwhiptail_menu.c / fbwhiptail_menu.h:

  • whiptail_mode enum moved before Menu struct (forward-declaration fix)
  • refresh_text_surface() made non-static, renamed menu_refresh_text(), clears the surface before redrawing to prevent ghost text on scroll
  • Menu struct gains: input_buf, input_len, password, nocancel, mode
  • whiptail_menu_item gains: status field (checklist/radiolist state)
  • whiptail_args gains: nocancel, defaultno, separate_output
  • load_text_from_file() and menu_refresh_text() exported in header

WiP/PoC until in desirable state, need full testing.

Add a patch against fbwhiptail 1.3 that brings it to feature parity
with newt's whiptail for the options used by Heads scripts:

Bugs fixed:
- --output-fd: output was always hardcoded to stderr; now uses fdopen()
  on the specified fd (default 2 keeps existing behaviour)
- backtitle: parsed but never passed to the draw layer (parse preserved,
  rendering to follow in a future patch)

New modes:
- --infobox: renders once and exits immediately (no interaction)
- --inputbox: live text entry with printable char / backspace handling;
  Enter confirms, Escape cancels (unless --nocancel)
- --passwordbox: same as inputbox, characters masked as '*'
- --textbox: loads file content into scrollable text surface;
  Page Up / Page Down scroll, Enter / Escape close
- --radiolist: single-selection list with [*]/[ ] markers; Space selects
- --checklist: multi-selection list with [X]/[ ] markers; Space toggles

New flags:
- --nocancel: suppresses double-Escape cancel in all modes
- --defaultno: yesno dialog starts with No selected
- --separate-output: checklist emits one tag per line instead of "a" "b"

Previously-silenced but accepted options:
- --scrolltext, --fullbuttons / --fb: no longer trigger "unknown argument"

Internal changes to fbwhiptail_menu.c / fbwhiptail_menu.h:
- whiptail_mode enum moved before Menu struct (forward-declaration fix)
- refresh_text_surface() made non-static, renamed menu_refresh_text(),
  clears the surface before redrawing to prevent ghost text on scroll
- Menu struct gains: input_buf, input_len, password, nocancel, mode
- whiptail_menu_item gains: status field (checklist/radiolist state)
- whiptail_args gains: nocancel, defaultno, separate_output
- load_text_from_file() and menu_refresh_text() exported in header

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Copilot AI review requested due to automatic review settings March 16, 2026 01:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Heads build patch against fbwhiptail 1.3 to improve whiptail compatibility for dialogs used by initrd scripts (new dialog modes/flags plus a fix for --output-fd).

Changes:

  • Implements additional whiptail dialog modes (e.g., infobox/inputbox/passwordbox/textbox/checklist/radiolist) and related flags (--nocancel, --defaultno, --separate-output).
  • Fixes --output-fd handling by writing results to the requested FD via fdopen().
  • Refactors/extends menu internals (mode enum placement, exported text refresh + file loader, new per-item status and input state).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +690 to +691
printf ("\033c");
fflush (stdout);
i += 4;
args->mode = MODE_MENU;
- args->items = malloc (sizeof(whiptail_menu_item) * (argc - i) / 2);
+ args->items = malloc (sizeof(whiptail_menu_item) * (argc - i) / 2 + 1);
Comment on lines +492 to +493
+ args->mode = is_radio ? MODE_RADIOLIST : MODE_CHECKLIST;
+ args->items = malloc (sizeof(whiptail_menu_item) * (argc - i) / 3 + 1);
Comment on lines +267 to +268
+ static char input_data[10] = {0};
+ static int input_size = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants