Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/repl-input.x
Inline terminal editing for the x2c REPL.
Functions
| Function | Summary |
|---|---|
ReplInput.close | Restores the terminal and releases editor-owned history storage. |
ReplInput.new | Creates an interactive terminal owner with empty in-memory history. |
ReplInput.read | Reads one accepted line, EOF, or cancellation. |
ReplInput.remember | Remembers one nonempty entry, suppressing an adjacent duplicate and evicting the oldest entry beyond 100. |
ReplInput
ReplInput.close
void ReplInput.close(ReplInput r)
Restores the terminal and releases editor-owned history storage.
Source: src/repl-input.x:1658
ReplInput.new
ReplInput ReplInput.new(void)
Creates an interactive terminal owner with empty in-memory history.
Source: src/repl-input.x:1598
ReplInput.read
ReplInputResult ReplInput.read( ReplInput r, String prompt, ReplInputComplete complete, void *completion_context)
Reads one accepted line, EOF, or cancellation. Supported terminals use inline editing; other terminal types use the basic line reader. Terminal mode is restored before return or transfer of an allocation, size, or I/O cause.
Source: src/repl-input.x:1611
ReplInput.remember
void ReplInput.remember(ReplInput r, String text)
Remembers one nonempty entry, suppressing an adjacent duplicate and evicting the oldest entry beyond 100.
Source: src/repl-input.x:1642
Public types
| Type | Kind | Summary |
|---|---|---|
ReplInput | struct | Owns terminal restoration and the current process’s bounded REPL history. |
ReplInputComplete | callback | Computes completion synchronously from borrowed text and a byte cursor. |
ReplInputCompletion | struct | Completion candidates replace [start,end) in the edited UTF-8 buffer. |
ReplInputResult | struct | status is line, eof, or cancelled. |
ReplInput
typedef struct ReplInput *ReplInput
Owns terminal restoration and the current process’s bounded REPL history.
Source: src/repl-input.x:49
ReplInputComplete
typedef ReplInputCompletion (*ReplInputComplete)( void *context, String text, size_t cursor)
Computes completion synchronously from borrowed text and a byte cursor. Returned candidates must remain live through the editor’s synchronous completion handling.
Source: src/repl-input.x:67
ReplInputCompletion
typedef struct ReplInputCompletion { size_t start, end; List candidates; } ReplInputCompletion
Completion candidates replace [start,end) in the edited UTF-8 buffer.
Source: src/repl-input.x:59
ReplInputResult
typedef struct ReplInputResult { Symbol status; String text; } ReplInputResult
status is line, eof, or cancelled. text is present for line, including
an accepted empty line.
Source: src/repl-input.x:53
Design notes
Derived from Linenoise commit
a473823d74b93eab2ba83480df16ed37617493f2:
https://github.com/antirez/linenoise
linenoise.c sha256
4bc28faf2a46ccaea11d07aa056e21aa2e9a748b4dc6962346a3f658593103a8
linenoise.h sha256
5f94c6295e3b62e0f8b4b62b0a2f351433d0b6b21029607aec0c9abbc60acff7
ReplInput owns terminal restoration and bounded session history. Each read
owns its edit buffer, display state, and mutable history view.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.