FACT++  1.0
Shell::Shell ( const char *  prgname)

This initializes the Ncurses environment. Since the ncurses environment is global only one instance of this class is allowed.

The first 8 color pairs (COLOR_PAIR) are set to the first 8 color with default background.

The shells windows and panels are created. And their pointers are propagated to the two associated WindowLog streams.

Also some key bindings are initialized.

Definition at line 95 of file Shell.cc.

References Readline::BindKeySequence(), CreateWindows(), FALSE, fPanelFrame, fPanelIn, fPanelOut, HandleResizeImp(), i, rl_proc_F1(), rl_scroll_bot(), rl_scroll_top(), rl_top_dec(), rl_top_inc(), rl_top_resize(), ReadlineWindow::SetColorPrompt(), ReadlineWindow::SetWindow(), WindowLog::SetWindow(), ShowHide(), This, win, and wout.

95  : ReadlineWindow(prgname),
96  fPanelHeight(13), fIsVisible(1), fLine(0)
97 {
98  if (stdscr!=0)
99  {
100  endwin();
101  cout << "ERROR - Only one instance of class Shell is allowed." << endl;
102  exit(-1);
103  }
104 
105  This = this;
106 
107  // ---------------------- Setup ncurses -------------------------
108 
109  initscr(); // Start curses mode
110 
111  cbreak(); // Line buffering disabled, Pass on
112  noecho(); // Switch off echo mode
113  nonl(); // Associate return with CR
114 
115  intrflush(stdscr, FALSE);
116  keypad(stdscr, FALSE); // Switch off keymapping for function keys
117 
118  start_color(); // Initialize ncurses colors
119  use_default_colors(); // Assign terminal default colors to -1
120  //assume_default_colors(-1, -1); // standard terminal colors assigned to pair 0
121 
122  // Setup colors
123  for (int i=1; i<8; i++)
124  init_pair(i, i, -1); // -1: def background
125 
126  signal(SIGWINCH, HandleResizeImp); // Attach HandleResize to SIGWINCH signal
127 
128  // ---------------------- Setup pansl --------------------------
129 
130  // Create the necessary windows
131  WINDOW *wins[4];
132  CreateWindows(wins);
133 
134  // Initialize the panels
135  fPanelIn = new_panel(wins[0]);
136  fPanelFrame = new_panel(wins[1]);
137  fPanelOut = new_panel(wins[2]);
138 
139  win.SetWindow(wins[0]);
140  wout.SetWindow(wins[2]);
141 
142  // Get the panels into the right order for startup
143  ShowHide(1);
144 
145  // Setup Readline
146  SetWindow(wins[0]);
147  SetColorPrompt(COLOR_PAIR(COLOR_BLUE));
148 
149  // ------------------- Setup key bindings -----------------------
150  BindKeySequence("\033OP", rl_proc_F1);
151  BindKeySequence("\033[1;5B", rl_scroll_top);
152  BindKeySequence("\033[1;5A", rl_scroll_top);
153  BindKeySequence("\033[1;3A", rl_scroll_bot);
154  BindKeySequence("\033[1;3B", rl_scroll_bot);
155  BindKeySequence("\033[5;3~", rl_top_inc);
156  BindKeySequence("\033[6;3~", rl_top_dec);
157  BindKeySequence("\033+", rl_top_resize);
158  BindKeySequence("\033-", rl_top_resize);
159 
160  /*
161  rl_bind_keyseq("\033\t", rl_complete); // Meta-Tab
162  rl_bind_keyseq("\033[1~", home); // Home (console)
163  rl_bind_keyseq("\033[H", home); // Home (x)
164  rl_bind_keyseq("\033[4~", end); // End (console)
165  rl_bind_keyseq("\033[F", end); // End (x)
166  rl_bind_keyseq("\033[A", up); // Up
167  rl_bind_keyseq("\033[B", down); // Down
168  rl_bind_keyseq("\033[[B", accept); // F2 (console)
169  rl_bind_keyseq("\033OQ", accept); // F2 (x)
170  rl_bind_keyseq("\033[21~", cancel); // F10
171  */
172 
173  // Ctrl+dn: \033[1;5B
174  // Ctrl+up: \033[1;5A
175  // Alt+up: \033[1;3A
176  // Alt+dn: \033[1;3B
177  // Alt+pg up: \033[5;3~
178  // Alt+pg dn: \033[6;3~
179 }
int fIsVisible
Space between the bottom of the screen and the output panel.
Definition: Shell.h:26
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
int i
Definition: db_dim_client.c:21
WindowLog win
pointer to our glocal object to get the static member functions into scope
Definition: Shell.h:17
void SetWindow(WINDOW *w)
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
#define FALSE
Definition: dim.h:136
static void HandleResizeImp(int dummy)
Signal handler for SIGWINCH, calls HandleResize.
Definition: Shell.cc:318
void BindKeySequence(const char *seq, int(*func)(int, int))
Definition: Readline.cc:648
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
ReadlineWindow(const char *prgname)
static Shell * This
Definition: Shell.h:15
void SetColorPrompt(int col)
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
static int rl_top_resize(int cnt, int key)
Definition: Shell.cc:307
static int rl_proc_F1(int cnt, int key)
Key binding for F1. Toggles upper panel by calling ShowHide(-1)
Definition: Shell.cc:277
void SetWindow(WINDOW *w)
Redirect the output to an ncurses WINDOW instead of cout.
Definition: WindowLog.h:118
PANEL * fPanelIn
Definition: Shell.h:21
struct _win_st WINDOW
Definition: ReadlineWindow.h:6
WindowLog wout
Definition: Shell.h:18
int fPanelHeight
Pointer to the panel for the output stream.
Definition: Shell.h:25
static int rl_top_dec(int cnt, int key)
Definition: Shell.cc:301

+ Here is the call graph for this function: