Remove what only the Qt frontend used

- The theme/font request globals (gThemeChange*, gFont*Request,
  gFontChangePending, gCurrentFont*, gFontDialogRequested): only Qt
  read them.
- The font-picker-toggle command: it only set gFontDialogRequested, so
  it did nothing in kge or kte.
- The terminal :font and :font-size recorded requests nothing read and
  answered "Font requested"; they now say fonts are not available in
  the terminal.
- kte::DisplayColumns, added for Qt's drawing and now unused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-24 14:41:12 -07:00
co-authored by Claude Opus 5.5
parent 501245da3d
commit b1576c4228
5 changed files with 5 additions and 131 deletions
+5 -94
View File
@@ -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",
-1
View File
@@ -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)
-14
View File
@@ -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 <imgui.h>
#include <vector>
#include <memory>
-1
View File
@@ -848,7 +848,6 @@ pub enum CommandId {
// GUI-specific
VisualFilePickerToggle,
VisualFontPickerToggle,
ThemeNext,
ThemePrev,
ThemeSetByName,
-21
View File
@@ -8,7 +8,6 @@
#include <cstddef>
#include <cwchar>
#include <string_view>
#include <vector>
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<std::size_t>(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<std::size_t> &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