A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/818456470c0ce0d463b0be82e9c35eb77cc65f19 below:

put modifiers back into typeahead buffer when needed · neovim/neovim@8184564 · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+54

-25

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+54

-25

lines changed Original file line number Diff line number Diff line change

@@ -973,27 +973,35 @@ int ins_typebuf(char_u *str, int noremap, int offset, bool nottyped, bool silent

973 973

* Uses cmd_silent, KeyTyped and KeyNoremap to restore the flags belonging to

974 974

* the char.

975 975

*/

976 -

void ins_char_typebuf(int c)

976 +

void ins_char_typebuf(int c, int modifier)

977 977

{

978 -

char_u buf[MB_MAXBYTES + 1];

979 -

if (IS_SPECIAL(c)) {

978 +

char_u buf[MB_MAXBYTES + 4];

979 +

int idx = 0;

980 +

if (modifier != 0) {

980 981

buf[0] = K_SPECIAL;

981 -

buf[1] = (char_u)K_SECOND(c);

982 -

buf[2] = (char_u)K_THIRD(c);

982 +

buf[1] = KS_MODIFIER;

983 +

buf[2] = (char_u)modifier;

983 984

buf[3] = NUL;

985 +

idx = 3;

986 +

}

987 +

if (IS_SPECIAL(c)) {

988 +

buf[idx] = K_SPECIAL;

989 +

buf[idx + 1] = (char_u)K_SECOND(c);

990 +

buf[idx + 2] = (char_u)K_THIRD(c);

991 +

buf[idx + 3] = NUL;

984 992

} else {

985 -

buf[utf_char2bytes(c, buf)] = NUL;

986 -

char_u *p = buf;

987 -

while (*p) {

993 +

char_u *p = buf + idx;

994 +

int char_len = utf_char2bytes(c, p);

995 +

// If the character contains K_SPECIAL bytes they need escaping.

996 +

for (int i = char_len; --i >= 0; p++) {

988 997

if ((uint8_t)(*p) == K_SPECIAL) {

989 -

memmove(p + 3, p + 1, STRLEN(p + 1) + 1);

998 +

memmove(p + 3, p + 1, (size_t)i);

990 999

*p++ = K_SPECIAL;

991 1000

*p++ = KS_SPECIAL;

992 -

*p++ = KE_FILLER;

993 -

} else {

994 -

p++;

1001 +

*p = KE_FILLER;

995 1002

}

996 1003

}

1004 +

*p = NUL;

997 1005

}

998 1006

(void)ins_typebuf(buf, KeyNoremap, 0, !KeyTyped, cmd_silent);

999 1007

}

@@ -1433,8 +1441,9 @@ int vgetc(void)

1433 1441

mouse_row = old_mouse_row;

1434 1442

mouse_col = old_mouse_col;

1435 1443

} else {

1436 -

mod_mask = 0x0;

1444 +

mod_mask = 0;

1437 1445

last_recorded_len = 0;

1446 + 1438 1447

for (;;) { // this is done twice if there are modifiers

1439 1448

bool did_inc = false;

1440 1449

if (mod_mask) { // no mapping after modifier has been read

@@ -1560,8 +1569,8 @@ int vgetc(void)

1560 1569

if (!no_mapping && KeyTyped && !(State & TERM_FOCUS)

1561 1570

&& (mod_mask == MOD_MASK_ALT || mod_mask == MOD_MASK_META)) {

1562 1571

mod_mask = 0;

1563 -

ins_char_typebuf(c);

1564 -

ins_char_typebuf(ESC);

1572 +

ins_char_typebuf(c, 0);

1573 +

ins_char_typebuf(ESC, 0);

1565 1574

continue;

1566 1575

}

1567 1576 Original file line number Diff line number Diff line change

@@ -127,7 +127,7 @@ typedef off_t off_T;

127 127 128 128

// When vgetc() is called, it sets mod_mask to the set of modifiers that are

129 129

// held down based on the MOD_MASK_* symbols that are read first.

130 -

EXTERN int mod_mask INIT(= 0x0); // current key modifiers

130 +

EXTERN int mod_mask INIT(= 0); // current key modifiers

131 131 132 132 133 133

// Cmdline_row is the row where the command line starts, just below the

Original file line number Diff line number Diff line change

@@ -1215,7 +1215,7 @@ void wait_return(int redraw)

1215 1215

} else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) {

1216 1216

// Put the character back in the typeahead buffer. Don't use the

1217 1217

// stuff buffer, because lmaps wouldn't work.

1218 -

ins_char_typebuf(c);

1218 +

ins_char_typebuf(c, mod_mask);

1219 1219

do_redraw = true; // need a redraw even though there is

1220 1220

// typeahead

1221 1221

}

@@ -3497,7 +3497,7 @@ int do_dialog(int type, char_u *title, char_u *message, char_u *buttons, int dfl

3497 3497

}

3498 3498

if (c == ':' && ex_cmd) {

3499 3499

retval = dfltbutton;

3500 -

ins_char_typebuf(':');

3500 +

ins_char_typebuf(':', 0);

3501 3501

break;

3502 3502

}

3503 3503 Original file line number Diff line number Diff line change

@@ -1010,7 +1010,7 @@ static int normal_execute(VimState *state, int key)

1010 1010

// restart automatically.

1011 1011

// Insert the typed character in the typeahead buffer, so that it can

1012 1012

// be mapped in Insert mode. Required for ":lmap" to work.

1013 -

ins_char_typebuf(s->c);

1013 +

ins_char_typebuf(s->c, mod_mask);

1014 1014

if (restart_edit != 0) {

1015 1015

s->c = 'd';

1016 1016

} else {

Original file line number Diff line number Diff line change

@@ -1299,7 +1299,7 @@ static bool send_mouse_event(Terminal *term, int c)

1299 1299

}

1300 1300 1301 1301

end:

1302 -

ins_char_typebuf(c);

1302 +

ins_char_typebuf(c, mod_mask);

1303 1303

return true;

1304 1304

}

1305 1305 Original file line number Diff line number Diff line change

@@ -1,7 +1,7 @@

1 1

local helpers = require('test.functional.helpers')(after_each)

2 2

local thelpers = require('test.functional.terminal.helpers')

3 3

local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval

4 -

local feed, nvim = helpers.feed, helpers.nvim

4 +

local feed, nvim, command = helpers.feed, helpers.nvim, helpers.command

5 5

local feed_data = thelpers.feed_data

6 6 7 7

describe(':terminal mouse', function()

@@ -10,9 +10,9 @@ describe(':terminal mouse', function()

10 10

before_each(function()

11 11

clear()

12 12

nvim('set_option', 'statusline', '==========')

13 -

nvim('command', 'highlight StatusLine cterm=NONE')

14 -

nvim('command', 'highlight StatusLineNC cterm=NONE')

15 -

nvim('command', 'highlight VertSplit cterm=NONE')

13 +

command('highlight StatusLine cterm=NONE')

14 +

command('highlight StatusLineNC cterm=NONE')

15 +

command('highlight VertSplit cterm=NONE')

16 16

screen = thelpers.screen_setup()

17 17

local lines = {}

18 18

for i = 1, 30 do

@@ -38,6 +38,26 @@ describe(':terminal mouse', function()

38 38

eq('nt', eval('mode(1)'))

39 39

end)

40 40 41 +

it('will exit focus and trigger Normal mode mapping on mouse click', function()

42 +

command('let g:got_leftmouse = 0')

43 +

command('nnoremap <LeftMouse> <Cmd>let g:got_leftmouse = 1<CR>')

44 +

eq('t', eval('mode(1)'))

45 +

eq(0, eval('g:got_leftmouse'))

46 +

feed('<LeftMouse>')

47 +

eq('nt', eval('mode(1)'))

48 +

eq(1, eval('g:got_leftmouse'))

49 +

end)

50 + 51 +

it('will exit focus and trigger Normal mode mapping on mouse click with modifier', function()

52 +

command('let g:got_ctrl_leftmouse = 0')

53 +

command('nnoremap <C-LeftMouse> <Cmd>let g:got_ctrl_leftmouse = 1<CR>')

54 +

eq('t', eval('mode(1)'))

55 +

eq(0, eval('g:got_ctrl_leftmouse'))

56 +

feed('<C-LeftMouse>')

57 +

eq('nt', eval('mode(1)'))

58 +

eq(1, eval('g:got_ctrl_leftmouse'))

59 +

end)

60 + 41 61

it('will exit focus on <C-\\> + mouse-scroll', function()

42 62

eq('t', eval('mode(1)'))

43 63

feed('<C-\\>')

@@ -180,7 +200,7 @@ describe(':terminal mouse', function()

180 200 181 201

it('will forward mouse clicks to the program with the correct even if set nu', function()

182 202

if helpers.pending_win32(pending) then return end

183 -

nvim('command', 'set number')

203 +

command('set number')

184 204

-- When the display area such as a number is clicked, it returns to the

185 205

-- normal mode.

186 206

feed('<LeftMouse><3,0>')

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4