feat: add Pure Black Terminal theme & make it default for Console session
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MONTAUK_BUILD_NUMBER 175
|
#define MONTAUK_BUILD_NUMBER 177
|
||||||
|
|||||||
@@ -820,13 +820,6 @@ extern "C" void _start() {
|
|||||||
if (!fonts::init())
|
if (!fonts::init())
|
||||||
montauk::exit(1);
|
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] = {};
|
char args[256] = {};
|
||||||
int arglen = montauk::getargs(args, sizeof(args));
|
int arglen = montauk::getargs(args, sizeof(args));
|
||||||
|
|
||||||
@@ -844,6 +837,14 @@ extern "C" void _start() {
|
|||||||
if (workdir && workdir[0])
|
if (workdir && workdir[0])
|
||||||
montauk::chdir(workdir);
|
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)
|
if (console_mode)
|
||||||
run_console();
|
run_console();
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -40,6 +40,23 @@ static const ThemeEntry kThemes[] = {
|
|||||||
"montauk-dark", "Montauk Dark",
|
"montauk-dark", "Montauk Dark",
|
||||||
TERM_PALETTE_DEFAULT
|
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",
|
"solarized-dark", "Solarized Dark",
|
||||||
{
|
{
|
||||||
@@ -154,7 +171,7 @@ static constexpr int FONT_SIZE_STEP = 2;
|
|||||||
// ==== Panel state ====
|
// ==== Panel state ====
|
||||||
|
|
||||||
static constexpr int PANEL_W = 380;
|
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 PAD = 16;
|
||||||
static constexpr int CARD_PAD = 4;
|
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}};
|
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 ====
|
// ==== Preferences ====
|
||||||
|
|
||||||
static void current_user(char* out, int cap) {
|
static void current_user(char* out, int cap) {
|
||||||
@@ -204,22 +228,37 @@ static void save_prefs() {
|
|||||||
current_user(user, sizeof(user));
|
current_user(user, sizeof(user));
|
||||||
|
|
||||||
montauk::toml::Doc doc = montauk::config::load_user(user, "terminal");
|
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::set_int(&doc, "appearance.font_size", fonts::TERM_SIZE);
|
||||||
montauk::config::save_user(user, "terminal", &doc);
|
montauk::config::save_user(user, "terminal", &doc);
|
||||||
doc.destroy();
|
doc.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_prefs() {
|
void load_prefs(bool console_session) {
|
||||||
|
g_console_session = console_session;
|
||||||
|
|
||||||
char user[64];
|
char user[64];
|
||||||
current_user(user, sizeof(user));
|
current_user(user, sizeof(user));
|
||||||
|
|
||||||
montauk::toml::Doc doc = montauk::config::load_user(user, "terminal");
|
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);
|
int size = (int)doc.get_int("appearance.font_size", fonts::TERM_SIZE);
|
||||||
doc.destroy();
|
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_panel.theme_index = idx;
|
||||||
g_term_palette = kThemes[idx].palette;
|
g_term_palette = kThemes[idx].palette;
|
||||||
fonts::TERM_SIZE = clamp_font_size(size);
|
fonts::TERM_SIZE = clamp_font_size(size);
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ struct Callbacks {
|
|||||||
|
|
||||||
// Load the saved theme and font size and apply them to the globals. Call
|
// 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
|
// before the first tab is created -- there is nothing to repaint yet, so this
|
||||||
// deliberately does not fire the callbacks.
|
// deliberately does not fire the callbacks. `console_session` selects the
|
||||||
void load_prefs();
|
// 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);
|
void init(const Callbacks& cb);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user