FACT++  1.0
void ReadlineWindow::CompletionDisplay ( char **  matches,
int  num,
int  max 
)
protectedvirtual

Callback function to display the finally compiled list of completion options. Adapts fPromtY for the number of scrolled lines.

Parameters
matchesA list with the matches found. The first element contains what was completed. The length of the list is therefore num+1.
numNumber of possible completion entries in the list.
maxmaximum length of the entries
Todo:
Maybe we can use rl_outstream here if we find a way to redirect the stream to us instead of a file.

Reimplemented from Readline.

Definition at line 277 of file ReadlineWindow.cc.

References fPromptY, fWindow, and i.

278 {
279  // Increase maximum size by two to get gaps in between the columns
280  max += 2; // Two whitespaces in between the output
281 
282  // Get size of window
283  int lines, cols;
284  getmaxyx(fWindow, lines, cols);
285 
286  // Allow an empty space at the end of the lines for a '\n'
287  cols--;
288 
289  // calculate the final number columns
290  const int ncols = cols / max;
291 
292  // Compile a proper format string
293  ostringstream fmt;
294  fmt << "%-" << max << 's';
295 
296  // loop over all entries and display them
297  int l=0;
298  for (int i=0; i<num; i++)
299  {
300  // Check if we have to put a line-break
301  if (i%ncols==0)
302  {
303  if ((max+0)*ncols < cols)
304  wprintw(fWindow, "\n");
305  l++;
306  }
307 
308  // Display an entry
309  wprintw(fWindow, fmt.str().c_str(), matches[i+1]);
310  }
311 
312  // Display an empty line after the list
313  if ((num-1)%ncols>0)
314  wprintw(fWindow, "\n");
315  wprintw(fWindow, "\n");
316 
317  // Get new cursor position
318  int x, y;
319  getyx(fWindow, y, x);
320 
321  // Clear everything behind the list
322  wclrtobot(fWindow);
323 
324  // Adapt fPromptY for the number of scrolled lines if any.
325  if (y==lines-1)
326  fPromptY = lines-1;
327 
328  // Display anything
329  wrefresh(fWindow);
330 }
WINDOW * fWindow
int i
Definition: db_dim_client.c:21
int fPromptY
When the readline call is issued the x position at which the output will start is stored here...