Optimization: rid of wedit and option_syntax_type global variables.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-04-28 16:44:00 +04:00
parent 1480937b17
commit 962bd6fc15
7 changed files with 18 additions and 20 deletions

View File

@ -31,6 +31,7 @@
#include "src/wtools.h"
#include "edit-impl.h"
#include "edit-widget.h"
#define MAX_ENTRY_LEN 40
#define LIST_LINES 14
@ -61,7 +62,7 @@ exec_edit_syntax_dialog (const char **names, const char *current_syntax) {
}
void
edit_syntax_dialog (const char *current_syntax) {
edit_syntax_dialog (WEdit *edit, const char *current_syntax) {
char *old_syntax_type;
int old_auto_syntax, syntax;
char **names;
@ -84,7 +85,7 @@ edit_syntax_dialog (const char *current_syntax) {
}
old_auto_syntax = option_auto_syntax;
old_syntax_type = g_strdup (option_syntax_type);
old_syntax_type = g_strdup (current_syntax);
switch (syntax) {
case 0: /* auto syntax */
@ -95,16 +96,16 @@ edit_syntax_dialog (const char *current_syntax) {
break;
default:
option_auto_syntax = 0;
g_free (option_syntax_type);
option_syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]);
g_free (edit->syntax_type);
edit->syntax_type = g_strdup (names[syntax - N_DFLT_ENTRIES]);
}
/* Load or unload syntax rules if the option has changed */
if ((option_auto_syntax && !old_auto_syntax) || old_auto_syntax ||
(old_syntax_type && option_syntax_type &&
(strcmp (old_syntax_type, option_syntax_type) != 0)) ||
(old_syntax_type && edit->syntax_type &&
(strcmp (old_syntax_type, edit->syntax_type) != 0)) ||
force_reload)
edit_load_syntax (wedit, NULL, option_syntax_type);
edit_load_syntax (edit, NULL, edit->syntax_type);
g_strfreev (names);
g_free (old_syntax_type);

View File

@ -284,8 +284,8 @@ void book_mark_dec (WEdit * edit, int line);
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 (void);
void edit_syntax_dialog (const char *current_syntax);
void edit_options_dialog (WEdit *edit);
void edit_syntax_dialog (WEdit *edit, const char *current_syntax);
void edit_mail_dialog (WEdit *edit);
void format_paragraph (WEdit *edit, int force);
@ -316,7 +316,6 @@ extern edit_search_options_t edit_search_options;
extern int edit_stack_iterator;
extern edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO];
extern WEdit *wedit;
extern struct WMenuBar *edit_menubar;
extern const global_keymap_t *editor_map;
@ -332,7 +331,6 @@ typedef enum {
extern int option_max_undo;
extern int option_auto_syntax;
extern char *option_syntax_type;
extern int option_edit_right_extreme;
extern int option_edit_left_extreme;

View File

@ -3457,7 +3457,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
edit_load_cmd (edit, EDIT_FILE_SYNTAX);
break;
case CK_Choose_Syntax:
edit_syntax_dialog (edit->syntax_type);
edit_syntax_dialog (edit, edit->syntax_type);
break;
case CK_Load_Menu_File:
@ -3466,7 +3466,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
case CK_Toggle_Syntax:
if ((option_syntax_highlighting ^= 1) == 1)
edit_load_syntax (edit, NULL, option_syntax_type);
edit_load_syntax (edit, NULL, edit->syntax_type);
edit->force |= REDRAW_PAGE;
break;
@ -3527,7 +3527,7 @@ edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion)
learn_keys ();
break;
case CK_Edit_Options:
edit_options_dialog ();
edit_options_dialog (edit);
break;
case CK_Edit_Save_Mode:
menu_save_mode_cmd ();

View File

@ -661,7 +661,7 @@ edit_save_as_cmd (WEdit * edit)
edit->modified = 0;
edit->delete_file = 0;
if (different_filename)
edit_load_syntax (edit, NULL, option_syntax_type);
edit_load_syntax (edit, NULL, edit->syntax_type);
edit->force |= REDRAW_COMPLETELY;
return 1;
default:

View File

@ -62,7 +62,7 @@ i18n_translate_array (const char *array[])
#endif /* ENABLE_NLS */
void
edit_options_dialog (void)
edit_options_dialog (WEdit *edit)
{
char wrap_length[16], tab_spacing[16], *p, *q;
int wrap_mode = 0;
@ -139,7 +139,7 @@ edit_options_dialog (void)
old_syntax_hl = option_syntax_highlighting;
if (!option_cursor_beyond_eol)
wedit->over_col = 0;
edit->over_col = 0;
if (p) {
option_word_wrap_line_length = atoi (p);
@ -165,5 +165,5 @@ edit_options_dialog (void)
/* Load or unload syntax rules if the option has changed */
if (option_syntax_highlighting != old_syntax_hl)
edit_load_syntax (wedit, NULL, option_syntax_type);
edit_load_syntax (edit, NULL, edit->syntax_type);
}

View File

@ -52,7 +52,6 @@
#include "src/menu.h" /* menubar_new() */
#include "src/cmddef.h"
WEdit *wedit;
struct WMenuBar *edit_menubar;
int column_highlighting = 0;
@ -231,6 +230,7 @@ edit_file (const char *_file, int line)
{
static gboolean made_directory = FALSE;
Dlg_head *edit_dlg;
WEdit *wedit;
if (!made_directory) {
char *dir = concat_dir_and_file (home_dir, EDIT_DIR);

View File

@ -114,7 +114,6 @@ struct _syntax_marker
int option_syntax_highlighting = 1;
int option_auto_syntax = 1;
char *option_syntax_type = NULL;
static gint
mc_defines_destroy (gpointer key, gpointer value, gpointer data)