PAASS
Software suite to Acquire and Analyze Data from Pixie16
|
#include <CTerminal.h>
Public Member Functions | |
Terminal () | |
~Terminal () | |
void | Initialize () |
Initialize the terminal interface. More... | |
bool | SetLogFile (std::string logFileName) |
Specify the log file to append. More... | |
void | SetDebug (bool debug=true) |
Initalize terminal debug mode. More... | |
void | AddStatusWindow (unsigned short numLines=1) |
Initalizes a status window under the input temrinal. More... | |
void | SetStatus (std::string status, unsigned short line=0) |
Set the status message. More... | |
void | ClearStatus (unsigned short line=0) |
Clear the status line. More... | |
void | AppendStatus (std::string status, unsigned short line=0) |
Append some text to the status line. More... | |
void | EnableTabComplete (bool enable=true) |
Enable tab auto complete functionlity. More... | |
void | TabComplete (const std::string &input_, const std::vector< std::string > &possibilities_) |
Handle tab complete functionality. More... | |
void | EnableTimeout (float timeout=0.5) |
Enable a timeout while waiting fro a command. More... | |
void | SetCommandHistory (std::string filename, bool overwrite=false) |
Set the command filename for storing previous commands. More... | |
void | SetPrompt (const char *input_) |
Set the command prompt. More... | |
void | putch (const char input_) |
Force a character to the output screen. More... | |
void | pause (bool &flag) |
Disrupt ncurses while boolean is true. More... | |
void | flush () |
Dump all text in the stream to the output screen. More... | |
void | PrintCommand (const std::string &cmd_) |
Print a command to the terminal output. More... | |
std::string | GetCommand (std::string &args, const int &prev_cmd_return_=0) |
Wait for the user to input a command. More... | |
void | Close () |
Close the window and restore control to the terminal. More... | |
Private Member Functions | |
void | refresh_ () |
Refresh the terminal. More... | |
void | resize_ () |
Resize the terminal. More... | |
void | scroll_ (int numLines) |
Scroll the output by a specified number of lines. More... | |
void | update_cursor_ () |
Update the positions of the physical and logical cursors. More... | |
void | clear_ () |
Clear the command prompt output. More... | |
void | in_char_ (const char input_) |
Force a character to the input screen. More... | |
void | in_print_ (const char *input_) |
Force a character string to the input screen. More... | |
void | init_colors_ () |
Initialize terminal colors. More... | |
bool | LoadCommandFile (const char *filename_) |
Read commands from a command script. More... | |
bool | LoadCommandHistory (bool overwrite) |
Load a list of previous commands from a file. More... | |
bool | SaveCommandHistory () |
Save previous commands to a file. More... | |
void | print (WINDOW *window, std::string input_) |
Force a character string to the output screen. More... | |
void | split_commands (const std::string &input_, std::deque< std::string > &cmds) |
Split a string into multiple commands separated by a ';'. More... | |
Private Attributes | |
std::map< std::string, int > | attrMap |
std::streambuf * | pbuf |
std::streambuf * | original |
std::stringstream | stream |
std::string | historyFilename_ |
WINDOW * | main |
WINDOW * | output_window |
WINDOW * | input_window |
WINDOW * | status_window |
CommandHolder | commands |
std::string | cmd |
bool | init |
int | cursX |
int | cursY |
int | offset |
int | _winSizeX |
int | _winSizeY |
int | _statusWindowSize |
std::vector< std::string > | statusStr |
std::deque< std::string > | cmd_queue |
std::string | prompt |
The prompt string. More... | |
bool | enableTabComplete |
The tab complete flag. More... | |
float | commandTimeout_ |
Time in seconds to wait for command. More... | |
bool | insertMode_ |
short | tabCount |
bool | debug_ |
Flag indicating verbose output is enabled. More... | |
std::ofstream | logFile |
bool | from_script |
bool | prompt_user |
Set to true if a command is read from a script instead of user input. More... | |
int | _scrollbackBufferSize |
Set to true if the user should be prompted with a yes/no question. More... | |
int | _scrollPosition |
Number of lines scrolled back. More... | |
Definition at line 111 of file CTerminal.h.
Terminal::Terminal | ( | ) |
Definition at line 518 of file CTerminal.cpp.
Terminal::~Terminal | ( | ) |
void Terminal::AddStatusWindow | ( | unsigned short | numLines = 1 | ) |
Initalizes a status window under the input temrinal.
Creates a status window and the refreshes the output. Takes an optional number of lines, defaulted to 1.
[in] | numLines | Vertical size of status window. |
Definition at line 307 of file CTerminal.cpp.
void Terminal::AppendStatus | ( | std::string | status, |
unsigned short | line = 0 |
||
) |
Append some text to the status line.
Definition at line 333 of file CTerminal.cpp.
|
private |
Clear the command prompt output.
Definition at line 292 of file CTerminal.cpp.
void Terminal::ClearStatus | ( | unsigned short | line = 0 | ) |
Clear the status line.
Definition at line 328 of file CTerminal.cpp.
void Terminal::Close | ( | ) |
Close the window and restore control to the terminal.
Definition at line 1093 of file CTerminal.cpp.
void Terminal::EnableTabComplete | ( | bool | enable = true | ) |
Enable tab auto complete functionlity.
By enabling tab autocomplete the current typed command is returned via GetCommand() with a trailing tab character.
[in] | enable | State of tab complete. |
Definition at line 717 of file CTerminal.cpp.
void Terminal::EnableTimeout | ( | float | timeout = 0.5 | ) |
Enable a timeout while waiting fro a command.
By enabling the timeout the GetCommand() routine returns after a set timesout period has passed. The current typed text is stored for the next GetCommand call.
[in] | timeout | The amount of time to wait before timeout in seconds defaults to 0.5 s. |
Definition at line 728 of file CTerminal.cpp.
void Terminal::flush | ( | ) |
Dump all text in the stream to the output screen.
Definition at line 690 of file CTerminal.cpp.
std::string Terminal::GetCommand | ( | std::string & | args, |
const int & | prev_cmd_return_ = 0 |
||
) |
Wait for the user to input a command.
Definition at line 822 of file CTerminal.cpp.
|
private |
Force a character to the input screen.
Definition at line 339 of file CTerminal.cpp.
|
private |
Force a character string to the input screen.
Definition at line 349 of file CTerminal.cpp.
|
private |
Initialize terminal colors.
Definition at line 356 of file CTerminal.cpp.
void Terminal::Initialize | ( | ) |
Initialize the terminal interface.
Definition at line 548 of file CTerminal.cpp.
|
private |
Read commands from a command script.
Read commands from a command script. param[in] filename_ : The relative path to the file containing CTerminal commands. Returns true if the file opened successfully and false otherwise.
An example CTerminal script is given below. Comments are denoted by a #.
.echo This script is intended to be used to test the script reader (i.e. '.cmd').
.prompt WARNING! This script will do something. Are you sure you wish to proceed?
help # Do something just to test that the script is working.
Definition at line 407 of file CTerminal.cpp.
|
private |
Load a list of previous commands from a file.
Definition at line 447 of file CTerminal.cpp.
void Terminal::pause | ( | bool & | flag | ) |
Disrupt ncurses while boolean is true.
Definition at line 246 of file CTerminal.cpp.
|
private |
Force a character string to the output screen.
Definition at line 658 of file CTerminal.cpp.
void Terminal::PrintCommand | ( | const std::string & | cmd_ | ) |
Print a command to the terminal output.
Definition at line 814 of file CTerminal.cpp.
void Terminal::putch | ( | const char | input_ | ) |
Force a character to the output screen.
Definition at line 652 of file CTerminal.cpp.
|
private |
Refresh the terminal.
Refreshes the specified window or if none specified all windows.
[in] | window | The pointer to the window to be updated. |
Definition at line 259 of file CTerminal.cpp.
|
private |
Resize the terminal.
Definition at line 216 of file CTerminal.cpp.
|
private |
Save previous commands to a file.
Definition at line 493 of file CTerminal.cpp.
|
private |
Scroll the output by a specified number of lines.
Definition at line 274 of file CTerminal.cpp.
void Terminal::SetCommandHistory | ( | std::string | filename, |
bool | overwrite = false |
||
) |
Set the command filename for storing previous commands.
This command will clear all current commands from the history if overwrite is set to true.
[in] | filename | The filename for the command history. |
[in] | overwrite | Flag indicating the current commands should be forgotten. |
Definition at line 607 of file CTerminal.cpp.
|
inline |
Initalize terminal debug mode.
Definition at line 202 of file CTerminal.h.
bool Terminal::SetLogFile | ( | std::string | logFileName | ) |
Specify the log file to append.
Definition at line 703 of file CTerminal.cpp.
void Terminal::SetPrompt | ( | const char * | input_ | ) |
Set the command prompt.
Definition at line 614 of file CTerminal.cpp.
void Terminal::SetStatus | ( | std::string | status, |
unsigned short | line = 0 |
||
) |
Set the status message.
Definition at line 323 of file CTerminal.cpp.
|
private |
Split a string into multiple commands separated by a ';'.
Split strings into multiple commands separated by ';'.
[in] | input_ | The string to be parsed. |
[out] | cmds | The vector to populate with sub-commands. |
Definition at line 1156 of file CTerminal.cpp.
void Terminal::TabComplete | ( | const std::string & | input_, |
const std::vector< std::string > & | possibilities_ | ||
) |
Handle tab complete functionality.
Take the list of matching tab complete values and output resulting tab completion. If the list is empty nothing happens, if a unique value is given the command is completed. If there are multiple matches the common part of the matches is determined and printed to the input. If there is no common part of the matches and the tab key has been pressed twice the list of matches is printed for the user to decide.
[in] | input_ | The string to complete. |
[in] | possibilities_ | A vector of strings of possible values. |
Definition at line 740 of file CTerminal.cpp.
|
private |
Update the positions of the physical and logical cursors.
Definition at line 285 of file CTerminal.cpp.
|
private |
Set to true if the user should be prompted with a yes/no question.
Size of the scroll back buffer in lines.
Definition at line 146 of file CTerminal.h.
|
private |
Number of lines scrolled back.
Definition at line 149 of file CTerminal.h.
|
private |
Definition at line 127 of file CTerminal.h.
|
private |
Definition at line 126 of file CTerminal.h.
|
private |
Definition at line 126 of file CTerminal.h.
|
private |
Definition at line 113 of file CTerminal.h.
|
private |
Definition at line 122 of file CTerminal.h.
|
private |
Definition at line 129 of file CTerminal.h.
|
private |
Definition at line 121 of file CTerminal.h.
|
private |
Time in seconds to wait for command.
Definition at line 134 of file CTerminal.h.
|
private |
Definition at line 124 of file CTerminal.h.
|
private |
Definition at line 124 of file CTerminal.h.
|
private |
Flag indicating verbose output is enabled.
Definition at line 138 of file CTerminal.h.
|
private |
The tab complete flag.
Definition at line 133 of file CTerminal.h.
|
private |
Definition at line 142 of file CTerminal.h.
|
private |
Definition at line 116 of file CTerminal.h.
|
private |
Definition at line 123 of file CTerminal.h.
|
private |
Definition at line 119 of file CTerminal.h.
|
private |
Definition at line 135 of file CTerminal.h.
|
private |
Definition at line 140 of file CTerminal.h.
|
private |
Definition at line 117 of file CTerminal.h.
|
private |
Definition at line 125 of file CTerminal.h.
|
private |
Definition at line 114 of file CTerminal.h.
|
private |
Definition at line 118 of file CTerminal.h.
|
private |
Definition at line 114 of file CTerminal.h.
|
private |
The prompt string.
The queue of commands read from a command script.
Definition at line 131 of file CTerminal.h.
|
private |
Set to true if a command is read from a script instead of user input.
Definition at line 143 of file CTerminal.h.
|
private |
Definition at line 120 of file CTerminal.h.
|
private |
Definition at line 128 of file CTerminal.h.
|
private |
Definition at line 115 of file CTerminal.h.
|
private |
Definition at line 137 of file CTerminal.h.