C# Class IrcShark.Extensions.Terminal.History

The History saves a list of typed commands on the console and provides methods to switch through the saved commands.
This code bases on Miguel de Icaza's ([email protected]) LineEditor from the mono project. It was changed to fit the needs of IrcShark and its coding standards.
Show file Open project: hapm/IrcShark Class Usage Examples

Public Methods

Method Description
Accept ( string s ) : void

Overrides the lastly added history item.

Append ( string s ) : void

Appends a value to the history.

CursorToEnd ( ) : void

Moves the cursor to the end of the history.

History ( int size ) : System

Initializes a new instance of the History class.

History ( int size, string savedHistory ) : System

Initializes a new instance of the History class.

Next ( ) : string

Moves the cursor to the next item if possible, and returns it.

NextAvailable ( ) : bool

Checks if there is a next item after the current item under the cursor.

Previous ( ) : string

Moves the cursor to the previous item if possible, and returns it.

PreviousAvailable ( ) : bool

Checks if there is a previous item before the current item under the cursor.

RemoveLast ( ) : void

Removes the last item that was added to the History.

SearchBackward ( string term ) : string

Searches a given term in the history backwards, from newest to oldest command.

Update ( string s ) : void

Updates the current cursor location with the string, to support editing of history items.

For the current line to participate, an Append must be done before.

Private Methods

Method Description
Close ( ) : void

Method Details

Accept() public method

Overrides the lastly added history item.
public Accept ( string s ) : void
s string The new value to add.
return void

Append() public method

Appends a value to the history.
public Append ( string s ) : void
s string The value to append.
return void

CursorToEnd() public method

Moves the cursor to the end of the history.
public CursorToEnd ( ) : void
return void

History() public method

Initializes a new instance of the History class.
Thrown if size is smaller than 1.
public History ( int size ) : System
size int The number of commands, this history instance can save.
return System

History() public method

Initializes a new instance of the History class.
Thrown if size is smaller than 1 or than the length of the savedHistory array.
public History ( int size, string savedHistory ) : System
size int The number of commands, this history instance can save.
savedHistory string An array of saved commands, that should be loaded to the History on initialisation.
return System

Next() public method

Moves the cursor to the next item if possible, and returns it.
public Next ( ) : string
return string

NextAvailable() public method

Checks if there is a next item after the current item under the cursor.
public NextAvailable ( ) : bool
return bool

Previous() public method

Moves the cursor to the previous item if possible, and returns it.
public Previous ( ) : string
return string

PreviousAvailable() public method

Checks if there is a previous item before the current item under the cursor.
public PreviousAvailable ( ) : bool
return bool

RemoveLast() public method

Removes the last item that was added to the History.
public RemoveLast ( ) : void
return void

SearchBackward() public method

Searches a given term in the history backwards, from newest to oldest command.
public SearchBackward ( string term ) : string
term string The term to search for.
return string

Update() public method

Updates the current cursor location with the string, to support editing of history items.
For the current line to participate, an Append must be done before.
public Update ( string s ) : void
s string The new value for the history item at the current location.
return void