FACT++  1.0
void ReadlineWindow::Redisplay ( )
protectedvirtual

This basically implement displaying the whole line, starting with the prompt and the rl_line_buffer. It also checks if displaying it results in a scroll of the window and adapt fPromptY accordingly.

The prompt is displayed in the color defined by fColor.

Before the cursor position is finally set a screen refresh (Refresh()) is initiated to ensure that nothing afterwards will change the cursor position. It might be necessary to overwrite this function.

Todo:
fix docu

Reimplemented from Readline.

Definition at line 202 of file ReadlineWindow.cc.

References buffer, end, fColor, fPromptX, fPromptY, fWindow, Readline::GetBuffer(), Readline::GetCursor(), Readline::GetPrompt(), and Refresh().

Referenced by EventHook().

203 {
204  // Move to the beginning of the output
205  wmove(fWindow, fPromptY, fPromptX);
206 
207  // Get site of the window
208  int lines, cols;
209  getmaxyx(fWindow, lines, cols);
210 
211  const string prompt = GetPrompt();
212  const string buffer = GetBuffer();
213 
214  // Issue promt and redisplay text
215  wattron(fWindow, fColor);
216  wprintw(fWindow, "%s", prompt.c_str());
217  wattroff(fWindow, fColor);
218  wprintw(fWindow, "%s", buffer.c_str());
219 
220  // Clear everything after that
221  wclrtobot(fWindow);
222 
223  // Calculate absolute position in window or beginning of output
224  int xy = fPromptY*cols + fPromptX;
225 
226  // Calculate position of end of prompt
227  xy += prompt.length();
228 
229  // Calculate position of cursor and end of output
230  const int cur = xy + GetCursor();
231  const int end = xy + buffer.size();
232 
233  // Calculate if the above output scrolled the window and by how many lines
234  int scrolls = end/cols - lines + 1;
235 
236  if (scrolls<0)
237  scrolls = 0;
238 
239  fPromptY -= scrolls;
240 
241  // new position
242  const int px = cur%cols;
243  const int py = scrolls>=1 ? cur/cols - scrolls : cur/cols;
244 
245  // Make sure that whatever happens while typing the correct
246  // screen is shown (otherwise the top-panel disappears when
247  // we scroll)
248  Refresh();
249 
250  // Move the cursor to the cursor position
251  wmove(fWindow, py, px);
252 
253  // Make changes visible on screen
254  wrefresh(fWindow);
255 }
WINDOW * fWindow
static std::string GetBuffer()
Definition: Readline.cc:768
static std::string GetPrompt()
Definition: Readline.cc:751
double end
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
int fPromptY
When the readline call is issued the x position at which the output will start is stored here...
virtual void Refresh()
int fPromptX
Pointer to the panel for the input stream.
static int GetCursor()
return rl_point (the current cursor position within the line buffer)
Definition: Readline.cc:777
int fColor
When the readline call is issued the y position at which the output will start is stored here...

+ Here is the call graph for this function:

+ Here is the caller graph for this function: