|
rlmm::basic_terminal< Lock > Struct Template Reference
[The Readline classes.]
#include <rlmm/terminal.hh>
Inheritance diagram for rlmm::basic_terminal< Lock >:
[legend]Collaboration diagram for rlmm::basic_terminal< Lock >:
[legend]List of all members.
Detailed Description
template<typename Lock>
struct rlmm::basic_terminal< Lock >
Terminal handling.
namespace examples
{
class simple : public rlmm::readline
{
private:
string _def;
string _fd;
int _n;
string _prompt;
public:
simple(int argc, char** argv);
virtual ~simple() {}
virtual int startup_hook();
void usage();
int run();
};
}
examples::simple::simple(int argc, char** argv)
{
_def = "";
_n = 0;
_fd = "";
name(argv[0]);
_prompt = argv[0];
for (int i = 1; i < argc; i++) {
if (argv[i][0] != '-' || argv[i][1] == '\0' || !argv[i+1])
continue;
stringstream sarg(argv[i+1]);
switch (argv[i][1]) {
case 'p': sarg >> _prompt; break;
case 'u': sarg >> _fd; break;
case 'd': sarg >> _def; break;
case 'n': sarg >> _n; break;
default: usage(); exit(2); break;
}
i++;
}
}
int examples::simple::run()
{
if (!_fd.empty()) {
FILE* fp = fopen(_fd.c_str(), "r");
if (!fp) {
stringstream ss;
ss << name() << ": Bad file descriptor: " << _fd;
terminal::active().print(ss.str());
return 2;
}
terminal::active().instream(fp);
}
if (_n > 0) max_read(_n);
_prompt.append("$ ");
string line;
if (!read(_prompt, line)) return 1;
terminal::active().print(line);
terminal::active().next_line();
return 0;
}
int examples::simple::startup_hook()
{
static bool first = false;
if (first) return 0;
first = true;
buffer::instance().insert(_def);
return 0;
}
void examples::simple::usage()
{
stringstream ss;
ss << "Usage: " << name()
<< " [-p prompt] [-u unit] [-d default] [-n nchars]\n";
terminal::active().print(ss.str());
fflush(terminal::active().outstream());
}
int main(int argc, char** argv)
{
examples::simple s(argc, argv);
return s.run();
}
Constructor & Destructor Documentation
Member Function Documentation
|
Set the terminal size to default.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::deprepare |
( |
|
) |
[inline, protected, virtual] |
|
|
Undo last PrepareTerminal (overload).
|
|
Ring the terminal bell, returns false if no echo.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::do_activate |
( |
|
) |
[inline, protected, virtual] |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::do_deactivate |
( |
|
) |
[inline, protected, virtual] |
|
template<typename Lock> |
virtual int rlmm::basic_terminal< Lock >::input_timeout |
( |
|
) |
const [inline, virtual] |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::input_timeout |
( |
int |
us |
) |
[inline, virtual] |
|
|
Set the time out (in microseconds) before Input hook is exec'd.
|
|
Set the input stream.
- Parameters:
-
| in | A pointer to a C file stream. |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::name |
( |
const std::string & |
name |
) |
[inline, virtual] |
|
template<typename Lock> |
const std::string & rlmm::basic_terminal< Lock >::name |
( |
|
) |
const [inline, virtual] |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::new_line |
( |
bool |
withPrompt = false |
) |
[inline, virtual] |
|
|
Signal a new line.
- Parameters:
-
| withPrompt | If true, then it's assumed that the prompt has already been shown. If false, then the prompt is reshown. This member function is a good candidate for begin the last thing to do in rlmm::completion::display_hook. |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::outstream |
( |
FILE * |
out |
) |
[inline, virtual] |
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::prepare |
( |
bool |
eightbit = false |
) |
[inline, protected, virtual] |
|
|
Prepare terminal for readline reads (overload).
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::print |
( |
const std::string & |
txt |
) |
[inline, virtual] |
|
template<typename Lock> |
int rlmm::basic_terminal< Lock >::read_character |
( |
|
) |
[inline, protected, virtual] |
|
|
Abstract method to be overloaded, read one character from passed file pointer.
|
|
Read a character from input buffer.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::redisplay |
( |
|
) |
[inline, protected, virtual] |
|
|
Abstract method to be overloaded, redisplay the screen.
|
|
Reset the terminal to term.
|
|
Redisplay the current line.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::resize |
( |
int |
width, |
|
|
int |
height |
|
) |
[inline, virtual] |
|
|
Set the size (in characters) of the terminal.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::size |
( |
int & |
width, |
|
|
int & |
height |
|
) |
const [inline, virtual] |
|
|
Get the size of the terminal.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::true_size |
( |
int & |
width, |
|
|
int & |
height |
|
) |
[inline, static] |
|
|
Get the size of the terminal.
|
template<typename Lock> |
int rlmm::basic_terminal< Lock >::write_character |
( |
int |
c |
) |
[inline, virtual] |
|
|
Write a character to output, returns # of chars written.
|
template<typename Lock> |
void rlmm::basic_terminal< Lock >::write_message |
( |
const std::string & |
message |
) |
[inline, virtual] |
|
|
Write a message to output in `echo area'.
|
Friends And Related Function Documentation
template<typename Lock> |
void rlmm_deprepare |
( |
|
) |
[friend] |
|
template<typename Lock> |
void rlmm_prepare |
( |
int |
eightbit |
) |
[friend] |
|
|
Prepare terminal.
- Parameters:
-
| eightbit | Whether to use the meta bit |
|
template<typename Lock> |
int rlmm_read_character |
( |
FILE * |
in |
) |
[friend] |
|
template<typename Lock> |
void rlmm_redisplay |
( |
|
) |
[friend] |
|
Member Data Documentation
|
Screen height in characters.
|
|
input time out in
|
|
Screen width in characters.
|
The documentation for this struct was generated from the following file:
Top of page
Last update Fri Aug 26 15:19:53 2005
Christian Holm
Created by DoxyGen 1.4.4
|