attr_clear(stdscr, lines, columns, dlg.screen.atr); /* Display background title if it exists ... - SLH */ if (dlg.backtitle != NULL) { int i, len = 0, skip = 0; struct subtitle_list *pos;
/* * End using dialog functions.
*/ void end_dialog(int x, int y)
{ /* move cursor back to original position */
move(y, x);
refresh();
endwin();
}
/* Print the title of the dialog. Center the title and truncate * tile if wider than dialog (- 2 chars).
**/ void print_title(WINDOW *dialog, constchar *title, int width)
{ if (title) { int tlen = MIN(width - 2, strlen(title));
wattrset(dialog, dlg.title.atr);
mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' ');
mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen);
waddch(dialog, ' ');
}
}
/* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline * characters '\n' are properly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space.
*/ void print_autowrap(WINDOW * win, constchar *prompt, int width, int y, int x)
{ int newl, cur_x, cur_y; int prompt_len, room, wlen; char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
if (prompt_len <= width - x * 2) { /* If prompt is short */
wmove(win, y, (width - prompt_len) / 2);
waddstr(win, tempstr);
} else {
cur_x = x;
cur_y = y;
newl = 1;
word = tempstr; while (word && *word) {
sp = strpbrk(word, "\n "); if (sp && *sp == '\n')
newline_separator = sp;
if (sp)
*sp++ = 0;
/* Wrap to next line if either the word does not fit, or it is the first word of a new sentence, and it is
short, and the next word does not fit. */
room = width - cur_x;
wlen = strlen(word); if (wlen > room ||
(newl && wlen < 4 && sp
&& wlen + 1 + strlen(sp) > room
&& (!(sp2 = strpbrk(sp, "\n "))
|| wlen + 1 + (sp2 - sp) > room))) {
cur_y++;
cur_x = x;
}
wmove(win, cur_y, cur_x);
waddstr(win, word);
getyx(win, cur_y, cur_x);
/* Move to the next line if the word separator was a newline */ if (newline_separator) {
cur_y++;
cur_x = x;
newline_separator = 0;
} else
cur_x++;
if (sp && *sp == ' ') {
cur_x++; /* double space */ while (*++sp == ' ') ;
newl = 1;
} else
newl = 0;
word = sp;
}
}
}
/* * Print a button
*/ void print_button(WINDOW * win, constchar *label, int y, int x, int selected)
{ int i, temp;
/* * Draw a rectangular box with line drawing characters
*/ void
draw_box(WINDOW * win, int y, int x, int height, int width,
chtype box, chtype border)
{ int i, j;
/* * Draw shadows along the right and bottom edge to give a more 3D look * to the boxes
*/ void draw_shadow(WINDOW * win, int y, int x, int height, int width)
{ int i;
if (has_colors()) { /* Whether terminal supports color? */
wattrset(win, dlg.shadow.atr);
wmove(win, y + height, x + 2); for (i = 0; i < width; i++)
waddch(win, winch(win) & A_CHARTEXT); for (i = y + 1; i < y + height + 1; i++) {
wmove(win, i, x + width);
waddch(win, winch(win) & A_CHARTEXT);
waddch(win, winch(win) & A_CHARTEXT);
}
wnoutrefresh(win);
}
}
/* * Return the position of the first alphabetic character in a string.
*/ int first_alpha(constchar *string, constchar *exempt)
{ int i, in_paren = 0, c;
for (i = 0; i < strlen(string); i++) {
c = tolower(string[i]);
if (strchr("<[(", c))
++in_paren; if (strchr(">])", c) && in_paren > 0)
--in_paren;
if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) return i;
}
return 0;
}
/* * ncurses uses ESC to detect escaped char sequences. This resutl in * a small timeout before ESC is actually delivered to the application. * lxdialog suggest <ESC> <ESC> which is correctly translated to two * times esc. But then we need to ignore the second esc to avoid stepping * out one menu too much. Filter away all escaped key sequences since * keypad(FALSE) turn off ncurses support for escape sequences - and that's * needed to make notimeout() do as expected.
*/ int on_key_esc(WINDOW *win)
{ int key; int key2; int key3;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.