Qore Linenoise Module  1.0.0
Linenoise Functions

Functions

int Qore::Linenoise::columns ()
 Get terminal width in characters. More...
 
list Qore::Linenoise::history ()
 Get complete history. More...
 
int Qore::Linenoise::history_add (string line)
 Add string to history. More...
 
nothing Qore::Linenoise::history_free ()
 Clear the history.
 
int Qore::Linenoise::history_get_max_len ()
 get size of the history More...
 
nothing Qore::Linenoise::history_load (string filename)
 Load history from file. More...
 
nothing Qore::Linenoise::history_save (string filename)
 Save history to file. More...
 
int Qore::Linenoise::history_set_max_len (int len)
 Set size of the history. More...
 
string Qore::Linenoise::line (string prompt)
 Main function to obtain line value. More...
 
nothing Qore::Linenoise::set_callback (code callback)
 Set auto-completion callback function. More...
 

Detailed Description

Function Documentation

int Qore::Linenoise::columns ( )

Get terminal width in characters.

Returns
int actual width of terminal window in characters
list Qore::Linenoise::history ( )

Get complete history.

Get complete history. History structure is limited by Qore::Linenoise::history_set_max_len()

Returns
list a list with histroy items. 0 index is the oldest.
See also
History Handling
int Qore::Linenoise::history_add ( string  line)

Add string to history.

It adds new item to history. The history queue is shifted if it hits the maximum history size.

Parameters
linea string to be added
int Qore::Linenoise::history_get_max_len ( )

get size of the history

Returns
int with size of history
nothing Qore::Linenoise::history_load ( string  filename)

Load history from file.

Load history queue from plain-text file.

Parameters
filenamea filename with relative or full path
Exceptions
LINENOISE-HISTORY-LOAD-ERROR
nothing Qore::Linenoise::history_save ( string  filename)

Save history to file.

Save history queue to plain-text file.

Parameters
filenamea filename with relative or full path
Exceptions
LINENOISE-HISTORY-SAVE-ERROR
int Qore::Linenoise::history_set_max_len ( int  len)

Set size of the history.

Parameters
lena new size
string Qore::Linenoise::line ( string  prompt)

Main function to obtain line value.

The function waits for user input confirmed by Enter.

Parameters
prompta custom string with prompt
Returns
User input string or Qore::NOTHING if the user sends ^C (Ctrl+C) interrupt signal

Features:

  • accept basic user input: regular characters, cursor keys, TAB, ENTER keys
  • accept advanced edits: Ctrl+key, Keyboard Shortcuts
  • waits until the ENTER is pressed

Example:

1 while (True) {
2  *string line = line("my prompt> ");
3  printf("echo: %s\n", line);
4 }
See also
Basic Usage
nothing Qore::Linenoise::set_callback ( code  callback)

Set auto-completion callback function.

Parameters
codea funnction/method reference or a closure to handle completion callback
See also
Line Completion
Warning
Qore language does not support complex types yet so you can register any code with this function. But if the function/code will not accept the string argument the RUNTIME-OVERLOAD-ERROR exception will be thrown