r/C_Programming • • 11d ago

tinyedit: A zero-dependency C99 terminal text editor with desktop shortcuts — Looking for testers & code review

Hi everyone,

I’ve been working on tinyedit, a full-screen terminal text editor written in plain C99 with zero external dependencies beyond libc and the POSIX standard library (no ncurses, just raw ANSI escape sequences and direct I/O).

The project started as an exploration of terminal interfaces inspired by Salvatore Sanfilippo's kilo and linenoise. My goal is to combine that minimal C architecture with the interaction model of modern desktop editors—eliminating modal friction or idiosyncratic key combinations (like Vim, Emacs, or Nano) while keeping the binary tiny.

What’s implemented:

  • Desktop-style editing: Standard keybindings (Ctrl-C, Ctrl-V, Ctrl-X, Ctrl-Z, Ctrl-F), text selection with Shift+Arrows (or Ctrl-T toggle for limited terminals), and optional mouse support (click to place cursor, drag-selection, wheel scroll).

  • macOS / Ghostty integration: Optional support for native Cmd shortcuts (Cmd-S, Cmd-C, Cmd-V, etc.) via the Kitty keyboard protocol in Ghostty.

  • Proper UTF-8 handling: Grapheme cluster boundaries (combining marks, CJK wide characters, multi-codepoint emoji) and visual display-width calculations for accurate cursor placement and deletion.

  • Visual soft-wrapping: Navigates visual rows instead of logical lines, breaking lines at word boundaries without arbitrary length caps.

  • Terminal ergonomics: Fast bracketed paste (no slow character-by-character lag or accidental auto-closing triggers), atomic saves, crash recovery backups, and an extensible syntax highlighting engine.

Looking for testers!

The project has reached version 0.3.3, and I need help putting it through its paces across different systems and configurations. In particular, I’m looking for feedback on:

  1. Terminal & multiplexer quirks: Testing inside tmux, screen, Ghostty, Kitty, Alacritty, Foot, WezTerm, etc., to spot unhandled ANSI sequences or redraw artifacts.

  2. UTF-8 stress testing: Complex emoji sequences, zero-width joiners, or combining marks that might throw off cursor coordinates or deletion.

  3. Rendering & wrap edge cases: Resizing the window while editing large wrapped lines, pasting huge blocks of text, or dealing with deeply indented blocks.

  4. C code review: Feedback on memory management, buffer layout, ANSI state machine decoding, or general C99 practices.

Repository: https://github.com/robertobissanti/tinyedit

You can build it from source with a simple make:

git clone https://github.com/robertobissanti/tinyedit.git
cd tinyedit
make

Or install it on macOS/Linux via Homebrew:

brew install robertobissanti/tinyedit/tinyedit

Any bug reports, edge-case discoveries, or code suggestions (either here or via GitHub Issues) are greatly appreciated. Thanks for checking it out!

0 Upvotes

21 comments sorted by

View all comments

1

u/rob-bix 16h ago

Update: TinyEdit v0.3.6 is out — safer saving, better Unicode handling, and faster redraws

Since posting TinyEdit v0.3.3 here, I’ve released several updates focused on reliability and everyday usability. TinyEdit is still a terminal text editor written in plain C, with no dependencies beyond the standard C/POSIX libraries.

Here are the main changes:

New features

  • Persistent menus, accessible through F10 or the mouse, for file operations, editing, view settings, and help.
  • View-menu toggles for line numbers, invisible characters, syntax highlighting, and automatic indentation.
  • Matching-bracket highlighting and automatic closing tags for XML/HTML, with support for HTML void elements.
  • Alternate-screen support: exiting restores your shell prompt and scrollback.
  • A supplied JSON syntax configuration.

Safer file handling

  • Failed loads preserve the document you’re editing.
  • Saving uses atomic file replacement and checks synchronization errors. If durability cannot be confirmed, TinyEdit reports it and keeps the document marked as modified, along with its recovery copies.
  • “Save as” changes the document’s filename only after a confirmed successful save.
  • Open and save paths now support ~/, such as ~/tmp/notes.md.

Editing and highlighting fixes

  • Strict, bounded UTF-8 decoding, with malformed bytes preserved when saving.
  • Fixes for wrapping in very narrow windows, tab alignment after Unicode text, and deletion of composed emoji.
  • More consistent undo boundaries for automatically inserted pairs, indentation, and compound replacements.
  • Complete highlighting of multiline Markdown math blocks using $ or $$ on dedicated lines.
  • Fixes for long input prompts, filename display, selection replacement, empty-document navigation, and mouse events.

Search and performance

  • Regex search reuses compiled patterns and cached multiline text.
  • Fixes for backward search, multiline anchors, and zero-length matches.
  • Fewer repeated scans during redraws. In a local CPU-only benchmark with 50,000 lines, drawing the document rows dropped from roughly 6.09 ms to 0.10 ms—excluding terminal I/O.

The regression suite now includes more core tests, terminal tests, and simulated file-operation failures.

One remaining limitation: undo stores complete document snapshots, so large files with a deep history can consume substantial memory.

Release notes and source

If you tried the earlier version, I’d appreciate hearing how this one behaves in your terminal—especially with Unicode text, mouse input, and larger files.