Optimization: rid of edit_menubar global variable.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-04-28 16:54:20 +04:00
parent 962bd6fc15
commit d391813325
3 changed files with 22 additions and 16 deletions

View File

@ -316,8 +316,6 @@ extern edit_search_options_t edit_search_options;
extern int edit_stack_iterator; extern int edit_stack_iterator;
extern edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO]; extern edit_stack_type edit_history_moveto [MAX_HISTORY_MOVETO];
extern struct WMenuBar *edit_menubar;
extern const global_keymap_t *editor_map; extern const global_keymap_t *editor_map;
extern const global_keymap_t *editor_x_map; extern const global_keymap_t *editor_x_map;

View File

@ -198,14 +198,18 @@ edit_init_menu (struct WMenuBar *menubar)
static void static void
edit_drop_menu_cmd (WEdit *e, int which) edit_drop_menu_cmd (WEdit *e, int which)
{ {
if (!edit_menubar->is_active) { WMenuBar *menubar;
edit_menubar->is_active = TRUE;
edit_menubar->is_dropped = (drop_menus != 0);
if (which >= 0)
edit_menubar->selected = which;
edit_menubar->previous_widget = e->widget.parent->current->dlg_id; menubar = find_menubar (e->widget.parent);
dlg_select_widget (edit_menubar);
if (!menubar->is_active) {
menubar->is_active = TRUE;
menubar->is_dropped = (drop_menus != 0);
if (which >= 0)
menubar->selected = which;
menubar->previous_widget = e->widget.parent->current->dlg_id;
dlg_select_widget (menubar);
} }
} }

View File

@ -52,8 +52,6 @@
#include "src/menu.h" /* menubar_new() */ #include "src/menu.h" /* menubar_new() */
#include "src/cmddef.h" #include "src/cmddef.h"
struct WMenuBar *edit_menubar;
int column_highlighting = 0; int column_highlighting = 0;
static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm); static cb_ret_t edit_callback (Widget *, widget_msg_t msg, int parm);
@ -87,8 +85,13 @@ edit_event (Gpm_Event *event, void *data)
return MOU_NORMAL; return MOU_NORMAL;
/* rest of the upper frame, the menu is invisible - call menu */ /* rest of the upper frame, the menu is invisible - call menu */
if ((event->type & GPM_DOWN) && (event->y == 1)) if ((event->type & GPM_DOWN) && (event->y == 1)) {
return edit_menubar->widget.mouse (event, edit_menubar); WMenuBar *menubar;
menubar = find_menubar (edit->widget.parent);
return menubar->widget.mouse (event, menubar);
}
edit_update_curs_row (edit); edit_update_curs_row (edit);
edit_update_curs_col (edit); edit_update_curs_col (edit);
@ -231,6 +234,7 @@ edit_file (const char *_file, int line)
static gboolean made_directory = FALSE; static gboolean made_directory = FALSE;
Dlg_head *edit_dlg; Dlg_head *edit_dlg;
WEdit *wedit; WEdit *wedit;
WMenuBar *menubar;
if (!made_directory) { if (!made_directory) {
char *dir = concat_dir_and_file (home_dir, EDIT_DIR); char *dir = concat_dir_and_file (home_dir, EDIT_DIR);
@ -249,9 +253,9 @@ edit_file (const char *_file, int line)
"[Internal File Editor]", NULL, DLG_WANT_TAB); "[Internal File Editor]", NULL, DLG_WANT_TAB);
edit_dlg->get_shortcut = edit_get_shortcut; edit_dlg->get_shortcut = edit_get_shortcut;
edit_menubar = menubar_new (0, 0, COLS, NULL); menubar = menubar_new (0, 0, COLS, NULL);
add_widget (edit_dlg, edit_menubar); add_widget (edit_dlg, menubar);
edit_init_menu (edit_menubar); edit_init_menu (menubar);
init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS, init_widget (&(wedit->widget), 0, 0, LINES - 1, COLS,
edit_callback, edit_event); edit_callback, edit_event);