module Linenoise

Defined in:

linenoise.cr
linenoise/completion.cr

Constant Summary

VERSION = "0.4.0"

Class Method Summary

Class Method Detail

def self.add_completion(completion_state : Pointer(LibLinenoise::Completions), completion : String) #

This method should only be called inside the completion callback to register valid completions.


[View source]
def self.add_history(line : String) : Bool #

Register the most recent line to the history. It will be the first option when the user presses the up arrow key.


[View source]
def self.clear_screen #

Clears the entire screen and sets the cursor to the top left corner.


[View source]
def self.load_history(filename : String) : Bool #

Load the history from a file.


[View source]
def self.max_history(length : Int) : Bool #

Change the maximum number of lines in the history.


[View source]
def self.print_key_codes #

Only used for debugging. It is used in the example.cr program.


[View source]
def self.prompt(prompt : String) : String | Nil #

Prompts the user for a new line of input.


[View source]
def self.save_history(filename : String) : Bool #

Write the current history to a file.


[View source]
def self.set_completion_callback(callback : CompletionCallback) #

Note: The completion callback cannot be a closure since it will end up being passed to the C library internally and that is a compiler error.


[View source]
def self.set_encoding(encoding : Encoding) #

Set the string encoding for the linenoise session. It defaults to UTF8.


[View source]
def self.set_hints_callback(callback : HintsCallback) #

Note: The hints callback cannot be a closure since it will end up being passed to the C library internally and that is a compiler error.


[View source]
def self.set_mask_mode(mask_mode : Bool) #

Set text input masking. This prevents the user's keyboard input from being echoed automatically to the screen. Instead, the characters all get converted to asterisks (*). This is useful when users are entering passwords for example.

By default mask mode is disabled.


[View source]
def self.set_multiline(multiline : Bool) #

Single line mode: Scrolls to the right if input text becomes wider than the current window. Mutiline mode: Wraps the input text if it becomes wider than the current window.

Defaults to single line mode.


[View source]