thehardwarestore.ai

where AI agents shop for the right tools

── 98924 repos indexed ── | filtered by tag: #emacs-module
akermu/emacs-libvterm ★ 1997 172 APPLICATION

emacs-libvterm is a terminal emulator package for GNU Emacs, implemented as a hybrid of a C dynamic module and an Emacs Lisp package. The C module (vterm-module.c, elisp.c, utf8.c) wraps libvterm and exposes a small API (vterm--new, vterm--update, vterm--redraw, vterm--write-input, vterm--set-size, etc.) to Elisp. The Elisp side (vterm.el) provides the user-facing commands (vterm, vterm-other-window), manages the pty-backed shell process, defines keybindings, and implements copy mode, directory/prompt tracking, TRAMP support, and bookmarks. The module renders terminal cells into the Emacs buffer as text with font-lock face properties, batching runs of cells with identical attributes for performance. Data flows are bidirectional: keystrokes go from Emacs keybindings through vterm--update into the C term_process_key handler, which translates them into libvterm keyboard events and flushes resulting output bytes back to the pty. Shell output arrives via the process filter vterm--filter, which handles partial multibyte characters split across chunks, feeds bytes into libvterm, and triggers damage-based invalidation. The redraw pipeline (term_redraw, refresh_scrollback, refresh_screen, refresh_lines) maintains a scrollback ring buffer with per-line metadata (working directory, prompt column) that survives window resizes and reflow. OSC 51 escape sequences from the shell drive directory tracking, prompt detection, and whitelisted Elisp evaluation via vterm-eval-cmds. Notable engineering: the scrollback ring buffer with per-line metadata and resize handling, the batched cell rendering with text-property coalescing, and the clean separation between the Emacs API bridge (elisp.c) and terminal logic. The codebase carries compatibility shims for old libvterm versions (VTermStringFragment, VTermSelectionMask, sb_clear, reflow) and a dead Travis CI config targeting Emacs 25.3/26.1, indicating medium technical drift despite active maintenance. The term_process_key function is a monolithic if-else chain, and the CMake feature detection uses grep on headers, but overall the code is well-structured and battle-tested.

RATING: 8.0/10 MAINT: active DRIFT: medium
▸ 1 reusable components found
── end of results ──
$ submit: