Emacs lite editor for TUI in Gerbil Scheme.
  • Scheme 99.5%
  • Makefile 0.3%
  • Dockerfile 0.2%
Find a file
Jaime Fournier f7dc0f94ed Add 10 real game/app implementations + sequential build fix
Real implementations replacing stubs: Tetris (7 pieces, rotation,
collision, scoring), Snake (movement, food, wall/self collision),
Dunnet (9 rooms, items, inventory, command parser), 2048 (slide/merge,
win detection), Solitaire (peg board, jumping), Blackbox (ray tracing
puzzle). New features: Animate, Type-break, Highlight-changes,
Glasses-mode. Both TUI and Qt layers.

Also includes GERBIL_BUILD_CORES=1 fix for compile-exe race condition,
and qt-widget-set-updates-enabled! stub for missing FFI binding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 09:48:04 -06:00
qt Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
scripts Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
.gitignore gitignore: exclude libvterm source download artifacts 2026-03-24 15:27:40 -06:00
app.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
async.ss Fix static-qt segfault: lazy-resolve ##thread-pin! for old Gambit builds 2026-03-17 13:41:35 -06:00
buffer.ss Phase 3: Comprehensive hooks with TUI/Qt parity 2026-03-08 23:14:09 -06:00
bug-repro.ss Fix LSP reader thread crash; add async protocol tests and bug report 2026-02-18 17:31:08 -07:00
bug.md Fix LSP reader thread crash; add async protocol tests and bug report 2026-02-18 17:31:08 -07:00
build.ss Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
chat.ss Add Claude AI chat integration (M-x claude-chat) 2026-02-22 20:22:08 -07:00
CLAUDE.md Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
core.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
customize.ss Phase 1: Add customize system with defvar! variable registry 2026-03-08 22:03:38 -06:00
debug-repl-test.ss Add TCP debug REPL server (--repl <port> / GEMACS_REPL_PORT) 2026-03-11 11:54:07 -06:00
debug-repl.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
Dockerfile Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
echo.ss Helm-style C-x C-f find-file with narrowing popup and default path 2026-03-06 17:33:32 -07:00
editor-advanced.ss Improve ediff highlighting, narrowing, bookmarks, and register insert 2026-03-09 20:39:05 -06:00
editor-cmds-a.ss Add auto-revert, desktop save/restore, multi-cursor typing, aggressive indent 2026-03-09 14:39:28 -06:00
editor-cmds-b.ss Improve ediff highlighting, narrowing, bookmarks, and register insert 2026-03-09 20:39:05 -06:00
editor-cmds-c.ss Add winner-mode hooks, hungry-delete, crux-move-beginning-of-line, isearch match counter, ws-butler 2026-03-10 00:52:24 -06:00
editor-core.ss Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
editor-extra-ai.ss Add project-query-replace and multi-file qreplace (Batch 5) 2026-03-10 16:41:29 -06:00
editor-extra-editing.ss Add 11 real features: org-roam, artist-mode, calc-embedded, hl-todo, writeroom, rainbow, auto-revert, save-place, envrc, focus-mode, golden-ratio 2026-03-29 11:40:00 -06:00
editor-extra-editing2.ss Upgrade deadgrep, hideshow, wdired, color-rg to real implementations 2026-03-10 08:53:10 -06:00
editor-extra-final.ss Upgrade stubs: electric-indent, grep navigation, dir-locals, completion frameworks 2026-03-10 07:27:52 -06:00
editor-extra-helpers.ss Upgrade devdocs-lookup to fetch real docs via curl, improve rcirc buffer 2026-03-10 09:46:24 -06:00
editor-extra-media.ss Add string-inflection, occur-edit-mode, and wdired (Batch 4) 2026-03-10 15:40:24 -06:00
editor-extra-media2.ss Add string-inflection, occur-edit-mode, and wdired (Batch 4) 2026-03-10 15:40:24 -06:00
editor-extra-modes.ss Add 11 real features: org-roam, artist-mode, calc-embedded, hl-todo, writeroom, rainbow, auto-revert, save-place, envrc, focus-mode, golden-ratio 2026-03-29 11:40:00 -06:00
editor-extra-notes.ss Add 11 real features: org-roam, artist-mode, calc-embedded, hl-todo, writeroom, rainbow, auto-revert, save-place, envrc, focus-mode, golden-ratio 2026-03-29 11:40:00 -06:00
editor-extra-notes2.ss Add 10 new features: corfu, minimap, orderless, marginalia, smooth-scroll, context-menu, ligature, nano-theme, page-break-lines, doom-modeline 2026-03-29 13:58:41 -06:00
editor-extra-notes3.ss Add 10 new features: surround, goto-last-change, crosshair, quickrun, eros, auto-dim, rainbow-identifiers, outline-minor-mode, string-edit, persistent-scratch 2026-03-29 15:05:12 -06:00
editor-extra-notes4.ss Add 10 new features: deft, dictionary, speed-type, pomodoro, doctor (Eliza), figlet, dice roller, morse code, gomoku, chronometer 2026-03-29 16:29:46 -06:00
editor-extra-notes5.ss Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
editor-extra-org.ss Add string-inflection, occur-edit-mode, and wdired (Batch 4) 2026-03-10 15:40:24 -06:00
editor-extra-regs.ss Upgrade CUA mode, debug-on-entry, DevOps commands to real implementations 2026-03-10 05:47:11 -06:00
editor-extra-regs2.ss Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
editor-extra-tools.ss Add which-key mode, repeat-mode, visual-line-mode, whitespace-mode, delete-trailing-whitespace 2026-03-09 16:28:06 -06:00
editor-extra-tools2.ss Upgrade DAP commands from stubs to real GDB/MI integration 2026-03-10 08:19:51 -06:00
editor-extra-vcs.ss Upgrade stubs: Qt GDB/MI integration, memory report, delegation commands 2026-03-10 10:15:58 -06:00
editor-extra-vcs2.ss Add 11 real features: org-roam, artist-mode, calc-embedded, hl-todo, writeroom, rainbow, auto-revert, save-place, envrc, focus-mode, golden-ratio 2026-03-29 11:40:00 -06:00
editor-extra-web.ss Add numbered backups, prog-mode-hook, scroll-bar toggle, after-init-hook 2026-03-07 22:19:35 -07:00
editor-extra.ss Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
editor-text.ss Upgrade dabbrev-expand to search across all open buffers 2026-03-10 06:38:31 -06:00
editor-ui.ss Add eshell tab completion for filenames and commands 2026-03-10 11:50:44 -06:00
editor.ss Add auto-revert, desktop save/restore, multi-cursor typing, aggressive indent 2026-03-09 14:39:28 -06:00
emacs-test.ss Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
emacsclient.ss rename to gemacs 2026-02-17 08:51:42 -07:00
eshell.ss Eshell: input redirection (<), command substitution $(), calendar upgraded 2026-03-07 02:41:52 -07:00
face.ss Phase 1: Add customize system with defvar! variable registry 2026-03-08 22:03:38 -06:00
foo.txt Helm-style C-x C-f find-file with narrowing popup and default path 2026-03-06 17:33:32 -07:00
functional-test.ss Add which-key mode, repeat-mode, visual-line-mode, whitespace-mode, delete-trailing-whitespace 2026-03-09 16:28:06 -06:00
gemacs-vs-emacs.md Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
gerbil.pkg Replace curl+lynx EWW rendering with litehtml HTML engine 2026-03-04 17:25:02 -07:00
gsh-eshell.ss Merge branch 'fix-smp-qt': SMP thread pinning + hang fixes 2026-03-13 16:47:34 -06:00
gsh-subprocess.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
helm-commands.ss Complete Helm framework and add persistent shell history 2026-02-23 14:14:04 -07:00
helm-sources.ss Complete Helm framework and add persistent shell history 2026-02-23 14:14:04 -07:00
helm-tui.ss Complete Helm framework and add persistent shell history 2026-02-23 14:14:04 -07:00
helm.md Complete Helm framework and add persistent shell history 2026-02-23 14:14:04 -07:00
helm.ss Complete Helm framework and add persistent shell history 2026-02-23 14:14:04 -07:00
highlight.ss Improve ediff highlighting, narrowing, bookmarks, and register insert 2026-03-09 20:39:05 -06:00
ipc.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
keymap.ss Phase 2: Move mode keymaps to core for TUI/Qt feature parity 2026-03-08 22:40:57 -06:00
lsp-functional-test.ss Implement nested split tree architecture (plan.md Section 7) 2026-02-18 18:53:15 -07:00
lsp-protocol-test.ss Fix LSP reader thread crash; add async protocol tests and bug report 2026-02-18 17:31:08 -07:00
macros.ss macro expansion 2026-02-19 18:30:49 -07:00
main.ss Revert "Disable Gambit SMP": restore full multi-processor mode 2026-03-13 15:33:17 -06:00
Makefile Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
manifest.ss Add 10 real game/app implementations + sequential build fix 2026-03-30 09:48:04 -06:00
modeline.ss Fix build errors after theme system implementation 2026-02-19 14:18:03 -07:00
OPTIMIZE.md Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-agenda-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-agenda.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-babel-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-babel.ss Add Babel :var resolution, session persistence, calendar-org integration 2026-02-23 02:42:03 -07:00
org-capture-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-capture.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-clock-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-clock.ss Add string-inflection, occur-edit-mode, and wdired (Batch 4) 2026-03-10 15:40:24 -06:00
org-duration-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-element-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-export-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-export.ss Add LSP inlay hints/type hierarchy, Forge, EWW bookmarks, custom export backends 2026-02-23 03:22:04 -07:00
org-fold-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-footnote-test.ss Integrate 17 org-mode test files from gemacs-org-tests 2026-02-21 12:13:26 -07:00
org-highlight.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-lint-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-list-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-list.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-num-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-parse-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-parse.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-property-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-src-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-table-test.ss Fix all 141 org-mode test failures across 17 test files 2026-02-21 13:26:29 -07:00
org-table.ss Integrate PCRE2 for 12-86x regex performance improvement 2026-02-20 08:18:28 -07:00
org-tempo-test.ss Integrate 17 org-mode test files from gemacs-org-tests 2026-02-21 12:13:26 -07:00
persist-test.ss Which-key: show human-readable descriptions alongside key names 2026-03-06 19:35:58 -07:00
persist.ss Upgrade VC commands from stubs to real git implementations 2026-03-09 19:59:20 -06:00
plan-core.md Phase 4: Add C-h m describe-mode keybinding and command docs 2026-03-08 23:45:28 -06:00
plan.md Add SMP thread pinning: pin UI thread and master timer to processor 0 2026-03-13 16:40:27 -06:00
pregexp-compat.ss updates to put pcre2 back 2026-02-23 21:08:49 -07:00
pty.ss Fix macOS build compatibility 2026-03-11 07:19:50 -06:00
qt-fix-smp.md Add SMP-safe Qt init: deferred startup via qt-schedule-init! 2026-03-10 19:16:55 -06:00
qt-functional-test.ss Add Group 53: open-file regression test for ~/proof.png 2026-03-11 10:49:55 -06:00
qt-highlight-test.ss fix: Qt backspace crash, directory open, and syntax highlighting 2026-02-15 20:25:55 -07:00
qt-split-comprehensive-test.ss.disabled Upgrade stubs: recover-session delegates to session-restore, what-face shows Scintilla style info 2026-03-07 14:58:06 -07:00
qt-split-debug-test.ss Fix Qt main window growing on split — save/restore geometry 2026-02-18 20:12:22 -07:00
qt-split-minimal-test.ss Fix Qt main window growing on split — save/restore geometry 2026-02-18 20:12:22 -07:00
qt-split-simple-test.ss Fix Qt main window growing on split — save/restore geometry 2026-02-18 20:12:22 -07:00
README.md rename to gemacs 2026-02-17 08:51:42 -07:00
repl-server.md Add --verbose flag: comprehensive hang-diagnosis logging to ~/.gemacs-verbose.log 2026-03-11 11:18:48 -06:00
repl.ss rename to gemacs 2026-02-17 08:51:42 -07:00
shell-history.ss Fix vterm crashes: env-alist format mismatch and Unicode string-trim 2026-03-05 14:54:48 -07:00
shell.md Integrate gerbil-shell (gsh) for in-process shell execution 2026-02-25 12:24:58 -07:00
shell.ss Merge branch 'fix-smp-qt': SMP thread pinning + hang fixes 2026-03-13 16:47:34 -06:00
snippets.ss Upgrade snippet system with disk persistence, fix yasnippet aliases 2026-03-10 05:53:02 -06:00
subprocess.ss Add C-g interrupt for blocking subprocess commands (grep, compile, shell) 2026-02-23 15:50:12 -07:00
term-hang-test.ss Add async PTY subprocess execution for shell and terminal modes 2026-02-26 08:42:02 -07:00
terminal.ss Sync bug fixes from jerboa-emacs fork 2026-03-26 13:04:02 -06:00
themes.ss Add comprehensive face and theme system — Phase 2.1-2.2 complete 2026-02-19 12:24:52 -07:00
vtscreen-test.ss Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
vtscreen.ss Fix vtscreen libvterm UTF-8 mode + static build pipeline 2026-03-24 15:27:24 -06:00
window.ss Fix TUI window.ss compilation — tree-based split rewrite complete 2026-02-19 10:05:33 -07:00

gemacs

An Emacs-like text editor written in Gerbil Scheme with dual backends — a terminal UI (TUI) using Scintilla and termbox, and a native GUI using Qt6. Over 1,000 registered commands covering the breadth of GNU Emacs functionality.

Features

  • 1,001 commands — navigation, editing, search, buffers, windows, files, version control, programming, org-mode, shells, and more
  • Dual backends — run in the terminal (gemacs) or as a native Qt desktop application (gemacs-qt)
  • Gerbil syntax highlighting — built-in lexer-based highlighting for Gerbil Scheme source files
  • Embedded shells — eshell (built-in Gerbil shell), external $SHELL subprocess, and Gerbil REPL (gxi)
  • Emacs keybindings — familiar C-x, C-c, M-x prefix sequences with a hash-table keymap state machine
  • Scintilla text engine — undo/redo history, reference-counted document pointers, folding, and multi-cursor support
  • Kill ring, registers, bookmarks, marks — standard Emacs text management
  • Macro recordingC-x ( / C-x ) / C-x e keyboard macros
  • Window management — splitting, resizing, balancing, tab-bar, winner-mode
  • In-process evalM-: evaluates Gerbil expressions from the echo area

Dependencies

Build

# Build gerbil-scintilla first (required)
cd ~/mine/gerbil-scintilla && make build

# Optionally build gerbil-qt for the Qt backend
cd ~/mine/gerbil-qt && make build

# Build gemacs (both TUI and Qt executables)
cd ~/mine/gemacs
make          # compile all modules + executables
make test     # run unit tests (55+ checks, 30+ test cases)
make install  # install binaries to ~/.local/bin/

Override the install prefix:

make install PREFIX=/usr/local

Usage

# Terminal UI
gemacs                    # open with *scratch* buffer
gemacs file1.txt file2.ss # open files

# Qt GUI
gemacs-qt                 # open with *scratch* buffer
gemacs-qt file1.txt       # open files

Key Bindings

Navigation

Key Command Description
C-f / Right forward-char Move forward one character
C-b / Left backward-char Move backward one character
C-n / Down next-line Move to next line
C-p / Up previous-line Move to previous line
C-a / Home beginning-of-line Move to beginning of line
C-e / End end-of-line Move to end of line
M-f forward-word Move forward one word
M-b backward-word Move backward one word
M-< beginning-of-buffer Move to beginning of buffer
M-> end-of-buffer Move to end of buffer
C-v / PgDn scroll-down Scroll down one page
M-v / PgUp scroll-up Scroll up one page
C-l recenter Recenter view on cursor
M-g g goto-line Go to a specific line number

