FACT++  1.0
Shell.h
Go to the documentation of this file.
1 #ifndef FACT_Shell
2 #define FACT_Shell
3 
4 #include "ReadlineWindow.h"
5 #include "ReadlineColor.h"
6 #include "WindowLog.h"
7 
8 class WindowLog;
9 
10 typedef struct panel PANEL;
11 
12 class Shell : public ReadlineWindow
13 {
14 protected:
15  static Shell *This;
16 
17  WindowLog win;//(&fPanelIn); // FIXME: Ref
18  WindowLog wout;//(&fPanelOut); // FIXME: Ref
19 
20 private:
24 
26  int fIsVisible;
27 
28  int fLine;
29 
30  // Callback function for key presses
31  static int rl_proc_F1(int cnt, int key);
32  static int rl_scroll_top(int cnt, int key);
33  static int rl_scroll_bot(int cnt, int key);
34  static int rl_top_inc(int cnt, int key);
35  static int rl_top_dec(int cnt, int key);
36  static int rl_top_resize(int cnt, int key);
37 
40  static void HandleResizeImp(int dummy);
41 
43  void HandleResize();
44 
46  void CreateWindows(WINDOW *w[3], int all=true);
47 
48  // Action after readline finished
49  void Shutdown(const char *);
50 
51 public:
52  Shell(const char *prgname);
53  ~Shell();
54 
55  bool Resize(int h);
56  void ShowHide(int v);
57  void Refresh() { ShowHide(-2); }
58 
60  bool PrintGeneralHelp();
61  bool PrintKeyBindings();
62 
63  bool Process(const std::string &str);
64 
65  void Lock() { }
66  void Run(const char * = "")
67  {
70  }
71  void Unlock() { }
72 
73  WindowLog &GetStreamOut() { return wout; }
74  WindowLog &GetStreamIn() { return win; }
75  const WindowLog &GetStreamOut() const { return wout; }
76  const WindowLog &GetStreamIn() const { return win; }
77 };
78 
79 #endif
int fIsVisible
Space between the bottom of the screen and the output panel.
Definition: Shell.h:26
static void Resize()
Definition: Readline.cc:816
static int rl_scroll_top(int cnt, int key)
Definition: Shell.cc:283
PANEL * fPanelOut
Pointer to the panel for the frame around the output.
Definition: Shell.h:23
WindowLog win
pointer to our glocal object to get the static member functions into scope
Definition: Shell.h:17
char str[80]
Definition: test_client.c:7
A C++ ostream to an ncurses window supporting attributes and colors.
Definition: WindowLog.h:50
static int rl_top_inc(int cnt, int key)
Definition: Shell.cc:295
static int rl_scroll_bot(int cnt, int key)
Definition: Shell.cc:289
static void HandleResizeImp(int dummy)
Signal handler for SIGWINCH, calls HandleResize.
Definition: Shell.cc:318
void CreateWindows(WINDOW *w[3], int all=true)
Helper for the constructor and window resizing to create the windows and panels.
Definition: Shell.cc:240
~Shell()
Ends the ncurses environment by calling endwin().
Definition: Shell.cc:185
void Unlock()
Definition: Shell.h:71
bool PrintCommands(std::ostream &out)
void Lock()
Definition: Shell.h:65
bool PrintGeneralHelp()
Definition: Shell.cc:434
static Shell * This
Definition: Shell.h:15
virtual void Run(const char *prompt=0)
Definition: Readline.cc:1406
WindowLog & GetStreamIn()
Definition: Shell.h:74
int fLine
Flag whether the output panel is visible or not (for toggle operations)
Definition: Shell.h:28
PANEL * fPanelFrame
Pointer to the panel for the input stream.
Definition: Shell.h:22
void ShowHide(int v)
Definition: Shell.cc:207
bool PrintBootMsg(std::ostream &out, const std::string &name, bool interactive=true)
static int rl_top_resize(int cnt, int key)
Definition: Shell.cc:307
bool PrintKeyBindings()
Definition: Shell.cc:425
static int rl_proc_F1(int cnt, int key)
Key binding for F1. Toggles upper panel by calling ShowHide(-1)
Definition: Shell.cc:277
PANEL * fPanelIn
Definition: Shell.h:21
void Run(const char *="")
Definition: Shell.h:66
struct _win_st WINDOW
Definition: ReadlineWindow.h:6
bool Process(const std::string &str)
Definition: Shell.cc:451
WindowLog & GetStreamOut()
Definition: Shell.h:73
const WindowLog & GetStreamOut() const
Definition: Shell.h:75
WindowLog wout
Definition: Shell.h:18
int fPanelHeight
Pointer to the panel for the output stream.
Definition: Shell.h:25
std::string GetName() const
Definition: Readline.h:88
struct panel PANEL
Definition: Shell.h:10
void Shutdown(const char *)
Definition: Shell.cc:502
bool PrintCommands()
Definition: Shell.h:59
Shell(const char *prgname)
Definition: Shell.cc:95
void Refresh()
Definition: Shell.h:57
void HandleResize()
Non static member function called by HandleResize.
Definition: Shell.cc:332
static int rl_top_dec(int cnt, int key)
Definition: Shell.cc:301
const WindowLog & GetStreamIn() const
Definition: Shell.h:76
Implementation of a console based user shell with an input and output window.
Definition: Shell.h:12
Helper to redirect readline's in- and output to an ncurses window.
Definition: ReadlineWindow.h:8