Repository navigation
Releases
v0.17.0
go get github.com/xo/rline@v0.17.0rline requires github.com/xo/inputrc v0.11.3. Each change below has a decision in docs/PLAN.md.
New in the API
Session.Palettereturns the colors that rline writes to the terminal. It returnsansi.PaletteMonowhen rline writes no color: withWithColor(false), with NO_COLOR set, on a dumb terminal, and when the output is not a terminal (D140).Session.Setchanges options afterNew. It takes the history options (WithHistory,WithHistoryFile,WithHistoryLimit,WithHistoryFileLimit,WithHistoryControl,WithHistoryFilter,WithHistoryDuplicates,WithManualHistoryandWithHistoryFileMode), and alsoWithPrompt,WithCompleterandWithHighlighter. For any other option it returnsErrNotSettableand changes nothing (D141).Optionis now a struct, where it was a function. A program makes an option only with the With functions, so no caller changes.
Fixed
- On a dumb terminal, and with horizontal-scroll-mode, a line that the function of
WithContinuesays goes on showed "^J". rline now writes a new row and the continuation prompt, and edits the new line in its own row, as bash does. In that row, the keys stop at the newline, as they do in bash (D139, D143). - In a locale of single bytes, the cursor stays where the terminal put it after a byte above 0x7f. This holds in the row of horizontal-scroll-mode and after a prompt that holds such a byte (D138, D142).
Changed
- revert-line rings the bell when there is nothing to take back, and vi's b and B ring it at the start of the line, as bash does (D143).
- A lower history limit given to
Setdrops the oldest entries at once, as HISTSIZE does in bash. A new file limit takes effect at the next save (D141).
config/v0.2.0
go get github.com/xo/rline/config@v0.2.0config requires rline v0.17.0 and github.com/xo/transit/styles v0.8.0.
Styles.SpecLanguage(capture, language)gives the style of a capture in a language. The entry ofeditor.styleswins, as inSpec. Then the theme's entry for the language wins, such askeyword.postgresoverkeyword(D144).HistoryOptionsalways gives the options forhistory.size,history.file_sizeandhistory.ignore. An empty value gives the default of rline, soSession.Setgoes back to the default when a program empties a key while it runs.Newbehaves as before (D145).
v0.16.0
go get github.com/xo/rline@v0.16.0rline requires github.com/xo/inputrc v0.11.3. Each change below has a decision in docs/PLAN.md.
New in the API
WithHistoryControlandHistoryControlleave lines out of the history as HISTCONTROL does in bash (D99, D103).WithHistoryFilterasks a function about each line before it goes into the history, as HISTIGNORE does (D99).WithHistoryFileLimitwrites at most the newest n entries to the history file, as HISTFILESIZE does (D99).WithInputrcLinesapplies lines of an inputrc file after the inputrc file itself (D100).WithManualInterruptNewlineleaves the newline after a line that Ctrl-C gave up to the program (D121).Candidate.Modegives the mode of the file that a completion names. A directory gets its slash from readline's mark-directories and mark-symlinked-directories (D127). SetMode, and do not put "/" inDisplayorSuffix.LineStyle.EditandEditsay how the line changed since the highlighter was last called, for an incremental parser such as tree-sitter (D128).
Changed
WithKeepInterruptedis deprecated and does nothing. A line that Ctrl-C gives up always stays on the screen with ^C after it, as in bash (D122).- bash 5.3 on Linux amd64 is the reference on every Unix system (D113).
- A locale that is not UTF-8 reads each byte as one character. In the C and POSIX locales, the four meta variables of readline take bash's values, and a byte above 0x7f is shown in octal when output-meta is off (D111, D112, D118). After such a byte, the cursor stays where the terminal put it (D137).
- On a dumb terminal, and with horizontal-scroll-mode, rline draws one row that scrolls sideways, as readline does (D119, D126). On a dumb terminal there is no carriage return after ^C, as in bash.
- A session that does not edit writes nothing of its own (D120).
- rline draws the active region as readline 8.3 does (D107).
- Each save of the history removes the temporary files that rline left beside it (D105).
- tty-status rings the bell on every Unix system (D110).
- keyseq-timeout sets how long rline waits for the rest of a key sequence (D98).
- The question before a long list, Ctrl-C on a line taller than the screen, and a resize at the question follow bash (D134, D136).
- Menu marks, tabs, braces and the width after a resize follow readline (D116, D117, D130 to D133).
- An inputrc file gives a notice for each line that is at fault (D104, D109).
- An unknown or limited terminfo entry keeps the escape sequences that rline wrote before (D123, D124).
- On Windows, the console reads escape sequences from
NewtoClose.
Also
- rline builds with TinyGo for js/wasm, WASI preview 1 and WASI preview 2, and CI checks it (D115).
- The
configmodule reads thehistoryandeditorstanzas of config.yaml. It is tagged on its own, asconfig/v0.1.0, later (D101). - The MIT license of rline and of isocline is in LICENSE.
config/v0.1.0
go get github.com/xo/rline/config@v0.1.0The first release of the module github.com/xo/rline/config (D101). It reads the history and editor stanzas of config.yaml, which usql and hail share, and turns them into options of rline.
It requires rline v0.16.0, github.com/xo/hail/pattern v0.1.0 for history.ignore (D106), and github.com/xo/transit/styles v0.7.11. It needs Go 1.27.4.
v0.15.3
go get github.com/xo/rline@v0.15.3rline builds with github.com/xo/inputrc v0.11.3. v0.15.2 did not build once go get -u picked inputrc v0.10.0 or later, because inputrc removed Parser.Errs.
What changed
- rline requires inputrc v0.11.3, and reads the faults of an inputrc file from the error that the parser returns.
Newstill gives no notice for a line of the inputrc file that is at fault. A file that cannot be read gives one, as before.ParseAndBindstill answersErrUnknownVariablefor a variable that readline does not have.- inputrc v0.11.1 and later read an inputrc file more as readline 8.3 does. For example,
"\C-a" end-of-line, with a space and no colon, binds\C-aas bash 5.3 does, where before it was refused.
Nothing else changed since v0.15.2.
v0.15.2
go get github.com/xo/rline@v0.15.2Each row of a line after a newline can have its own prompt, as psql's
PROMPT2 draws one for each row of a statement.
What changed
WithRowPrompt(rowPrompt func(before string) string)gives each row that
starts after a newline its own prompt, in place of the continuation
marker. rline gives the function all the text before the row, the newline
included. It asks again whenever the text changes, so an edit on an
earlier row or a paste changes the prompts after it (D96).- A row that only wraps keeps the continuation marker.
- The rows after the first all take the width of the widest prompt, and a
narrower prompt is padded on the left, as the continuation marker is. When
a wider prompt appears, as when the row number gains a digit, the rows
above it move one column to the right. psql does not do that.
Nothing changes for a program that does not use the option.
v0.15.1
go get github.com/xo/rline@v0.15.1rline now compiles for WASI preview 2 with TinyGo. Nothing changes on any
other system.
What changed
tinygo build -target=wasip2compiles rline. TinyGo builds that target as
linux with the build tagwasip2, andgolang.org/x/sys/unixdoes not
compile there. The files that import it now leave outwasip2. The target
reads plain lines, as wasip1 does, and a program can give it a terminal
withWithTerminal(D95).- CI has no TinyGo.
TestNoSystemCallsUnderWASIP2reads each build line with
the tags that TinyGo 0.44.0 sets for wasip2, and fails when a file that the
target takes importsgolang.org/x/sys/unix.
Known limits
- The build was checked by hand up to the link step. The link needs
wasm-tools, which was not on the host. CI does not build with TinyGo
(backlog 86).
v0.15.0
go get github.com/xo/rline@v0.15.0The prompt is written once, rows follow readline's layout without the wrap
mark, and a function that runs at the prompt can end the line. This release
changes the signature of RunAtPrompt, which v0.14.0 brought a day ago.
What changed
- The prompt is written once, and each draw after that moves the cursor
past it, as readline does. A program that waits for the prompt on a
pseudo-terminal no longer takes a copy of it for the next one (D90). - With
WithWrapMark(false), rows follow readline's layout: a row fills the
terminal to its edge, a row that only wraps starts at the left edge with
no continuation marker, and a cursor at the edge goes to the next row. The
default layout is unchanged (D91). - A completion that a program command queues with
Line.Completecounts as
a second press only after the same command, so Tab and that command do not
list after each other (D92). RunAtPromptnow takesfunc(w io.Writer) error. An error gives up the
line, ends raw mode, and is whatReadLinereturns. What else was asked
for waits for the next line (D94). A function that returns nil works as
before.- D93 corrects the reasoning of D87 about when bash runs a trap at the
prompt. rline's behaviour does not change.
Known limits
- In readline's layout, a resize still measures the rows as isocline lays
them out, so a row of the old draw can stay on the screen (backlog 89). - The wake of
RunAtPrompton Windows is checked only bygo vet
(backlog 88). - The questions that are still open, and the work that is known and not
done, are in
docs/PLAN.md and
docs/BACKLOG.md.
v0.14.0
go get github.com/xo/rline@v0.14.0A program can run work at the prompt, and a program command can print
below the line or finish it and have the terminal. Two faults against
readline are fixed: a change that stty made at the prompt was undone at
the next line, and the end of a line drew the line again.
What changed
Session.RunAtPrompt(fn)runs fn whileReadLinewaits for a key, as
bash runs a trap or writes a job notice at the prompt. It is safe to call
from any goroutine. The line goes off the screen, fn writes where it was,
and the line is drawn again below, with the text and the cursor kept. When
no line is read, fn runs before the next prompt (D87).Line.Print(text)writes below the line and keeps the line, as bash's
display-shell-version does.Line.AcceptAndRelease(fn)finishes the line
as it stands and gives the terminal to fn, andReadLinehands the line
back with no prompt after it, as bash's edit-and-execute-command does
(D85).WithWrapMark(false)leaves out the mark at the end of a row that wraps
(D86).- A command that a program command queues with
RunorCompletesees the
command before the program's, so a second press of a key that completes
lists, and menu-complete goes on to the next completion. The line is drawn
before a list of completions (D84). - Raw mode reads the terminal's settings each time, as readline does, so a
change thatsttymade at the prompt stays (D88). - The end of a line moves the cursor to its end and writes nothing more when
the line is drawn as it stands, as readline does. It is drawn again only
when keys came faster than it was drawn, Ctrl-C emptied it, or a brace is
highlighted (D89).
Known limits
- A row that wraps ends one column before the edge, where readline fills it
(backlog 87). - The wake of
RunAtPrompton Windows is checked only bygo vet
(backlog 88). - CI does not build with TinyGo yet (backlog 86).
- The questions that are still open, and the work that is known and not
done, are in
docs/PLAN.md and
docs/BACKLOG.md.
v0.13.0
go get github.com/xo/rline@v0.13.0A command of the program's own can do more of what readline's commands do,
and a fault of v0.12.0 after Ctrl-C is fixed. No exported name changed its
meaning.
What changed
Line.Run(name)runs a readline or rline command after the program's
command returns, as a step of its own for undo.Line.Complete(name, completer)runs a command that completes, such ascompleteor
possible-completions, with a completer of its own (D80).Line.Release(fn)gives the terminal to fn while the line is off the
screen, and draws the prompt and the line again below what fn wrote, as
bash does forbind -x(D81).Line.Mark,Line.SetMarkandLine.CountGivengive a command the mark
and whether a count was typed, as bash givesbind -xREADLINE_MARK and
READLINE_ARGUMENT (D82).Line.Kill(start, end)takes text out of the line onto the kill ring, as
readline's kill commands do: kills in a row join, and yank brings the text
back (D83).- A change that a command makes to the line now happens at once, inside the
command's undo step.TextandCursorshow it straight away. - Fixed: the "^C" after a line that Ctrl-C gave up landed at the start of
the row since v0.12.0, because the end of bracketed paste, with its
carriage return, reached the terminal first. What the line wrote now goes
out before raw mode ends.
Known limits
- CI does not build with TinyGo yet (backlog 86).
- A prompt whose last line is wider than the terminal breaks the redraw
(backlog 84). - The questions that are still open, and the work that is known and not
done, are in
docs/PLAN.md and
docs/BACKLOG.md.