Skip to content

Commit

Permalink
MORE CHANGES AFTER REBASE
Browse files Browse the repository at this point in the history
  • Loading branch information
xaizek committed Nov 12, 2022
1 parent 9206f45 commit 1055f51
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/modes/menu.c
Expand Up @@ -108,7 +108,9 @@ static void cmd_zh(key_info_t key_info, keys_info_t *keys_info);
static void cmd_zl(key_info_t key_info, keys_info_t *keys_info);
static void cmd_zt(key_info_t key_info, keys_info_t *keys_info);
static void cmd_zz(key_info_t key_info, keys_info_t *keys_info);
static void mouse_event(key_info_t key_info, keys_info_t *keys_info);
static int all_lines_visible(const menu_data_t *menu);

static int goto_cmd(const cmd_info_t *cmd_info);
static int nohlsearch_cmd(const cmd_info_t *cmd_info);
static int quit_cmd(const cmd_info_t *cmd_info);
Expand Down Expand Up @@ -174,6 +176,7 @@ static keys_add_info_t builtin_cmds[] = {
{{WC_z, K(KEY_LEFT)}, {{&cmd_zh}, .descr = "scroll one column left"}},
{{WC_z, K(KEY_RIGHT)}, {{&cmd_zl}, .descr = "scroll one column right"}},
#endif /* ENABLE_EXTENDED_KEYS */
{{KEY_MOUSE}, {{&mouse_event}, FOLLOWED_BY_NONE}},
};

/* Specification of builtin commands. */
Expand Down Expand Up @@ -1097,5 +1100,40 @@ menu_get_current(void)
return menu;
}

/* Processes events from the mouse. */
static void
mouse_event(key_info_t key_info, keys_info_t *keys_info)
{
MEVENT e;

if(getmouse(&e) != OK)
{
return;
}

if(!wenclose(menu_win, e.y, e.x))
{
return;
}

if(e.bstate & BUTTON1_PRESSED)
{
wmouse_trafo(menu_win, &e.y, &e.x, FALSE);

menus_erase_current(menu->state);
menus_set_pos(menu->state, menu->top + e.y - 1);
ui_refresh_win(menu_win);
}
else if(e.bstate & BUTTON3_RELEASED)
{
wmouse_trafo(menu_win, &e.y, &e.x, FALSE);

menus_erase_current(menu->state);
menus_set_pos(menu->state, menu->top + e.y - 1);
ui_refresh_win(menu_win);

cmd_return(key_info, keys_info);
}
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */
3 changes: 2 additions & 1 deletion src/modes/visual.c
Expand Up @@ -30,6 +30,7 @@
#include "../engine/keys.h"
#include "../engine/mode.h"
#include "../menus/filetypes_menu.h"
#include "../menus/menus.h"
#include "../modes/dialogs/msg_dialog.h"
#include "../ui/fileview.h"
#include "../ui/statusbar.h"
Expand Down Expand Up @@ -1577,7 +1578,7 @@ mouse_event(key_info_t key_info, keys_info_t *keys_info)
{
if(view != &lwin)
{
change_window();
return;
}
}
else if(wenclose(rwin.win, e.y, e.x))
Expand Down

0 comments on commit 1055f51

Please sign in to comment.