From 385fdc7f2b7961af357f2a2918e85e86a960f18e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 8 Oct 2011 20:03:32 +0400 Subject: [PATCH] Handle CK_SyntaxOnOff action in dialog level instead of widget one. --- src/editor/edit-impl.h | 1 + src/editor/edit.c | 7 ------- src/editor/editcmd.c | 38 ++++++++++++++++++++++++++++++++++++++ src/editor/editwidget.c | 3 +++ 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index c94a63939..3ad30d669 100644 --- a/src/editor/edit-impl.h +++ b/src/editor/edit-impl.h @@ -251,6 +251,7 @@ gboolean edit_load_back_cmd (WEdit * edit); gboolean edit_load_forward_cmd (WEdit * edit); void edit_block_process_cmd (WEdit * edit, int macro_number); void edit_refresh_cmd (void); +void edit_syntax_onoff_cmd (Dlg_head * h); void edit_date_cmd (WEdit * edit); void edit_goto_cmd (WEdit * edit); int eval_marks (WEdit * edit, long *start_mark, long *end_mark); diff --git a/src/editor/edit.c b/src/editor/edit.c index 13a5f4880..376b8de33 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -4056,13 +4056,6 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) edit_syntax_dialog (edit); break; - case CK_SyntaxOnOff: - option_syntax_highlighting ^= 1; - if (option_syntax_highlighting == 1) - edit_load_syntax (edit, NULL, edit->syntax_type); - edit->force |= REDRAW_PAGE; - break; - case CK_ShowTabTws: enable_show_tabs_tws ^= 1; edit->force |= REDRAW_PAGE; diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index a0d9e5c2a..27879a8c8 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -1431,6 +1431,29 @@ edit_delete_macro (WEdit * edit, int hotkey) return TRUE; } +/* --------------------------------------------------------------------------------------------- */ +/** + * Callback for the iteration of objects in the 'editors' array. + * Toggle syntax highlighting in editor object. + * + * @param data probably WEdit object + * @param user_data unused + */ + +static void +edit_syntax_onoff_cb (void *data, void *user_data) +{ + (void) user_data; + + if (edit_widget_is_editor ((const Widget *) data)) + { + WEdit *edit = (WEdit *) data; + + if (option_syntax_highlighting) + edit_load_syntax (edit, NULL, edit->syntax_type); + edit->force |= REDRAW_PAGE; + } +} /* --------------------------------------------------------------------------------------------- */ /*** public functions ****************************************************************************/ @@ -1445,6 +1468,21 @@ edit_refresh_cmd (void) } /* --------------------------------------------------------------------------------------------- */ +/** + * Toggle syntax highlighting in all editor windows. + * + * @param h root widget for all windows + */ + +void +edit_syntax_onoff_cmd (Dlg_head * h) +{ + option_syntax_highlighting = !option_syntax_highlighting; + g_list_foreach (h->widgets, edit_syntax_onoff_cb, NULL); + dlg_redraw (h); +} + +/* --------------------------------------------------------------------------------------------- */ void edit_save_mode_cmd (void) diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index 50c5db289..b680ec71a 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -581,6 +581,9 @@ edit_dialog_command_execute (Dlg_head * h, unsigned long command) case CK_About: edit_about (); break; + case CK_SyntaxOnOff: + edit_syntax_onoff_cmd (h); + break; case CK_Refresh: edit_refresh_cmd (); break; -- 2.11.4.GIT