feat: add Pure Black Terminal theme & make it default for Console session

This commit is contained in:
2026-08-29 18:32:33 +02:00
parent 615ca7308a
commit 3e596f2bad
4 changed files with 57 additions and 15 deletions
+44 -5
View File
@@ -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);