diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-11-25 08:56:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-25 08:56:42 -0800 |
commit | 36d1335a667d54c26ab7cca23bc60998cb8e0fb2 (patch) | |
tree | af85eb985ad73cad656b3b16221fde95bcbc0f68 /src | |
parent | 4a77df2e518a51ffd5a5fe311424b4b5305009a7 (diff) | |
download | rneovim-36d1335a667d54c26ab7cca23bc60998cb8e0fb2.tar.gz rneovim-36d1335a667d54c26ab7cca23bc60998cb8e0fb2.tar.bz2 rneovim-36d1335a667d54c26ab7cca23bc60998cb8e0fb2.zip |
UI: emit mouse_on/mouse_off on attach #11455
closes #11372
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mouse.c | 29 | ||||
-rw-r--r-- | src/nvim/option.c | 7 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index d0aa0653cb..deb7ee6342 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -508,31 +508,30 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp) return NULL; } -/* - * setmouse() - switch mouse on/off depending on current mode and 'mouse' - */ +/// Set UI mouse depending on current mode and 'mouse'. +/// +/// Emits mouse_on/mouse_off UI event (unless 'mouse' is empty). void setmouse(void) { - int checkfor; - ui_cursor_shape(); - /* be quick when mouse is off */ - if (*p_mouse == NUL) + // Be quick when mouse is off. + if (*p_mouse == NUL) { return; + } - if (VIsual_active) + int checkfor = MOUSE_NORMAL; // assume normal mode + if (VIsual_active) { checkfor = MOUSE_VISUAL; - else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) + } else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) { checkfor = MOUSE_RETURN; - else if (State & INSERT) + } else if (State & INSERT) { checkfor = MOUSE_INSERT; - else if (State & CMDLINE) + } else if (State & CMDLINE) { checkfor = MOUSE_COMMAND; - else if (State == CONFIRM || State == EXTERNCMD) - checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */ - else - checkfor = MOUSE_NORMAL; /* assume normal mode */ + } else if (State == CONFIRM || State == EXTERNCMD) { + checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd" + } if (mouse_has(checkfor)) { ui_call_mouse_on(); diff --git a/src/nvim/option.c b/src/nvim/option.c index 20351d3908..7c830da981 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5173,6 +5173,13 @@ void ui_refresh_options(void) } ui_call_option_set(name, value); } + if (p_mouse != NULL) { + if (*p_mouse == NUL) { + ui_call_mouse_off(); + } else { + setmouse(); + } + } } /* |