mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
api/cursor_style_set: mode descriptions
This commit is contained in:
@@ -13,35 +13,25 @@
|
||||
/// Handling of cursor and mouse pointer shapes in various modes.
|
||||
static cursorentry_T shape_table[SHAPE_IDX_COUNT] =
|
||||
{
|
||||
// The values will be filled in from the 'guicursor' and 'mouseshape'
|
||||
// defaults when Vim starts.
|
||||
// Adjust the SHAPE_IDX_ defines when making changes!
|
||||
{ "normal",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "visual",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "insert",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "replace",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmd_normal",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmd_insert", 0,
|
||||
0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmd_replace",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "pending",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "visual_select",
|
||||
0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmd_line", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE },
|
||||
{ "statusline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE },
|
||||
{ "drag_statusline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE },
|
||||
{ "vsep", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE },
|
||||
{ "vdrag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE },
|
||||
// Values are set by 'guicursor' and 'mouseshape'.
|
||||
// Adjust the SHAPE_IDX_ defines when changing this!
|
||||
{ "normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "visual", 0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmdline_normal", 0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmdline_insert", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmdline_replace", 0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "operator", 0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "visual_select", 0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE },
|
||||
{ "cmdline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE },
|
||||
{ "statusline_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE },
|
||||
{ "statusline_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE },
|
||||
{ "vsep_hover", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE },
|
||||
{ "vsep_drag", 0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE },
|
||||
{ "more", 0, 0, 0, 0L, 0L, 0L, 0, 0, "m", SHAPE_MOUSE },
|
||||
{ "more_lastline", 0, 0, 0, 0L, 0L, 0L, 0, 0, "ml", SHAPE_MOUSE },
|
||||
{ "match_paren", 0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR },
|
||||
{ "showmatch", 0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR },
|
||||
};
|
||||
|
||||
/// Converts cursor_shapes into a Dictionary of dictionaries
|
||||
|
@@ -14,9 +14,9 @@ SHAPE_IDX_CR = 6, ///< Command line Replace mode
|
||||
SHAPE_IDX_O = 7, ///< Operator-pending mode
|
||||
SHAPE_IDX_VE = 8, ///< Visual mode with 'selection' exclusive
|
||||
SHAPE_IDX_CLINE = 9, ///< On command line
|
||||
SHAPE_IDX_STATUS = 10, ///< status line
|
||||
SHAPE_IDX_STATUS = 10, ///< On status line
|
||||
SHAPE_IDX_SDRAG = 11, ///< dragging a status line
|
||||
SHAPE_IDX_VSEP = 12, ///< A vertical separator line
|
||||
SHAPE_IDX_VSEP = 12, ///< On vertical separator line
|
||||
SHAPE_IDX_VDRAG = 13, ///< dragging a vertical separator line
|
||||
SHAPE_IDX_MORE = 14, ///< Hit-return or More
|
||||
SHAPE_IDX_MOREL = 15, ///< Hit-return or More in last line
|
||||
|
@@ -487,7 +487,7 @@ static void tui_cursor_style_set(UI *ui, Dictionary args)
|
||||
data->cursor_shapes[mode_id] = r;
|
||||
}
|
||||
|
||||
// force redrawal
|
||||
// force redraw
|
||||
MouseMode cursor_mode = tui_mode2cursor(data->showing_mode);
|
||||
tui_set_cursor(ui, cursor_mode);
|
||||
}
|
||||
|
@@ -5,8 +5,6 @@ local insert, execute = helpers.insert, helpers.execute
|
||||
local eq, funcs = helpers.eq, helpers.funcs
|
||||
local command = helpers.command
|
||||
|
||||
if helpers.pending_win32(pending) then return end
|
||||
|
||||
describe('ui/cursor', function()
|
||||
local screen
|
||||
|
||||
@@ -24,7 +22,10 @@ describe('ui/cursor', function()
|
||||
command('redraw')
|
||||
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
|
||||
local expected_cursor_style = {
|
||||
cmd_insert = {
|
||||
cmdline_hover = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'e' },
|
||||
cmdline_insert = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
blinkwait = 700,
|
||||
@@ -34,10 +35,7 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'ci' },
|
||||
cmd_line = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'e' },
|
||||
cmd_normal = {
|
||||
cmdline_normal = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
blinkwait = 700,
|
||||
@@ -47,7 +45,7 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'c' },
|
||||
cmd_replace = {
|
||||
cmdline_replace = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
blinkwait = 700,
|
||||
@@ -57,9 +55,6 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'cr' },
|
||||
drag_statusline = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'sd' },
|
||||
insert = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
@@ -70,15 +65,6 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'i' },
|
||||
match_paren = {
|
||||
blinkoff = 150,
|
||||
blinkon = 175,
|
||||
blinkwait = 175,
|
||||
cell_percentage = 0,
|
||||
cursor_shape = 'block',
|
||||
hl_id = 45,
|
||||
id_lm = 45,
|
||||
short_name = 'sm' },
|
||||
more = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'm' },
|
||||
@@ -95,7 +81,7 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'n' },
|
||||
pending = {
|
||||
operator = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
blinkwait = 700,
|
||||
@@ -115,12 +101,21 @@ describe('ui/cursor', function()
|
||||
id_lm = 46,
|
||||
mouse_shape = 0,
|
||||
short_name = 'r' },
|
||||
statusline = {
|
||||
showmatch = {
|
||||
blinkoff = 150,
|
||||
blinkon = 175,
|
||||
blinkwait = 175,
|
||||
cell_percentage = 0,
|
||||
cursor_shape = 'block',
|
||||
hl_id = 45,
|
||||
id_lm = 45,
|
||||
short_name = 'sm' },
|
||||
statusline_drag = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'sd' },
|
||||
statusline_hover = {
|
||||
mouse_shape = 0,
|
||||
short_name = 's' },
|
||||
vdrag = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'vd' },
|
||||
visual = {
|
||||
blinkoff = 250,
|
||||
blinkon = 400,
|
||||
@@ -141,7 +136,10 @@ describe('ui/cursor', function()
|
||||
id_lm = 45,
|
||||
mouse_shape = 0,
|
||||
short_name = 've' },
|
||||
vsep = {
|
||||
vsep_drag = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'vd' },
|
||||
vsep_hover = {
|
||||
mouse_shape = 0,
|
||||
short_name = 'vs' }
|
||||
}
|
||||
@@ -161,19 +159,23 @@ describe('ui/cursor', function()
|
||||
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
|
||||
eq('vertical', screen._cursor_style.normal.cursor_shape)
|
||||
eq('horizontal', screen._cursor_style.visual_select.cursor_shape)
|
||||
eq('vertical', screen._cursor_style.pending.cursor_shape)
|
||||
eq('vertical', screen._cursor_style.operator.cursor_shape)
|
||||
eq('block', screen._cursor_style.insert.cursor_shape)
|
||||
eq('vertical', screen._cursor_style.match_paren.cursor_shape)
|
||||
eq('vertical', screen._cursor_style.showmatch.cursor_shape)
|
||||
eq(171, screen._cursor_style.normal.blinkwait)
|
||||
eq(172, screen._cursor_style.normal.blinkoff)
|
||||
eq(173, screen._cursor_style.normal.blinkon)
|
||||
end)
|
||||
|
||||
it("empty 'guicursor' sets cursor_shape=block in all modes", function()
|
||||
meths.set_option('guicursor', '')
|
||||
command('redraw')
|
||||
screen:expect('', nil, nil, nil, true) -- Tickle the event-loop.
|
||||
for _, m in ipairs({ 'cmd_insert', 'cmd_normal', 'cmd_replace', 'insert',
|
||||
'match_paren', 'normal', 'replace', 'visual',
|
||||
for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert',
|
||||
'showmatch', 'normal', 'replace', 'visual',
|
||||
'visual_select', }) do
|
||||
eq('block', screen._cursor_style[m].cursor_shape)
|
||||
eq(0, screen._cursor_style[m].blinkon)
|
||||
end
|
||||
end)
|
||||
|
||||
|
@@ -313,8 +313,8 @@ function Screen:_redraw(updates)
|
||||
if handler ~= nil then
|
||||
handler(self, unpack(update[i]))
|
||||
else
|
||||
assert(self._on_event, "Either add an Screen:_handle_XXX method "..
|
||||
" or call Screen:set_on_event_handler")
|
||||
assert(self._on_event,
|
||||
"Add Screen:_handle_XXX method or call Screen:set_on_event_handler")
|
||||
self._on_event(method, update[i])
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user