linenoise
| Kind | ffi-c |
|---|---|
| Capabilities | ffi |
| Categories | terminal ffi |
| Keywords | linenoise readline line-editing repl terminal |
linenoise line editing library bindings for Kit
Files
| File | Description |
|---|---|
.editorconfig | Editor formatting configuration |
.gitignore | Git ignore rules for build artifacts and dependencies |
.tool-versions | asdf tool versions (Zig, Kit) |
LICENSE | MIT license file |
README.md | This file |
c/kit_linenoise.c | C FFI wrapper |
c/kit_linenoise.h | C header for FFI wrapper |
c/linenoise.c | C FFI wrapper |
c/linenoise.h | C header for FFI wrapper |
examples/basic.kit | Basic usage example |
kit.toml | Package manifest with metadata and dependencies |
src/linenoise.kit | Kit Linenoise - Line editing library bindings |
tests/linenoise.test.kit | Tests for linenoise |
Dependencies
No Kit package dependencies. No external libraries required — linenoise is bundled.
Installation
kit add gitlab.com/kit-lang/packages/kit-linenoise.gitSystem Requirements
No external dependencies — linenoise source is bundled in the package.
Usage
import Kit.Linenoise as Linenoise
main = fn =>
println "Type 'quit' to exit\n"
# Set history size
Linenoise.history-set-max 100
# Load previous history
match Linenoise.history-load "/tmp/history.txt"
| Ok _ -> println "(History loaded)"
| Err _ -> println "(No previous history)"
# Read a line with prompt
repl = fn(running) =>
if running then
line = Linenoise.readline "kit> "
if line == "quit" then
println "Goodbye!"
match Linenoise.history-save "/tmp/history.txt"
| Ok _ -> println "(History saved)"
| Err e -> println ("Save error: " ++ e)
else if line == "clear" then
Linenoise.clear-screen
repl true
else
Linenoise.history-add line
println ("You typed: " ++ line)
repl true
else
no-op
repl true
mainDevelopment
Running Examples
Run examples with the interpreter:
kit run examples/basic.kitCompile examples to a native binary:
kit build examples/basic.kit && ./basicRunning Tests
Run the test suite:
kit testRun the test suite with coverage:
kit test --coverageRunning kit dev
Run the standard development workflow (format, check, test):
kit devThis will:
- Format and check source files in
src/ - Run tests in
tests/with coverage
Generating Documentation
Generate API documentation from doc comments:
kit docNote: Kit sources with doc comments (##) will generate HTML documents in docs/*.html
Cleaning Build Artifacts
Remove generated files, caches, and build artifacts:
kit task cleanNote: Defined in kit.toml.
Local Installation
To install this package locally for development:
kit installThis installs the package to ~/.kit/packages/@kit/linenoise/, making it available for import as Kit.Linenoise in other projects.
License
This package is released under the MIT License - see LICENSE for details.
linenoise is released under the BSD 2-Clause License.
Exported Functions & Types
readline
Read a line of input with the given prompt.
Supports line editing (arrow keys, backspace, etc.) and history navigation (up/down arrows). Returns empty string on EOF (Ctrl-D).
Parameters:
Returns:
String -> String
readline-default
Read a line with the default prompt ("> ").
String
history-add
Add a line to the history.
Parameters:
String -> Unit
history-set-max
Set the maximum number of history entries.
Parameters:
Int -> Unit
history-save
Save history to a file.
Parameters:
Returns:
String -> Result Unit String
history-load
Load history from a file.
Parameters:
Returns:
String -> Result Unit String
set-multiline
Enable or disable multi-line editing mode.
When enabled, long lines wrap to the next line instead of scrolling.
Parameters:
Bool -> Unit
set-mask-mode
Enable or disable password masking mode.
When enabled, typed characters are shown as asterisks.
Parameters:
Bool -> Unit
clear-screen
Clear the terminal screen.
Unit