Editing

Key Command Description
C-d / Delete delete-char Delete character at point
DEL / C-h backward-delete-char Delete character before point
C-k kill-line Kill from point to end of line
C-y yank Yank (paste) last killed text
M-y yank-pop Cycle through kill ring
C-w kill-region Kill region (mark to point)
M-w copy-region Copy region without killing
C-@ set-mark Set mark at point
C-_ undo Undo last change
C-x u redo Redo last undone change
C-o open-line Open a new line below
C-m / C-j newline Insert newline
M-q fill-paragraph Reflow paragraph
M-; comment-dwim Toggle comment on region/line
C-t transpose-chars Transpose characters
M-t transpose-words Transpose words
M-u upcase-word Uppercase word
M-l downcase-word Lowercase word
M-c capitalize-word Capitalize word

Search and Replace

Key Command Description
C-s search-forward Incremental search forward
C-r search-backward Incremental search backward
M-% query-replace Interactive search and replace
M-x occur occur List matching lines

Files and Buffers

Key Command Description
C-x C-f find-file Open a file
C-x C-s save-buffer Save current buffer
C-x C-w write-file Save buffer to a new file
C-x b switch-buffer Switch to a buffer by name
C-x k kill-buffer Kill current buffer
C-x C-b buffer-list List all buffers
C-x d dired Directory editor

