Documentation scrub

README now covers fetching, building, installing and using kte/kge.
The man pages are rewritten against KKeymap.cc and the command
registry: missing bindings and prompt commands, +N, kte --gui exiting
with status 2, real FILES, the theme list, and a full kge.toml
reference including the [font] keys. CONFIG.md, themes.md, swap.md,
syntax.md, the developer guide and the in-editor help are corrected
where they had drifted from the code. ke.md is labelled as the
predecessor's manual.

: font is left out of the docs: the per-frame edit-mode font switch
in ImGuiFrontend.cc reloads the configured font right after it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:02:51 -08:00
co-authored by Claude Opus 5.5
parent c52a54cc59
commit 6dcfaa93ef
12 changed files with 903 additions and 528 deletions
+2 -1
View File
@@ -51,7 +51,8 @@ Then update `/opt/homebrew/Library/Taps/kisom/homebrew-tap` and push. Leave unre
Report the zip SHA256, the release URL, and the tap commits. Report the zip SHA256, the release URL, and the tap commits.
## Docs that govern ## Docs that govern
- `docs/ke.md` — canonical keybinding/spec reference, inherited from the predecessor editor `ke` - `docs/kte.1`, `docs/kge.1` — user manual and keybinding reference (keep the two pages' shared sections in step, and in step with `KKeymap.cc` and `HelpText.cc`)
- `docs/ke.md` — manual of the predecessor editor `ke`; historical, not kte's spec
- `REWRITE.md`, `ROADMAP.md`, `CONFIG.md` — design rationale, roadmap, and config reference - `REWRITE.md`, `ROADMAP.md`, `CONFIG.md` — design rationale, roadmap, and config reference
- `README.md` — project overview - `README.md` — project overview
+41 -15
View File
@@ -1,7 +1,11 @@
# kge Configuration # kge Configuration
kge loads configuration from `~/.config/kte/kge.toml`. If no TOML file is kge reads `~/.config/kte/kge.toml` when it starts. Every setting is
found, it falls back to the legacy `kge.ini` format. optional; leave out anything you're happy with. If the file is missing,
or has a syntax error (kge prints the error), kge falls back to the
older `kge.ini` format described at the end.
The terminal editor, `kte`, has no configuration file.
## TOML Format ## TOML Format
@@ -39,14 +43,34 @@ syntax = true
| `columns` | int | 80 | Initial window width in columns | | `columns` | int | 80 | Initial window width in columns |
| `rows` | int | 42 | Initial window height in rows | | `rows` | int | 42 | Initial window height in rows |
`columns` and `rows` outside 1–1000 are ignored.
### `[font]` ### `[font]`
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----------|--------|--------------|------------------------------------------| |-----------|--------|--------------|------------------------------------------|
| `name` | string | "default" | Default font loaded at startup | | `name` | string | "default" | Base font; `code` and `writing` fall back to it |
| `size` | float | 18.0 | Font size in pixels | | `size` | float | 18.0 | Font size in pixels (4–200) |
| `code` | string | "default" | Font for code mode (monospace) | | `code` | string | same as `name` | Font for code mode |
| `writing` | string | "crimsonpro" | Font for writing mode (proportional) | | `writing` | string | "crimsonpro" | Font for writing mode |
How the three font names fit together:
- `code` follows `name` unless you set it.
- `writing` stays "crimsonpro" unless you set it, or you set `name` to
something other than "default", in which case it follows `name`.
So `name = "iosevka"` on its own gives you Iosevka everywhere. Add
`writing = "etbook"` to keep a serif font for prose.
Each buffer is drawn in the font for its edit mode, so in practice
`code` and `writing` are the fonts you see; `name` only supplies their
defaults.
`"default"` is Berkeley Mono Bold (the same as `berkeley-bold`). Set
fonts here; the size can also change while kge runs, with
`: font-size NUM` (press `C-k ;` for the prompt) or Ctrl `+`/`-`/`0`
(Cmd on macOS). Ctrl+0 goes back to `size`.
### `[appearance]` ### `[appearance]`
@@ -66,9 +90,9 @@ syntax = true
kge has two edit modes that control which font is used: kge has two edit modes that control which font is used:
- **code** — Uses the monospace font (`font.code`). Default for source files. - **code** — Uses the monospace font (`font.code`). Default for source files.
- **writing** — Uses the proportional font (`font.writing`). Auto-detected - **writing** — Uses the proportional font (`font.writing`), with no
for `.txt`, `.md`, `.markdown`, `.rst`, `.org`, `.tex`, `.adoc`, and syntax highlighting. Files ending in `.txt`, `.md`, `.markdown`,
`.asciidoc` files. `.rst`, `.org`, `.tex`, `.adoc` or `.asciidoc` open in this mode.
Toggle with `C-k m` or `: mode [code|writing]`. Toggle with `C-k m` or `: mode [code|writing]`.
@@ -89,13 +113,15 @@ crimsonpro, etbook, spectral
amber, eink, everforest, gruvbox, kanagawa-paper, lcars, leuchtturm, nord, amber, eink, everforest, gruvbox, kanagawa-paper, lcars, leuchtturm, nord,
old-book, orbital, plan9, solarized, tufte, weyland-yutani, zenburn old-book, orbital, plan9, solarized, tufte, weyland-yutani, zenburn
Themes with light/dark variants: eink, gruvbox, leuchtturm, old-book, Themes with light and dark versions: eink, gruvbox, kanagawa-paper,
solarized. Set `background = "light"` or use `: background light`. leuchtturm, old-book, solarized, tufte. Set `background = "light"` or
use `: background light`. See [docs/themes.md](docs/themes.md) for
descriptions and how to add a theme.
## Migrating from kge.ini ## Migrating from kge.ini
If you have an existing `kge.ini`, kge will still read it but prints a If you have an existing `kge.ini` and no `kge.toml`, kge still reads it
notice to stderr suggesting migration. To migrate, create `kge.toml` in the but prints a notice to stderr suggesting migration. To migrate, create `kge.toml` in the
same directory (`~/.config/kte/`) using the format above. The TOML file same directory (`~/.config/kte/`) using the format above. The TOML file
takes priority when both exist. takes priority when both exist.
@@ -112,5 +138,5 @@ The INI keys map to TOML as follows:
| `background` | `appearance.background` | | `background` | `appearance.background` |
| `syntax` | `editor.syntax` | | `syntax` | `editor.syntax` |
New keys `font.code` and `font.writing` have no INI equivalent (the INI | `code_font` | `font.code` |
parser accepts `code_font` and `writing_font` if needed). | `writing_font`| `font.writing` |
+12 -1
View File
@@ -64,6 +64,7 @@ HelpText::Text()
" ESC d Delete next word (Alt-d)\n" " ESC d Delete next word (Alt-d)\n"
" ESC BACKSPACE Delete previous word (Alt-Backspace)\n" " ESC BACKSPACE Delete previous word (Alt-Backspace)\n"
" ESC q Reflow paragraph\n" " ESC q Reflow paragraph\n"
" ESC Enter Newline without auto-indent\n"
"\n" "\n"
"Universal argument:\n" "Universal argument:\n"
" C-u Begin repeat count (then type digits); C-u alone multiplies by 4\n" " C-u Begin repeat count (then type digits); C-u alone multiplies by 4\n"
@@ -85,9 +86,15 @@ HelpText::Text()
"\n" "\n"
"Edit modes:\n" "Edit modes:\n"
" code Monospace font (default for source files)\n" " code Monospace font (default for source files)\n"
" writing Proportional font (auto for .txt, .md, .rst, .org, .tex)\n" " writing Proportional font, no highlighting (auto for .txt, .md,\n"
" .markdown, .rst, .org, .tex, .adoc, .asciidoc)\n"
" C-k m or : mode [code|writing] to toggle\n" " C-k m or : mode [code|writing] to toggle\n"
"\n" "\n"
"Command prompt (C-k ;, Tab completes):\n"
" : syntax on|off|reload Syntax highlighting for this buffer\n"
" : set filetype=NAME Pick the highlighter (cpp, go, python, rust,\n"
" shell, json, markdown, lisp, sql, erlang, forth)\n"
"\n"
"GUI commands (command prompt):\n" "GUI commands (command prompt):\n"
" : theme NAME Set theme (amber, eink, everforest, gruvbox,\n" " : theme NAME Set theme (amber, eink, everforest, gruvbox,\n"
" kanagawa-paper, lcars, leuchtturm, nord, old-book,\n" " kanagawa-paper, lcars, leuchtturm, nord, old-book,\n"
@@ -108,6 +115,10 @@ HelpText::Text()
" Config file: ~/.config/kte/kge.toml (see CONFIG.md)\n" " Config file: ~/.config/kte/kge.toml (see CONFIG.md)\n"
" Legacy kge.ini is also supported.\n" " Legacy kge.ini is also supported.\n"
"\n" "\n"
"GUI keys (Cmd instead of Ctrl on macOS):\n"
" Ctrl+= Ctrl+- Ctrl+0 Font size bigger / smaller / reset\n"
" Ctrl+V Paste from the system clipboard\n"
"\n"
"GUI window management:\n" "GUI window management:\n"
" Cmd+N (macOS) Open a new editor window sharing the same buffers\n" " Cmd+N (macOS) Open a new editor window sharing the same buffers\n"
" Ctrl+Shift+N (Linux) Open a new editor window sharing the same buffers\n" " Ctrl+Shift+N (Linux) Open a new editor window sharing the same buffers\n"
+156 -119
View File
@@ -1,148 +1,185 @@
kte - Kyle's Text Editor kte - Kyle's Text Editor
========================
![Editor screenshot](./docs/screenshot.jpg) ![Editor screenshot](./docs/screenshot.jpg)
Vision kte is a small text editor with WordStar-style `C-k` commands and a
------- few Emacs habits. It comes in two forms that share one editor core:
kte is a small, fast, and understandable text editor with a
terminal-first UX and an optional ImGui GUI. It modernizes the
original ke editor while preserving its familiar WordStar/VDE‑style
command model and Emacs‑influenced ergonomics. The focus is on
simplicity of design, excellent latency, and pragmatic features you
can learn and keep in your head.
I am experimenting with using Jetbrains Junie to assist in - `kte` runs in a terminal (ncurses).
development, largely as a way to learn the effective use of agentic - `kge` is the graphical version (SDL2, OpenGL and Freetype through
coding. I worked with the agent by feeding it notes that I've been Dear ImGui). It adds themes, a choice of embedded fonts and multiple
taking about text editors for the last few years, as well as the windows.
sources from the original ke editor that is all handwritten C.
Project Goals This project is a hobby text editor meant to be my personal editor. I
------------- do not warrant its suitability for anyone else.
- Keep the core minimal and readable; favor straightforward data
structures (gap buffer, piece table) and incremental evolution.
- Round‑trip editing of large files with low latency in a terminal
environment.
- Preserve ke keybindings and command semantics wherever sensible;
smooth migration for ke users.
- Provide a clean separation between core model, input, and rendering
so a GUI can grow independently of the TUI.
- Minimize dependencies; the GUI layer remains optional and isolated.
Keybindings Getting kte
----------- -----------
kte maintains ke’s command model while internals evolve. Highlights (
subject to refinement):
- K‑command prefix: `C-k` enters k‑command mode; exit with `ESC` or The source lives at <https://github.com/kisom/kte> (mirrored from
`C-g`. `git.wntrmute.dev:kyle/kte`):
- Save/Exit: `C-k s` (save), `C-k x` or `C-k C-x` (save and exit),
`C-k q` (quit with confirm), `C-k C-q` (quit immediately).
- Editing: `C-k d` (kill to EOL), `C-k C-d` (kill line), `C-w` (kill
region), `C-y` (yank), `C-u` (universal argument).
- Navigation/Search: `C-s` (incremental find), `C-r` (regex search),
`ESC f/b` (word next/prev), `ESC BACKSPACE` (delete previous word).
- Buffers/Files: `C-k e` (open), `C-k b`/`C-k p` (switch), `C-k c`
(close), `C-k l` (reload).
- Misc: `C-l` (refresh), `C-g` (cancel), `C-k g` (goto line).
See `ke.md` for the canonical ke reference retained for now.
Build and Run
-------------
Prerequisites: C++20 compiler, CMake, and ncurses development
headers/libs.
Dependencies by platform
------------------------
- macOS (Homebrew)
- Terminal (default):
- `brew install ncurses`
- Optional GUI (enable with `-DBUILD_GUI=ON`):
- `brew install sdl2 freetype`
- OpenGL is provided by the system framework on macOS; no
package needed.
- Debian/Ubuntu
- Terminal (default):
- `sudo apt-get install -y libncurses5-dev libncursesw5-dev`
- Optional GUI (enable with `-DBUILD_GUI=ON`):
-
`sudo apt-get install -y libsdl2-dev libfreetype6-dev mesa-common-dev`
- The `mesa-common-dev` package provides OpenGL headers/libs (
`libGL`).
- NixOS/Nix
- Terminal (default):
- Ad-hoc shell: `nix-shell -p cmake gcc ncurses`
- Optional GUI (enable with `-DBUILD_GUI=ON`):
- Ad-hoc shell:
`nix-shell -p cmake gcc ncurses SDL2 freetype libGL`
- With flakes/devshell (example `flake.nix` inputs not provided):
include
`ncurses` for TUI, and `SDL2`, `freetype`, `libGL` for GUI in your
devShell.
Notes
-----
- The GUI is OFF by default to keep SDL/OpenGL/Freetype optional. Enable
it by
configuring with `-DBUILD_GUI=ON` and ensuring the GUI deps above are
installed for your platform.
- If you previously configured with GUI ON and want to disable it,
reconfigure
the build directory with `-DBUILD_GUI=OFF`.
Example build:
``` ```
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug git clone https://github.com/kisom/kte.git
cmake --build cmake-build-debug cd kte
``` ```
Run: On macOS you can skip building and use Homebrew:
``` ```
./cmake-build-debug/kte [files] brew install kisom/tap/kte # terminal editor
brew install --cask kisom/tap/kge # graphical editor (kge.app)
``` ```
If you configured the GUI, you can also run the GUI-first target (when Each [GitHub release](https://github.com/kisom/kte/releases) also has a
built as `kge`) or request the GUI from `kte`: prebuilt `kge.app.zip` for macOS.
Building
--------
You need a C++20 compiler, CMake and ncurses. The GUI also needs SDL2
and Freetype (plus OpenGL, which macOS already provides). If PCRE2 is
installed, regex search uses it; otherwise kte falls back to
`std::regex`.
Install the dependencies:
- macOS (Homebrew): `brew install cmake ncurses sdl2 freetype pcre2`
- Debian/Ubuntu: `sudo apt-get install -y build-essential cmake
pkg-config libncurses-dev libsdl2-dev libfreetype6-dev mesa-common-dev
libpcre2-dev`
- Alpine: see the package list in the `Dockerfile`.
- Nix: `nix develop` gives you a shell with everything (`nix develop
.#terminal` for the terminal-only set).
Then configure and build:
``` ```
./cmake-build-debug/kte --gui [files] cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
# or if built/installed as a separate GUI target cmake --build build
./cmake-build-debug/kge [files]
``` ```
GUI build example That builds `build/kte` and `build/kge` (on macOS, `build/kge.app`). To
----------------- build only the terminal editor, and skip the GUI dependencies, add
`-DBUILD_GUI=OFF` to the first command. `-DBUILD_TESTS=OFF` skips the
test suite.
To build with the optional GUI (after installing the GUI dependencies With Nix you can also build straight from the flake: `nix build .#kte`
listed above): or `nix build .#kge`.
Installing
----------
``` ```
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -DBUILD_GUI=ON sudo cmake --install build
cmake --build cmake-build-debug
./cmake-build-debug/kte --gui [files]
``` ```
Theming and Fonts This installs into `/usr/local` by default (pick another place with
`--prefix DIR`). You get the `kte` and `kge` binaries, the `kte(1)` and
`kge(1)` man pages, and on Linux a desktop entry and icons for kge. On
macOS the install puts the app at `/usr/local/kge.app` (that is, under
the prefix); move it to `/Applications`, or just copy `build/kge.app`
there yourself.
To install from Nix: `nix profile install .#kte` (or `.#kge`).
Using kte
---------
Open files by naming them:
```
kte notes.md main.cc
kge +120 Buffer.cc # open Buffer.cc at line 120
```
With no files you get an empty buffer. `kte` always runs in the
terminal; `kge` opens a window, and `kge --term` runs it in the
terminal instead.
Most commands start with `C-k` (Control-K) followed by another key.
`C-g` cancels anything half-typed. Press `C-k h` for the built-in help,
which lists every binding; the man page (`man kte`) has the same list
with more detail. The ones you need on day one:
| Keys | What it does |
|-------------------------|-----------------------------------------------|
| `C-k s` | Save (asks for a name if the buffer has none) |
| `C-k x` | Save and quit |
| `C-k q` | Quit; press it twice to discard changes |
| `C-k e` | Open another file |
| `C-k b`, `C-k n`/`C-k p`| Switch buffers; previous/next buffer |
| `C-k c` | Close the current buffer |
| `C-k u`, `C-k r` | Undo, redo |
| `C-k g` | Go to a line |
| `C-a`/`C-e` | Start/end of line |
| `C-f`/`C-b`/`C-n`/`C-p` | Right/left/down/up (arrow keys work too) |
| `ESC f`/`ESC b` | Next/previous word |
| `ESC <`/`ESC >` | Start/end of the file |
| `C-s`, `C-r` | Incremental search, regex search |
| `C-h`, `C-t` | Search and replace, regex search and replace |
| `ESC m` or `C-k SPACE` | Set the mark (start a selection) |
| `C-w`, `ESC w`, `C-y` | Cut, copy, paste (kill, copy, yank) |
| `C-k d`, `C-k C-d` | Delete to end of line; delete the whole line |
| `ESC q` | Reflow the paragraph to 72 columns |
| `C-u N` | Repeat the next command N times |
`ESC` followed by a key is the same as holding Alt (Meta) and pressing
it.
`C-k ;` opens a command prompt for things that don't have a key. Type
a command and press Enter; Tab completes. For example:
```
: syntax off
: set filetype=python
: theme gruvbox (kge)
: font-size 20 (kge)
```
If kte crashes or the machine goes down, your edits aren't lost. Each
buffer keeps a journal under `~/.local/state/kte/swap/`, and the next
time you open the file kte asks whether to recover them.
### kge: themes, fonts and windows
kge has 15 color themes and two dozen built-in fonts. Switch themes
while you work with `: theme NAME`, and change the text size with Ctrl
`+`/`-`/`0` (Cmd on macOS). Fonts are chosen in the config file below. `C-k m` switches between code
mode (a monospace font) and writing mode (a proportional font, used by
default for `.md`, `.txt` and similar files). Cmd+N (macOS) or
Ctrl+Shift+N opens another window onto the same buffers.
Settings that should stick go in `~/.config/kte/kge.toml`:
```toml
[font]
name = "iosevka" # the font for everything not set below
size = 18.0 # in pixels
writing = "etbook" # the font for writing mode
[appearance]
theme = "gruvbox"
background = "light"
```
[CONFIG.md](CONFIG.md) lists every setting, font and theme, and
[docs/themes.md](docs/themes.md) explains how to add a theme. The
terminal editor has no configuration file.
More documentation
------------------ ------------------
The GUI (`kge`) ships with 15 built-in color themes (several with - `kte(1)`, `kge(1)`: the man pages (`docs/kte.1`, `docs/kge.1` in
light/dark variants), each with a matching syntax-highlighting the source tree).
palette, plus two dozen embedded fonts. Switch either at runtime from - [docs/DEVELOPER_GUIDE.md](docs/DEVELOPER_GUIDE.md): how the code is
the command prompt with `: theme NAME` and `: font NAME` (both tab- put together, for anyone working on kte itself.
complete), or set defaults in `~/.config/kte/kge.toml`. `: help` lists - [docs/ke.md](docs/ke.md): the manual for ke, the older C editor kte
the available theme and font names; see `docs/themes.md` for the full replaces. Most of its bindings carried over, but not all of them.
theme reference and how to add a new one.
Status
------
- This project is a hobby text editor meant to be my personal editor. I
do not warrant its suitability for anyone else.
+2 -2
View File
@@ -8,6 +8,6 @@ ROADMAP / TODO:
- [x] When the filename is longer than the message window, scoot left to - [x] When the filename is longer than the message window, scoot left to
keep it in view keep it in view
- [x] Syntax highlighting - [x] Syntax highlighting
- [ ] Swap files (crash recovery). See `docs/plans/swap-files.md` - [x] Swap files (crash recovery). See `docs/swap.md`
- [ ] The undo system should actually work - [x] The undo system should actually work
- [ ] LSP integration - [ ] LSP integration
+29 -27
View File
@@ -84,17 +84,15 @@ Represents an open document. Manages:
- Swap recording integration - Swap recording integration
**Key Insight**: Buffer wraps a PieceTable and provides a higher-level **Key Insight**: Buffer wraps a PieceTable and provides a higher-level
interface. The nested `Buffer::Line` class is a legacy wrapper that has interface. The old `Buffer::Line` wrapper and `Buffer::Rows()` are gone;
been largely phased out in favor of direct PieceTable operations. read lines through the APIs below.
**Line Access APIs**: Buffer provides three ways to access line content: **Line Access APIs**: Buffer provides three ways to access line content:
- `GetLineView(row)` - Zero-copy `string_view` (fastest, 11x faster than - `Nrows()` - Number of lines
Rows()) - `GetLineView(row)` - Zero-copy `string_view` when the line lies within
- `GetLineString(row)` - Returns `std::string` copy (1.7x faster than one piece; valid only until the next buffer modification
Rows()) - `GetLineString(row)` - Returns a `std::string` copy
- `Rows()` - Materializes all lines into cache (legacy, avoid in new
code)
See `docs/BENCHMARKS.md` for detailed performance analysis and usage See `docs/BENCHMARKS.md` for detailed performance analysis and usage
guidance. guidance.
@@ -260,14 +258,17 @@ Test files by category:
- `test_command_semantics.cc` - Command execution - `test_command_semantics.cc` - Command execution
- `test_kkeymap.cc` - Keybinding system - `test_kkeymap.cc` - Keybinding system
- `test_visual_line_mode.cc` - Visual line selection - `test_visual_line_mode.cc` - Visual line selection
- `test_smart_newline.cc` - Enter copies the current line's indent
- `test_paste_split.cc` - Splitting pasted text into commands
- **Search and Replace**: - **Search and Replace**:
- `test_search.cc` - Search functionality - `test_search_replace_flow.cc` - Search and interactive
- `test_search_replace_flow.cc` - Interactive search/replace search/replace
- **Text Reflow**: - **Text Reflow**:
- `test_reflow_paragraph.cc` - Paragraph reformatting - `test_reflow_paragraph.cc` - Paragraph reformatting
- `test_reflow_indented_bullets.cc` - Indented list handling - `test_reflow_indented_bullets.cc` - Indented list handling
- `test_reflow_undo.cc` - Undo after a reflow
- **Undo System**: - **Undo System**:
- `test_undo.cc` - Undo/redo operations - `test_undo.cc` - Undo/redo operations
@@ -277,9 +278,13 @@ Test files by category:
- `test_swap_writer.cc` - Writing swap files - `test_swap_writer.cc` - Writing swap files
- `test_swap_replay.cc` - Replaying operations - `test_swap_replay.cc` - Replaying operations
- `test_swap_recovery_prompt.cc` - Recovery UI - `test_swap_recovery_prompt.cc` - Recovery UI
- `test_swap_cleanup.cc` - Cleanup logic - `test_swap_cleanup.cc`, `test_swap_cleanup2.cc` - Cleanup logic
- `test_swap_edge_cases.cc` - Minimal and truncated journal records
- `test_swap_git_editor.cc` - Git editor integration - `test_swap_git_editor.cc` - Git editor integration
- **Syntax Highlighting**:
- `test_syntax_highlighting.cc` - Highlighters and the engine cache
- **Performance and Migration**: - **Performance and Migration**:
- `test_benchmarks.cc` - Performance benchmarks for core operations - `test_benchmarks.cc` - Performance benchmarks for core operations
- `test_migration_coverage.cc` - Buffer::Line migration validation - `test_migration_coverage.cc` - Buffer::Line migration validation
@@ -287,9 +292,11 @@ Test files by category:
- **Integration Tests**: - **Integration Tests**:
- `test_daily_workflows.cc` - Real-world editing scenarios - `test_daily_workflows.cc` - Real-world editing scenarios
- `test_daily_driver_harness.cc` - Workflow test infrastructure - `test_daily_driver_harness.cc` - Workflow test infrastructure
- `test_audit_regressions.cc` - Regression tests for audit findings
**Total**: 98 tests across 22 test files. See `docs/BENCHMARKS.md` for **Total**: about 280 tests across 27 test files. `docs/BENCHMARKS.md`
performance benchmark results. records the benchmarks from the `Rows()` removal; that API no longer
exists, but the numbers explain why `GetLineView()` is preferred.
### Docker/Podman for Linux Builds ### Docker/Podman for Linux Builds
@@ -349,7 +356,7 @@ Mount your source tree and run the build + tests:
# Build and test (default command) # Build and test (default command)
docker run --rm -v "$(pwd):/kte" kte-linux docker run --rm -v "$(pwd):/kte" kte-linux
# Expected output: "98 tests passed, 0 failed" # Expected last line: "Done in N ms. Failures: 0"
``` ```
The default command builds both `kte` (terminal) and `kge` (GUI) The default command builds both `kte` (terminal) and `kge` (GUI)
@@ -475,12 +482,11 @@ TEST(Feature_Behavior_Scenario) {
### Common Pitfalls ### Common Pitfalls
- **Don't modify `Buffer::Rows()` directly** - Use the PieceTable API ( - **Mutate text only through the PieceTable API** (`insert_text`,
`insert_text`, `delete_text`, etc.) to ensure undo and swap recording `delete_text`, etc.) so undo and swap recording work correctly.
work correctly.
- **Prefer efficient line access** - Use `GetLineView()` for read-only - **Prefer efficient line access** - Use `GetLineView()` for read-only
access (11x faster than `Rows()`), or `GetLineString()` when you need access, or `GetLineString()` when you need a copy that outlives the
a copy. Avoid `Rows()` in new code. next edit.
- **Remember to invalidate caches** - If you modify PieceTable - **Remember to invalidate caches** - If you modify PieceTable
internals, ensure line index and materialization caches are internals, ensure line index and materialization caches are
invalidated. invalidated.
@@ -1120,15 +1126,11 @@ Areas where the codebase could be improved:
1. **Split Command.cc** - Break into logical groups (editing, 1. **Split Command.cc** - Break into logical groups (editing,
navigation, file ops, etc.) navigation, file ops, etc.)
2. **Complete Buffer::Line migration** - A few legacy editing functions 2. **Add more inline documentation** - Especially for complex algorithms
in Command.cc still use `Buffer::Rows()` directly (see lines 86-90 3. **Improve test coverage** - Add more edge case tests
comment) 4. **Performance profiling** - Continue monitoring performance with
3. **Add more inline documentation** - Especially for complex algorithms
4. **Improve test coverage** - Add more edge case tests (current: 98
tests)
5. **Performance profiling** - Continue monitoring performance with
benchmark suite benchmark suite
6. **API documentation** - Consider adding Doxygen-style comments 5. **API documentation** - Consider adding Doxygen-style comments
--- ---
+3 -3
View File
@@ -79,9 +79,9 @@ int main() {
// Inspect results // Inspect results
Buffer *buf = editor.CurrentBuffer(); Buffer *buf = editor.CurrentBuffer();
if (buf && buf->Rows().size() >= 2) { if (buf && buf->Nrows() >= 2) {
std::cout << "Line 1: " << std::string(buf->Rows()[0]) << "\n"; std::cout << "Line 1: " << buf->GetLineString(0) << "\n";
std::cout << "Line 2: " << std::string(buf->Rows()[1]) << "\n"; std::cout << "Line 2: " << buf->GetLineString(1) << "\n";
} }
frontend.Shutdown(); frontend.Shutdown();
+373 -158
View File
@@ -1,260 +1,475 @@
.\" kge(1) — Kyle's Graphical Editor (GUI-first) .\" kge(1) - Kyle's Graphical Editor
.\" .\"
.\" Project homepage: https://github.com/wntrmute/kte .\" The keybinding sections are copied from kte.1; keep the two in step.
.TH KGE 1 "2025-12-01" "kte 0.1.0" "User Commands" .TH KGE 1 "2026-11-17" "kte 1.14.0" "User Commands"
.SH NAME .SH NAME
kge \- Kyle's Graphical Editor (GUI-first) kge \- Kyle's Text Editor, graphical version
.SH SYNOPSIS .SH SYNOPSIS
.B kge .B kge
[ .RI [ options ]
.I options .RI [[+ line ]
] .IR file " ...]"
[
.I files ...
]
.SH DESCRIPTION .SH DESCRIPTION
.B kge .B kge
is the GUI-first build target of Kyle's Text Editor. It shares the same is the graphical version of
editor core and command model as
.BR kte (1),
and defaults to the graphical ImGui frontend when available. A terminal
(ncurses) frontend is also available and can be requested explicitly with
.B --term
or by invoking
.BR kte (1). .BR kte (1).
It has the same commands and keybindings and adds color themes, a
If one or more choice of built-in fonts, and multiple windows. It is built with SDL2,
.I files OpenGL and Dear ImGui.
are provided, they are opened on startup; otherwise, an empty buffer is .PP
created. Each
.I file
named on the command line opens in its own buffer. A file that does not
exist yet is created when you first save it. An argument of the form
.BI + N
moves the cursor to line
.I N
of the file that follows it. With no files,
.B kge
starts with an empty buffer.
.PP
On macOS
.B kge
is usually installed as the application
.IR kge.app .
.SH OPTIONS .SH OPTIONS
.TP .TP
.B -g, --gui .BR \-g ", " \-\-gui
Use the GUI frontend (default for Open a window. This is the default.
.B kge
when built).
.TP .TP
.B -t, --term .BR \-t ", " \-\-term
Use the terminal (ncurses) frontend instead of the GUI. Run in the terminal instead, exactly like
.BR kte (1).
.TP .TP
.B -h, --help .BR \-h ", " \-\-help
Display a brief usage summary and exit. Print a usage summary and exit.
.TP .TP
.B -V, --version .BR \-V ", " \-\-version
Print version information and exit. Print the version and exit.
.SH KEYBINDINGS .SH NOTATION
The GUI shares the same commands and keybindings as the terminal editor. .B C-x
They are summarized here for convenience. See the ke manual in the source means hold Control and press x.
tree for the canonical reference and notes: .B ESC x
.I docs/ke.md means press Escape and then x; holding Alt (Meta) while pressing x does
. the same thing.
.SS K-commands (prefix Ctrl-K) .B C-k x
.PP means press Control-K, let go, and then press x. Hold Control on the
Enter K-command mode with Ctrl-K. Exit K-command mode with ESC or Ctrl-G. second key only where the list below says so (for example
.BR "C-k C-d" ,
which differs from
.BR "C-k d" ).
ESC or
.B C-g
abandons a half-typed K-command.
.SH K-COMMANDS
.TP .TP
.B C-k ' .B C-k SPACE
Set or clear the mark.
.TP
.B C-k \(aq
Toggle read-only for the current buffer. Toggle read-only for the current buffer.
.TP .TP
.B C-k - .B C-k \-
If the mark is set, unindent the region. Unindent the region (the mark must be set).
.TP .TP
.B C-k = .B C-k =
If the mark is set, indent the region. Indent the region (the mark must be set).
.TP
.B C-k /
Toggle visual-line mode, which edits several lines at once.
.TP .TP
.B C-k ; .B C-k ;
Open the generic command prompt (": "). Open the command prompt; see
.B COMMAND PROMPT
below.
.TP .TP
.B C-k a .B C-k a
Set the mark at the beginning of the file, then jump to the end of the file. Set the mark at the start of the file and move to the end, selecting
everything.
.TP .TP
.B C-k b .B C-k b
Switch to a buffer. Switch to a buffer by name.
.TP .TP
.B C-k c .B C-k c
Close the current buffer. If no other buffers are open, an empty buffer will be opened. To exit, use C-k q. Close the current buffer. Closing the last buffer leaves an empty one;
use
.B C-k q
to leave the editor.
.TP .TP
.B C-k d .B C-k d
Delete from the cursor to the end of the line. Delete from the cursor to the end of the line.
.TP .TP
.B C-k C-d .B C-k C-d
Delete the entire line. Delete the whole line.
.TP .TP
.B C-k e .B C-k e
Edit (open) a new file. Open a file.
.TP .TP
.B C-k f .B C-k f
Flush the kill ring. Empty the kill ring.
.TP .TP
.B C-k g .B C-k g
Go to a specific line. Go to a line number.
.TP .TP
.B C-k h .B C-k h
Show the built-in help (+HELP+ buffer). Show the built-in help in a read-only +HELP+ buffer.
.TP
.B C-k i
Open a new, empty buffer.
.TP .TP
.B C-k j .B C-k j
Jump to the mark. Jump to the mark.
.TP .TP
.B C-k k
Scroll so the cursor's line is in the middle of the screen.
.TP
.B C-k l .B C-k l
Reload the current buffer from disk. Reload the current buffer from disk and redraw the screen.
.TP
.B C-k m
Switch the buffer between code and writing mode, which changes the
font; see
.BR "FONTS AND EDIT MODES" .
.TP .TP
.B C-k n .B C-k n
Switch to the previous buffer. Switch to the previous buffer.
.TP .TP
.B C-k o .B C-k o
Change working directory (prompt). Change the working directory.
.TP .TP
.B C-k p .B C-k p
Switch to the next buffer. Switch to the next buffer.
.TP .TP
.B C-k q .B C-k q
Exit the editor. If the file has unsaved changes, a warning will be printed; a second C-k q will exit. Quit. If a buffer has unsaved changes you are warned, and a second
.B C-k q
quits anyway.
.TP .TP
.B C-k C-q .B C-k C-q
Immediately exit the editor. Quit at once, without asking.
.TP .TP
.B C-k r .B C-k r
Redo changes. Redo.
.TP .TP
.B C-k s .BR "C-k s" ", " "C-k C-s"
Save the file, prompting for a filename if needed. Save the buffer, asking for a file name if it has none.
.TP .TP
.B C-k u .B C-k u
Undo. Undo.
.TP .TP
.B C-k v .B C-k v
Toggle visual file picker (GUI). Toggle the file picker.
.TP .TP
.B C-k w .B C-k w
Show the current working directory. Show the working directory.
.TP .TP
.B C-k x .BR "C-k x" ", " "C-k C-x"
Save the file and exit. Also C-k C-x. Save and quit.
.TP .TP
.B C-k y .B C-k y
Yank the kill ring. Yank (paste) from the kill ring.
.SH OTHER KEYS
.SS Moving
.TP .TP
.B C-k C-x .BR C-f ", " C-b ", " C-n ", " C-p
Save the file and exit. Right, left, down, up. The arrow keys do the same.
.SS Other keybindings
.TP .TP
.B C-g .BR C-a ", " C-e
Cancel the current operation. Start and end of the line (also Home and End).
.TP .TP
.B C-a .BR "ESC f" ", " "ESC b"
Move to the beginning of the line. Next and previous word.
.TP .TP
.B C-e .BR "ESC <" ", " "ESC >"
Move to the end of the line. Start and end of the file.
.PP
Page Up and Page Down move a screen at a time.
.SS Editing
.TP .TP
.B C-b .B Enter
Move left. Start a new line, indented to match the current one.
.TP .TP
.B C-f .BR "ESC Enter" ", " Shift+Enter
Move right. Start a new line with no indentation.
.TP
.B C-n
Move down.
.TP
.B C-p
Move up.
.TP
.B C-l
Refresh the display.
.TP .TP
.B C-d .B C-d
Delete the character at the cursor. Delete the character under the cursor (also Delete).
.TP
.B C-r
Regex search.
.TP
.B C-s
Incremental find.
.TP
.B C-t
Regex search and replace.
.TP
.B C-h
Search and replace.
.TP
.B C-u
Universal argument. C-u followed by numbers will repeat an operation n times.
.TP
.B C-w
Kill the region if the mark is set.
.TP
.B C-y
Yank the kill ring.
.TP
.B ESC <
Move to the beginning of the file.
.TP
.B ESC >
Move to the end of the file.
.TP
.B ESC m
Toggle the mark.
.TP
.B ESC BACKSPACE
Delete the previous word.
.TP
.B ESC b
Move to the previous word.
.TP .TP
.B ESC d .B ESC d
Delete the next word. Delete the next word.
.TP .TP
.B ESC f .B ESC BACKSPACE
Move to the next word. Delete the previous word.
.TP .TP
.B ESC q .B ESC q
Reflow the paragraph to 72 columns or the value of the universal argument. Reflow the paragraph to 72 columns, or to the width given with
.BR C-u .
.SS The mark and the kill ring
.TP
.B ESC m
Set or clear the mark (same as
.BR "C-k SPACE" ).
The text between the mark and the cursor is the region.
.TP
.B C-w
Cut (kill) the region.
.TP .TP
.B ESC w .B ESC w
Save the region (if the mark is set) to the kill ring. Copy the region to the kill ring.
.TP
.B C-y
Yank (paste) from the kill ring.
.SS Searching
.TP
.B C-s
Incremental search. The down and right arrows go to the next match;
up and left go to the previous one.
.TP
.B C-r
Regular-expression search.
.TP
.B C-h
Search and replace.
.TP
.B C-t
Regular-expression search and replace.
.SS Everything else
.TP
.B C-u
Universal argument: type
.B C-u
and a number, and the next command repeats that many times.
.B C-u
on its own means 4.
.TP
.B C-g
Cancel the current prompt or operation.
.TP
.B C-l
Redraw the screen.
.SS Window keys
On macOS use Cmd where these say Ctrl.
.TP
.BR Ctrl+= ", " Ctrl+\- ", " Ctrl+0
Make the text bigger, smaller, or back to the
.B size
in the configuration file.
.TP
.B Ctrl+V
Paste from the system clipboard. Text you cut or copy with
.BR C-w ,
.B ESC w
and the other kill commands also goes to the system clipboard.
.TP
.B Ctrl+Shift+N
Open another window (Cmd+N on macOS). All windows share the same
buffers. Closing a secondary window leaves the others open; closing the
first window quits the editor.
.PP
The mouse wheel scrolls, and clicking or dragging moves the cursor and
selects text.
.SH COMMAND PROMPT
.B C-k ;
opens a prompt at the bottom of the screen. Type a command and press
Enter. Tab completes command names and their arguments.
.TP
.BR syntax " " on | off | reload
Turn syntax highlighting on or off for the buffer, or rescan it.
.TP
.BI "set filetype=" type
Choose the highlighter by hand. Known types: cpp, go, python, rust,
shell, json, markdown, lisp, sql, erlang and forth (common file
extensions such as c, py and sh are accepted too).
.TP
.BR mode " [" code | writing ]
Switch, or set, the buffer's edit mode.
.TP
.BI "theme " name
Switch to another color theme; see
.BR THEMES .
.TP
.BR background " " light | dark
Choose the light or dark version of themes that have both.
.TP
.BI "font\-size " pixels
Set the text size until you quit.
.SH FONTS AND EDIT MODES
Every buffer is in one of two edit modes, and each mode has its own
font.
.B Code
mode uses a monospace font and is the default.
.B Writing
mode uses a proportional font and no syntax highlighting. Files
ending in .txt, .md, .markdown, .rst, .org, .tex, .adoc or .asciidoc
open in writing mode. Switch modes with
.B C-k m
or
.BR ":\ mode" .
.PP
These fonts are built in; you do not need them installed:
.PP
.RS
Monospace: b612, berkeley, berkeley\-bold, brassmono,
brassmono\-bold, brassmonocode, brassmonocode\-bold, fira, go, ibm,
idealist, inconsolata, inconsolataex, iosevka, iosevkaex, sharetech,
space, syne, triplicate, unispace.
.PP
Proportional: crimsonpro, etbook, spectral.
.PP
.B default
is Berkeley Mono Bold, the same as berkeley\-bold.
.RE
.PP
Choose fonts in the configuration file below.
.SH THEMES
amber, eink, everforest, gruvbox, kanagawa\-paper, lcars, leuchtturm,
nord, old\-book, orbital, plan9, solarized, tufte, weyland\-yutani and
zenburn. The default is nord.
.PP
eink, gruvbox, kanagawa\-paper, leuchtturm, old\-book, solarized and
tufte have light and dark versions, chosen with
.BR ":\ background"
or the
.B background
setting. Names such as gruvbox\-light or solarized\-dark pick the theme
and the background in one go.
.SH CONFIGURATION
.B kge
reads
.I ~/.config/kte/kge.toml
when it starts. Every setting is optional. A complete file looks like
this:
.PP
.RS
.nf
[window]
fullscreen = false
columns = 80
rows = 42
[font]
name = "default"
size = 18.0
code = "default"
writing = "crimsonpro"
[appearance]
theme = "nord"
background = "dark"
[editor]
syntax = true
.fi
.RE
.SS [window]
.TP
.B fullscreen
true to start full screen. Default false.
.TP
.BR columns ", " rows
The starting window size in characters. Defaults 80 and 42; values
outside 1 to 1000 are ignored.
.SS [font]
.TP
.B name
The base font, which
.B code
and
.B writing
fall back to. Default "default".
.TP
.B size
The text size in pixels. Default 18; values outside 4 to 200 are
ignored.
.TP
.B code
The font for code mode. If you leave it out, it follows
.BR name .
.TP
.B writing
The font for writing mode. Default "crimsonpro"; if you leave it out
and set
.B name
to something other than "default", writing mode uses
.B name
too.
.PP
Each buffer is drawn in the font for its edit mode, so
.B name
matters only through those defaults. To use one font everywhere, set
only
.BR name .
To keep a serif font for prose, set
.B writing
as well.
.SS [appearance]
.TP
.B theme
The color theme. Default "nord".
.TP
.B background
"dark" (the default) or "light".
.SS [editor]
.TP
.B syntax
false to start with syntax highlighting off. Default true.
.PP
If
.I kge.toml
is missing or cannot be parsed (the error is printed),
.B kge
falls back to the older
.I ~/.config/kte/kge.ini
format, whose keys are fullscreen, columns, rows, font, font_size,
code_font, writing_font, theme, background and syntax, written as
.IR key = value .
.SH FILES
.TP
.I ~/.config/kte/kge.toml
The configuration file.
.TP
.I ~/.local/state/kte/swap/
Crash-recovery journals, one per open file. If the editor dies with
unsaved changes, the next time you open that file you are asked whether
to recover them. Set
.B XDG_STATE_HOME
to move this directory.
.TP
.I ~/.local/state/kte/error.log
Errors the editor has logged.
.SH ENVIRONMENT .SH ENVIRONMENT
.TP .TP
.B TERM .B TERM
Used if the terminal frontend is selected. The terminal type, used with
.BR \-\-term .
.TP .TP
.B LANG, LC_ALL, LC_CTYPE .BR LANG ", " LC_ALL ", " LC_CTYPE
Determine locale and character encoding. The locale; use a UTF-8 locale to edit non-ASCII text.
.SH FILES
.TP .TP
.I ~/.kte/ .B XDG_STATE_HOME
Future configuration directory (not yet stabilized). Where the swap journals live (default
.TP .IR ~/.local/state ).
.I kge.app
On macOS, the GUI is built and installed as an app bundle. The command-line
wrapper
.B kge
may still be available for launching with files.
.SH EXIT STATUS .SH EXIT STATUS
Returns 0 on success, non-zero on failure. 0 on success; 2 for a bad option; non-zero on other failures.
.SH EXAMPLES .SH EXAMPLES
.TP Edit two files in one window:
Launch GUI (default) with multiple files: .PP
.RS .RS
.nf .nf
kge main.cc Buffer.cc kge main.cc Buffer.cc
.fi .fi
.RE .RE
.TP .PP
Open using the terminal frontend from kge: Edit in the terminal:
.PP
.RS .RS
.nf .nf
kge --term README.md kge \-\-term README.md
.fi .fi
.RE .RE
.SH SEE ALSO .SH SEE ALSO
.BR kte (1), .BR kte (1)
.I docs/ke.md .PP
(project keybinding manual) The source and releases are at https://github.com/kisom/kte.
.br
Project homepage: https://github.com/wntrmute/kte
.SH AUTHORS .SH AUTHORS
Kyle (wntrmute) and contributors. Kyle Isom and contributors.
.SH COPYRIGHT
Copyright \(co 2025 Kyle. License as per project repository.
.SH NOTES
This page documents kte/kge version 0.1.0.
+248 -186
View File
@@ -1,287 +1,349 @@
.\" kte(1) — Kyle's Text Editor (terminal-first) .\" kte(1) - Kyle's Text Editor
.\" .\"
.\" Project homepage: https://github.com/wntrmute/kte .\" The keybinding sections are shared with kge.1; keep the two in step.
.TH KTE 1 "2025-12-01" "kte 0.1.0" "User Commands" .TH KTE 1 "2026-11-17" "kte 1.14.0" "User Commands"
.SH NAME .SH NAME
kte \- Kyle's Text Editor (terminal-first) kte \- Kyle's Text Editor, terminal version
.SH SYNOPSIS .SH SYNOPSIS
.B kte .B kte
[ .RI [ options ]
.I options .RI [[+ line ]
] .IR file " ...]"
[
.I files ...
]
.SH DESCRIPTION .SH DESCRIPTION
.B kte .B kte
is a small, fast, and understandable text editor with a terminal-first is a small text editor that runs in a terminal. Its commands follow
experience. It preserves ke's WordStar/VDE-style command model with the WordStar and VDE tradition: most of them are Control-K followed by
Emacs-influenced ergonomics. The core uses ncurses in the terminal. another key. Movement and the kill ring work much as they do in Emacs.
.PP
By default, .B kte Each
runs in the terminal (ncurses) frontend. If the binary was built with GUI .I file
support, the same editor core can be shown with an ImGui-based GUI by passing named on the command line opens in its own buffer. A file that does not
.B --gui exist yet is created when you first save it. An argument of the form
or by invoking the GUI-first target .BI + N
.BR kge (1) moves the cursor to line
when available. .I N
of the file that follows it. With no files,
If one or more .B kte
.I files starts with an empty buffer.
are provided, they are opened on startup; otherwise, an empty buffer is .PP
created. The graphical version of the editor is
.BR kge (1).
It shares the same commands and keybindings.
.SH OPTIONS .SH OPTIONS
.TP .TP
.B -g, --gui .BR \-t ", " \-\-term
Use the GUI frontend (if the binary was built with GUI support). If GUI was Use the terminal frontend. This is the default and only choice for
not built, the editor exits with an error. .BR kte .
.TP .TP
.B -t, --term .BR \-g ", " \-\-gui
Use the terminal (ncurses) frontend. This is the default for Accepted for compatibility, but
.B kte .B kte
. is always built without the GUI, so this prints an error and exits
with status 2. Run
.BR kge (1)
instead.
.TP .TP
.B -h, --help .BR \-h ", " \-\-help
Display a brief usage summary and exit. Print a usage summary and exit.
.TP .TP
.B -V, --version .BR \-V ", " \-\-version
Print version information and exit. Print the version and exit.
.SH KEYBINDINGS .SH NOTATION
The command model and keybindings are inherited from .B C-x
.I ke means hold Control and press x.
and are summarized here for convenience. See .B ESC x
.I docs/ke.md means press Escape and then x; holding Alt (Meta) while pressing x does
in the source tree for the canonical reference and notes. the same thing.
.B C-k x
.SS K-commands (prefix Ctrl-K) means press Control-K, let go, and then press x. Hold Control on the
.PP second key only where the list below says so (for example
Enter K-command mode with Ctrl-K. Exit K-command mode with ESC or Ctrl-G. .BR "C-k C-d" ,
which differs from
.BR "C-k d" ).
ESC or
.B C-g
abandons a half-typed K-command.
.SH K-COMMANDS
.TP .TP
.B C-k ' .B C-k SPACE
Set or clear the mark.
.TP
.B C-k \(aq
Toggle read-only for the current buffer. Toggle read-only for the current buffer.
.TP .TP
.B C-k - .B C-k \-
If the mark is set, unindent the region. Unindent the region (the mark must be set).
.TP .TP
.B C-k = .B C-k =
If the mark is set, indent the region. Indent the region (the mark must be set).
.TP
.B C-k /
Toggle visual-line mode, which edits several lines at once.
.TP .TP
.B C-k ; .B C-k ;
Open the generic command prompt (": "). Open the command prompt; see
.B COMMAND PROMPT
below.
.TP .TP
.B C-k a .B C-k a
Set the mark at the beginning of the file, then jump to the end of the file. Set the mark at the start of the file and move to the end, selecting
everything.
.TP .TP
.B C-k b .B C-k b
Switch to a buffer. Switch to a buffer by name.
.TP .TP
.B C-k c .B C-k c
Close the current buffer. If no other buffers are open, an empty buffer will be opened. To exit, use C-k q. Close the current buffer. Closing the last buffer leaves an empty one;
use
.B C-k q
to leave the editor.
.TP .TP
.B C-k d .B C-k d
Delete from the cursor to the end of the line. Delete from the cursor to the end of the line.
.TP .TP
.B C-k C-d .B C-k C-d
Delete the entire line. Delete the whole line.
.TP .TP
.B C-k e .B C-k e
Edit (open) a new file. Open a file.
.TP .TP
.B C-k f .B C-k f
Flush the kill ring. Empty the kill ring.
.TP .TP
.B C-k g .B C-k g
Go to a specific line. Go to a line number.
.TP .TP
.B C-k h .B C-k h
Show the built-in help (+HELP+ buffer). Show the built-in help in a read-only +HELP+ buffer.
.TP
.B C-k i
Open a new, empty buffer.
.TP .TP
.B C-k j .B C-k j
Jump to the mark. Jump to the mark.
.TP .TP
.B C-k k
Scroll so the cursor's line is in the middle of the screen.
.TP
.B C-k l .B C-k l
Reload the current buffer from disk. Reload the current buffer from disk and redraw the screen.
.TP
.B C-k m
Switch the buffer between code and writing mode. In
.BR kge (1)
this changes the font; see that page.
.TP .TP
.B C-k n .B C-k n
Switch to the previous buffer. Switch to the previous buffer.
.TP .TP
.B C-k o .B C-k o
Change working directory (prompt). Change the working directory.
.TP .TP
.B C-k p .B C-k p
Switch to the next buffer. Switch to the next buffer.
.TP .TP
.B C-k q .B C-k q
Exit the editor. If the file has unsaved changes, a warning will be printed; a second C-k q will exit. Quit. If a buffer has unsaved changes you are warned, and a second
.B C-k q
quits anyway.
.TP .TP
.B C-k C-q .B C-k C-q
Immediately exit the editor. Quit at once, without asking.
.TP .TP
.B C-k r .B C-k r
Redo changes. Redo.
.TP .TP
.B C-k s .BR "C-k s" ", " "C-k C-s"
Save the file, prompting for a filename if needed. Save the buffer, asking for a file name if it has none.
.TP .TP
.B C-k u .B C-k u
Undo. Undo.
.TP .TP
.B C-k v .B C-k v
Toggle visual file picker (GUI). Toggle the file picker
.RB ( kge (1)
only).
.TP .TP
.B C-k w .B C-k w
Show the current working directory. Show the working directory.
.TP .TP
.B C-k x .BR "C-k x" ", " "C-k C-x"
Save the file and exit. Also C-k C-x. Save and quit.
.TP .TP
.B C-k y .B C-k y
Yank the kill ring. Yank (paste) from the kill ring.
.SH OTHER KEYS
.SS Moving
.TP .TP
.B C-k C-x .BR C-f ", " C-b ", " C-n ", " C-p
Save the file and exit. Right, left, down, up. The arrow keys do the same.
.SH GUI APPEARANCE
When running the GUI frontend, you can control appearance via the generic
command prompt (type "C-k ;" then enter commands):
.TP .TP
.B : theme NAME .BR C-a ", " C-e
Set the GUI theme. Available names: "amber", "eink", "everforest", "gruvbox", "kanagawa-paper", "lcars", "nord", "old-book", "orbital", "plan9", "solarized", "weyland-yutani", "zenburn". Start and end of the line (also Home and End).
Compatibility aliases are also accepted: "gruvbox-dark", "gruvbox-light",
"solarized-dark", "solarized-light", "eink-dark", "eink-light",
"everforest-hard", "oldbook", "old-book-dark", "old-book-light",
"kanagawa", "kanagawa-light", "kanagawa-paper-light", "vim-amber", "weyland".
.TP .TP
.B : background MODE .BR "ESC f" ", " "ESC b"
Set background mode for supported themes. MODE is either "light" or "dark". Next and previous word.
Themes that respond to background: eink, gruvbox, kanagawa-paper, old-book, solarized. The
"lcars", "nord" and "plan9" themes do not vary with background.
.SH CONFIGURATION
The GUI reads a simple configuration file at
~/.config/kte/kge.ini. Recognized keys include:
.IP "fullscreen=on|off"
.IP "columns=NUM"
.IP "rows=NUM"
.IP "font_size=NUM"
.IP "theme=NAME"
.IP "background=light|dark"
The theme name accepts the values listed above. The background key controls
light/dark variants when the selected theme supports it.
.SS Other keybindings
.TP .TP
.B C-g .BR "ESC <" ", " "ESC >"
Cancel the current operation. Start and end of the file.
.PP
Page Up and Page Down move a screen at a time.
.SS Editing
.TP .TP
.B C-a .B Enter
Move to the beginning of the line. Start a new line, indented to match the current one.
.TP .TP
.B C-e .B ESC Enter
Move to the end of the line. Start a new line with no indentation.
.TP
.B C-b
Move left.
.TP
.B C-f
Move right.
.TP
.B C-n
Move down.
.TP
.B C-p
Move up.
.TP
.B C-l
Refresh the display.
.TP .TP
.B C-d .B C-d
Delete the character at the cursor. Delete the character under the cursor (also Delete).
.TP
.B C-r
Regex search.
.TP
.B C-s
Incremental find.
.TP
.B C-t
Regex search and replace.
.TP
.B C-h
Search and replace.
.TP
.B C-u
Universal argument. C-u followed by numbers will repeat an operation n times.
.TP
.B C-w
Kill the region if the mark is set.
.TP
.B C-y
Yank the kill ring.
.TP
.B ESC <
Move to the beginning of the file.
.TP
.B ESC >
Move to the end of the file.
.TP
.B ESC m
Toggle the mark.
.TP
.B ESC BACKSPACE
Delete the previous word.
.TP
.B ESC b
Move to the previous word.
.TP .TP
.B ESC d .B ESC d
Delete the next word. Delete the next word.
.TP .TP
.B ESC f .B ESC BACKSPACE
Move to the next word. Delete the previous word.
.TP .TP
.B ESC q .B ESC q
Reflow the paragraph to 72 columns or the value of the universal argument. Reflow the paragraph to 72 columns, or to the width given with
.BR C-u .
.SS The mark and the kill ring
.TP
.B ESC m
Set or clear the mark (same as
.BR "C-k SPACE" ).
The text between the mark and the cursor is the region.
.TP
.B C-w
Cut (kill) the region.
.TP .TP
.B ESC w .B ESC w
Save the region (if the mark is set) to the kill ring. Copy the region to the kill ring.
.TP
.B C-y
Yank (paste) from the kill ring.
.SS Searching
.TP
.B C-s
Incremental search. The down and right arrows go to the next match;
up and left go to the previous one.
.TP
.B C-r
Regular-expression search.
.TP
.B C-h
Search and replace.
.TP
.B C-t
Regular-expression search and replace.
.SS Everything else
.TP
.B C-u
Universal argument: type
.B C-u
and a number, and the next command repeats that many times.
.B C-u
on its own means 4.
.TP
.B C-g
Cancel the current prompt or operation.
.TP
.B C-l
Redraw the screen.
.PP
In the terminal the mouse wheel scrolls, and clicking or dragging moves
the cursor and selects text.
.SH COMMAND PROMPT
.B C-k ;
opens a prompt at the bottom of the screen. Type a command and press
Enter. Tab completes command names and their arguments.
.TP
.BR syntax " " on | off | reload
Turn syntax highlighting on or off for the buffer, or rescan it.
.TP
.BI "set filetype=" type
Choose the highlighter by hand. Known types: cpp, go, python, rust,
shell, json, markdown, lisp, sql, erlang and forth (common file
extensions such as c, py and sh are accepted too).
.TP
.BR mode " [" code | writing ]
Switch, or set, the buffer's edit mode.
.PP
The GUI-only commands
.BR theme ,
.B background
and
.B font\-size
are described in
.BR kge (1).
.SH CONFIGURATION
.B kte
itself has no configuration file.
.PP
The GUI,
.BR kge (1),
reads
.IR ~/.config/kte/kge.toml .
That is where you choose the window size, the theme, and the font and
its size, for example:
.PP
.RS
.nf
[font]
name = "iosevka"
size = 18.0
.fi
.RE
.PP
See
.BR kge (1)
for every setting.
.SH FILES
.TP
.I ~/.local/state/kte/swap/
Crash-recovery journals, one per open file. If the editor dies with
unsaved changes, the next time you open that file you are asked whether
to recover them. Set
.B XDG_STATE_HOME
to move this directory.
.TP
.I ~/.local/state/kte/error.log
Errors the editor has logged.
.SH ENVIRONMENT .SH ENVIRONMENT
.TP .TP
.B TERM .B TERM
Specifies terminal type and capabilities for ncurses. The terminal type, used by ncurses.
.TP .TP
.B LANG, LC_ALL, LC_CTYPE .BR LANG ", " LC_ALL ", " LC_CTYPE
Determine locale and character encoding. The locale; use a UTF-8 locale to edit non-ASCII text.
.SH FILES
.TP .TP
.I ~/.kte/ .B XDG_STATE_HOME
Future configuration directory (not yet stabilized). Where the swap journals live (default
.IR ~/.local/state ).
.SH EXIT STATUS .SH EXIT STATUS
Returns 0 on success, non-zero on failure. 0 on success; 2 for a bad option or for
.BR \-\-gui ;
non-zero on other failures.
.SH EXAMPLES .SH EXAMPLES
.TP Edit two files:
Edit a file in the terminal (default): .PP
.RS .RS
.nf .nf
kte README.md kte README.md main.cc
.fi .fi
.RE .RE
.TP .PP
Force GUI frontend (if available): Open Buffer.cc at line 120:
.PP
.RS .RS
.nf .nf
kte --gui main.cc kte +120 Buffer.cc
.fi .fi
.RE .RE
.SH SEE ALSO .SH SEE ALSO
.BR kge (1), .BR kge (1)
.I docs/ke.md .PP
(project keybinding manual) The source and releases are at https://github.com/kisom/kte.
.br
Project homepage: https://github.com/wntrmute/kte
.SH AUTHORS .SH AUTHORS
Kyle (wntrmute) and contributors. Kyle Isom and contributors.
.SH COPYRIGHT
Copyright \(co 2025 Kyle. License as per project repository.
.SH NOTES
This page documents kte version 0.1.0.
+13 -5
View File
@@ -30,15 +30,21 @@ swap journal exists.
content than what is currently on disk, kte prompts: content than what is currently on disk, kte prompts:
```text ```text
Recover swap edits for <path>? (y/N, C-g cancel) Recover swap edits for <path>? (y/n, C-g cancel)
``` ```
- `y`: open the file and apply swap replay (buffer becomes dirty) - `y`: open the file and apply swap replay (buffer becomes dirty)
- `Enter` (default) / any non-`y`: delete the swap file ( - any other answer: delete the swap file (best-effort) and open
best-effort) the file normally
and open the file normally
- `C-g`: cancel opening the file - `C-g`: cancel opening the file
- If the file on disk changed after the journal was written, so the
journal cannot be applied to it, kte prompts:
```text
Swap file for <path> predates changes to the file on disk and cannot be applied. Delete it? (y/N, C-g cancel)
```
- If a swap file exists but is unreadable/corrupt, kte prompts: - If a swap file exists but is unreadable/corrupt, kte prompts:
```text ```text
@@ -46,7 +52,9 @@ swap journal exists.
``` ```
- `y`: delete the swap file (best-effort) and open the file normally - `y`: delete the swap file (best-effort) and open the file normally
- `Enter` (default): keep the swap file and open the file normally - `Enter` (default): rename the swap file to `<swap>.corrupt` (kept
for inspection, out of the new journal's way) and open the file
normally
- `C-g`: cancel opening the file - `C-g`: cancel opening the file
## Where swap files live ## Where swap files live
+8 -7
View File
@@ -5,8 +5,11 @@ Overview
-------- --------
kte provides lightweight syntax highlighting with a pluggable kte provides lightweight syntax highlighting with a pluggable
highlighter interface. The initial implementation targets C/C++ and highlighter interface, built for speed and responsiveness. Built-in
focuses on speed and responsiveness. highlighters cover C/C++, Go, Python, Rust, shell, JSON, Markdown,
Lisp, SQL, Erlang and Forth (`syntax/`). The filetype comes from the
file extension or a `#!` line, or is set by hand with
`: set filetype=NAME`.
Core types Core types
---------- ----------
@@ -66,8 +69,6 @@ Limitations and TODOs
not yet tracked. not yet tracked.
- No semantic analysis; identifiers are classified via small - No semantic analysis; identifiers are classified via small
keyword/type sets. keyword/type sets.
- Additional languages (JSON, Markdown, Shell, Python, Go, Rust,
Lisp, …) are planned.
- Terminal color mapping is conservative to support 8/16-color - Terminal color mapping is conservative to support 8/16-color
terminals. Rich color-pair themes can be added later. terminals. Rich color-pair themes can be added later.
@@ -89,9 +90,9 @@ Renderer-side robustness
- Drop empty/invalid spans and sort by start. - Drop empty/invalid spans and sort by start.
- Clip drawing to the horizontally visible region and the - Clip drawing to the horizontally visible region and the
tab-expanded line length. tab-expanded line length.
- The highlighter engine returns `LineHighlight` by value to avoid - The highlighter engine returns cached `LineHighlight`s by const
cross-thread lifetime issues; renderers operate on a local copy for reference. Highlighting runs on the main thread only, and a returned
each frame. reference is valid until the next call on the engine.
Extensibility (Phase 4) Extensibility (Phase 4)
----------------------- -----------------------
+15 -3
View File
@@ -21,7 +21,8 @@ Current themes (alphabetically):
- **eink** — E-ink inspired high-contrast theme (light/dark variants) - **eink** — E-ink inspired high-contrast theme (light/dark variants)
- **everforest** — Warm, forest-inspired palette - **everforest** — Warm, forest-inspired palette
- **gruvbox** — Retro groove color scheme (light/dark variants) - **gruvbox** — Retro groove color scheme (light/dark variants)
- **kanagawa-paper** — Inspired by traditional Japanese art - **kanagawa-paper** — Inspired by traditional Japanese art (light/dark
variants)
- **lcars** — Star Trek LCARS interface style - **lcars** — Star Trek LCARS interface style
- **leuchtturm** — Modern, clean theme (light/dark variants) - **leuchtturm** — Modern, clean theme (light/dark variants)
- **nord** — Arctic, north-bluish color palette - **nord** — Arctic, north-bluish color palette
@@ -354,13 +355,24 @@ ThemeRegistry()
} }
``` ```
**e) Keep the index mapping and syntax colors in step:**
`ThemeIndexFromId()` and `ThemeIdFromIndex()` in `GUITheme.h` map each
`ThemeId` to its position in the registry; add a case for the new theme
and renumber the ones after it. To give the theme its own syntax
colors, add a `SyntaxInkMyTheme()` function and a branch for it in
`SyntaxInk()`; otherwise it gets the default Nord-like palette.
**f) Update the user-facing lists:** the theme names in `HelpText.cc`,
`docs/kge.1`, `CONFIG.md` and the list at the top of this file.
### 3. Test your theme ### 3. Test your theme
Rebuild kte and test: Rebuild kte and test:
```bash ```bash
# Set theme in config # Set theme in config: in ~/.config/kte/kge.toml, under [appearance]
echo "theme = mytheme" >> ~/.config/kte/kge.ini # theme = "mytheme"
# Or switch at runtime # Or switch at runtime
kge kge