Handle CK_Option action in dialog level instead of widget one.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-09-19 14:08:46 +04:00
parent 92923aff29
commit 5018bdc3fc
4 changed files with 48 additions and 8 deletions

View File

@ -303,7 +303,7 @@ void book_mark_restore (WEdit * edit, int color);
int line_is_blank (WEdit * edit, long line);
int edit_indent_width (WEdit * edit, long p);
void edit_insert_indent (WEdit * edit, int indent);
void edit_options_dialog (WEdit * edit);
void edit_options_dialog (Dlg_head * h);
void edit_syntax_dialog (WEdit * edit);
void edit_mail_dialog (WEdit * edit);
void format_paragraph (WEdit * edit, int force);

View File

@ -4097,9 +4097,6 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
case CK_Refresh:
edit_refresh_cmd (edit);
break;
case CK_Options:
edit_options_dialog (edit);
break;
case CK_Date:
{
char s[BUF_MEDIUM];

View File

@ -1,11 +1,13 @@
/*
Editor options dialog box
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2007, 2011
Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2004, 2005, 2007, 2011,
2012
The Free Software Foundation, Inc.
Written by:
Paul Sheer, 1996, 1997
Andrew Borodin <aborodin@vmail.ru> 2012
This file is part of the Midnight Commander.
@ -72,13 +74,51 @@ i18n_translate_array (const char *array[])
}
}
#endif /* ENABLE_NLS */
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for the iteration of objects in the 'editors' array.
* Tear down 'over_col' property in all editors.
*
* @param data probably WEdit object
* @param user_data unused
*/
static void
edit_reset_over_col (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
((WEdit *) data)->over_col = 0;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for the iteration of objects in the 'editors' array.
* Reload syntax lighlighting in all editors.
*
* @param data probably WEdit object
* @param user_data unused
*/
static void
edit_reload_syntax (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((Widget *) data))
{
WEdit *edit = (WEdit *) data;
edit_load_syntax (edit, NULL, edit->syntax_type);
}
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
void
edit_options_dialog (WEdit * edit)
edit_options_dialog (Dlg_head * h)
{
char wrap_length[16], tab_spacing[16], *p, *q;
int wrap_mode = 0;
@ -154,7 +194,7 @@ edit_options_dialog (WEdit * edit)
old_syntax_hl = option_syntax_highlighting;
if (!option_cursor_beyond_eol)
edit->over_col = 0;
g_list_foreach (h->widgets, edit_reset_over_col, NULL);
if (p != NULL)
{
@ -190,7 +230,7 @@ edit_options_dialog (WEdit * edit)
/* Load or unload syntax rules if the option has changed */
if (option_syntax_highlighting != old_syntax_hl)
edit_load_syntax (edit, NULL, edit->syntax_type);
g_list_foreach (h->widgets, edit_reload_syntax, NULL);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -603,6 +603,9 @@ edit_dialog_command_execute (Dlg_head * h, unsigned long command)
dlg_one_up (h);
dlg_set_top_widget (h->current->data);
break;
case CK_Options:
edit_options_dialog (h);
break;
case CK_OptionsSaveMode:
edit_save_mode_cmd ();
break;