diff --git a/Command.cc b/Command.cc index 490c654..efa90f1 100644 --- a/Command.cc +++ b/Command.cc @@ -28,21 +28,6 @@ # include "imgui.h" #endif -// Define cross-frontend theme change flags declared in GUITheme.h -namespace kte { -bool gThemeChangePending = false; -std::string gThemeChangeRequest; -// Font change request globals -bool gFontChangePending = false; -std::string gFontFamilyRequest; -float gFontSizeRequest = 0.0f; -std::string gCurrentFontFamily; -float gCurrentFontSize = 0.0f; -// Request a visual font dialog -bool gFontDialogRequested = false; -} - - // UTF-8 aware stepping. Cursor columns are byte offsets; these keep motion // and deletion on code point boundaries so a multibyte character is never // split. Malformed bytes are treated as single-byte characters. @@ -425,7 +410,6 @@ allowed_during_prompt(CommandId id) case CommandId::FontZoomOut: case CommandId::FontZoomReset: case CommandId::VisualFilePickerToggle: - case CommandId::VisualFontPickerToggle: return true; default: return false; @@ -1742,7 +1726,7 @@ cmd_set_option(CommandContext &ctx) } -// GUI theme cycling commands (available in GUI build; ImGui-only for now) +// GUI theme cycling commands (available in GUI build) #if defined(KTE_BUILD_GUI) static bool cmd_theme_next(CommandContext &ctx) @@ -1884,37 +1868,13 @@ cmd_font_set_by_name(const CommandContext &ctx) static bool cmd_font_set_by_name(CommandContext &ctx) { - // Non-GUI build: record the requested font family - std::string name = ctx.arg; - // trim - auto ltrim = [](std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { - return !std::isspace(ch); - })); - }; - auto rtrim = [](std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { - return !std::isspace(ch); - }).base(), s.end()); - }; - ltrim(name); - rtrim(name); - if (name.empty()) { - // Show current font when no argument provided - std::string cur = kte::gCurrentFontFamily.empty() ? std::string("default") : kte::gCurrentFontFamily; - ctx.editor.SetStatus(std::string("Current font: ") + cur); - return true; - } - kte::gFontFamilyRequest = name; - // Keep size if not specified by user; signal change - kte::gFontChangePending = true; - ctx.editor.SetStatus(std::string("Font requested: ") + name); + ctx.editor.SetStatus("Fonts are not available in the terminal"); return true; } #endif -// Font size set (GUI, ImGui-only for now) +// Font size set (GUI) #if defined(KTE_BUILD_GUI) static bool cmd_font_set_size(const CommandContext &ctx) @@ -1974,38 +1934,7 @@ cmd_font_set_size(const CommandContext &ctx) static bool cmd_font_set_size(CommandContext &ctx) { - // Non-GUI build: parse size and record the request - std::string a = ctx.arg; - auto ltrim = [](std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { - return !std::isspace(ch); - })); - }; - auto rtrim = [](std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { - return !std::isspace(ch); - }).base(), s.end()); - }; - ltrim(a); - rtrim(a); - if (a.empty()) { - float cur = (kte::gCurrentFontSize > 0.0f) ? kte::gCurrentFontSize : 18.0f; - ctx.editor.SetStatus(std::string("Current font size: ") + std::to_string((int) std::round(cur))); - return true; - } - char *endp = nullptr; - float size = strtof(a.c_str(), &endp); - if (endp == a.c_str() || !std::isfinite(size)) { - ctx.editor.SetStatus("font-size: expected number"); - return true; - } - if (size < 6.0f) - size = 6.0f; - if (size > 96.0f) - size = 96.0f; - kte::gFontSizeRequest = size; - kte::gFontChangePending = true; - ctx.editor.SetStatus(std::string("Font size requested: ") + std::to_string((int) std::round(size))); + ctx.editor.SetStatus("Fonts are not available in the terminal"); return true; } #endif @@ -2048,7 +1977,7 @@ cmd_toggle_edit_mode(const CommandContext &ctx) } -// Background set command (GUI, ImGui-only for now) +// Background set command (GUI) #if defined(KTE_BUILD_GUI) static bool cmd_background_set(const CommandContext &ctx) @@ -2222,20 +2151,6 @@ cmd_visual_file_picker_toggle(const CommandContext &ctx) } -// GUI: request visual font picker (sets a flag for the frontend) -static bool -cmd_visual_font_picker_toggle(const CommandContext &ctx) -{ -#ifdef KTE_BUILD_GUI - kte::gFontDialogRequested = true; - ctx.editor.SetStatus("Font chooser"); -#else - ctx.editor.SetStatus("Font chooser not available in terminal"); -#endif - return true; -} - - static bool cmd_jump_to_line_start(const CommandContext &ctx) { @@ -5627,10 +5542,6 @@ InstallDefaultCommands() CommandId::VisualFilePickerToggle, "file-picker-toggle", "Toggle visual file picker", cmd_visual_file_picker_toggle, false, false }); - CommandRegistry::Register({ - CommandId::VisualFontPickerToggle, "font-picker-toggle", "Show visual font picker", - cmd_visual_font_picker_toggle, false, false - }); // Working directory CommandRegistry::Register({ CommandId::ShowWorkingDirectory, "show-working-directory", "Show current working directory", diff --git a/Command.h b/Command.h index f6af21c..4f99480 100644 --- a/Command.h +++ b/Command.h @@ -28,7 +28,6 @@ enum class CommandId { OpenFileStart, // begin open-file prompt VisualFilePickerToggle, // GUI-only: toggle/show a visual font selector dialog - VisualFontPickerToggle, // Buffers BufferSwitchStart, // begin buffer switch prompt BufferNew, // create a new empty, unnamed buffer (C-k i) diff --git a/GUITheme.h b/GUITheme.h index 8f6747a..6cdde35 100644 --- a/GUITheme.h +++ b/GUITheme.h @@ -8,20 +8,6 @@ #include "Highlight.h" -// Cross-frontend theme change request hook: declared here, defined in Command.cc -namespace kte { -extern bool gThemeChangePending; -extern std::string gThemeChangeRequest; // raw user-provided name -// Font change request hooks and current font state (set by command handlers) -extern bool gFontChangePending; -extern std::string gFontFamilyRequest; // requested family (case-insensitive) -extern float gFontSizeRequest; // <= 0 means keep size -extern std::string gCurrentFontFamily; // last applied family -extern float gCurrentFontSize; // last applied size -// Request to show a visual font dialog (set by command handler) -extern bool gFontDialogRequested; -} - #include #include #include diff --git a/REWRITE.md b/REWRITE.md index 83988b2..88c3294 100644 --- a/REWRITE.md +++ b/REWRITE.md @@ -848,7 +848,6 @@ pub enum CommandId { // GUI-specific VisualFilePickerToggle, - VisualFontPickerToggle, ThemeNext, ThemePrev, ThemeSetByName, diff --git a/TermWidth.h b/TermWidth.h index 05c8a1a..e2a8bfa 100644 --- a/TermWidth.h +++ b/TermWidth.h @@ -8,7 +8,6 @@ #include #include #include -#include namespace kte { // Tab stops every kTabWidth columns, in every frontend and in the command @@ -70,24 +69,4 @@ MeasureChar(std::string_view line, std::size_t i, std::size_t col, std::size_t & else width = static_cast(CellWidth(wch)); } - - -// The display column at which each byte of `line` is drawn (bytes inside a -// multi-byte character share its column); out[line.size()] is the line's -// width. Lets a renderer map byte offsets to columns without rescanning. -inline void -DisplayColumns(std::string_view line, std::vector &out) -{ - out.assign(line.size() + 1, 0); - std::size_t col = 0; - for (std::size_t i = 0; i < line.size();) { - std::size_t len = 1, width = 1; - MeasureChar(line, i, col, len, width); - for (std::size_t k = 0; k < len && i + k < line.size(); ++k) - out[i + k] = col; - col += width; - i += len; - } - out[line.size()] = col; -} } // namespace kte