Add proportional fonts, edit modes, and TOML config

- Add three proportional serif fonts: Crimson Pro, ET Book, Spectral
- Fix text rendering for variable-width fonts: selection, cursor,
  mouse click mapping, search highlights, and syntax-colored text
  now use pixel-accurate measurement via ImGui::CalcTextSize()
- Add per-buffer edit mode (code/writing) with auto-detection from
  file extension (.txt, .md, .rst, .org, .tex default to writing)
- Add C-k m keybinding and :mode command to toggle edit modes
- Switch config format from INI to TOML (kge.toml), with legacy
  INI fallback; vendor toml++ v3.4.0
- New config keys: font.code and font.writing for per-mode defaults
- Add font tab completion for ImGui builds
- Add tab completion for :mode command
- Update help text, themes.md, and add CONFIG.md
- Bump version to 1.10.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 23:05:56 -07:00
parent 0585edad9e
commit 23f04e4357
21 changed files with 24521 additions and 123 deletions

View File

@@ -38,6 +38,11 @@ apply_syntax_to_buffer(Buffer *b, const GUIConfig &cfg)
{
if (!b)
return;
// Auto-detect edit mode from file extension
if (!b->Filename().empty())
b->SetEditMode(DetectEditMode(b->Filename()));
if (cfg.syntax) {
b->SetSyntaxEnabled(true);
b->EnsureHighlighter();
@@ -518,6 +523,9 @@ GUIFrontend::Step(Editor &ed, bool &running)
// Allow deferred opens
wed.ProcessPendingOpens();
// Ensure newly opened buffers get syntax + edit mode detection
apply_syntax_to_buffer(wed.CurrentBuffer(), config_);
// Drain input queue
for (;;) {
MappedInput mi;
@@ -557,6 +565,25 @@ GUIFrontend::Step(Editor &ed, bool &running)
running = false;
}
// Switch font based on current buffer's edit mode
{
Buffer *cur = wed.CurrentBuffer();
if (cur) {
auto &fr = kte::Fonts::FontRegistry::Instance();
const std::string &expected =
(cur->GetEditMode() == EditMode::Writing)
? config_.writing_font
: config_.code_font;
if (fr.CurrentFontName() != expected && fr.HasFont(expected)) {
float sz = fr.CurrentFontSize();
if (sz <= 0.0f) sz = config_.font_size;
fr.LoadFont(expected, sz);
ImGui_ImplOpenGL3_DestroyFontsTexture();
ImGui_ImplOpenGL3_CreateFontsTexture();
}
}
}
// Draw
ws.renderer.Draw(wed);