mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
4a77df2e51
commit
36d1335a66
@ -349,8 +349,8 @@ External UIs are expected to implement these common features:
|
|||||||
chords (<C-,> <C-Enter> <C-S-x> <D-x>) and patterns ("shift shift") that do
|
chords (<C-,> <C-Enter> <C-S-x> <D-x>) and patterns ("shift shift") that do
|
||||||
not potentially conflict with Nvim defaults, plugins, etc.
|
not potentially conflict with Nvim defaults, plugins, etc.
|
||||||
- Consider the "option_set" |ui-global| event as a hint for other GUI
|
- Consider the "option_set" |ui-global| event as a hint for other GUI
|
||||||
behaviors. UI-related options ('guifont', 'ambiwidth', …) are published in
|
behaviors. Various UI-related options ('guifont', 'ambiwidth', …) are
|
||||||
this event.
|
published in this event. See also "mouse_on", "mouse_off".
|
||||||
|
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -201,8 +201,8 @@ the editor.
|
|||||||
sent from Nvim, like for |ui-cmdline|.
|
sent from Nvim, like for |ui-cmdline|.
|
||||||
|
|
||||||
["mode_change", mode, mode_idx]
|
["mode_change", mode, mode_idx]
|
||||||
The mode changed. The first parameter `mode` is a string representing
|
Editor mode changed. The `mode` parameter is a string representing
|
||||||
the current mode. `mode_idx` is an index into the array received in
|
the current mode. `mode_idx` is an index into the array emitted in
|
||||||
the `mode_info_set` event. UIs should change the cursor style
|
the `mode_info_set` event. UIs should change the cursor style
|
||||||
according to the properties specified in the corresponding item. The
|
according to the properties specified in the corresponding item. The
|
||||||
set of modes reported will change in new versions of Nvim, for
|
set of modes reported will change in new versions of Nvim, for
|
||||||
@ -211,11 +211,11 @@ the editor.
|
|||||||
|
|
||||||
["mouse_on"]
|
["mouse_on"]
|
||||||
["mouse_off"]
|
["mouse_off"]
|
||||||
Tells the client whether mouse support, as determined by |'mouse'|
|
|'mouse'| was enabled/disabled in the current editor mode. Useful for
|
||||||
option, is considered to be active in the current mode. This is mostly
|
a terminal UI, or other situations where Nvim mouse would conflict
|
||||||
useful for a terminal frontend, or other situations where Nvim mouse
|
with other usages of the mouse. UIs may ignore this and always send
|
||||||
would conflict with other usages of the mouse. It is safe for a client
|
mouse input, because 'mouse' decides the behavior of |nvim_input()|
|
||||||
to ignore this and always send mouse events.
|
implicitly.
|
||||||
|
|
||||||
["busy_start"]
|
["busy_start"]
|
||||||
["busy_stop"]
|
["busy_stop"]
|
||||||
|
@ -508,31 +508,30 @@ static win_T *mouse_find_grid_win(int *gridp, int *rowp, int *colp)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Set UI mouse depending on current mode and 'mouse'.
|
||||||
* setmouse() - switch mouse on/off depending on current mode and 'mouse'
|
///
|
||||||
*/
|
/// Emits mouse_on/mouse_off UI event (unless 'mouse' is empty).
|
||||||
void setmouse(void)
|
void setmouse(void)
|
||||||
{
|
{
|
||||||
int checkfor;
|
|
||||||
|
|
||||||
ui_cursor_shape();
|
ui_cursor_shape();
|
||||||
|
|
||||||
/* be quick when mouse is off */
|
// Be quick when mouse is off.
|
||||||
if (*p_mouse == NUL)
|
if (*p_mouse == NUL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (VIsual_active)
|
int checkfor = MOUSE_NORMAL; // assume normal mode
|
||||||
|
if (VIsual_active) {
|
||||||
checkfor = MOUSE_VISUAL;
|
checkfor = MOUSE_VISUAL;
|
||||||
else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE)
|
} else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE) {
|
||||||
checkfor = MOUSE_RETURN;
|
checkfor = MOUSE_RETURN;
|
||||||
else if (State & INSERT)
|
} else if (State & INSERT) {
|
||||||
checkfor = MOUSE_INSERT;
|
checkfor = MOUSE_INSERT;
|
||||||
else if (State & CMDLINE)
|
} else if (State & CMDLINE) {
|
||||||
checkfor = MOUSE_COMMAND;
|
checkfor = MOUSE_COMMAND;
|
||||||
else if (State == CONFIRM || State == EXTERNCMD)
|
} else if (State == CONFIRM || State == EXTERNCMD) {
|
||||||
checkfor = ' '; /* don't use mouse for ":confirm" or ":!cmd" */
|
checkfor = ' '; // don't use mouse for ":confirm" or ":!cmd"
|
||||||
else
|
}
|
||||||
checkfor = MOUSE_NORMAL; /* assume normal mode */
|
|
||||||
|
|
||||||
if (mouse_has(checkfor)) {
|
if (mouse_has(checkfor)) {
|
||||||
ui_call_mouse_on();
|
ui_call_mouse_on();
|
||||||
|
@ -5173,6 +5173,13 @@ void ui_refresh_options(void)
|
|||||||
}
|
}
|
||||||
ui_call_option_set(name, value);
|
ui_call_option_set(name, value);
|
||||||
}
|
}
|
||||||
|
if (p_mouse != NULL) {
|
||||||
|
if (*p_mouse == NUL) {
|
||||||
|
ui_call_mouse_off();
|
||||||
|
} else {
|
||||||
|
setmouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5,7 +5,7 @@ local command = helpers.command
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
local shallowcopy = helpers.shallowcopy
|
local shallowcopy = helpers.shallowcopy
|
||||||
|
|
||||||
describe('ui receives option updates', function()
|
describe('UI receives option updates', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
local function reset(opts, ...)
|
local function reset(opts, ...)
|
||||||
@ -47,6 +47,33 @@ describe('ui receives option updates', function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('on attach #11372', function()
|
||||||
|
clear()
|
||||||
|
local evs = {}
|
||||||
|
screen = Screen.new(20,5)
|
||||||
|
-- Override mouse_on/mouse_off handlers.
|
||||||
|
function screen._handle_mouse_on()
|
||||||
|
table.insert(evs, 'mouse_on')
|
||||||
|
end
|
||||||
|
function screen._handle_mouse_off()
|
||||||
|
table.insert(evs, 'mouse_off')
|
||||||
|
end
|
||||||
|
screen:attach()
|
||||||
|
screen:expect(function()
|
||||||
|
eq({'mouse_off'}, evs)
|
||||||
|
end)
|
||||||
|
command("set mouse=nvi")
|
||||||
|
screen:expect(function()
|
||||||
|
eq({'mouse_off','mouse_on'}, evs)
|
||||||
|
end)
|
||||||
|
screen:detach()
|
||||||
|
eq({'mouse_off','mouse_on'}, evs)
|
||||||
|
screen:attach()
|
||||||
|
screen:expect(function()
|
||||||
|
eq({'mouse_off','mouse_on','mouse_on'}, evs)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
it("when setting options", function()
|
it("when setting options", function()
|
||||||
local expected = reset()
|
local expected = reset()
|
||||||
local defaults = shallowcopy(expected)
|
local defaults = shallowcopy(expected)
|
||||||
|
Loading…
Reference in New Issue
Block a user