15382d832SPeter Avalos /*
2*a8e38dc0SAntonio Huete Jimenez * $Id: tailbox.c,v 1.80 2022/04/03 22:38:16 tom Exp $
35382d832SPeter Avalos *
45382d832SPeter Avalos * tailbox.c -- implements the tail box
55382d832SPeter Avalos *
6*a8e38dc0SAntonio Huete Jimenez * Copyright 2000-2020,2022 Thomas E. Dickey
75382d832SPeter Avalos *
85382d832SPeter Avalos * This program is free software; you can redistribute it and/or modify
95382d832SPeter Avalos * it under the terms of the GNU Lesser General Public License, version 2.1
105382d832SPeter Avalos * as published by the Free Software Foundation.
115382d832SPeter Avalos *
125382d832SPeter Avalos * This program is distributed in the hope that it will be useful, but
135382d832SPeter Avalos * WITHOUT ANY WARRANTY; without even the implied warranty of
145382d832SPeter Avalos * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
155382d832SPeter Avalos * Lesser General Public License for more details.
165382d832SPeter Avalos *
175382d832SPeter Avalos * You should have received a copy of the GNU Lesser General Public
185382d832SPeter Avalos * License along with this program; if not, write to
195382d832SPeter Avalos * Free Software Foundation, Inc.
205382d832SPeter Avalos * 51 Franklin St., Fifth Floor
215382d832SPeter Avalos * Boston, MA 02110, USA.
225382d832SPeter Avalos *
235382d832SPeter Avalos * An earlier version of this program lists as authors
245382d832SPeter Avalos * Pasquale De Marco (demarco_p@abramo.it)
255382d832SPeter Avalos */
265382d832SPeter Avalos
27*a8e38dc0SAntonio Huete Jimenez #include <dlg_internals.h>
285382d832SPeter Avalos #include <dlg_keys.h>
295382d832SPeter Avalos
305382d832SPeter Avalos typedef struct {
315382d832SPeter Avalos DIALOG_CALLBACK obj;
325382d832SPeter Avalos WINDOW *text;
335382d832SPeter Avalos const char **buttons;
345382d832SPeter Avalos int hscroll;
355382d832SPeter Avalos int old_hscroll;
365382d832SPeter Avalos char line[MAX_LEN + 2];
375382d832SPeter Avalos off_t last_pos;
385382d832SPeter Avalos } MY_OBJ;
395382d832SPeter Avalos
405382d832SPeter Avalos /*
415382d832SPeter Avalos * Return current line of text.
425382d832SPeter Avalos */
435382d832SPeter Avalos static char *
get_line(MY_OBJ * obj)445382d832SPeter Avalos get_line(MY_OBJ * obj)
455382d832SPeter Avalos {
465382d832SPeter Avalos FILE *fp = obj->obj.input;
475382d832SPeter Avalos int col = -(obj->hscroll);
485382d832SPeter Avalos int j, tmpint, ch;
495382d832SPeter Avalos
505382d832SPeter Avalos do {
515382d832SPeter Avalos if (((ch = getc(fp)) == EOF) && !feof(fp))
525382d832SPeter Avalos dlg_exiterr("Error moving file pointer in get_line().");
535382d832SPeter Avalos else if (!feof(fp) && (ch != '\n')) {
545382d832SPeter Avalos if ((ch == TAB) && (dialog_vars.tab_correct)) {
555382d832SPeter Avalos tmpint = dialog_state.tab_len
565382d832SPeter Avalos - ((col + obj->hscroll) % dialog_state.tab_len);
575382d832SPeter Avalos for (j = 0; j < tmpint; j++) {
585382d832SPeter Avalos if (col >= 0 && col < MAX_LEN)
595382d832SPeter Avalos obj->line[col] = ' ';
605382d832SPeter Avalos ++col;
615382d832SPeter Avalos }
625382d832SPeter Avalos } else {
635382d832SPeter Avalos if (col >= 0)
645382d832SPeter Avalos obj->line[col] = (char) ch;
655382d832SPeter Avalos ++col;
665382d832SPeter Avalos }
675382d832SPeter Avalos if (col >= MAX_LEN)
685382d832SPeter Avalos break;
695382d832SPeter Avalos }
705382d832SPeter Avalos } while (!feof(fp) && (ch != '\n'));
715382d832SPeter Avalos
725382d832SPeter Avalos if (col < 0)
735382d832SPeter Avalos col = 0;
745382d832SPeter Avalos obj->line[col] = '\0';
755382d832SPeter Avalos
765382d832SPeter Avalos return obj->line;
775382d832SPeter Avalos }
785382d832SPeter Avalos
795382d832SPeter Avalos /*
805382d832SPeter Avalos * Print a new line of text.
815382d832SPeter Avalos */
825382d832SPeter Avalos static void
print_line(MY_OBJ * obj,WINDOW * win,int row,int width)835382d832SPeter Avalos print_line(MY_OBJ * obj, WINDOW *win, int row, int width)
845382d832SPeter Avalos {
855382d832SPeter Avalos int i, y, x;
865382d832SPeter Avalos char *line = get_line(obj);
875382d832SPeter Avalos
885382d832SPeter Avalos (void) wmove(win, row, 0); /* move cursor to correct line */
895382d832SPeter Avalos (void) waddch(win, ' ');
905382d832SPeter Avalos (void) waddnstr(win, line, MIN((int) strlen(line), width - 2));
915382d832SPeter Avalos
925382d832SPeter Avalos getyx(win, y, x);
935382d832SPeter Avalos (void) y;
945382d832SPeter Avalos /* Clear 'residue' of previous line */
955382d832SPeter Avalos for (i = 0; i < width - x; i++)
965382d832SPeter Avalos (void) waddch(win, ' ');
975382d832SPeter Avalos }
985382d832SPeter Avalos
995382d832SPeter Avalos /*
1005382d832SPeter Avalos * Go back 'target' lines in text file. BUFSIZ has to be in 'size_t' range.
1015382d832SPeter Avalos */
1025382d832SPeter Avalos static void
last_lines(MY_OBJ * obj,int target)1035382d832SPeter Avalos last_lines(MY_OBJ * obj, int target)
1045382d832SPeter Avalos {
1055382d832SPeter Avalos FILE *fp = obj->obj.input;
1065382d832SPeter Avalos long fpos = 0;
1075382d832SPeter Avalos
1085382d832SPeter Avalos if (fseek(fp, 0L, SEEK_END) == -1
1095382d832SPeter Avalos || (fpos = ftell(fp)) < 0)
1105382d832SPeter Avalos dlg_exiterr("Error moving file pointer in last_lines().");
1115382d832SPeter Avalos
1125382d832SPeter Avalos if (fpos != 0) {
1135940c9abSDaniel Fojt long offset = 0;
1145940c9abSDaniel Fojt
1155382d832SPeter Avalos ++target;
1165382d832SPeter Avalos for (;;) {
1175940c9abSDaniel Fojt size_t inx;
1185940c9abSDaniel Fojt size_t size_to_read;
1195940c9abSDaniel Fojt size_t size_as_read;
1205940c9abSDaniel Fojt int count = 0;
1215940c9abSDaniel Fojt char buf[BUFSIZ + 1];
1225940c9abSDaniel Fojt
1235382d832SPeter Avalos if (fpos >= BUFSIZ) {
1245382d832SPeter Avalos size_to_read = BUFSIZ;
1255382d832SPeter Avalos } else {
1265382d832SPeter Avalos size_to_read = (size_t) fpos;
1275382d832SPeter Avalos }
1285382d832SPeter Avalos fpos = fpos - (long) size_to_read;
1295382d832SPeter Avalos if (fseek(fp, fpos, SEEK_SET) == -1)
1305382d832SPeter Avalos dlg_exiterr("Error moving file pointer in last_lines().");
1315382d832SPeter Avalos size_as_read = fread(buf, sizeof(char), size_to_read, fp);
1325382d832SPeter Avalos if (ferror(fp))
1335382d832SPeter Avalos dlg_exiterr("Error reading file in last_lines().");
1345382d832SPeter Avalos
1355382d832SPeter Avalos if (size_as_read == 0) {
1365382d832SPeter Avalos fpos = 0;
1375382d832SPeter Avalos offset = 0;
1385382d832SPeter Avalos break;
1395382d832SPeter Avalos }
1405382d832SPeter Avalos
1415382d832SPeter Avalos offset += (long) size_as_read;
1425382d832SPeter Avalos for (inx = size_as_read - 1; inx != 0; --inx) {
1435382d832SPeter Avalos if (buf[inx] == '\n') {
1445382d832SPeter Avalos if (++count > target)
1455382d832SPeter Avalos break;
1465382d832SPeter Avalos offset = (long) (inx + 1);
1475382d832SPeter Avalos }
1485382d832SPeter Avalos }
1495382d832SPeter Avalos
1505382d832SPeter Avalos if (count > target) {
1515382d832SPeter Avalos break;
1525382d832SPeter Avalos } else if (fpos == 0) {
1535382d832SPeter Avalos offset = 0;
1545382d832SPeter Avalos break;
1555382d832SPeter Avalos }
1565382d832SPeter Avalos }
1575382d832SPeter Avalos
1585382d832SPeter Avalos if (fseek(fp, fpos + offset, SEEK_SET) == -1)
1595382d832SPeter Avalos dlg_exiterr("Error moving file pointer in last_lines().");
1605382d832SPeter Avalos }
1615382d832SPeter Avalos }
1625382d832SPeter Avalos
1635382d832SPeter Avalos /*
1645382d832SPeter Avalos * Print a new page of text.
1655382d832SPeter Avalos */
1665382d832SPeter Avalos static void
print_page(MY_OBJ * obj,int height,int width)1675382d832SPeter Avalos print_page(MY_OBJ * obj, int height, int width)
1685382d832SPeter Avalos {
1695382d832SPeter Avalos int i;
1705382d832SPeter Avalos
1715382d832SPeter Avalos for (i = 0; i < height; i++) {
1725382d832SPeter Avalos print_line(obj, obj->text, i, width);
1735382d832SPeter Avalos }
1745382d832SPeter Avalos (void) wnoutrefresh(obj->text);
1755382d832SPeter Avalos }
1765382d832SPeter Avalos
1775382d832SPeter Avalos static void
print_last_page(MY_OBJ * obj)1785382d832SPeter Avalos print_last_page(MY_OBJ * obj)
1795382d832SPeter Avalos {
1805382d832SPeter Avalos int high = getmaxy(obj->obj.win) - (2 * MARGIN + (obj->obj.bg_task ? 1 : 3));
1815382d832SPeter Avalos int wide = getmaxx(obj->text);
1825382d832SPeter Avalos
1835382d832SPeter Avalos last_lines(obj, high);
1845382d832SPeter Avalos print_page(obj, high, wide);
1855382d832SPeter Avalos }
1865382d832SPeter Avalos
1875382d832SPeter Avalos static void
repaint_text(MY_OBJ * obj)1885382d832SPeter Avalos repaint_text(MY_OBJ * obj)
1895382d832SPeter Avalos {
1905382d832SPeter Avalos FILE *fp = obj->obj.input;
1915382d832SPeter Avalos int cur_y, cur_x;
1925382d832SPeter Avalos
1935382d832SPeter Avalos getyx(obj->obj.win, cur_y, cur_x);
1945382d832SPeter Avalos obj->old_hscroll = obj->hscroll;
1955382d832SPeter Avalos
1965382d832SPeter Avalos print_last_page(obj);
1975382d832SPeter Avalos obj->last_pos = ftell(fp);
1985382d832SPeter Avalos
1995382d832SPeter Avalos (void) wmove(obj->obj.win, cur_y, cur_x); /* Restore cursor position */
2005382d832SPeter Avalos wrefresh(obj->obj.win);
2015382d832SPeter Avalos }
2025382d832SPeter Avalos
2035382d832SPeter Avalos static bool
handle_input(DIALOG_CALLBACK * cb)2045382d832SPeter Avalos handle_input(DIALOG_CALLBACK * cb)
2055382d832SPeter Avalos {
2065382d832SPeter Avalos MY_OBJ *obj = (MY_OBJ *) cb;
2075382d832SPeter Avalos FILE *fp = obj->obj.input;
2085382d832SPeter Avalos struct stat sb;
2095382d832SPeter Avalos
2105382d832SPeter Avalos if (fstat(fileno(fp), &sb) == 0
2115382d832SPeter Avalos && sb.st_size != obj->last_pos) {
2125382d832SPeter Avalos repaint_text(obj);
2135382d832SPeter Avalos }
2145382d832SPeter Avalos
2155382d832SPeter Avalos return TRUE;
2165382d832SPeter Avalos }
2175382d832SPeter Avalos
2185382d832SPeter Avalos static bool
valid_callback(DIALOG_CALLBACK * cb)2195940c9abSDaniel Fojt valid_callback(DIALOG_CALLBACK * cb)
2205940c9abSDaniel Fojt {
2215940c9abSDaniel Fojt bool valid = FALSE;
2225940c9abSDaniel Fojt DIALOG_CALLBACK *p;
2235940c9abSDaniel Fojt for (p = dialog_state.getc_callbacks; p != 0; p = p->next) {
2245940c9abSDaniel Fojt if (p == cb) {
2255940c9abSDaniel Fojt valid = TRUE;
2265940c9abSDaniel Fojt break;
2275940c9abSDaniel Fojt }
2285940c9abSDaniel Fojt }
2295940c9abSDaniel Fojt return valid;
2305940c9abSDaniel Fojt }
2315940c9abSDaniel Fojt
2325940c9abSDaniel Fojt static bool
handle_my_getc(DIALOG_CALLBACK * cb,int ch,int fkey,int * result)2335382d832SPeter Avalos handle_my_getc(DIALOG_CALLBACK * cb, int ch, int fkey, int *result)
2345382d832SPeter Avalos {
2355382d832SPeter Avalos MY_OBJ *obj = (MY_OBJ *) cb;
2365382d832SPeter Avalos bool done = FALSE;
2375382d832SPeter Avalos
2385940c9abSDaniel Fojt if (!valid_callback(cb))
2395940c9abSDaniel Fojt return FALSE;
2405940c9abSDaniel Fojt
2415382d832SPeter Avalos if (!fkey && dlg_char_to_button(ch, obj->buttons) == 0) {
2425382d832SPeter Avalos ch = DLGK_ENTER;
2435382d832SPeter Avalos fkey = TRUE;
2445382d832SPeter Avalos }
2455382d832SPeter Avalos
2465382d832SPeter Avalos if (fkey) {
2475382d832SPeter Avalos switch (ch) {
2485382d832SPeter Avalos case DLGK_ENTER:
2495382d832SPeter Avalos *result = DLG_EXIT_OK;
2505382d832SPeter Avalos done = TRUE;
2515382d832SPeter Avalos break;
2525382d832SPeter Avalos case DLGK_BEGIN: /* Beginning of line */
2535382d832SPeter Avalos obj->hscroll = 0;
2545382d832SPeter Avalos break;
2555382d832SPeter Avalos case DLGK_GRID_LEFT: /* Scroll left */
2565382d832SPeter Avalos if (obj->hscroll > 0) {
2575382d832SPeter Avalos obj->hscroll -= 1;
2585382d832SPeter Avalos }
2595382d832SPeter Avalos break;
2605382d832SPeter Avalos case DLGK_GRID_RIGHT: /* Scroll right */
2615382d832SPeter Avalos if (obj->hscroll < MAX_LEN)
2625382d832SPeter Avalos obj->hscroll += 1;
2635382d832SPeter Avalos break;
2645382d832SPeter Avalos default:
2655940c9abSDaniel Fojt if (is_DLGK_MOUSE(ch)) {
2665940c9abSDaniel Fojt *result = dlg_ok_buttoncode(ch - M_EVENT);
2675940c9abSDaniel Fojt if (*result != DLG_EXIT_ERROR) {
2685940c9abSDaniel Fojt done = TRUE;
2695940c9abSDaniel Fojt } else {
2705382d832SPeter Avalos beep();
2715940c9abSDaniel Fojt }
2725940c9abSDaniel Fojt } else {
2735940c9abSDaniel Fojt beep();
2745940c9abSDaniel Fojt }
2755382d832SPeter Avalos break;
2765382d832SPeter Avalos }
2775382d832SPeter Avalos if ((obj->hscroll != obj->old_hscroll))
2785382d832SPeter Avalos repaint_text(obj);
2795382d832SPeter Avalos } else {
2805382d832SPeter Avalos switch (ch) {
2815382d832SPeter Avalos case ERR:
2825382d832SPeter Avalos clearerr(cb->input);
2835382d832SPeter Avalos ch = getc(cb->input);
2845382d832SPeter Avalos (void) ungetc(ch, cb->input);
2855382d832SPeter Avalos if (ch != EOF) {
2865382d832SPeter Avalos handle_input(cb);
2875382d832SPeter Avalos }
2885382d832SPeter Avalos break;
2895382d832SPeter Avalos case ESC:
2905382d832SPeter Avalos done = TRUE;
2915382d832SPeter Avalos *result = DLG_EXIT_ESC;
2925382d832SPeter Avalos break;
2935382d832SPeter Avalos default:
2945382d832SPeter Avalos beep();
2955382d832SPeter Avalos break;
2965382d832SPeter Avalos }
2975382d832SPeter Avalos }
2985382d832SPeter Avalos
2995382d832SPeter Avalos return !done;
3005382d832SPeter Avalos }
3015382d832SPeter Avalos
3025382d832SPeter Avalos /*
3035382d832SPeter Avalos * Display text from a file in a dialog box, like in a "tail -f".
3045382d832SPeter Avalos */
3055382d832SPeter Avalos int
dialog_tailbox(const char * title,const char * filename,int height,int width,int bg_task)3065940c9abSDaniel Fojt dialog_tailbox(const char *title,
3075940c9abSDaniel Fojt const char *filename,
3085940c9abSDaniel Fojt int height,
3095940c9abSDaniel Fojt int width,
3105940c9abSDaniel Fojt int bg_task)
3115382d832SPeter Avalos {
3125382d832SPeter Avalos /* *INDENT-OFF* */
3135382d832SPeter Avalos static DLG_KEYS_BINDING binding[] = {
3145382d832SPeter Avalos HELPKEY_BINDINGS,
3155382d832SPeter Avalos ENTERKEY_BINDINGS,
3165382d832SPeter Avalos DLG_KEYS_DATA( DLGK_BEGIN, '0' ),
3175382d832SPeter Avalos DLG_KEYS_DATA( DLGK_BEGIN, KEY_BEG ),
3185382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_LEFT, 'H' ),
3195382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_LEFT, 'h' ),
3205382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_LEFT, KEY_LEFT ),
3215382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_RIGHT, 'L' ),
3225382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_RIGHT, 'l' ),
3235382d832SPeter Avalos DLG_KEYS_DATA( DLGK_GRID_RIGHT, KEY_RIGHT ),
3245382d832SPeter Avalos END_KEYS_BINDING
3255382d832SPeter Avalos };
3265382d832SPeter Avalos /* *INDENT-ON* */
3275382d832SPeter Avalos
3285382d832SPeter Avalos #ifdef KEY_RESIZE
3295382d832SPeter Avalos int old_height = height;
3305382d832SPeter Avalos int old_width = width;
3315382d832SPeter Avalos #endif
3325382d832SPeter Avalos int fkey;
333*a8e38dc0SAntonio Huete Jimenez int x, y, result = DLG_EXIT_UNKNOWN, thigh;
3345382d832SPeter Avalos WINDOW *dialog, *text;
3355382d832SPeter Avalos const char **buttons = 0;
3365382d832SPeter Avalos MY_OBJ *obj;
3375382d832SPeter Avalos FILE *fd;
3385382d832SPeter Avalos int min_width = 12;
3395382d832SPeter Avalos
3405940c9abSDaniel Fojt DLG_TRACE(("# tailbox args:\n"));
3415940c9abSDaniel Fojt DLG_TRACE2S("title", title);
3425940c9abSDaniel Fojt DLG_TRACE2S("filename", filename);
3435940c9abSDaniel Fojt DLG_TRACE2N("height", height);
3445940c9abSDaniel Fojt DLG_TRACE2N("width", width);
3455940c9abSDaniel Fojt DLG_TRACE2N("bg_task", bg_task);
3465940c9abSDaniel Fojt
3475382d832SPeter Avalos /* Open input file for reading */
3485940c9abSDaniel Fojt if ((fd = fopen(filename, "rb")) == NULL)
3495382d832SPeter Avalos dlg_exiterr("Can't open input file in dialog_tailbox().");
3505382d832SPeter Avalos
3515382d832SPeter Avalos #ifdef KEY_RESIZE
3525382d832SPeter Avalos retry:
3535382d832SPeter Avalos #endif
3545940c9abSDaniel Fojt dlg_auto_sizefile(title, filename, &height, &width, 2, min_width);
3555382d832SPeter Avalos dlg_print_size(height, width);
3565382d832SPeter Avalos dlg_ctl_size(height, width);
3575382d832SPeter Avalos
3585382d832SPeter Avalos x = dlg_box_x_ordinate(width);
3595382d832SPeter Avalos y = dlg_box_y_ordinate(height);
3605382d832SPeter Avalos thigh = height - ((2 * MARGIN) + (bg_task ? 0 : 2));
3615382d832SPeter Avalos
3625382d832SPeter Avalos dialog = dlg_new_window(height, width, y, x);
3635382d832SPeter Avalos
3645382d832SPeter Avalos dlg_mouse_setbase(x, y);
3655382d832SPeter Avalos
3665382d832SPeter Avalos /* Create window for text region, used for scrolling text */
3675382d832SPeter Avalos text = dlg_sub_window(dialog,
3685382d832SPeter Avalos thigh,
3695382d832SPeter Avalos width - (2 * MARGIN),
3705382d832SPeter Avalos y + MARGIN,
3715382d832SPeter Avalos x + MARGIN);
3725382d832SPeter Avalos
3735382d832SPeter Avalos dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
3745382d832SPeter Avalos dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
3755382d832SPeter Avalos dlg_draw_title(dialog, title);
3765382d832SPeter Avalos dlg_draw_helpline(dialog, FALSE);
3775382d832SPeter Avalos
3785382d832SPeter Avalos if (!bg_task) {
3795382d832SPeter Avalos buttons = dlg_exit_label();
3805382d832SPeter Avalos dlg_button_layout(buttons, &min_width);
3815382d832SPeter Avalos dlg_draw_buttons(dialog, height - (2 * MARGIN), 0, buttons, FALSE,
3825382d832SPeter Avalos FALSE, width);
3835382d832SPeter Avalos }
3845382d832SPeter Avalos
3855382d832SPeter Avalos (void) wmove(dialog, thigh, (MARGIN + 1));
3865382d832SPeter Avalos (void) wnoutrefresh(dialog);
3875382d832SPeter Avalos
3885382d832SPeter Avalos obj = dlg_calloc(MY_OBJ, 1);
3895382d832SPeter Avalos assert_ptr(obj, "dialog_tailbox");
3905382d832SPeter Avalos
3915382d832SPeter Avalos obj->obj.input = fd;
3925382d832SPeter Avalos obj->obj.win = dialog;
3935382d832SPeter Avalos obj->obj.handle_getc = handle_my_getc;
3945382d832SPeter Avalos obj->obj.handle_input = bg_task ? handle_input : 0;
3955382d832SPeter Avalos obj->obj.keep_bg = bg_task && dialog_vars.cant_kill;
3965940c9abSDaniel Fojt obj->obj.bg_task = (bool) bg_task;
3975382d832SPeter Avalos obj->text = text;
3985382d832SPeter Avalos obj->buttons = buttons;
3995382d832SPeter Avalos dlg_add_callback(&(obj->obj));
4005382d832SPeter Avalos
4015382d832SPeter Avalos dlg_register_window(dialog, "tailbox", binding);
4025382d832SPeter Avalos dlg_register_buttons(dialog, "tailbox", buttons);
4035382d832SPeter Avalos
4045382d832SPeter Avalos /* Print last page of text */
4055382d832SPeter Avalos dlg_attr_clear(text, thigh, getmaxx(text), dialog_attr);
4065382d832SPeter Avalos repaint_text(obj);
4075382d832SPeter Avalos
4085382d832SPeter Avalos dlg_trace_win(dialog);
4095382d832SPeter Avalos if (bg_task) {
4105382d832SPeter Avalos result = DLG_EXIT_OK;
4115382d832SPeter Avalos } else {
4125382d832SPeter Avalos int ch;
4135382d832SPeter Avalos do {
4145940c9abSDaniel Fojt ch = dlg_mouse_wgetch(dialog, &fkey);
4155382d832SPeter Avalos #ifdef KEY_RESIZE
4165382d832SPeter Avalos if (fkey && ch == KEY_RESIZE) {
4175940c9abSDaniel Fojt dlg_will_resize(dialog);
4185382d832SPeter Avalos /* reset data */
4195382d832SPeter Avalos height = old_height;
4205382d832SPeter Avalos width = old_width;
4215382d832SPeter Avalos /* repaint */
4225940c9abSDaniel Fojt _dlg_resize_cleanup(dialog);
4235382d832SPeter Avalos dlg_button_layout(buttons, &min_width);
4245382d832SPeter Avalos goto retry;
4255382d832SPeter Avalos }
4265382d832SPeter Avalos #endif
4275382d832SPeter Avalos }
4285382d832SPeter Avalos while (handle_my_getc(&(obj->obj), ch, fkey, &result));
4295382d832SPeter Avalos }
4305382d832SPeter Avalos dlg_mouse_free_regions();
4315382d832SPeter Avalos return result;
4325382d832SPeter Avalos }
433