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
+156 -119
View File
@@ -1,148 +1,185 @@
kte - Kyle's Text Editor
========================
![Editor screenshot](./docs/screenshot.jpg)
Vision
-------
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.
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:
I am experimenting with using Jetbrains Junie to assist in
development, largely as a way to learn the effective use of agentic
coding. I worked with the agent by feeding it notes that I've been
taking about text editors for the last few years, as well as the
sources from the original ke editor that is all handwritten C.
- `kte` runs in a terminal (ncurses).
- `kge` is the graphical version (SDL2, OpenGL and Freetype through
Dear ImGui). It adds themes, a choice of embedded fonts and multiple
windows.
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
`C-g`.
- 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:
The source lives at <https://github.com/kisom/kte> (mirrored from
`git.wntrmute.dev:kyle/kte`):
```
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug
cmake --build cmake-build-debug
git clone https://github.com/kisom/kte.git
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
built as `kge`) or request the GUI from `kte`:
Each [GitHub release](https://github.com/kisom/kte/releases) also has a
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]
# or if built/installed as a separate GUI target
./cmake-build-debug/kge [files]
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
```
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
listed above):
With Nix you can also build straight from the flake: `nix build .#kte`
or `nix build .#kge`.
Installing
----------
```
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -DBUILD_GUI=ON
cmake --build cmake-build-debug
./cmake-build-debug/kte --gui [files]
sudo cmake --install build
```
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
light/dark variants), each with a matching syntax-highlighting
palette, plus two dozen embedded fonts. Switch either at runtime from
the command prompt with `: theme NAME` and `: font NAME` (both tab-
complete), or set defaults in `~/.config/kte/kge.toml`. `: help` lists
the available theme and font names; see `docs/themes.md` for the full
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.
- `kte(1)`, `kge(1)`: the man pages (`docs/kte.1`, `docs/kge.1` in
the source tree).
- [docs/DEVELOPER_GUIDE.md](docs/DEVELOPER_GUIDE.md): how the code is
put together, for anyone working on kte itself.
- [docs/ke.md](docs/ke.md): the manual for ke, the older C editor kte
replaces. Most of its bindings carried over, but not all of them.