72 #include <sys/ioctl.h> 96 fPanelHeight(13), fIsVisible(1), fLine(0)
101 cout <<
"ERROR - Only one instance of class Shell is allowed." << endl;
115 intrflush(stdscr,
FALSE);
116 keypad(stdscr,
FALSE);
119 use_default_colors();
123 for (
int i=1;
i<8;
i++)
194 cout <<
"The end." << endl;
243 getmaxyx(stdscr, maxy, maxx);
247 WINDOW *new_in = all ? newwin(maxy, maxx, 0, 0) : 0;
248 WINDOW *new_frame = newwin(separator-1, maxx, 0, 0);
249 WINDOW *new_out = newwin(separator-1-2, maxx-2, 1, 1);
252 wmove(new_frame, 0, 1);
253 waddch(new_frame, ACS_RTEE);
254 wprintw(new_frame,
" F1 ");
255 waddch(new_frame, ACS_LTEE);
257 scrollok(new_out,
true);
258 leaveok (new_out,
true);
262 scrollok(new_in,
true);
263 leaveok (new_in,
false);
265 wmove(new_in, maxy-1, 0);
285 This->
win <<
"Scroll " << key << endl;
291 This->
win <<
"Scroll " << key << endl;
297 This->
win <<
"Increase " << key << endl;
303 This->
win <<
"Increase " << key << endl;
336 ioctl(0, TIOCGWINSZ, &w);
339 resize_term(w.ws_row, w.ws_col);
387 getmaxyx(stdscr, lines, cols);
390 if (h<1 || h>lines-5)
428 win <<
" " <<
kUnderline <<
"Special key bindings:" << endl << endl;;
429 win <<
kBold <<
" F1 " <<
kReset <<
"Toggle visibility of upper panel" << endl;
437 win <<
kBold <<
" hide " <<
kReset <<
"Hide upper panel." << endl;
438 win <<
kBold <<
" show " <<
kReset <<
"Show upper panel." << endl;
439 win <<
kBold <<
" height <h> " <<
kReset <<
"Set height of upper panel to h." << endl;
466 if (
string(str)==
"hide")
471 if (
string(str)==
"show")
477 if (str.substr(0, 7)==
"height ")
480 sscanf(str.c_str()+7,
"%d", &h);
int fIsVisible
Space between the bottom of the screen and the output panel.
bool PrintGeneralHelp(std::ostream &out, const std::string &name)
static int rl_scroll_top(int cnt, int key)
PANEL * fPanelOut
Pointer to the panel for the frame around the output.
WindowLog win
pointer to our glocal object to get the static member functions into scope
void SetWindow(WINDOW *w)
static int rl_top_inc(int cnt, int key)
static int rl_scroll_bot(int cnt, int key)
virtual bool Process(const std::string &str)
static void HandleResizeImp(int dummy)
Signal handler for SIGWINCH, calls HandleResize.
void BindKeySequence(const char *seq, int(*func)(int, int))
void CreateWindows(WINDOW *w[3], int all=true)
Helper for the constructor and window resizing to create the windows and panels.
~Shell()
Ends the ncurses environment by calling endwin().
void SetColorPrompt(int col)
static std::string GetPrompt()
PANEL * fPanelFrame
Pointer to the panel for the input stream.
static int rl_top_resize(int cnt, int key)
static int rl_proc_F1(int cnt, int key)
Key binding for F1. Toggles upper panel by calling ShowHide(-1)
bool Process(std::ostream &out, const std::string &str)
void SetWindow(WINDOW *w)
Redirect the output to an ncurses WINDOW instead of cout.
void Shutdown(const char *buf)
bool Process(const std::string &str)
bool PrintKeyBindings(std::ostream &out)
void RewindCursor() const
void Display(bool empty=false)
Display backlog.
int fPanelHeight
Pointer to the panel for the output stream.
std::string GetName() const
void Shutdown(const char *)
Shell(const char *prgname)
void HandleResize()
Non static member function called by HandleResize.
static int rl_top_dec(int cnt, int key)
Implementation of a console based user shell with an input and output window.
Helper to redirect readline's in- and output to an ncurses window.