Skip to content

About

Reusable Lean 4 terminal REPL primitives for the termcolor stack

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

lean-termcolor-repl

CI Release Lean 4 Docs License

Pure input history, key handling, adaptive completion, and cooperative background-job support for Lean 4 terminal REPLs.

Problem

Terminal REPLs repeatedly need editing, completion, history, and job handling that should not be rewritten for each application.

Development

This project is maintained by its author with AI-assisted development tools. Changes are reviewed, tested, and remain the maintainer's responsibility.

Install

require termcolor-repl from git
  "https://github.com/jonaprieto/lean-termcolor-repl.git" @ "v0.8.2"

API

TermColor.Repl.State stores editable input and submitted history. update maps widget keys to pure actions. Keymap.BindingSpec and Keymap.fromSpecs keep editor/application bindings inspectable, and Config.editorKeymap applies a custom editor map to single- and multiline input. FileCompletion provides bounded completion for the token under the cursor, and History provides opt-in file persistence through Except results.

Config.resizeMs remains as a compatibility field; resize checks are event-driven and use tickMs.

TermColor.Repl.Terminal adds terminal size lookup, resize-aware key input, multiline input, transient-command suspension, and cooperative jobs. Each submitted line may run independently; the renderer merges completed results while input and other jobs continue. Config.handleKey and Config.handleMouse let an application consume its own input before normal REPL handling; set Config.mouse to enable SGR mouse capture.

import TermColor.Repl

open TermColor TermColor.Repl TermColor.Widgets

def complete : TextInputState → List Completion
  | input => ["/help", "/history"].filter (·.startsWith input.value) |>.map
      (fun replacement => { replacement })

def handle (state : State) (key : Key) : State × Action :=
  update { width := 120, maxLength := 120 } complete state key

Build

lake build TermColor.Repl TermColor.Repl.Properties tests

Related projects

termcolor-terminal owns terminal IO; lean-calc-chat is a complete consumer; argus provides its command-line integration; and oatp uses the REPL layer.

License

Apache-2.0.

About

Reusable Lean 4 terminal REPL primitives for the termcolor stack

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages