1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# FFI Manifest for libedit (BSD-licensed readline alternative)
#
# Provides line-editing and history functionality for interactive programs.
# This is the BSD-licensed alternative to GNU readline, used by PostgreSQL,
# Python (on macOS), and many other projects.
#
# Installation:
# macOS: Already installed (Apple ships libedit)
# Ubuntu/Debian: apt install libedit-dev
# Fedora: dnf install libedit-devel
#
# Usage in Seq:
# include ffi:libedit
#
# "prompt> " readline # Read a line with editing
# dup add-history # Add to history
#
# Persistent history:
# "/path/to/history" read-history drop # Load at startup
# # ... run REPL ...
# "/path/to/history" write-history drop # Save at exit
#
# Note: These functions accept file paths as-is. Shell expansions like ~
# are not performed - that's the responsibility of your application.
# A future std:os module could provide getenv for building paths like
# "$HOME/.myapp_history".
#
# Note: The function names (readline, add-history) match GNU readline's API,
# making it easy to switch between the two libraries.
[[]]
= "libedit"
= "edit"
[[]]
= "readline"
= "readline"
= "( String -- String )"
= [
{ = "string", = "c_string" }
]
[]
= "string"
= "caller_frees"
[[]]
= "add_history"
= "add-history"
= "( String -- )"
= [
{ = "string", = "c_string" }
]
[]
= "void"
# read_history(const char *filename) -> int
# Loads command history from a file. Call at program startup.
# Returns 0 on success, non-zero on error (e.g., file not found).
[[]]
= "read_history"
= "read-history"
= "( String -- Int )"
= [
{ = "string", = "c_string" }
]
[]
= "int"
# write_history(const char *filename) -> int
# Saves command history to a file. Call at program exit.
# Returns 0 on success, non-zero on error.
[[]]
= "write_history"
= "write-history"
= "( String -- Int )"
= [
{ = "string", = "c_string" }
]
[]
= "int"