linenoise - Linenoise - Package Reference
Welcome to Linenoise, a binding to Antirez's linenoise minimal line editor library, as modified and extended by Steve Bennet of Workware.au
This document is the reference manpage for the linenoise package, a binding to Antirez's minimal line editor library (of the same name) and as extended by Steve Bennet. Its intended audience are developers wishing to write Tcl applications and packages using linenoise.
This section describe the available commands.
All of them are found under the linenoise ensemble command.
This command implements the core of a REPL (read-eval-print loop). While the defaults of the various options are geared towards the REPL of a Tcl shell, other types of REPL can implemented just fine by overriding them with the proper callbacks. By default the loop can be aborted only by entering Control-C on the keyboard, or equivalent.
The recognized options are
This command returns the current width of the console window the package is talking to. This enables the user to adapt its output (for example help texts) to the console.
This command returns the current state of the system's hidden flag, which is true if hidden input is activated, and false otherwise. If the argument is specified it has to be a boolean value which becomes the new value of the flag. This new value is then returned.
This command adds the string to the history. The result of the command is a boolean flag, true if the addition suceeded, and false otherwise. The string will not be added if it is identical to the last entry of the history, preventing entry of adjacent duplicates.
The history reaching its maximal size does not prevent the addition of the string. It simply bumps of the oldest entry to make room for the new.
This command clears (empties) the history.
This command returns a list containing the history. The first element of the result is the oldest entry in the history, and the last element the newest.
This command loads the contents of the file at path into the history. Note, this is not a replacement, but an appending, like with linenoise history add.
This command returns the current maximal size of the system's history, as a positive integer number greater than zero. If the argument is specified it has to be a positive integer number greater than zero, which becomes the new maximal size of the history. This new value is then returned.
If the new maximal size is less than the current size of the history the oldest entries are discarded to bring the history down to the new size.
This command takes the history and stores it into the file at the specified path. The previous contents of the file are written over and lost.
This command returns the number of entries in the history, as positive integer number (including zero).
This command implements a one-shot prompt (instead of a REPL), returning the string entered by the user after completing the interaction.
The recognized options are similar to what is recognized by cmdloop, albeit reduced and simplified:
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report them at the Issues tracker. Ideas for enhancements you may have for either package, application, and/or the documentation are also very welcome and should be reported at the Issues tracker as well.
Copyright © 2013 Andreas Kupries