Construct a Readline object. The constructor reads the history from a history file. The filename is compiled by adding ".his" to the supplied argument. The name oif the history file is stored in fName.
Since readline has a global namespace, the creation of only one Readline instance is allowed.
The provided program name is supplied to readline by means of rl_readline_name.
Readlines default callback frunction for completions is redirected to CompletionImp which in turn will call Completion, which can be overwritten by the user.
Bind some default key sequences like Page-up/-down for searching forward and backward in history.
- Parameters
-
prgname | The prefix of the history filename. Usually the program name, which can be initialized by argv[0]. |
Definition at line 105 of file Readline.cc.
References fCommandLog, fName, rl_ncurses_completion_display(), rl_ncurses_completion_function(), rl_ncurses_event_hook(), rl_ncurses_getc(), rl_ncurses_redisplay(), rl_ncurses_startup(), and This.
Referenced by SetSection().
110 cout <<
"ERROR - Readline can only be instatiated once!" << endl;
120 #if BOOST_VERSION < 104600 121 static const string fname = boost::filesystem::path(prgname).filename();
123 static const string fname = boost::filesystem::path(prgname).filename().string();
125 rl_readline_name = fname.c_str();
128 fName = string(prgname)+
".his";
131 read_history(
fName.c_str());
146 rl_bind_keyseq(
"\e[1~", rl_named_function(
"beginning-of-line"));
147 rl_bind_keyseq(
"\e[3~", rl_named_function(
"delete-char"));
148 rl_bind_keyseq(
"\e[4~", rl_named_function(
"end-of-line"));
149 rl_bind_keyseq(
"\e[5~", rl_named_function(
"history-search-backward"));
150 rl_bind_keyseq(
"\e[6~", rl_named_function(
"history-search-forward"));
151 rl_bind_keyseq(
"\033[1;3F", rl_named_function(
"kill-line"));
152 rl_bind_keyseq(
"\033[1;5D", rl_named_function(
"backward-word"));
153 rl_bind_keyseq(
"\033[1;5C", rl_named_function(
"forward-word"));
154 rl_bind_key(25, rl_named_function(
"kill-whole-line"));
const std::vector< std::string > * fCompletion
Pointer to a list of possible matched for auto-completion.
static int rl_ncurses_event_hook()
std::ofstream fCommandLog
Maximum number of lines in the history file.
int fMaxLines
Filename for the history file compiled in the constructor.
static int rl_ncurses_startup()
static char ** rl_ncurses_completion_function(const char *text, int start, int end)
static void rl_ncurses_completion_display(char **matches, int num, int max)
static int rl_ncurses_getc(FILE *)
Static member function which are used to adapt readline to ncurses.
int fLine
Last line adde to history.
static void rl_ncurses_redisplay()