From 3e596f2bada67adb0acd7b5c72714a9596960a1e Mon Sep 17 00:00:00 2001 From: Daniel Hammer Date: Sat, 29 Aug 2026 18:32:33 +0200 Subject: [PATCH] feat: add Pure Black Terminal theme & make it default for Console session --- kernel/src/Api/BuildNo.hpp | 2 +- programs/src/terminal/main.cpp | 15 ++++----- programs/src/terminal/settings.cpp | 49 +++++++++++++++++++++++++++--- programs/src/terminal/settings.hpp | 6 ++-- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index dec456a..267149c 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 175 +#define MONTAUK_BUILD_NUMBER 177 diff --git a/programs/src/terminal/main.cpp b/programs/src/terminal/main.cpp index 0249413..ea65995 100644 --- a/programs/src/terminal/main.cpp +++ b/programs/src/terminal/main.cpp @@ -820,13 +820,6 @@ extern "C" void _start() { if (!fonts::init()) montauk::exit(1); - // Must run before the first cell grid is sized: the saved font size decides - // the mono cell metrics, and so how many columns and rows fit. Console mode - // has no settings window, but it shares the saved appearance and the zoom - // shortcut, so it needs the callbacks too. - termset::init({term_on_theme_changed, term_on_font_changed}); - termset::load_prefs(); - char args[256] = {}; int arglen = montauk::getargs(args, sizeof(args)); @@ -844,6 +837,14 @@ extern "C" void _start() { if (workdir && workdir[0]) montauk::chdir(workdir); + // Must run before the first cell grid is sized: the font size decides the + // mono cell metrics, and so how many columns and rows fit. It also needs the + // run mode, which picks the fallback theme. Console mode has no settings + // window, but it shares the saved appearance and the zoom shortcut, so it + // needs the callbacks too. + termset::init({term_on_theme_changed, term_on_font_changed}); + termset::load_prefs(console_mode); + if (console_mode) run_console(); else diff --git a/programs/src/terminal/settings.cpp b/programs/src/terminal/settings.cpp index effc53e..15d3763 100644 --- a/programs/src/terminal/settings.cpp +++ b/programs/src/terminal/settings.cpp @@ -40,6 +40,23 @@ static const ThemeEntry kThemes[] = { "montauk-dark", "Montauk Dark", TERM_PALETTE_DEFAULT }, + { + "pure-black", "Pure Black", + { + Color::from_hex(0x000000), Color::from_hex(0xFFFFFF), + Color::from_hex(0xFFFFFF), + { + Color::from_hex(0x000000), Color::from_hex(0xD00000), + Color::from_hex(0x00C000), Color::from_hex(0xC0C000), + Color::from_hex(0x4060E0), Color::from_hex(0xC000C0), + Color::from_hex(0x00C0C0), Color::from_hex(0xE5E5E5), + Color::from_hex(0x7F7F7F), Color::from_hex(0xFF4040), + Color::from_hex(0x40FF40), Color::from_hex(0xFFFF40), + Color::from_hex(0x6080FF), Color::from_hex(0xFF40FF), + Color::from_hex(0x40FFFF), Color::from_hex(0xFFFFFF), + } + } + }, { "solarized-dark", "Solarized Dark", { @@ -154,7 +171,7 @@ static constexpr int FONT_SIZE_STEP = 2; // ==== Panel state ==== static constexpr int PANEL_W = 380; -static constexpr int PANEL_H = 416; +static constexpr int PANEL_H = 452; static constexpr int PAD = 16; static constexpr int CARD_PAD = 4; @@ -179,6 +196,13 @@ struct Panel { static Panel g_panel = {-1, nullptr, PANEL_W, PANEL_H, false, -1, -1, 0, {nullptr, nullptr}}; +// The console session takes over the whole framebuffer with no desktop around +// it, so it defaults to the plain black palette rather than the windowed +// terminal's lighter grey. +static constexpr const char* kConsoleDefaultTheme = "pure-black"; + +static bool g_console_session = false; + // ==== Preferences ==== static void current_user(char* out, int cap) { @@ -204,22 +228,37 @@ static void save_prefs() { current_user(user, sizeof(user)); montauk::toml::Doc doc = montauk::config::load_user(user, "terminal"); - montauk::config::set_string(&doc, "appearance.theme", kThemes[g_panel.theme_index].id); + // The console session has no panel, so its theme is a default rather than a + // choice -- writing it back would let a zoom in the console silently retheme + // every windowed terminal. Leaving the key untouched round-trips whatever + // the user actually picked. + if (!g_console_session) + montauk::config::set_string(&doc, "appearance.theme", + kThemes[g_panel.theme_index].id); montauk::config::set_int(&doc, "appearance.font_size", fonts::TERM_SIZE); montauk::config::save_user(user, "terminal", &doc); doc.destroy(); } -void load_prefs() { +void load_prefs(bool console_session) { + g_console_session = console_session; + char user[64]; current_user(user, sizeof(user)); montauk::toml::Doc doc = montauk::config::load_user(user, "terminal"); - int idx = theme_index_by_id(doc.get_string("appearance.theme", kThemes[0].id)); + int idx = theme_index_by_id(doc.get_string("appearance.theme", "")); int size = (int)doc.get_int("appearance.font_size", fonts::TERM_SIZE); doc.destroy(); - if (idx < 0) idx = 0; + // A saved theme is an explicit choice and wins in either mode; with none + // saved, the full-screen console starts on Pure Black and the windowed + // terminal on the default palette. + if (idx < 0) { + idx = console_session ? theme_index_by_id(kConsoleDefaultTheme) : 0; + if (idx < 0) idx = 0; + } + g_panel.theme_index = idx; g_term_palette = kThemes[idx].palette; fonts::TERM_SIZE = clamp_font_size(size); diff --git a/programs/src/terminal/settings.hpp b/programs/src/terminal/settings.hpp index ee05876..775dbda 100644 --- a/programs/src/terminal/settings.hpp +++ b/programs/src/terminal/settings.hpp @@ -21,8 +21,10 @@ struct Callbacks { // Load the saved theme and font size and apply them to the globals. Call // before the first tab is created -- there is nothing to repaint yet, so this -// deliberately does not fire the callbacks. -void load_prefs(); +// deliberately does not fire the callbacks. `console_session` selects the +// fallback theme used when nothing is saved yet, and stops the console from +// writing a theme it was only given as a default. +void load_prefs(bool console_session); void init(const Callbacks& cb);