diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2012-12-30 04:22:34 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2012-12-30 04:22:34 +0000 |
commit | 52bf5abd924bc78494905f16ffbd4bd67062240c (patch) | |
tree | 6d48accafd38ffd900622df8c9eab499d302c36f /contrib/dialog/editbox.c | |
parent | 7e3a527820c0248a0703bbf8809aabef78a41db6 (diff) | |
download | FreeBSD-src-52bf5abd924bc78494905f16ffbd4bd67062240c.zip FreeBSD-src-52bf5abd924bc78494905f16ffbd4bd67062240c.tar.gz |
Revert r241818 that updated dialog to 20120706. This turns out to horribly
break mixed form dialogs in conjunction with the FreeBSD termcap, making
the bsdinstall partition editor Add dialog, among other things, completely
nonfunctional. This restores dialog 20110707.
Diffstat (limited to 'contrib/dialog/editbox.c')
-rw-r--r-- | contrib/dialog/editbox.c | 103 |
1 files changed, 47 insertions, 56 deletions
diff --git a/contrib/dialog/editbox.c b/contrib/dialog/editbox.c index 7488d65..c7da10c 100644 --- a/contrib/dialog/editbox.c +++ b/contrib/dialog/editbox.c @@ -1,9 +1,9 @@ /* - * $Id: editbox.c,v 1.61 2012/07/01 18:13:32 Zoltan.Kelemen Exp $ + * $Id: editbox.c,v 1.55 2011/06/21 00:10:46 tom Exp $ * * editbox.c -- implements the edit box * - * Copyright 2007-2011,2012 Thomas E. Dickey + * Copyright 2007-2010,2011 Thomas E. Dickey * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License, version 2.1 @@ -43,10 +43,9 @@ grow_list(char ***list, int *have, int want) (*list) = dlg_realloc(char *, need, *list); if ((*list) == 0) { fail_list(); - } else { - while (++last < need) { - (*list)[last] = 0; - } + } + while (++last < need) { + (*list)[last] = 0; } } } @@ -69,47 +68,45 @@ load_list(const char *file, char ***list, int *rows) dlg_exiterr("Not a file: %s", file); size = (size_t) sb.st_size; - if ((blob = dlg_malloc(char, size + 1)) == 0) { - fail_list(); - } else { - blob[size] = '\0'; - - if ((fp = fopen(file, "r")) == 0) - dlg_exiterr("Cannot open: %s", file); - size = fread(blob, sizeof(char), size, fp); - fclose(fp); - - for (pass = 0; pass < 2; ++pass) { - int first = TRUE; - need = 0; - for (n = 0; n < size; ++n) { - if (first && pass) { - (*list)[need] = blob + n; - first = FALSE; - } - if (blob[n] == '\n') { - first = TRUE; - ++need; - if (pass) - blob[n] = '\0'; - } + if ((blob = dlg_malloc(char, size + 1)) == 0) + fail_list(); + blob[size] = '\0'; + + if ((fp = fopen(file, "r")) == 0) + dlg_exiterr("Cannot open: %s", file); + size = fread(blob, sizeof(char), size, fp); + fclose(fp); + + for (pass = 0; pass < 2; ++pass) { + int first = TRUE; + need = 0; + for (n = 0; n < size; ++n) { + if (first && pass) { + (*list)[need] = blob + n; + first = FALSE; } - if (pass) { - if (need == 0) { - (*list)[0] = dlg_strclone(""); - (*list)[1] = 0; - } else { - for (n = 0; n < need; ++n) { - (*list)[n] = dlg_strclone((*list)[n]); - } - (*list)[need] = 0; - } + if (blob[n] == '\n') { + first = TRUE; + ++need; + if (pass) + blob[n] = '\0'; + } + } + if (pass) { + if (need == 0) { + (*list)[0] = dlg_strclone(""); + (*list)[1] = 0; } else { - grow_list(list, rows, (int) need + 1); + for (n = 0; n < need; ++n) { + (*list)[n] = dlg_strclone((*list)[n]); + } + (*list)[need] = 0; } + } else { + grow_list(list, rows, (int) need + 1); } - free(blob); } + free(blob); } static void @@ -347,7 +344,6 @@ dlg_editbox(const char *title, size_t max_len = (size_t) dlg_max_input(widest_line(*list)); char *input, *buffer; bool show_all, show_one, was_mouse; - bool first_trace = TRUE; WINDOW *dialog; WINDOW *editing; DIALOG_VARS save_vars; @@ -368,8 +364,8 @@ dlg_editbox(const char *title, retry: #endif show_buttons = TRUE; - state = dialog_vars.default_button >= 0 ? dlg_default_button() : sTEXT; - fkey = 0; + state = dialog_vars.defaultno ? dlg_defaultno_button() : sTEXT; + key = fkey = 0; dlg_button_layout(buttons, &mincols); dlg_auto_size(title, "", &height, &width, 3 * LINES / 4, mincols); @@ -385,11 +381,11 @@ dlg_editbox(const char *title, dlg_mouse_setbase(x, y); - dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr); - dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr); + dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + dlg_draw_bottom_box(dialog); dlg_draw_title(dialog, title); - (void) wattrset(dialog, dialog_attr); + wattrset(dialog, dialog_attr); /* Draw the editing field in a box */ box_y = MARGIN + 0; @@ -402,7 +398,7 @@ dlg_editbox(const char *title, box_x, box_height, box_width, - border_attr, border2_attr); + border_attr, dialog_attr); dlg_mouse_mkbigregion(box_y + MARGIN, box_x + MARGIN, box_height - (2 * MARGIN), @@ -413,7 +409,7 @@ dlg_editbox(const char *title, box_width - (2 * MARGIN), getbegy(dialog) + box_y + 1, getbegx(dialog) + box_x + 1); - dlg_register_window(editing, "editbox2", binding2); + dlg_register_window(editing, "editbox", binding2); show_all = TRUE; show_one = FALSE; @@ -448,7 +444,7 @@ dlg_editbox(const char *title, box_x + getmaxx(editing), box_y + 0, box_y + getmaxy(editing) + 1, - border2_attr, + dialog_attr, border_attr); wmove(editing, y, x); show_one = FALSE; @@ -480,11 +476,6 @@ dlg_editbox(const char *title, } } - if (first_trace) { - first_trace = FALSE; - dlg_trace_win(dialog); - } - key = dlg_mouse_wgetch((state == sTEXT) ? editing : dialog, &fkey); if (key == ERR) { result = DLG_EXIT_ERROR; |