1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/kconfig/nconf.gui.c Mon Apr 16 15:29:06 2012 +0200
1.3 @@ -0,0 +1,617 @@
1.4 +/*
1.5 + * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
1.6 + * Released under the terms of the GNU GPL v2.0.
1.7 + *
1.8 + * Derived from menuconfig.
1.9 + *
1.10 + */
1.11 +#include "nconf.h"
1.12 +
1.13 +/* a list of all the different widgets we use */
1.14 +attributes_t attributes[ATTR_MAX+1] = {0};
1.15 +
1.16 +/* available colors:
1.17 + COLOR_BLACK 0
1.18 + COLOR_RED 1
1.19 + COLOR_GREEN 2
1.20 + COLOR_YELLOW 3
1.21 + COLOR_BLUE 4
1.22 + COLOR_MAGENTA 5
1.23 + COLOR_CYAN 6
1.24 + COLOR_WHITE 7
1.25 + */
1.26 +static void set_normal_colors(void)
1.27 +{
1.28 + init_pair(NORMAL, -1, -1);
1.29 + init_pair(MAIN_HEADING, COLOR_MAGENTA, -1);
1.30 +
1.31 + /* FORE is for the selected item */
1.32 + init_pair(MAIN_MENU_FORE, -1, -1);
1.33 + /* BACK for all the rest */
1.34 + init_pair(MAIN_MENU_BACK, -1, -1);
1.35 + init_pair(MAIN_MENU_GREY, -1, -1);
1.36 + init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1);
1.37 + init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1);
1.38 +
1.39 + init_pair(SCROLLWIN_TEXT, -1, -1);
1.40 + init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1);
1.41 + init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1);
1.42 +
1.43 + init_pair(DIALOG_TEXT, -1, -1);
1.44 + init_pair(DIALOG_BOX, COLOR_YELLOW, -1);
1.45 + init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1);
1.46 + init_pair(DIALOG_MENU_FORE, COLOR_RED, -1);
1.47 +
1.48 + init_pair(INPUT_BOX, COLOR_YELLOW, -1);
1.49 + init_pair(INPUT_HEADING, COLOR_GREEN, -1);
1.50 + init_pair(INPUT_TEXT, -1, -1);
1.51 + init_pair(INPUT_FIELD, -1, -1);
1.52 +
1.53 + init_pair(FUNCTION_HIGHLIGHT, -1, -1);
1.54 + init_pair(FUNCTION_TEXT, COLOR_BLUE, -1);
1.55 +}
1.56 +
1.57 +/* available attributes:
1.58 + A_NORMAL Normal display (no highlight)
1.59 + A_STANDOUT Best highlighting mode of the terminal.
1.60 + A_UNDERLINE Underlining
1.61 + A_REVERSE Reverse video
1.62 + A_BLINK Blinking
1.63 + A_DIM Half bright
1.64 + A_BOLD Extra bright or bold
1.65 + A_PROTECT Protected mode
1.66 + A_INVIS Invisible or blank mode
1.67 + A_ALTCHARSET Alternate character set
1.68 + A_CHARTEXT Bit-mask to extract a character
1.69 + COLOR_PAIR(n) Color-pair number n
1.70 + */
1.71 +static void normal_color_theme(void)
1.72 +{
1.73 + /* automatically add color... */
1.74 +#define mkattr(name, attr) do { \
1.75 +attributes[name] = attr | COLOR_PAIR(name); } while (0)
1.76 + mkattr(NORMAL, NORMAL);
1.77 + mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE);
1.78 +
1.79 + mkattr(MAIN_MENU_FORE, A_REVERSE);
1.80 + mkattr(MAIN_MENU_BACK, A_NORMAL);
1.81 + mkattr(MAIN_MENU_GREY, A_NORMAL);
1.82 + mkattr(MAIN_MENU_HEADING, A_BOLD);
1.83 + mkattr(MAIN_MENU_BOX, A_NORMAL);
1.84 +
1.85 + mkattr(SCROLLWIN_TEXT, A_NORMAL);
1.86 + mkattr(SCROLLWIN_HEADING, A_BOLD);
1.87 + mkattr(SCROLLWIN_BOX, A_BOLD);
1.88 +
1.89 + mkattr(DIALOG_TEXT, A_BOLD);
1.90 + mkattr(DIALOG_BOX, A_BOLD);
1.91 + mkattr(DIALOG_MENU_FORE, A_STANDOUT);
1.92 + mkattr(DIALOG_MENU_BACK, A_NORMAL);
1.93 +
1.94 + mkattr(INPUT_BOX, A_NORMAL);
1.95 + mkattr(INPUT_HEADING, A_BOLD);
1.96 + mkattr(INPUT_TEXT, A_NORMAL);
1.97 + mkattr(INPUT_FIELD, A_UNDERLINE);
1.98 +
1.99 + mkattr(FUNCTION_HIGHLIGHT, A_BOLD);
1.100 + mkattr(FUNCTION_TEXT, A_REVERSE);
1.101 +}
1.102 +
1.103 +static void no_colors_theme(void)
1.104 +{
1.105 + /* automatically add highlight, no color */
1.106 +#define mkattrn(name, attr) { attributes[name] = attr; }
1.107 +
1.108 + mkattrn(NORMAL, NORMAL);
1.109 + mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE);
1.110 +
1.111 + mkattrn(MAIN_MENU_FORE, A_STANDOUT);
1.112 + mkattrn(MAIN_MENU_BACK, A_NORMAL);
1.113 + mkattrn(MAIN_MENU_GREY, A_NORMAL);
1.114 + mkattrn(MAIN_MENU_HEADING, A_BOLD);
1.115 + mkattrn(MAIN_MENU_BOX, A_NORMAL);
1.116 +
1.117 + mkattrn(SCROLLWIN_TEXT, A_NORMAL);
1.118 + mkattrn(SCROLLWIN_HEADING, A_BOLD);
1.119 + mkattrn(SCROLLWIN_BOX, A_BOLD);
1.120 +
1.121 + mkattrn(DIALOG_TEXT, A_NORMAL);
1.122 + mkattrn(DIALOG_BOX, A_BOLD);
1.123 + mkattrn(DIALOG_MENU_FORE, A_STANDOUT);
1.124 + mkattrn(DIALOG_MENU_BACK, A_NORMAL);
1.125 +
1.126 + mkattrn(INPUT_BOX, A_BOLD);
1.127 + mkattrn(INPUT_HEADING, A_BOLD);
1.128 + mkattrn(INPUT_TEXT, A_NORMAL);
1.129 + mkattrn(INPUT_FIELD, A_UNDERLINE);
1.130 +
1.131 + mkattrn(FUNCTION_HIGHLIGHT, A_BOLD);
1.132 + mkattrn(FUNCTION_TEXT, A_REVERSE);
1.133 +}
1.134 +
1.135 +void set_colors()
1.136 +{
1.137 + start_color();
1.138 + use_default_colors();
1.139 + set_normal_colors();
1.140 + if (has_colors()) {
1.141 + normal_color_theme();
1.142 + } else {
1.143 + /* give defaults */
1.144 + no_colors_theme();
1.145 + }
1.146 +}
1.147 +
1.148 +
1.149 +/* this changes the windows attributes !!! */
1.150 +void print_in_middle(WINDOW *win,
1.151 + int starty,
1.152 + int startx,
1.153 + int width,
1.154 + const char *string,
1.155 + chtype color)
1.156 +{ int length, x, y;
1.157 + float temp;
1.158 +
1.159 +
1.160 + if (win == NULL)
1.161 + win = stdscr;
1.162 + getyx(win, y, x);
1.163 + if (startx != 0)
1.164 + x = startx;
1.165 + if (starty != 0)
1.166 + y = starty;
1.167 + if (width == 0)
1.168 + width = 80;
1.169 +
1.170 + length = strlen(string);
1.171 + temp = (width - length) / 2;
1.172 + x = startx + (int)temp;
1.173 + (void) wattrset(win, color);
1.174 + mvwprintw(win, y, x, "%s", string);
1.175 + refresh();
1.176 +}
1.177 +
1.178 +int get_line_no(const char *text)
1.179 +{
1.180 + int i;
1.181 + int total = 1;
1.182 +
1.183 + if (!text)
1.184 + return 0;
1.185 +
1.186 + for (i = 0; text[i] != '\0'; i++)
1.187 + if (text[i] == '\n')
1.188 + total++;
1.189 + return total;
1.190 +}
1.191 +
1.192 +const char *get_line(const char *text, int line_no)
1.193 +{
1.194 + int i;
1.195 + int lines = 0;
1.196 +
1.197 + if (!text)
1.198 + return 0;
1.199 +
1.200 + for (i = 0; text[i] != '\0' && lines < line_no; i++)
1.201 + if (text[i] == '\n')
1.202 + lines++;
1.203 + return text+i;
1.204 +}
1.205 +
1.206 +int get_line_length(const char *line)
1.207 +{
1.208 + int res = 0;
1.209 + while (*line != '\0' && *line != '\n') {
1.210 + line++;
1.211 + res++;
1.212 + }
1.213 + return res;
1.214 +}
1.215 +
1.216 +/* print all lines to the window. */
1.217 +void fill_window(WINDOW *win, const char *text)
1.218 +{
1.219 + int x, y;
1.220 + int total_lines = get_line_no(text);
1.221 + int i;
1.222 +
1.223 + getmaxyx(win, y, x);
1.224 + /* do not go over end of line */
1.225 + total_lines = min(total_lines, y);
1.226 + for (i = 0; i < total_lines; i++) {
1.227 + char tmp[x+10];
1.228 + const char *line = get_line(text, i);
1.229 + int len = get_line_length(line);
1.230 + strncpy(tmp, line, min(len, x));
1.231 + tmp[len] = '\0';
1.232 + mvwprintw(win, i, 0, "%s", tmp);
1.233 + }
1.234 +}
1.235 +
1.236 +/* get the message, and buttons.
1.237 + * each button must be a char*
1.238 + * return the selected button
1.239 + *
1.240 + * this dialog is used for 2 different things:
1.241 + * 1) show a text box, no buttons.
1.242 + * 2) show a dialog, with horizontal buttons
1.243 + */
1.244 +int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
1.245 +{
1.246 + va_list ap;
1.247 + char *btn;
1.248 + int btns_width = 0;
1.249 + int msg_lines = 0;
1.250 + int msg_width = 0;
1.251 + int total_width;
1.252 + int win_rows = 0;
1.253 + WINDOW *win;
1.254 + WINDOW *msg_win;
1.255 + WINDOW *menu_win;
1.256 + MENU *menu;
1.257 + ITEM *btns[btn_num+1];
1.258 + int i, x, y;
1.259 + int res = -1;
1.260 +
1.261 +
1.262 + va_start(ap, btn_num);
1.263 + for (i = 0; i < btn_num; i++) {
1.264 + btn = va_arg(ap, char *);
1.265 + btns[i] = new_item(btn, "");
1.266 + btns_width += strlen(btn)+1;
1.267 + }
1.268 + va_end(ap);
1.269 + btns[btn_num] = NULL;
1.270 +
1.271 + /* find the widest line of msg: */
1.272 + msg_lines = get_line_no(msg);
1.273 + for (i = 0; i < msg_lines; i++) {
1.274 + const char *line = get_line(msg, i);
1.275 + int len = get_line_length(line);
1.276 + if (msg_width < len)
1.277 + msg_width = len;
1.278 + }
1.279 +
1.280 + total_width = max(msg_width, btns_width);
1.281 + /* place dialog in middle of screen */
1.282 + y = (LINES-(msg_lines+4))/2;
1.283 + x = (COLS-(total_width+4))/2;
1.284 +
1.285 +
1.286 + /* create the windows */
1.287 + if (btn_num > 0)
1.288 + win_rows = msg_lines+4;
1.289 + else
1.290 + win_rows = msg_lines+2;
1.291 +
1.292 + win = newwin(win_rows, total_width+4, y, x);
1.293 + keypad(win, TRUE);
1.294 + menu_win = derwin(win, 1, btns_width, win_rows-2,
1.295 + 1+(total_width+2-btns_width)/2);
1.296 + menu = new_menu(btns);
1.297 + msg_win = derwin(win, win_rows-2, msg_width, 1,
1.298 + 1+(total_width+2-msg_width)/2);
1.299 +
1.300 + set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
1.301 + set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
1.302 +
1.303 + (void) wattrset(win, attributes[DIALOG_BOX]);
1.304 + box(win, 0, 0);
1.305 +
1.306 + /* print message */
1.307 + (void) wattrset(msg_win, attributes[DIALOG_TEXT]);
1.308 + fill_window(msg_win, msg);
1.309 +
1.310 + set_menu_win(menu, win);
1.311 + set_menu_sub(menu, menu_win);
1.312 + set_menu_format(menu, 1, btn_num);
1.313 + menu_opts_off(menu, O_SHOWDESC);
1.314 + menu_opts_off(menu, O_SHOWMATCH);
1.315 + menu_opts_on(menu, O_ONEVALUE);
1.316 + menu_opts_on(menu, O_NONCYCLIC);
1.317 + set_menu_mark(menu, "");
1.318 + post_menu(menu);
1.319 +
1.320 +
1.321 + touchwin(win);
1.322 + refresh_all_windows(main_window);
1.323 + while ((res = wgetch(win))) {
1.324 + switch (res) {
1.325 + case KEY_LEFT:
1.326 + menu_driver(menu, REQ_LEFT_ITEM);
1.327 + break;
1.328 + case KEY_RIGHT:
1.329 + menu_driver(menu, REQ_RIGHT_ITEM);
1.330 + break;
1.331 + case 10: /* ENTER */
1.332 + case 27: /* ESCAPE */
1.333 + case ' ':
1.334 + case KEY_F(F_BACK):
1.335 + case KEY_F(F_EXIT):
1.336 + break;
1.337 + }
1.338 + touchwin(win);
1.339 + refresh_all_windows(main_window);
1.340 +
1.341 + if (res == 10 || res == ' ') {
1.342 + res = item_index(current_item(menu));
1.343 + break;
1.344 + } else if (res == 27 || res == KEY_F(F_BACK) ||
1.345 + res == KEY_F(F_EXIT)) {
1.346 + res = KEY_EXIT;
1.347 + break;
1.348 + }
1.349 + }
1.350 +
1.351 + unpost_menu(menu);
1.352 + free_menu(menu);
1.353 + for (i = 0; i < btn_num; i++)
1.354 + free_item(btns[i]);
1.355 +
1.356 + delwin(win);
1.357 + return res;
1.358 +}
1.359 +
1.360 +int dialog_inputbox(WINDOW *main_window,
1.361 + const char *title, const char *prompt,
1.362 + const char *init, char *result, int result_len)
1.363 +{
1.364 + int prompt_lines = 0;
1.365 + int prompt_width = 0;
1.366 + WINDOW *win;
1.367 + WINDOW *prompt_win;
1.368 + WINDOW *form_win;
1.369 + PANEL *panel;
1.370 + int i, x, y;
1.371 + int res = -1;
1.372 + int cursor_position = strlen(init);
1.373 +
1.374 +
1.375 + /* find the widest line of msg: */
1.376 + prompt_lines = get_line_no(prompt);
1.377 + for (i = 0; i < prompt_lines; i++) {
1.378 + const char *line = get_line(prompt, i);
1.379 + int len = get_line_length(line);
1.380 + prompt_width = max(prompt_width, len);
1.381 + }
1.382 +
1.383 + if (title)
1.384 + prompt_width = max(prompt_width, strlen(title));
1.385 +
1.386 + /* place dialog in middle of screen */
1.387 + y = (LINES-(prompt_lines+4))/2;
1.388 + x = (COLS-(prompt_width+4))/2;
1.389 +
1.390 + strncpy(result, init, result_len);
1.391 +
1.392 + /* create the windows */
1.393 + win = newwin(prompt_lines+6, prompt_width+7, y, x);
1.394 + prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2);
1.395 + form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
1.396 + keypad(form_win, TRUE);
1.397 +
1.398 + (void) wattrset(form_win, attributes[INPUT_FIELD]);
1.399 +
1.400 + (void) wattrset(win, attributes[INPUT_BOX]);
1.401 + box(win, 0, 0);
1.402 + (void) wattrset(win, attributes[INPUT_HEADING]);
1.403 + if (title)
1.404 + mvwprintw(win, 0, 3, "%s", title);
1.405 +
1.406 + /* print message */
1.407 + (void) wattrset(prompt_win, attributes[INPUT_TEXT]);
1.408 + fill_window(prompt_win, prompt);
1.409 +
1.410 + mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
1.411 + mvwprintw(form_win, 0, 0, "%s", result);
1.412 +
1.413 + /* create panels */
1.414 + panel = new_panel(win);
1.415 +
1.416 + /* show the cursor */
1.417 + curs_set(1);
1.418 +
1.419 + touchwin(win);
1.420 + refresh_all_windows(main_window);
1.421 + while ((res = wgetch(form_win))) {
1.422 + int len = strlen(result);
1.423 + switch (res) {
1.424 + case 10: /* ENTER */
1.425 + case 27: /* ESCAPE */
1.426 + case KEY_F(F_HELP):
1.427 + case KEY_F(F_EXIT):
1.428 + case KEY_F(F_BACK):
1.429 + break;
1.430 + case 127:
1.431 + case KEY_BACKSPACE:
1.432 + if (cursor_position > 0) {
1.433 + memmove(&result[cursor_position-1],
1.434 + &result[cursor_position],
1.435 + len-cursor_position+1);
1.436 + cursor_position--;
1.437 + }
1.438 + break;
1.439 + case KEY_DC:
1.440 + if (cursor_position >= 0 && cursor_position < len) {
1.441 + memmove(&result[cursor_position],
1.442 + &result[cursor_position+1],
1.443 + len-cursor_position+1);
1.444 + }
1.445 + break;
1.446 + case KEY_UP:
1.447 + case KEY_RIGHT:
1.448 + if (cursor_position < len &&
1.449 + cursor_position < min(result_len, prompt_width))
1.450 + cursor_position++;
1.451 + break;
1.452 + case KEY_DOWN:
1.453 + case KEY_LEFT:
1.454 + if (cursor_position > 0)
1.455 + cursor_position--;
1.456 + break;
1.457 + default:
1.458 + if ((isgraph(res) || isspace(res)) &&
1.459 + len-2 < result_len) {
1.460 + /* insert the char at the proper position */
1.461 + memmove(&result[cursor_position+1],
1.462 + &result[cursor_position],
1.463 + len+1);
1.464 + result[cursor_position] = res;
1.465 + cursor_position++;
1.466 + } else {
1.467 + mvprintw(0, 0, "unknow key: %d\n", res);
1.468 + }
1.469 + break;
1.470 + }
1.471 + wmove(form_win, 0, 0);
1.472 + wclrtoeol(form_win);
1.473 + mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
1.474 + mvwprintw(form_win, 0, 0, "%s", result);
1.475 + wmove(form_win, 0, cursor_position);
1.476 + touchwin(win);
1.477 + refresh_all_windows(main_window);
1.478 +
1.479 + if (res == 10) {
1.480 + res = 0;
1.481 + break;
1.482 + } else if (res == 27 || res == KEY_F(F_BACK) ||
1.483 + res == KEY_F(F_EXIT)) {
1.484 + res = KEY_EXIT;
1.485 + break;
1.486 + } else if (res == KEY_F(F_HELP)) {
1.487 + res = 1;
1.488 + break;
1.489 + }
1.490 + }
1.491 +
1.492 + /* hide the cursor */
1.493 + curs_set(0);
1.494 + del_panel(panel);
1.495 + delwin(prompt_win);
1.496 + delwin(form_win);
1.497 + delwin(win);
1.498 + return res;
1.499 +}
1.500 +
1.501 +/* refresh all windows in the correct order */
1.502 +void refresh_all_windows(WINDOW *main_window)
1.503 +{
1.504 + update_panels();
1.505 + touchwin(main_window);
1.506 + refresh();
1.507 +}
1.508 +
1.509 +/* layman's scrollable window... */
1.510 +void show_scroll_win(WINDOW *main_window,
1.511 + const char *title,
1.512 + const char *text)
1.513 +{
1.514 + int res;
1.515 + int total_lines = get_line_no(text);
1.516 + int x, y;
1.517 + int start_x = 0, start_y = 0;
1.518 + int text_lines = 0, text_cols = 0;
1.519 + int total_cols = 0;
1.520 + int win_cols = 0;
1.521 + int win_lines = 0;
1.522 + int i = 0;
1.523 + WINDOW *win;
1.524 + WINDOW *pad;
1.525 + PANEL *panel;
1.526 +
1.527 + /* find the widest line of msg: */
1.528 + total_lines = get_line_no(text);
1.529 + for (i = 0; i < total_lines; i++) {
1.530 + const char *line = get_line(text, i);
1.531 + int len = get_line_length(line);
1.532 + total_cols = max(total_cols, len+2);
1.533 + }
1.534 +
1.535 + /* create the pad */
1.536 + pad = newpad(total_lines+10, total_cols+10);
1.537 + (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
1.538 + fill_window(pad, text);
1.539 +
1.540 + win_lines = min(total_lines+4, LINES-2);
1.541 + win_cols = min(total_cols+2, COLS-2);
1.542 + text_lines = max(win_lines-4, 0);
1.543 + text_cols = max(win_cols-2, 0);
1.544 +
1.545 + /* place window in middle of screen */
1.546 + y = (LINES-win_lines)/2;
1.547 + x = (COLS-win_cols)/2;
1.548 +
1.549 + win = newwin(win_lines, win_cols, y, x);
1.550 + keypad(win, TRUE);
1.551 + /* show the help in the help window, and show the help panel */
1.552 + (void) wattrset(win, attributes[SCROLLWIN_BOX]);
1.553 + box(win, 0, 0);
1.554 + (void) wattrset(win, attributes[SCROLLWIN_HEADING]);
1.555 + mvwprintw(win, 0, 3, " %s ", title);
1.556 + panel = new_panel(win);
1.557 +
1.558 + /* handle scrolling */
1.559 + do {
1.560 +
1.561 + copywin(pad, win, start_y, start_x, 2, 2, text_lines,
1.562 + text_cols, 0);
1.563 + print_in_middle(win,
1.564 + text_lines+2,
1.565 + 0,
1.566 + text_cols,
1.567 + "<OK>",
1.568 + attributes[DIALOG_MENU_FORE]);
1.569 + wrefresh(win);
1.570 +
1.571 + res = wgetch(win);
1.572 + switch (res) {
1.573 + case KEY_NPAGE:
1.574 + case ' ':
1.575 + start_y += text_lines-2;
1.576 + break;
1.577 + case KEY_PPAGE:
1.578 + start_y -= text_lines+2;
1.579 + break;
1.580 + case KEY_HOME:
1.581 + start_y = 0;
1.582 + break;
1.583 + case KEY_END:
1.584 + start_y = total_lines-text_lines;
1.585 + break;
1.586 + case KEY_DOWN:
1.587 + case 'j':
1.588 + start_y++;
1.589 + break;
1.590 + case KEY_UP:
1.591 + case 'k':
1.592 + start_y--;
1.593 + break;
1.594 + case KEY_LEFT:
1.595 + case 'h':
1.596 + start_x--;
1.597 + break;
1.598 + case KEY_RIGHT:
1.599 + case 'l':
1.600 + start_x++;
1.601 + break;
1.602 + }
1.603 + if (res == 10 || res == 27 || res == 'q'
1.604 + || res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) {
1.605 + break;
1.606 + }
1.607 + if (start_y < 0)
1.608 + start_y = 0;
1.609 + if (start_y >= total_lines-text_lines)
1.610 + start_y = total_lines-text_lines;
1.611 + if (start_x < 0)
1.612 + start_x = 0;
1.613 + if (start_x >= total_cols-text_cols)
1.614 + start_x = total_cols-text_cols;
1.615 + } while (res);
1.616 +
1.617 + del_panel(panel);
1.618 + delwin(win);
1.619 + refresh_all_windows(main_window);
1.620 +}