From c40c252c9a5474450f0bce9320e16421a12d4d61 Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 12 Jul 2026 16:26:44 -0500 Subject: [PATCH] feat(console): persist accent toggle + add monochrome-text toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Persist the two console output display preferences and add a second toolbar toggle for monochrome text. - Persistence: new Settings fields console_line_accents / console_text_color (both default true, matching the ConsoleTab statics so an upgrade re-save can't flip visible behavior). Restored into the statics at startup in the App constructor, and saved from a diff-and-save after the console renders (only when a value actually changed — save() is disk I/O). The startup restore also fixes a pre-existing bug: scanline was only synced from settings when the Settings page or first-run wizard ran, so an existing wallet ignored a saved scanline preference on launch. - Monochrome text: a new toolbar toggle (FORMAT_COLOR_TEXT, dimmed when off) next to the accent toggle. channelTextColor() early-returns the neutral COLOR_RESULT for every channel (and JSON syntax role) when off, leaving the left accent bars independent. COLOR_RESULT is contrast-floored per theme, so text stays readable on light and dark terminals. Adds console_toggle_text_color to the English source + all 8 translations. Verified: both toggles independent, persistence round-trips across restart, monochrome readable on light + dark skins. Co-Authored-By: Claude Opus 4.8 (1M context) --- res/lang/de.json | 1 + res/lang/es.json | 1 + res/lang/fr.json | 1 + res/lang/ja.json | 1 + res/lang/ko.json | 1 + res/lang/pt.json | 1 + res/lang/ru.json | 1 + res/lang/zh.json | 1 + src/app.cpp | 18 ++++++++++++++++++ src/config/settings.cpp | 4 ++++ src/config/settings.h | 9 +++++++++ src/ui/windows/console_tab.cpp | 17 +++++++++++++++++ src/ui/windows/console_tab.h | 3 +++ src/util/i18n.cpp | 1 + 14 files changed, 60 insertions(+) diff --git a/res/lang/de.json b/res/lang/de.json index 87ba674..831450f 100644 --- a/res/lang/de.json +++ b/res/lang/de.json @@ -241,6 +241,7 @@ "console_status_unknown": "Unbekannt", "console_tab_completion": "Tab zur Vervollständigung", "console_toggle_accents": "Farbakzente der Zeilen umschalten", + "console_toggle_text_color": "Textfarben der Zeilen umschalten", "console_type_help": "Geben Sie 'help' ein für verfügbare Befehle", "console_welcome": "Willkommen bei ObsidianDragon Konsole", "console_zoom_in": "Vergrößern", diff --git a/res/lang/es.json b/res/lang/es.json index 383057a..ce0a098 100644 --- a/res/lang/es.json +++ b/res/lang/es.json @@ -241,6 +241,7 @@ "console_status_unknown": "Desconocido", "console_tab_completion": "Tab para completar", "console_toggle_accents": "Alternar acentos de color de línea", + "console_toggle_text_color": "Alternar colores de texto de línea", "console_type_help": "Escribe 'help' para ver los comandos disponibles", "console_welcome": "Bienvenido a la Consola de ObsidianDragon", "console_zoom_in": "Acercar", diff --git a/res/lang/fr.json b/res/lang/fr.json index 5de633b..d1e7aea 100644 --- a/res/lang/fr.json +++ b/res/lang/fr.json @@ -241,6 +241,7 @@ "console_status_unknown": "Inconnu", "console_tab_completion": "Tab pour compléter", "console_toggle_accents": "Basculer les accents de couleur des lignes", + "console_toggle_text_color": "Basculer les couleurs du texte des lignes", "console_type_help": "Tapez 'help' pour les commandes disponibles", "console_welcome": "Bienvenue dans la console ObsidianDragon", "console_zoom_in": "Agrandir", diff --git a/res/lang/ja.json b/res/lang/ja.json index ff09e52..12ae0ea 100644 --- a/res/lang/ja.json +++ b/res/lang/ja.json @@ -241,6 +241,7 @@ "console_status_unknown": "不明", "console_tab_completion": "Tabで補完", "console_toggle_accents": "行のカラーアクセントを切り替え", + "console_toggle_text_color": "行のテキスト色を切り替え", "console_type_help": "'help'と入力して利用可能なコマンドを表示", "console_welcome": "ObsidianDragonコンソールへようこそ", "console_zoom_in": "拡大", diff --git a/res/lang/ko.json b/res/lang/ko.json index 39c4988..5bfe259 100644 --- a/res/lang/ko.json +++ b/res/lang/ko.json @@ -241,6 +241,7 @@ "console_status_unknown": "알 수 없음", "console_tab_completion": "Tab으로 자동 완성", "console_toggle_accents": "줄 색상 강조 전환", + "console_toggle_text_color": "줄 텍스트 색상 전환", "console_type_help": "'help'를 입력하여 사용 가능한 명령어 보기", "console_welcome": "ObsidianDragon 콘솔에 오신 것을 환영합니다", "console_zoom_in": "확대", diff --git a/res/lang/pt.json b/res/lang/pt.json index 0a9bb5c..f732448 100644 --- a/res/lang/pt.json +++ b/res/lang/pt.json @@ -241,6 +241,7 @@ "console_status_unknown": "Desconhecido", "console_tab_completion": "Tab para completar", "console_toggle_accents": "Alternar destaques de cor das linhas", + "console_toggle_text_color": "Alternar cores do texto das linhas", "console_type_help": "Digite 'help' para comandos disponíveis", "console_welcome": "Bem-vindo ao Console ObsidianDragon", "console_zoom_in": "Aumentar zoom", diff --git a/res/lang/ru.json b/res/lang/ru.json index ced22ba..ce6d7eb 100644 --- a/res/lang/ru.json +++ b/res/lang/ru.json @@ -241,6 +241,7 @@ "console_status_unknown": "Неизвестно", "console_tab_completion": "Tab для дополнения", "console_toggle_accents": "Переключить цветовые акценты строк", + "console_toggle_text_color": "Переключить цвета текста строк", "console_type_help": "Введите 'help' для списка команд", "console_welcome": "Добро пожаловать в консоль ObsidianDragon", "console_zoom_in": "Увеличить", diff --git a/res/lang/zh.json b/res/lang/zh.json index 94b301a..3a66d6c 100644 --- a/res/lang/zh.json +++ b/res/lang/zh.json @@ -241,6 +241,7 @@ "console_status_unknown": "未知", "console_tab_completion": "Tab 补全", "console_toggle_accents": "切换行颜色强调", + "console_toggle_text_color": "切换行文本颜色", "console_type_help": "输入 'help' 查看可用命令", "console_welcome": "欢迎使用 ObsidianDragon 控制台", "console_zoom_in": "放大", diff --git a/src/app.cpp b/src/app.cpp index 6abde46..81532fd 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -307,6 +307,13 @@ bool App::init() // Apply verbose logging preference from saved settings util::Logger::instance().setVerbose(settings_->getVerboseLogging()); + // Restore console display preferences into the ConsoleTab statics at startup. These are the only + // startup restore for these toggles — the Settings page / first-run wizard also sync scanline, but + // only when visited, so without this an existing wallet would ignore a saved preference on launch. + ui::ConsoleTab::s_scanline_enabled = settings_->getScanlineEnabled(); + ui::ConsoleTab::s_line_accents_enabled = settings_->getConsoleLineAccents(); + ui::ConsoleTab::s_line_text_color_enabled = settings_->getConsoleTextColor(); + // Apply saved user font scale so fonts are correct on first reload { float fs = settings_->getFontScale(); @@ -1786,6 +1793,17 @@ void App::render() console_exec_ = std::make_unique(this); } console_tab_.render(*console_exec_); + // Persist the console toolbar toggles (ConsoleTab has no settings pointer). Save only when + // a value actually changed — this runs every frame the console is visible and save() is + // disk I/O — and only here in the Console case where these statics can change. + if (settings_) { + if (ui::ConsoleTab::s_line_accents_enabled != settings_->getConsoleLineAccents() || + ui::ConsoleTab::s_line_text_color_enabled != settings_->getConsoleTextColor()) { + settings_->setConsoleLineAccents(ui::ConsoleTab::s_line_accents_enabled); + settings_->setConsoleTextColor(ui::ConsoleTab::s_line_text_color_enabled); + settings_->save(); + } + } break; case ui::NavPage::Settings: ui::RenderSettingsPage(this); diff --git a/src/config/settings.cpp b/src/config/settings.cpp index 70d2873..5ff57d1 100644 --- a/src/config/settings.cpp +++ b/src/config/settings.cpp @@ -175,6 +175,8 @@ bool Settings::load(const std::string& path) loadScalar(j, "portfolio_style", portfolio_style_); if (portfolio_style_ < 0 || portfolio_style_ > 2) portfolio_style_ = 0; loadScalar(j, "scanline_enabled", scanline_enabled_); + loadScalar(j, "console_line_accents", console_line_accents_); + loadScalar(j, "console_text_color", console_text_color_); if (j.contains("hidden_addresses") && j["hidden_addresses"].is_array()) { hidden_addresses_.clear(); for (const auto& a : j["hidden_addresses"]) @@ -425,6 +427,8 @@ bool Settings::save(const std::string& path) j["balance_layout"] = balance_layout_; // saved as string ID j["portfolio_style"] = portfolio_style_; j["scanline_enabled"] = scanline_enabled_; + j["console_line_accents"] = console_line_accents_; + j["console_text_color"] = console_text_color_; j["hidden_addresses"] = json::array(); for (const auto& addr : hidden_addresses_) j["hidden_addresses"].push_back(addr); diff --git a/src/config/settings.h b/src/config/settings.h index b61dfda..9ea2cf1 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -189,6 +189,13 @@ public: bool getScanlineEnabled() const { return scanline_enabled_; } void setScanlineEnabled(bool v) { scanline_enabled_ = v; } + // Console output appearance: per-line left color accent bars, and per-channel text coloring. + // (Defaults match the ConsoleTab statics so an upgrade re-save doesn't flip visible behavior.) + bool getConsoleLineAccents() const { return console_line_accents_; } + void setConsoleLineAccents(bool v) { console_line_accents_ = v; } + bool getConsoleTextColor() const { return console_text_color_; } + void setConsoleTextColor(bool v) { console_text_color_ = v; } + // Hidden addresses (addresses hidden from the UI by the user) const std::set& getHiddenAddresses() const { return hidden_addresses_; } bool isAddressHidden(const std::string& addr) const { return hidden_addresses_.count(addr) > 0; } @@ -482,6 +489,8 @@ private: std::string balance_layout_ = "classic"; int portfolio_style_ = 0; // Market portfolio row style (0 single / 1 two-line / 2 hero) bool scanline_enabled_ = true; + bool console_line_accents_ = true; // left color accent bars in console output + bool console_text_color_ = true; // per-channel text coloring in console output std::set hidden_addresses_; std::set favorite_addresses_; std::map address_meta_; diff --git a/src/ui/windows/console_tab.cpp b/src/ui/windows/console_tab.cpp index 9e4495f..773695d 100644 --- a/src/ui/windows/console_tab.cpp +++ b/src/ui/windows/console_tab.cpp @@ -45,6 +45,7 @@ ImU32 ConsoleTab::COLOR_INFO = IM_COL32(191, 209, 229, 255); ImU32 ConsoleTab::COLOR_RPC = IM_COL32(120, 180, 255, 210); bool ConsoleTab::s_scanline_enabled = true; bool ConsoleTab::s_line_accents_enabled = true; +bool ConsoleTab::s_line_text_color_enabled = true; float ConsoleTab::s_console_zoom = 1.0f; bool ConsoleTab::s_daemon_messages_enabled = true; bool ConsoleTab::s_errors_only_enabled = false; @@ -189,6 +190,10 @@ void ConsoleTab::refreshColors() ImU32 ConsoleTab::channelTextColor(ConsoleChannel channel) const { using namespace material; + // Monochrome mode: collapse every channel (and JSON syntax role) to the neutral result-body + // color. COLOR_RESULT is theme-correct (contrast-floored on light terminals in refreshColors), + // so text stays readable. The left accent bars are gated separately and stay independent. + if (!s_line_text_color_enabled) return COLOR_RESULT; switch (channel) { // COLOR_* channels are already palette-derived + contrast-floored in refreshColors(). The // roles below are computed live from the theme palette, so floor them to a readable contrast on @@ -560,6 +565,18 @@ void ConsoleTab::renderToolbar(ConsoleCommandExecutor& exec) if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_accents")); } + // Text-color toggle: colored per-channel text vs. monochrome (grouped with the accent toggle). + ImGui::SameLine(); + { + float btnSz = ImGui::GetFrameHeight(); + if (!s_line_text_color_enabled) + ImGui::PushStyleColor(ImGuiCol_Text, ImGui::ColorConvertU32ToFloat4(OnSurfaceDisabled())); + if (TactileButton(ICON_MD_FORMAT_COLOR_TEXT, ImVec2(btnSz, btnSz), Type().iconMed())) + s_line_text_color_enabled = !s_line_text_color_enabled; + if (!s_line_text_color_enabled) ImGui::PopStyleColor(); + if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("console_toggle_text_color")); + } + // Zoom +/- buttons (right side of toolbar) ImGui::SameLine(); ImGui::Spacing(); diff --git a/src/ui/windows/console_tab.h b/src/ui/windows/console_tab.h index 22b025d..4229347 100644 --- a/src/ui/windows/console_tab.h +++ b/src/ui/windows/console_tab.h @@ -72,6 +72,9 @@ public: // Draw the per-line left color accent bars (channel-colored). Toggled from the toolbar. static bool s_line_accents_enabled; + // Color output text per channel. When false the console is monochrome text. Toolbar-toggled. + static bool s_line_text_color_enabled; + // Show/hide daemon output messages static bool s_daemon_messages_enabled; diff --git a/src/util/i18n.cpp b/src/util/i18n.cpp index 408743e..74730ac 100644 --- a/src/util/i18n.cpp +++ b/src/util/i18n.cpp @@ -1291,6 +1291,7 @@ void I18n::loadBuiltinEnglish() strings_["console_zoom_in"] = "Zoom in"; strings_["console_zoom_out"] = "Zoom out"; strings_["console_toggle_accents"] = "Toggle line color accents"; + strings_["console_toggle_text_color"] = "Toggle line text colors"; // --- Export All Keys Dialog --- strings_["export_keys_btn"] = "Export Keys";