diff --git a/edit/editcmd.c b/edit/editcmd.c index 8bead4890..7ada3c911 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -526,16 +526,17 @@ edit_save_as_cmd (WEdit *edit) /* {{{ Macro stuff starts here */ -static int -raw_callback (struct Dlg_head *h, int key, int Msg) +static cb_ret_t +raw_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_KEY: h->running = 0; - h->ret_value = key; + h->ret_value = parm; return MSG_HANDLED; + default: + return default_dlg_callback (h, msg, parm); } - return default_dlg_callback (h, key, Msg);; } /* gets a raw key from the keyboard. Passing cancel = 1 draws diff --git a/edit/editwidget.c b/edit/editwidget.c index f8053818e..ebac42410 100644 --- a/edit/editwidget.c +++ b/edit/editwidget.c @@ -140,8 +140,8 @@ edit_adjust_size (Dlg_head *h) } /* Callback for the edit dialog */ -static int -edit_dialog_callback (Dlg_head *h, int id, int msg) +static cb_ret_t +edit_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm) { WEdit *edit; @@ -149,13 +149,17 @@ edit_dialog_callback (Dlg_head *h, int id, int msg) case DLG_RESIZE: edit_adjust_size (h); return MSG_HANDLED; + case DLG_VALIDATE: edit = (WEdit *) find_widget_type (h, edit_callback); if (!edit_ok_to_exit (edit)) { h->running = 1; } + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return default_dlg_callback (h, id, msg); } int diff --git a/src/ChangeLog b/src/ChangeLog index e64452b9b..891775b0b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2003-09-07 Pavel Roskin + * dlg.h: Use new types for dialog callbacks. + (dlg_cb_fn): Swap msg and parm arguments for consistency with + widget callbacks. Adjust all dependencies. + * dlg.h: Remove WIDGET_USER. Define new types dlg_msg_t, widget_msg_t and cb_ret_t. diff --git a/src/achown.c b/src/achown.c index ef66bd541..9d6a094d6 100644 --- a/src/achown.c +++ b/src/achown.c @@ -110,24 +110,24 @@ static int inc_flag_pos (int f_pos) { if (flag_pos == 10) { flag_pos = 0; - return 0; + return MSG_NOT_HANDLED; } flag_pos++; if (!(flag_pos % 3) || f_pos > 2) - return 0; - return 1; + return MSG_NOT_HANDLED; + return MSG_HANDLED; } -static int dec_flag_pos (int f_pos) +static cb_ret_t dec_flag_pos (int f_pos) { if (!flag_pos) { flag_pos = 10; - return 0; + return MSG_NOT_HANDLED; } flag_pos--; if (!((flag_pos + 1) % 3) || f_pos > 2) - return 0; - return 1; + return MSG_NOT_HANDLED; + return MSG_HANDLED; } static void set_perm_by_flags (char *s, int f_p) @@ -217,22 +217,21 @@ static void update_mode (Dlg_head * h) send_message (h->current->widget, WIDGET_FOCUS, 0); } -static int chl_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +chl_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { - case DLG_DRAW: - common_dialog_repaint (h); - break; - + switch (msg) { case DLG_KEY: - switch (Par) { + switch (parm) { case KEY_LEFT: case KEY_RIGHT: - h->ret_value = Par; + h->ret_value = parm; dlg_stop (h); } + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void @@ -388,20 +387,21 @@ static void b_setpos (int f_pos) { b_att[f_pos]->hotpos = (flag_pos % 3); } -static int advanced_chown_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +advanced_chown_callback (Dlg_head *h, dlg_msg_t msg, int parm) { int i = 0, f_pos = BUTTONS - h->current->dlg_id - single_set - 1; - switch (Msg) { + switch (msg) { case DLG_DRAW: chown_refresh (); chown_info_update (); - return 1; - + return MSG_HANDLED; + case DLG_POST_KEY: if (f_pos < 3) - b_setpos (f_pos); - break; + b_setpos (f_pos); + return MSG_HANDLED; case DLG_FOCUS: if (f_pos < 3) { @@ -410,78 +410,81 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg) b_setpos (f_pos); } else if (f_pos < 5) flag_pos = f_pos + 6; - break; + return MSG_HANDLED; case DLG_KEY: - switch (Par) { - - case XCTRL('b'): + switch (parm) { + + case XCTRL ('b'): case KEY_LEFT: if (f_pos < 5) return (dec_flag_pos (f_pos)); break; - - case XCTRL('f'): + + case XCTRL ('f'): case KEY_RIGHT: if (f_pos < 5) return (inc_flag_pos (f_pos)); break; - + case ' ': if (f_pos < 3) - return 1; + return MSG_HANDLED; break; - + case '\n': case KEY_ENTER: if (f_pos <= 2 || f_pos >= 5) break; do_enter_key (h, f_pos); - return 1; - + return MSG_HANDLED; + case ALT ('x'): i++; - + case ALT ('w'): i++; - + case ALT ('r'): - Par = i + 3; + parm = i + 3; for (i = 0; i < 3; i++) - ch_flags[i * 3 + Par - 3] = (x_toggle & (1 << Par)) ? '-' : '+'; - x_toggle ^= (1 << Par); + ch_flags[i * 3 + parm - 3] = + (x_toggle & (1 << parm)) ? '-' : '+'; + x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, WIDGET_DRAW, 0); send_message (h->current->widget, WIDGET_FOCUS, 0); break; - + case XCTRL ('x'): i++; - + case XCTRL ('w'): i++; - + case XCTRL ('r'): - Par = i; + parm = i; for (i = 0; i < 3; i++) - ch_flags[i * 3 + Par] = (x_toggle & (1 << Par)) ? '-' : '+'; - x_toggle ^= (1 << Par); + ch_flags[i * 3 + parm] = + (x_toggle & (1 << parm)) ? '-' : '+'; + x_toggle ^= (1 << parm); update_mode (h); dlg_broadcast_msg (h, WIDGET_DRAW, 0); send_message (h->current->widget, WIDGET_FOCUS, 0); break; - + case 'x': i++; - + case 'w': i++; - + case 'r': if (f_pos > 2) break; - flag_pos = f_pos * 3 + i; /* (strchr(ch_perm,Par)-ch_perm); */ - if (((WButton *) h->current->widget)->text[(flag_pos % 3)] == '-') + flag_pos = f_pos * 3 + i; /* (strchr(ch_perm,parm)-ch_perm); */ + if (((WButton *) h->current->widget)->text[(flag_pos % 3)] == + '-') ch_flags[flag_pos] = '+'; else ch_flags[flag_pos] = '-'; @@ -490,10 +493,10 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg) case '4': i++; - + case '2': i++; - + case '1': if (f_pos > 2) break; @@ -501,29 +504,32 @@ static int advanced_chown_callback (Dlg_head * h, int Par, int Msg) ch_flags[flag_pos] = '='; update_mode (h); break; - + case '-': if (f_pos > 2) break; - + case '*': - if (Par == '*') - Par = '='; - + if (parm == '*') + parm = '='; + case '=': case '+': if (f_pos > 4) break; - ch_flags[flag_pos] = Par; + ch_flags[flag_pos] = parm; update_mode (h); advanced_chown_callback (h, KEY_RIGHT, DLG_KEY); - if (flag_pos>8 || !(flag_pos%3)) dlg_one_down (h); + if (flag_pos > 8 || !(flag_pos % 3)) + dlg_one_down (h); break; } - return 0; + return MSG_NOT_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void diff --git a/src/boxes.c b/src/boxes.c index 6a27b2a32..99cdb7b53 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -81,51 +81,51 @@ static char *displays [LIST_TYPES] = { static int user_hotkey = 'u'; -static int -display_callback (struct Dlg_head *h, int id, int Msg) +static cb_ret_t +display_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg){ - case DLG_DRAW: - common_dialog_repaint (h); - break; - + switch (msg) { case DLG_UNFOCUS: - if((WRadio *) h->current->widget == my_radio){ - assign_text (status, displays_status [my_radio->sel]); + if ((WRadio *) h->current->widget == my_radio) { + assign_text (status, displays_status[my_radio->sel]); input_set_point (status, 0); } - break; - + return MSG_HANDLED; + case DLG_KEY: - if (id == '\n'){ - if((WRadio *) h->current->widget == my_radio){ - assign_text (status, displays_status [my_radio->sel]); + if (parm == '\n') { + if ((WRadio *) h->current->widget == my_radio) { + assign_text (status, displays_status[my_radio->sel]); dlg_stop (h); - break; + return MSG_HANDLED; } - - if ((WInput *) h->current->widget == user){ + + if ((WInput *) h->current->widget == user) { h->ret_value = B_USER + 6; dlg_stop (h); - break; + return MSG_HANDLED; } - - if ((WInput *) h->current->widget == status){ + + if ((WInput *) h->current->widget == status) { h->ret_value = B_USER + 7; dlg_stop (h); - break; + return MSG_HANDLED; } } - if (tolower(id) == user_hotkey && h->current->widget != (Widget *) user - && h->current->widget != (Widget *) status){ + if (tolower (parm) == user_hotkey + && h->current->widget != (Widget *) user + && h->current->widget != (Widget *) status) { my_radio->sel = 3; - dlg_select_widget (h, my_radio); /* force redraw */ + dlg_select_widget (h, my_radio); /* force redraw */ dlg_select_widget (h, user); return MSG_HANDLED; } + return MSG_NOT_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return MSG_NOT_HANDLED; } static void @@ -637,24 +637,22 @@ display_bits_box (void) #define TREE_Y 20 #define TREE_X 60 -static int -tree_callback (struct Dlg_head *h, int id, int msg) +static cb_ret_t +tree_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (msg){ + switch (msg) { case DLG_POST_KEY: /* The enter key will be processed by the tree widget */ - if (id == '\n') { + if (parm == '\n') { h->ret_value = B_ENTER; dlg_stop (h); } return MSG_HANDLED; - case DLG_DRAW: - common_dialog_repaint (h); - break; + default: + return default_dlg_callback (h, msg, parm); } - return MSG_NOT_HANDLED; } /* Show tree in a box, not on a panel */ diff --git a/src/chmod.c b/src/chmod.c index a641972a2..85f0a207c 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -149,36 +149,39 @@ static void chmod_refresh (Dlg_head *h) addstr (_(" File ")); } -static int chmod_callback (Dlg_head *h, int Par, int Msg) +static cb_ret_t +chmod_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - char buffer [BUF_TINY]; - - switch (Msg) { + char buffer[BUF_TINY]; + + switch (msg) { case DLG_ACTION: - if (Par >= BUTTONS - single_set * 2){ - c_stat ^= check_perm[Par - BUTTONS + single_set * 2].mode; + if (parm >= BUTTONS - single_set * 2) { + c_stat ^= check_perm[parm - BUTTONS + single_set * 2].mode; g_snprintf (buffer, sizeof (buffer), "%o", c_stat); label_set_text (statl, buffer); chmod_toggle_select (h); mode_change = 1; } - break; + return MSG_HANDLED; case DLG_KEY: - if ((Par == 'T' || Par == 't' || Par == KEY_IC) && - h->current->dlg_id >= BUTTONS - single_set * 2) { + if ((parm == 'T' || parm == 't' || parm == KEY_IC) + && h->current->dlg_id >= BUTTONS - single_set * 2) { chmod_toggle_select (h); - if (Par == KEY_IC) + if (parm == KEY_IC) dlg_one_down (h); - return 1; + return MSG_HANDLED; } - break; + return MSG_NOT_HANDLED; case DLG_DRAW: chmod_refresh (h); - break; + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static Dlg_head * diff --git a/src/chown.c b/src/chown.c index 3ca9c2868..72a5d7443 100644 --- a/src/chown.c +++ b/src/chown.c @@ -130,15 +130,17 @@ next_file (void) return cpanel->dir.list[current_file].fname; } -static int -chown_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +chown_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: chown_refresh (h); - break; + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static Dlg_head * diff --git a/src/complete.c b/src/complete.c index b60df92c8..0414a3ef4 100644 --- a/src/complete.c +++ b/src/complete.c @@ -807,16 +807,12 @@ static int insert_text (WInput *in, char *text, int len) return len != 0; } -static int -query_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +query_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { - case DLG_DRAW: - common_dialog_repaint (h); - break; - + switch (msg) { case DLG_KEY: - switch (Par) { + switch (parm) { case KEY_LEFT: case KEY_RIGHT: h->ret_value = 0; @@ -838,7 +834,7 @@ query_callback (Dlg_head * h, int Par, int Msg) end - start - 1)) { listbox_select_entry ((WListbox *) (h->current-> widget), e1); - handle_char (input, Par); + handle_char (input, parm); end--; send_message (h->current->widget, WIDGET_DRAW, 0); break; @@ -849,8 +845,8 @@ query_callback (Dlg_head * h, int Par, int Msg) return 1; default: - if (Par > 0xff || !is_printable (Par)) { - if (is_in_input_map (input, Par) == 2) { + if (parm > 0xff || !is_printable (parm)) { + if (is_in_input_map (input, parm) == 2) { if (end == min_end) return 1; h->ret_value = B_USER; /* This means we want to refill the @@ -869,13 +865,13 @@ query_callback (Dlg_head * h, int Par, int Msg) do { if (!strncmp (input->buffer + start, e1->text, end - start)) { - if (e1->text[end - start] == Par) { + if (e1->text[end - start] == parm) { if (need_redraw) { register int c1, c2, si; for (si = end - start + 1; - (c1 = last_text[si]) && - (c2 = e1->text[si]); si++) + (c1 = last_text[si]) + && (c2 = e1->text[si]); si++) if (c1 != c2) break; if (low > si) @@ -902,11 +898,13 @@ query_callback (Dlg_head * h, int Par, int Msg) dlg_stop (h); } } - return 1; + return MSG_HANDLED; } break; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } #define DO_INSERTION 1 diff --git a/src/dlg.c b/src/dlg.c index 229e01161..32d429a0a 100644 --- a/src/dlg.c +++ b/src/dlg.c @@ -191,7 +191,7 @@ common_dialog_repaint (struct Dlg_head *h) } /* Default dialog callback */ -int default_dlg_callback (Dlg_head *h, int id, int msg) +cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm) { if (msg == DLG_DRAW && h->color) { common_dialog_repaint (h); @@ -348,7 +348,7 @@ int dlg_focus (Dlg_head *h) return 0; if (send_message (h->current->widget, WIDGET_FOCUS, 0)){ - (*h->callback) (h, h->current->dlg_id, DLG_FOCUS); + (*h->callback) (h, DLG_FOCUS, h->current->dlg_id); return 1; } return 0; @@ -361,7 +361,7 @@ dlg_unfocus (Dlg_head *h) return 0; if (send_message (h->current->widget, WIDGET_UNFOCUS, 0)){ - (*h->callback) (h, h->current->dlg_id, DLG_UNFOCUS); + (*h->callback) (h, DLG_UNFOCUS, h->current->dlg_id); return 1; } return 0; @@ -500,7 +500,7 @@ void update_cursor (Dlg_head *h) */ void dlg_redraw (Dlg_head *h) { - (h->callback)(h, 0, DLG_DRAW); + (h->callback)(h, DLG_DRAW, 0); dlg_broadcast_msg (h, WIDGET_DRAW, 1); @@ -645,14 +645,14 @@ dlg_key_event (Dlg_head *h, int d_key) } else { /* first can dlg_callback handle the key */ - handled = (*h->callback) (h, d_key, DLG_KEY); + handled = (*h->callback) (h, DLG_KEY, d_key); /* next try the hotkey */ if (!handled) handled = dlg_try_hotkey (h, d_key); if (handled) - (*h->callback) (h, 0, DLG_HOTKEY_HANDLED); + (*h->callback) (h, DLG_HOTKEY_HANDLED, 0); /* not used - then try widget_callback */ if (!handled) @@ -660,11 +660,11 @@ dlg_key_event (Dlg_head *h, int d_key) /* not used- try to use the unhandled case */ if (!handled) - handled = (*h->callback) (h, d_key, DLG_UNHANDLED_KEY); + handled = (*h->callback) (h, DLG_UNHANDLED_KEY, d_key); if (!handled) dialog_handle_key (h, d_key); - (*h->callback) (h, d_key, DLG_POST_KEY); + (*h->callback) (h, DLG_POST_KEY, d_key); return handled; } @@ -716,7 +716,7 @@ void init_dlg (Dlg_head *h) int refresh_mode; /* Initialize dialog manager and widgets */ - (*h->callback) (h, 0, DLG_INIT); + (*h->callback) (h, DLG_INIT, 0); dlg_broadcast_msg (h, WIDGET_INIT, 0); if (h->x == 0 && h->y == 0 && h->cols == COLS && h->lines == LINES) @@ -755,7 +755,7 @@ void init_dlg (Dlg_head *h) void dlg_run_done (Dlg_head *h) { if (h->current) - (*h->callback) (h, h->current->dlg_id, DLG_END); + (*h->callback) (h, DLG_END, h->current->dlg_id); current_dlg = (Dlg_head *) h->previous_dialog; } @@ -791,7 +791,7 @@ frontend_run_dlg (Dlg_head *h) execute_hooks (idle_hook); while ((h->flags & DLG_WANT_IDLE) && is_idle ()) - (*h->callback) (h, 0, DLG_IDLE); + (*h->callback) (h, DLG_IDLE, 0); /* Allow terminating the dialog from the idle handler */ if (!h->running) @@ -807,7 +807,7 @@ frontend_run_dlg (Dlg_head *h) dlg_process_event (h, d_key, &event); if (!h->running) - (*h->callback) (h, 0, DLG_VALIDATE); + (*h->callback) (h, DLG_VALIDATE, 0); } } diff --git a/src/dlg.h b/src/dlg.h index dc2232e8e..b803bc397 100644 --- a/src/dlg.h +++ b/src/dlg.h @@ -61,7 +61,7 @@ typedef enum { /* Dialog callback */ struct Dlg_head; -typedef int (*dlg_cb_fn)(struct Dlg_head *h, int Par, int Msg); +typedef cb_ret_t (*dlg_cb_fn)(struct Dlg_head *h, dlg_msg_t msg, int parm); typedef struct Dlg_head { @@ -170,7 +170,7 @@ void init_widget (Widget *w, int y, int x, int lines, int cols, mouse_h mouse_handler); /* Default callback for dialogs */ -int default_dlg_callback (Dlg_head *h, int id, int msg); +cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm); /* Default callback for widgets */ int default_proc (int Msg, int Par); diff --git a/src/find.c b/src/find.c index 900e3f5ab..ed7c44b89 100644 --- a/src/find.c +++ b/src/find.c @@ -123,12 +123,12 @@ static int case_sensitive = 1; * Callback for the parameter dialog. * Validate regex, prevent closing the dialog if it's invalid. */ -static int -find_parm_callback (struct Dlg_head *h, int id, int Msg) +static cb_ret_t +find_parm_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { int flags; - switch (Msg) { + switch (msg) { case DLG_VALIDATE: if ((h->ret_value != B_ENTER) || !in_with->buffer[0]) return MSG_HANDLED; @@ -144,8 +144,10 @@ find_parm_callback (struct Dlg_head *h, int id, int Msg) h->running = 1; /* Don't stop the dialog */ } return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return default_dlg_callback (h, id, Msg); } /* @@ -696,29 +698,27 @@ view_edit_currently_selected_file (int unparsed_view, int edit) return MSG_HANDLED; } -static int -find_callback (struct Dlg_head *h, int id, int Msg) +static cb_ret_t +find_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg){ - case DLG_DRAW: - common_dialog_repaint (h); - break; - + switch (msg) { case DLG_KEY: - if (id == KEY_F(3) || id == KEY_F(13)){ - int unparsed_view = (id == KEY_F(13)); + if (parm == KEY_F (3) || parm == KEY_F (13)) { + int unparsed_view = (parm == KEY_F (13)); return view_edit_currently_selected_file (unparsed_view, 0); } - if (id == KEY_F(4)){ + if (parm == KEY_F (4)) { return view_edit_currently_selected_file (0, 1); - } - return MSG_NOT_HANDLED; + } + return MSG_NOT_HANDLED; - case DLG_IDLE: - do_search (h); - break; - } - return 0; + case DLG_IDLE: + do_search (h); + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); + } } /* Handles the Stop/Start button in the find window */ diff --git a/src/help.c b/src/help.c index 4e7631576..ea4a2007a 100644 --- a/src/help.c +++ b/src/help.c @@ -90,7 +90,7 @@ typedef struct Link_Area { static Link_Area *link_area = NULL; static int inside_link_area = 0; -static int help_callback (struct Dlg_head *h, int id, int msg); +static cb_ret_t help_callback (struct Dlg_head *h, dlg_msg_t, int parm); #ifdef HAS_ACS_AS_PCCHARS static const struct { @@ -483,7 +483,7 @@ static int help_event (Gpm_Event *event, Widget *w) if (history_ptr < 0) history_ptr = HISTORY_SIZE-1; - help_callback (w->parent, 0, DLG_DRAW); + help_callback (w->parent, DLG_DRAW, 0); return 0; } @@ -529,7 +529,7 @@ static int help_event (Gpm_Event *event, Widget *w) } /* Show the new node */ - help_callback (w->parent, 0, DLG_DRAW); + help_callback (w->parent, DLG_DRAW, 0); return 0; } @@ -543,7 +543,7 @@ help_help_cmd (Dlg_head *h) history [history_ptr].link = selected_item; currentpoint = startpoint = search_string (data, "[How to use help]") + 1; selected_item = NULL; - help_callback (h, 0, DLG_DRAW); + help_callback (h, DLG_DRAW, 0); } static void @@ -563,7 +563,7 @@ help_index_cmd (Dlg_head * h) currentpoint = startpoint = new_item + 1; selected_item = NULL; - help_callback (h, 0, DLG_DRAW); + help_callback (h, DLG_DRAW, 0); } static void help_quit_cmd (void *x) @@ -579,7 +579,7 @@ static void prev_node_cmd (Dlg_head *h) if (history_ptr < 0) history_ptr = HISTORY_SIZE-1; - help_callback (h, 0, DLG_DRAW); + help_callback (h, DLG_DRAW, 0); } static int md_callback (Widget *w, int msg, int par) @@ -597,7 +597,8 @@ static Widget *mousedispatch_new (int y, int x, int yl, int xl) return w; } -static int help_handle_key (struct Dlg_head *h, int c) +static cb_ret_t +help_handle_key (struct Dlg_head *h, int c) { char *new_item; @@ -715,25 +716,28 @@ static int help_handle_key (struct Dlg_head *h, int c) break; default: - return 0; + return MSG_NOT_HANDLED; } - help_callback (h, 0, DLG_DRAW); - return 1; + help_callback (h, DLG_DRAW, 0); + return MSG_HANDLED; } -static int help_callback (struct Dlg_head *h, int id, int msg) +static cb_ret_t +help_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (msg){ + switch (msg) { case DLG_DRAW: common_dialog_repaint (h); help_show (h, currentpoint); - break; + return MSG_HANDLED; case DLG_KEY: - return help_handle_key (h, id); + return help_handle_key (h, parm); + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void diff --git a/src/hotlist.c b/src/hotlist.c index 278a0171d..b5bf987b9 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -267,19 +267,20 @@ static void add_name_to_list (char *path) } #endif /* !USE_VFS */ -static int hotlist_button_callback (int action) +static int +hotlist_button_callback (int action) { switch (action) { case B_MOVE: { - struct hotlist *saved = current_group; - struct hotlist *item; - struct hotlist *moveto_item = 0; - struct hotlist *moveto_group = 0; - int ret; + struct hotlist *saved = current_group; + struct hotlist *item; + struct hotlist *moveto_item = 0; + struct hotlist *moveto_group = 0; + int ret; if (!l_hotlist->current) - return 0; /* empty group - nothing to do */ + return MSG_NOT_HANDLED; /* empty group - nothing to do */ item = l_hotlist->current->data; hotlist_state.moving = 1; init_movelist (LIST_MOVELIST, item); @@ -292,9 +293,9 @@ static int hotlist_button_callback (int action) destroy_dlg (movelist_dlg); current_group = saved; if (ret == B_CANCEL) - return 0; + return MSG_NOT_HANDLED; if (moveto_item == item) - return 0; /* If we insert/append a before/after a + return MSG_NOT_HANDLED; /* If we insert/append a before/after a it hardly changes anything ;) */ unlink_entry (item); listbox_remove_current (l_hotlist, 1); @@ -314,104 +315,105 @@ static int hotlist_button_callback (int action) else { item->next = moveto_item->next; moveto_item->next = item; - } - else if (moveto_group->head == moveto_item) { - moveto_group->head = item; - item->next = moveto_item; - } else { - struct hotlist *p = moveto_group->head; + } else if (moveto_group->head == moveto_item) { + moveto_group->head = item; + item->next = moveto_item; + } else { + struct hotlist *p = moveto_group->head; - while (p->next != moveto_item) - p = p->next; - item->next = p->next; - p->next = item; - } + while (p->next != moveto_item) + p = p->next; + item->next = p->next; + p->next = item; + } listbox_remove_list (l_hotlist); fill_listbox (); repaint_screen (); hotlist_state.modified = 1; - return 0; + return MSG_NOT_HANDLED; break; } case B_REMOVE: if (l_hotlist->current && l_hotlist->current->data) remove_from_hotlist (l_hotlist->current->data); - return 0; + return MSG_NOT_HANDLED; break; case B_NEW_GROUP: add_new_group_cmd (); - return 0; + return MSG_NOT_HANDLED; break; case B_ADD_CURRENT: add2hotlist_cmd (); - return 0; + return MSG_NOT_HANDLED; break; case B_NEW_ENTRY: add_new_entry_cmd (); - return 0; + return MSG_NOT_HANDLED; break; case B_ENTER: { - WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist; - if (list->current){ - if (list->current->data) { - struct hotlist *hlp = (struct hotlist*) list->current->data; - if (hlp->type == HL_TYPE_ENTRY) - return 1; - else { - listbox_remove_list (list); - current_group = hlp; - fill_listbox (); - return 0; - } - } else - return 1; - } + WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist; + if (list->current) { + if (list->current->data) { + struct hotlist *hlp = + (struct hotlist *) list->current->data; + if (hlp->type == HL_TYPE_ENTRY) + return MSG_HANDLED; + else { + listbox_remove_list (list); + current_group = hlp; + fill_listbox (); + return MSG_NOT_HANDLED; + } + } else + return MSG_HANDLED; + } } /* Fall through if list empty - just go up */ case B_UP_GROUP: { - WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist; - listbox_remove_list (list); - current_group = current_group->up; - fill_listbox (); - return 0; - break; + WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist; + listbox_remove_list (list); + current_group = current_group->up; + fill_listbox (); + return MSG_NOT_HANDLED; + break; } #ifdef USE_VFS case B_FREE_ALL_VFS: - vfs_expire (1); + vfs_expire (1); /* fall through */ case B_REFRESH_VFS: listbox_remove_list (l_hotlist); listbox_add_item (l_hotlist, 0, 0, home_dir, 0); vfs_fill_names (add_name_to_list); - return 0; -#endif /* USE_VFS */ + return MSG_NOT_HANDLED; +#endif /* USE_VFS */ default: - return 1; + return MSG_HANDLED; break; } } -static int hotlist_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +hotlist_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: hotlist_refresh (h); - break; + return MSG_HANDLED; case DLG_UNHANDLED_KEY: - switch (Par) { + switch (parm) { case KEY_M_CTRL | '\n': goto l1; case '\n': @@ -421,44 +423,43 @@ static int hotlist_callback (Dlg_head * h, int Par, int Msg) h->ret_value = B_ENTER; dlg_stop (h); }; - return 1; + return MSG_HANDLED; break; case KEY_LEFT: - if (hotlist_state.type != LIST_VFSLIST ) - return !hotlist_button_callback (B_UP_GROUP); + if (hotlist_state.type != LIST_VFSLIST) + return !hotlist_button_callback (B_UP_GROUP); else - return 0; + return MSG_NOT_HANDLED; break; case KEY_DC: if (!hotlist_state.moving) { hotlist_button_callback (B_REMOVE); - return 1; + return MSG_HANDLED; } break; -l1: - case ALT('\n'): - case ALT('\r'): - if (!hotlist_state.moving) - { - if (l_hotlist->current){ + l1: + case ALT ('\n'): + case ALT ('\r'): + if (!hotlist_state.moving) { + if (l_hotlist->current) { if (l_hotlist->current->data) { - struct hotlist *hlp = (struct hotlist*) l_hotlist->current->data; + struct hotlist *hlp = + (struct hotlist *) l_hotlist->current->data; if (hlp->type == HL_TYPE_ENTRY) { - char *tmp = g_strconcat ( "cd ", hlp->directory, NULL); + char *tmp = + g_strconcat ("cd ", hlp->directory, NULL); stuff (cmdline, tmp, 0); g_free (tmp); dlg_stop (h); h->ret_value = B_CANCEL; - return 1; - } + return MSG_HANDLED; + } } } } - return 1; /* ignore key */ - default: - return 0; + return MSG_HANDLED; /* ignore key */ } - break; + return MSG_NOT_HANDLED; case DLG_POST_KEY: if (hotlist_state.moving) @@ -471,9 +472,11 @@ l1: case DLG_INIT: attrset (MENU_ENTRY_COLOR); update_path_name (); - break; + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static int l_call (WListbox *list) diff --git a/src/layout.c b/src/layout.c index 9720f66fc..e855c56b0 100644 --- a/src/layout.c +++ b/src/layout.c @@ -264,9 +264,10 @@ static int bminus_cback (int action) return 0; } -static int layout_callback (struct Dlg_head *h, int Id, int Msg) +static cb_ret_t +layout_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg){ + switch (msg) { case DLG_DRAW: /*When repainting the whole dialog (e.g. with C-l) we have to update everything*/ @@ -301,7 +302,7 @@ static int layout_callback (struct Dlg_head *h, int Id, int Msg) printw ("%02d", _output_lines); } } - break; + return MSG_HANDLED; case DLG_POST_KEY: _filetype_mode = check_options [8].widget->state & C_BOOL; @@ -343,12 +344,11 @@ static int layout_callback (struct Dlg_head *h, int Id, int Msg) printw ("%02d", _output_lines); } } - break; + return MSG_HANDLED; - case DLG_END: - break; + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void init_layout (void) diff --git a/src/learn.c b/src/learn.c index 7bf8ecefc..3c087c56b 100644 --- a/src/learn.c +++ b/src/learn.c @@ -207,16 +207,20 @@ learn_check_key (int c) return 0; } -static int learn_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +learn_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: common_dialog_repaint (h); - break; + return MSG_HANDLED; + case DLG_KEY: - return learn_check_key (Par); + return learn_check_key (parm); + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void diff --git a/src/listmode.c b/src/listmode.c index d879226bf..22531acfe 100644 --- a/src/listmode.c +++ b/src/listmode.c @@ -158,17 +158,18 @@ bremove_cback (int action) return 0; } -static int -listmode_callback (Dlg_head *h, int Par, int Msg) +static cb_ret_t +listmode_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: listmode_refresh (h); - break; + return MSG_HANDLED; + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static Dlg_head * diff --git a/src/main.c b/src/main.c index 7b2ca3e91..87277c29f 100644 --- a/src/main.c +++ b/src/main.c @@ -1477,8 +1477,8 @@ done_mc_profile (void) free_profiles (); } -static int -midnight_callback (struct Dlg_head *h, int id, int msg) +static cb_ret_t +midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { int i; @@ -1496,32 +1496,32 @@ midnight_callback (struct Dlg_head *h, int id, int msg) if (ctl_x_map_enabled) { ctl_x_map_enabled = 0; for (i = 0; ctl_x_map[i].key_code; i++) - if (id == ctl_x_map[i].key_code) { - (*ctl_x_map[i].fn) (id); + if (parm == ctl_x_map[i].key_code) { + (*ctl_x_map[i].fn) (parm); return MSG_HANDLED; } } /* FIXME: should handle all menu shortcuts before this point */ if (the_menubar->active) - break; + return MSG_NOT_HANDLED; - if (id == KEY_F (10)) { + if (parm == KEY_F (10)) { quit_cmd (); return MSG_HANDLED; } - if (id == '\t') + if (parm == '\t') free_completions (cmdline); - if (id == '\n' && cmdline->buffer[0]) { - send_message ((Widget *) cmdline, WIDGET_KEY, id); + if (parm == '\n' && cmdline->buffer[0]) { + send_message ((Widget *) cmdline, WIDGET_KEY, parm); return MSG_HANDLED; } /* Ctrl-Enter and Alt-Enter */ - if (((id & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') - && (id & (KEY_M_CTRL | KEY_M_ALT))) { + if (((parm & ~(KEY_M_CTRL | KEY_M_ALT)) == '\n') + && (parm & (KEY_M_CTRL | KEY_M_ALT))) { copy_prog_name (); return MSG_HANDLED; } @@ -1530,17 +1530,17 @@ midnight_callback (struct Dlg_head *h, int id, int msg) && !quote && !cpanel->searching) { if (!only_leading_plus_minus) { /* Special treatement, since the input line will eat them */ - if (id == '+') { + if (parm == '+') { select_cmd (); return MSG_HANDLED; } - if (id == '\\' || id == '-') { + if (parm == '\\' || parm == '-') { unselect_cmd (); return MSG_HANDLED; } - if (id == '*') { + if (parm == '*') { reverse_selection_cmd (); return MSG_HANDLED; } @@ -1549,50 +1549,50 @@ midnight_callback (struct Dlg_head *h, int id, int msg) * first char on input line */ - if (id == '+') { + if (parm == '+') { select_cmd (); return MSG_HANDLED; } - if (id == '\\' || id == '-') { + if (parm == '\\' || parm == '-') { unselect_cmd (); return MSG_HANDLED; } - if (id == '*') { + if (parm == '*') { reverse_selection_cmd (); return MSG_HANDLED; } } } - break; + return MSG_NOT_HANDLED; case DLG_HOTKEY_HANDLED: if ((get_current_type () == view_listing) && cpanel->searching) { cpanel->searching = 0; panel_update_contents (cpanel); } - break; + return MSG_HANDLED; case DLG_UNHANDLED_KEY: if (command_prompt) { int v; - v = send_message ((Widget *) cmdline, WIDGET_KEY, id); + v = send_message ((Widget *) cmdline, WIDGET_KEY, parm); if (v) return v; } if (ctl_x_map_enabled) { ctl_x_map_enabled = 0; for (i = 0; ctl_x_map[i].key_code; i++) - if (id == ctl_x_map[i].key_code) { - (*ctl_x_map[i].fn) (id); + if (parm == ctl_x_map[i].key_code) { + (*ctl_x_map[i].fn) (parm); return MSG_HANDLED; } } else { for (i = 0; default_map[i].key_code; i++) { - if (id == default_map[i].key_code) { - (*default_map[i].fn) (id); + if (parm == default_map[i].key_code) { + (*default_map[i].fn) (parm); return MSG_HANDLED; } } @@ -1607,8 +1607,9 @@ midnight_callback (struct Dlg_head *h, int id, int msg) 1, LINES - keybar_visible - 1); return MSG_HANDLED; + default: + return default_dlg_callback (h, msg, parm); } - return default_dlg_callback (h, id, msg); } #define xtoolkit_panel_setup() diff --git a/src/option.c b/src/option.c index bd7cd5eb4..2a55d2e53 100644 --- a/src/option.c +++ b/src/option.c @@ -107,9 +107,10 @@ static char *pause_options [3] = { #define RX X_MARGIN #define OX (first_width + X_MARGIN + X_PANE_GAP) -static int configure_callback (struct Dlg_head *h, int Id, int Msg) +static cb_ret_t +configure_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: common_dialog_repaint (h); @@ -125,13 +126,15 @@ static int configure_callback (struct Dlg_head *h, int Id, int Msg) addstr (title2); dlg_move (h, PY, PX+1); addstr (title1); - break; + return MSG_HANDLED; case DLG_END: - r_but = Id; - break; + r_but = parm; + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } /* Create the "Configure options" dialog */ diff --git a/src/panelize.c b/src/panelize.c index 1d21a4071..c7400913e 100644 --- a/src/panelize.c +++ b/src/panelize.c @@ -93,24 +93,26 @@ update_command (void) } } -static int -panelize_callback (Dlg_head * h, int Par, int Msg) +static cb_ret_t +panelize_callback (Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg) { + switch (msg) { case DLG_DRAW: common_dialog_repaint (h); attrset (COLOR_NORMAL); draw_box (h, UY, UX, h->lines - 10, h->cols - 10); - break; + return MSG_HANDLED; case DLG_POST_KEY: /* fall */ case DLG_INIT: attrset (MENU_ENTRY_COLOR); update_command (); - break; + return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } static void diff --git a/src/view.c b/src/view.c index f92a5f126..a33b73b5d 100644 --- a/src/view.c +++ b/src/view.c @@ -2608,15 +2608,17 @@ view_adjust_size (Dlg_head *h) } /* Callback for the view dialog */ -static int -view_dialog_callback (Dlg_head *h, int id, int msg) +static cb_ret_t +view_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm) { switch (msg) { case DLG_RESIZE: view_adjust_size (h); return MSG_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return default_dlg_callback (h, id, msg); } /* Real view only */ diff --git a/src/wtools.c b/src/wtools.c index 7cc83334d..9afe72153 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -235,20 +235,21 @@ message (int error, char *header, const char *text, ...) /* {{{ Quick dialog routines */ -static int quick_callback (struct Dlg_head *h, int id, int Msg) +static cb_ret_t +quick_callback (struct Dlg_head *h, dlg_msg_t msg, int parm) { - switch (Msg){ - case DLG_DRAW: - common_dialog_repaint (h); - break; + switch (msg) { case DLG_KEY: - if (id == '\n'){ + if (parm == '\n') { h->ret_value = B_ENTER; dlg_stop (h); - break; + return MSG_HANDLED; } + return MSG_NOT_HANDLED; + + default: + return default_dlg_callback (h, msg, parm); } - return 0; } #define I18N(x) (do_int && *x ? (x = _(x)): x)