term: Implement interruptible quiet mode
diff --git a/CONFIG.md b/CONFIG.md
index a9dd8fca..e0b49970 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -52,6 +52,7 @@ Some keys take *URIs* as values; these are described in the next section.
*Globally assignable* keys are:
* `TIMEOUT` - Specifies the timeout in seconds before the first *entry* is automatically booted. If set to `no`, disable automatic boot. If set to `0`, boots default entry instantly (see `DEFAULT_ENTRY` key).
+* `QUIET` - If set to `yes`, enable quiet mode, where all screen output except panics and important warnings is suppressed. If `TIMEOUT` is not 0, the `TIMEOUT` still occurs, and pressing any key during the timeout will reveal the menu and disable quiet mode.
* `DEFAULT_ENTRY` - 1-based entry index of the entry which will be automatically selected at startup. If unspecified, it is `1`.
* `GRAPHICS` - If set to `yes`, use a graphical framebuffer for the boot menu, else use text mode. Ignored with Limine UEFI, forced to `yes`.
* `MENU_RESOLUTION` - Specify screen resolution to be used by the Limine menu in the form `<width>x<height>`. This will *only* affect the menu, not any booted OS. If not specified, Limine will pick a resolution automatically. If the resolution is not available, Limine will pick another one automatically. Ignored if `GRAPHICS` is not `yes`.
@@ -82,7 +83,6 @@ Some keys take *URIs* as values; these are described in the next section.
* `EDITOR_HIGHLIGHTING` - If set to `no`, syntax highlighting in the editor will be disabled. Defaults to `yes`.
* `EDITOR_VALIDATION` - If set to `no`, the editor will not alert you about invalid keys / syntax errors. Defaults to `yes`.
* `VERBOSE` - If set to `yes`, print additional information during boot. Defaults to not verbose.
-* `QUIET` - If set to `yes`, enable quiet mode, where all screen output except panics and important warnings is suppressed.
* `RANDOMISE_MEMORY` - If set to `yes`, randomise the contents of RAM at bootup in order to find bugs related to non zeroed memory or for security reasons. This option will slow down boot time significantly.
* `RANDOMIZE_MEMORY` - Alias of `RANDOMISE_MEMORY`.
diff --git a/stage23/entry.s3.c b/stage23/entry.s3.c
index 2ff6a8d1..ef07aff8 100644
--- a/stage23/entry.s3.c
+++ b/stage23/entry.s3.c
@@ -141,10 +141,6 @@ void stage3_common(void) {
char *quiet_str = config_get_value(NULL, 0, "QUIET");
quiet = quiet_str != NULL && strcmp(quiet_str, "yes") == 0;
-#if bios == 1
- term_textmode();
-#endif
-
char *verbose_str = config_get_value(NULL, 0, "VERBOSE");
verbose = verbose_str != NULL && strcmp(verbose_str, "yes") == 0;
diff --git a/stage23/menu.c b/stage23/menu.c
index 7181c934..d0b6d3e1 100644
--- a/stage23/menu.c
+++ b/stage23/menu.c
@@ -76,6 +76,7 @@ static size_t get_prev_line(size_t index, const char *buffer) {
static const char *VALID_KEYS[] = {
"TIMEOUT",
+ "QUIET",
"DEFAULT_ENTRY",
"GRAPHICS",
"MENU_RESOLUTION",
@@ -565,6 +566,8 @@ char *menu(char **cmdline) {
#elif uefi == 1
char *graphics = "yes";
#endif
+
+reterm:
if (graphics != NULL && !strcmp(graphics, "yes")) {
size_t req_width = 0, req_height = 0, req_bpp = 0;
@@ -573,6 +576,10 @@ char *menu(char **cmdline) {
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
term_vbe(req_width, req_height);
+ } else {
+#if bios == 1
+ term_textmode();
+#endif
}
refresh:
@@ -665,9 +672,14 @@ refresh:
term_double_buffer_flush();
if ((c = pit_sleep_and_quit_on_keypress(1))) {
skip_timeout = true;
- print("\e[2K");
- term_double_buffer_flush();
- goto timeout_aborted;
+ if (quiet) {
+ quiet = false;
+ goto reterm;
+ } else {
+ print("\e[2K");
+ term_double_buffer_flush();
+ goto timeout_aborted;
+ }
}
}
goto autoboot;