Windows

Key Command Description
C-x 2 split-window Split window vertically
C-x 3 split-window-right Split window horizontally
C-x o other-window Switch to other window
C-x 0 delete-window Delete current window
C-x 1 delete-other-windows Delete all other windows
C-x + balance-windows Balance window sizes

Help

Key Command Description
C-h k describe-key Describe what a key does
C-h f describe-function Describe a command
C-h b describe-bindings List all key bindings
C-h a apropos-command Search commands by name
C-h w where-is Find key binding for a command

Shells and REPL

Key Command Description
C-x r repl Open Gerbil REPL (gxi subprocess)
M-x eshell eshell Open built-in Gerbil shell
M-x shell shell Open external $SHELL subprocess
M-: eval-expression Evaluate Gerbil expression in echo area

Bookmarks and Registers

Key Command Description
C-x r m bookmark-set Set a bookmark
C-x r b bookmark-jump Jump to a bookmark
C-x r s copy-to-register Save region to register
C-x r i insert-register Insert register contents

Macros

Key Command Description
C-x ( start-kbd-macro Start recording a macro
C-x ) end-kbd-macro Stop recording
C-x e call-last-kbd-macro Execute last macro

Other

Key Command Description
M-x execute-extended-command Run a command by name
C-g keyboard-quit Cancel current operation
C-x C-c quit Exit the editor

Command Categories

The 1,001 commands span these areas:

Category Examples
Core editing kill/yank, undo/redo, transpose, case conversion, fill, indent
Navigation goto-line, imenu, avy, bookmarks, mark ring, sexp movement
Search isearch, query-replace, occur, grep, rg, deadgrep
Buffers & Windows split, resize, balance, tab-bar, winner, ibuffer, windmove
File management find-file, save, revert, dired, recent files, auto-save
Programming syntax highlighting, paren matching, compile, xref, LSP, DAP, flycheck
Language modes Gerbil, Scheme, Emacs Lisp, Python, Ruby, JavaScript, TypeScript, Go, Rust, C/C++, Java, Haskell, OCaml
Version control magit (status, log, commit, diff, blame, stash, fetch, push, pull, rebase, merge), git-gutter
Text processing sort, align, rectangles, string inflection, multiple cursors, paredit, smartparens
Org-mode headings, TODO cycling, scheduling, agenda, export, babel
Shell & REPL eshell (built-in), shell (external), Gerbil REPL (gxi), eval-expression
Modern packages consult, embark, corfu, cape, vertico, marginalia, orderless, which-key
Writing olivetti, writeroom, focus-mode, spell checking (jinx, flyspell)
Utilities calc, calendar, EWW browser, EMMS media, PDF tools, markdown, snippets, ediff
Appearance themes, rainbow delimiters, hl-todo, indent guides, minimap, doom-modeline
Modal editing evil-mode, meow-mode stubs

Architecture

