Mercurial > vim
annotate src/testdir/view_util.vim @ 32190:73489b6c4a02 v9.0.1426
patch 9.0.1426: indent wrong after "export namespace" in C++
Commit: https://github.com/vim/vim/commit/99e4ab2a1e577ddb29030c09c308b67e16fd51c4
Author: Virginia Senioria <91khr@users.noreply.github.com>
Date: Fri Mar 24 19:25:06 2023 +0000
patch 9.0.1426: indent wrong after "export namespace" in C++
Problem: Indent wrong after "export namespace" in C++.
Solution: Skip over "inline" and "export" in any order. (Virginia Senioria,
closes #12134, closes #12133)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 24 Mar 2023 20:30:04 +0100 |
parents | 9fc3b3928ad5 |
children | a20bd67056d7 |
rev | line source |
---|---|
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Functions about view shared by several tests |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
12580
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
3 " Only load this script once. |
17164
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
4 if exists('*Screenline') |
12580
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
5 finish |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
6 endif |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
7 |
17164
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
8 " Get line "lnum" as displayed on the screen. |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
9 " Trailing white space is trimmed. |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
10 func Screenline(lnum) |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
11 let chars = [] |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
12 for c in range(1, winwidth(0)) |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
13 call add(chars, nr2char(screenchar(a:lnum, c))) |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
14 endfor |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
15 let line = join(chars, '') |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
16 return matchstr(line, '^.\{-}\ze\s*$') |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
17 endfunc |
7927cf327396
patch 8.1.1581: shared functions for testing are disorganised
Bram Moolenaar <Bram@vim.org>
parents:
16148
diff
changeset
|
18 |
16148
90b0f2227d73
patch 8.1.1079: no need for a separate ScreenLinesUtf8() test function
Bram Moolenaar <Bram@vim.org>
parents:
16133
diff
changeset
|
19 " Get text on the screen, including composing characters. |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 " ScreenLines(lnum, width) or |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " ScreenLines([start, end], width) |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
22 func ScreenLines(lnum, width) abort |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 redraw! |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 if type(a:lnum) == v:t_list |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 let start = a:lnum[0] |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 let end = a:lnum[1] |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 else |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let start = a:lnum |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 let end = a:lnum |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 endif |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 let lines = [] |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 for l in range(start, end) |
16133
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
12580
diff
changeset
|
33 let lines += [join(map(range(1, a:width), 'screenstring(l, v:val)'), '')] |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
12580
diff
changeset
|
34 endfor |
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
12580
diff
changeset
|
35 return lines |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
36 endfunc |
16133
eb087f8a26a8
patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents:
12580
diff
changeset
|
37 |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
38 func ScreenAttrs(lnum, width) abort |
12580
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
39 redraw! |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
40 if type(a:lnum) == v:t_list |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
41 let start = a:lnum[0] |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
42 let end = a:lnum[1] |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
43 else |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
44 let start = a:lnum |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
45 let end = a:lnum |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
46 endif |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
47 let attrs = [] |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
48 for l in range(start, end) |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
49 let attrs += [map(range(1, a:width), 'screenattr(l, v:val)')] |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
50 endfor |
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
51 return attrs |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
52 endfunc |
12580
ba55861aa52c
patch 8.0.1168: wrong highlighting with combination of match and 'cursorline'
Christian Brabandt <cb@256bit.org>
parents:
10843
diff
changeset
|
53 |
31906
9fc3b3928ad5
patch 9.0.1285: various small problems
Bram Moolenaar <Bram@vim.org>
parents:
31303
diff
changeset
|
54 " Create a new window with the requested size and fix it. |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
55 func NewWindow(height, width) abort |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 exe a:height . 'new' |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 exe a:width . 'vsp' |
18131
851a014dfd8b
patch 8.1.2060: "precedes" in 'listchars' not used properly
Bram Moolenaar <Bram@vim.org>
parents:
17164
diff
changeset
|
58 set winfixwidth winfixheight |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 redraw! |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
60 endfunc |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
62 func CloseWindow() abort |
10843
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 bw! |
678edb254216
patch 8.0.0311: linebreak tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 redraw! |
30687
f936d46cc9c1
patch 9.0.0678: using exclamation marks on :function
Bram Moolenaar <Bram@vim.org>
parents:
18131
diff
changeset
|
65 endfunc |
31247
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
66 |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
67 |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
68 " When using RunVimInTerminal() we expect modifyOtherKeys level 2 to be enabled |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
69 " automatically. The key + modifier Escape codes must then use the |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
70 " modifyOtherKeys encoding. They are recognized anyway, thus it's safer to use |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
71 " than the raw code. |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
72 |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
73 " Return the modifyOtherKeys level 2 encoding for "key" with "modifier" |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
74 " (number value, e.g. CTRL is 5). |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
75 func GetEscCodeCSI27(key, modifier) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
76 let key = printf("%d", char2nr(a:key)) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
77 let mod = printf("%d", a:modifier) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
78 return "\<Esc>[27;" .. mod .. ';' .. key .. '~' |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
79 endfunc |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
80 |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
81 " Return the modifyOtherKeys level 2 encoding for "key" with "modifier" |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
82 " (character value, e.g. CTRL is "C"). |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
83 func GetEscCodeWithModifier(modifier, key) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
84 let modifier = get({'C': 5}, a:modifier, '') |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
85 if modifier == '' |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
86 echoerr 'Unknown modifier: ' .. a:modifier |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
87 endif |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
88 return GetEscCodeCSI27(a:key, modifier) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
89 endfunc |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
90 |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
91 " Return the kitty keyboard protocol encoding for "key" with "modifier" |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
92 " (number value, e.g. CTRL is 5). |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
93 func GetEscCodeCSIu(key, modifier) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
94 let key = printf("%d", char2nr(a:key)) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
95 let mod = printf("%d", a:modifier) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
96 return "\<Esc>[" .. key .. ';' .. mod .. 'u' |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
97 endfunc |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
98 |
31303
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
99 " Return the kitty keyboard protocol encoding for a function key: |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
100 " CSI {key} |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
101 " CSS 1;{modifier} {key} |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
102 func GetEscCodeFunckey(key, modifier) |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
103 if a:modifier == 0 |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
104 return "\<Esc>[" .. a:key |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
105 endif |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
106 |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
107 let mod = printf("%d", a:modifier) |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
108 return "\<Esc>[1;".. mod .. a:key |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
109 endfunc |
d2107f7b2155
patch 9.0.0985: when using kitty keyboard protocol function keys may not work
Bram Moolenaar <Bram@vim.org>
parents:
31247
diff
changeset
|
110 |
31247
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
111 " Return the kitty keyboard protocol encoding for "key" without a modifier. |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
112 " Used for the Escape key. |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
113 func GetEscCodeCSIuWithoutModifier(key) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
114 let key = printf("%d", char2nr(a:key)) |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
115 return "\<Esc>[" .. key .. 'u' |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
116 endfunc |
a864e75257dd
patch 9.0.0957: tests fail without the terminal feature
Bram Moolenaar <Bram@vim.org>
parents:
30687
diff
changeset
|
117 |