diff --git a/src/ChangeLog b/src/ChangeLog index 6d92c564d..52914d4bd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2002-09-23 Pavel Roskin + * dlg.h: New message DLG_RESIZE. + * layout.c: Call DLG_RESIZE instead of resizing viewer and + editor individually. + * view.c (view): Install handler for DLG_RESIZE. Make view_dlg + a local variable. + * view.c (view): Set view_dlg to NULL after it's destroyed. * color.h: Remove EDITOR_UNDERLINED_COLOR, it's unused. diff --git a/src/dlg.h b/src/dlg.h index c0cc9a8d5..f7ff95a0e 100644 --- a/src/dlg.h +++ b/src/dlg.h @@ -52,6 +52,7 @@ enum { DLG_DRAW, /* Sent for updating dialog managed area */ DLG_FOCUS, /* Sent on give focus to a widget */ DLG_UNFOCUS, /* Sent on remove focus from widget */ + DLG_RESIZE, /* Sent when the window size changes */ DLG_ONE_UP, /* Sent on selecting next */ DLG_ONE_DOWN, /* Sent on selecting prev */ DLG_POST_KEY, /* Sent after key has been sent */ diff --git a/src/layout.c b/src/layout.c index b4cd0f14a..832e59b92 100644 --- a/src/layout.c +++ b/src/layout.c @@ -723,8 +723,6 @@ void flag_winch (int dummy) winch_flag = 1; } -void edit_adjust_size (Dlg_head * h); - static void low_level_change_screen_size (void) { @@ -751,11 +749,12 @@ low_level_change_screen_size (void) #endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ } -void change_screen_size (void) +void +change_screen_size (void) { #if defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 #if defined TIOCGWINSZ && !defined SCO_FLAVOR - + #ifndef NCURSES_VERSION mc_noraw_mode (); endwin (); @@ -772,22 +771,20 @@ void change_screen_size (void) init_curses (); #endif setup_panels (); - if (current_dlg == view_dlg) - view_adjust_size (view_dlg); -#ifdef USE_INTERNAL_EDIT - if (current_dlg == edit_dlg) - edit_adjust_size (edit_dlg); -#endif - + + /* Inform currently running dialog */ + (*current_dlg->callback) (current_dlg, current_dlg->current->dlg_id, + DLG_RESIZE); + #ifdef RESIZABLE_MENUBAR - menubar_arrange(the_menubar); + menubar_arrange (the_menubar); #endif - + /* Now, force the redraw */ do_refresh (); touchwin (stdscr); -#endif /* TIOCGWINSZ && !SCO_FLAVOR */ -#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ +#endif /* TIOCGWINSZ && !SCO_FLAVOR */ +#endif /* defined(HAVE_SLANG) || NCURSES_VERSION_MAJOR >= 4 */ winch_flag = 0; } diff --git a/src/view.c b/src/view.c index 03188efcb..070ec9bc0 100644 --- a/src/view.c +++ b/src/view.c @@ -2398,8 +2398,17 @@ view_adjust_size (Dlg_head *h) view_update_bytes_per_line(view); } -/* Only the text mode edition uses this */ -Dlg_head *view_dlg; +/* Callback for the view dialog */ +static int +view_dialog_callback (Dlg_head * h, int id, int msg) +{ + switch (msg) { + case DLG_RESIZE: + view_adjust_size (h); + return MSG_HANDLED; + } + return default_dlg_callback (h, id, msg); +} /* Real view only */ int @@ -2408,20 +2417,19 @@ view (char *_command, const char *_file, int *move_dir_p, int start_line) int error; WView *wview; WButtonBar *bar; - Dlg_head *our_dlg; + Dlg_head *view_dlg; /* Create dialog and widgets, put them on the dialog */ - our_dlg = - create_dlg (0, 0, LINES, COLS, NULL, NULL, + view_dlg = + create_dlg (0, 0, LINES, COLS, NULL, view_dialog_callback, "[Internal File Viewer]", NULL, DLG_NONE); - view_dlg = our_dlg; wview = view_new (0, 0, COLS, LINES - 1, 0); bar = buttonbar_new (1); - add_widget (our_dlg, wview); - add_widget (our_dlg, bar); + add_widget (view_dlg, wview); + add_widget (view_dlg, bar); error = view_init (wview, _command, _file, start_line); if (move_dir_p) @@ -2432,12 +2440,11 @@ view (char *_command, const char *_file, int *move_dir_p, int start_line) * be aware of it */ if (!error) { - run_dlg (our_dlg); + run_dlg (view_dlg); if (move_dir_p) *move_dir_p = wview->move_dir; } - destroy_dlg (our_dlg); - view_dlg = NULL; + destroy_dlg (view_dlg); return !error; }