gemacs/
  core.ss           Shared state, buffer predicates, eval helpers, default keybindings
  keymap.ss         Key event translation and keymap state machine
  buffer.ss         Buffer management with Scintilla document pointers
  window.ss         Frame and window layout (splitting, resizing)
  modeline.ss       Status line rendering (file, line/col, modified, mode)
  echo.ss           Echo area / minibuffer (messages and blocking prompts)
  highlight.ss      Gerbil syntax highlighting via Scintilla lexers
  editor.ss         527 editor commands + command registry
  editor-extra.ss   474 additional commands (overflow module)
  app.ss            Main event loop, rendering, event dispatch
  main.ss           TUI executable entry point
  repl.ss           Gerbil REPL subprocess management (gxi)
  eshell.ss         Built-in Gerbil shell (pwd, cd, ls, echo, eval, which)
  shell.ss          External $SHELL subprocess terminal
  emacs-test.ss     Unit tests (55+ checks, 30+ test cases)

  qt/
    keymap.ss       Qt key event translation
    buffer.ss       Qt buffer management
    window.ss       Qt window/frame layout
    modeline.ss     Qt status line
    echo.ss         Qt echo area
    commands.ss     Qt editor commands
    app.ss          Qt main event loop
    main.ss         Qt executable entry point

Module Details

core.ss — Backend-agnostic shared state: buffer predicates (repl-buffer?, eshell-buffer?, shell-buffer?), eval-expression-string for in-process Gerbil eval, and default keybinding setup for both backends.

keymap.ss — Translates terminal/Qt key events into Emacs-style key strings (C-x, M-f, <up>, etc.) and implements a state machine for multi-key prefix sequences. Keymaps are hash tables mapping key strings to command symbols or nested sub-keymaps.

buffer.ss — Each buffer owns a reference-counted Scintilla document pointer. Switching buffers calls SCI_SETDOCPOINTER on the editor widget, preserving per-document undo history, cursor position, and content. Tracks file path, modified state, and lexer language.

window.ss — Manages a frame containing one or more vertically-stacked edit windows. Each window owns a Scintilla editor instance. Supports splitting, deletion, resizing, and balancing.

modeline.ss — Draws the status line at the bottom of each window: -UU-:**- buffer-name (line,col) Mode with reversed colors for the active window.

echo.ss — The bottom row of the terminal. Displays messages, errors (in red), and handles blocking text input with prompt display for commands like find-file and switch-buffer.

editor.ss + editor-extra.ss — Define all 1,001 editor commands and the app-state struct that ties everything together. Commands are stored in a registry and dispatched by symbol name from the keymap. The split into two files is for build performance.

app.ss — Initialization (terminal setup, keybindings, command registration, buffer creation) and the main event loop: process notifications, refresh windows, draw modelines and echo area, present to terminal, poll for input, dispatch events, poll REPL/shell output.

repl.ss — Manages gxi subprocesses for the embedded Gerbil REPL. Handles process lifecycle (start/send/read/stop) and non-blocking output polling integrated into the event loop.

eshell.ss — A built-in shell implemented entirely in Gerbil. Supports pwd, cd, ls, echo, which, eval, clear, exit, and falls through to external commands via open-process.

shell.ss — Spawns an external $SHELL process with pseudo-terminal emulation, ANSI code stripping, and bidirectional I/O integrated into the event loop.

How It Works

The editor uses Scintilla as its text engine and termbox (bundled inside gerbil-scintilla) for terminal I/O. The event loop:

  1. Processes Scintilla notifications
  2. Polls REPL, shell, and eshell buffers for subprocess output
  3. Refreshes all editor windows
  4. Draws modelines and echo area
  5. Presents to terminal via tui-present!
  6. Positions the cursor at the caret
  7. Polls for input with a 50ms timeout
  8. Dispatches key/mouse/resize events through the keymap state machine

Printable characters with no modifier are self-inserted. Unbound key sequences display an error in the echo area. M-x opens a command prompt for executing any of the 1,001 registered commands by name.

The Qt backend follows the same architecture but uses Qt widgets for rendering and Qt's event system for input handling, producing a native desktop application with the same command set.

License

MIT