Mercurial > vim
annotate src/create_cmdidxs.vim @ 34219:a0a4a774117b v9.1.0058
patch 9.1.0058: Cannot map Super Keys in GTK UI
Commit: https://github.com/vim/vim/commit/92e90a1e102825aa9149262cacfc991264db05df
Author: Casey Tucker <dctucker@hotmail.com>
Date: Thu Jan 25 22:44:00 2024 +0100
patch 9.1.0058: Cannot map Super Keys in GTK UI
Problem: Cannot map Super Keys in GTK UI
(Casey Tucker)
Solution: Enable Super Key mappings in GTK using <D-Key>
(Casey Tucker)
As a developer who works in both Mac and Linux using the same keyboard,
it can be frustrating having to remember different key combinations or
having to rely on system utilities to remap keys.
This change allows `<D-z>` `<D-x>` `<D-c>` `<D-v>` etc. to be recognized
by the `map` commands, along with the `<D-S-...>` shifted variants.
```vimrc
if has('gui_gtk')
nnoremap <D-z> u
nnoremap <D-S-Z> <C-r>
vnoremap <D-x> "+d
vnoremap <D-c> "+y
cnoremap <D-v> <C-R>+
inoremap <D-v> <C-o>"+gP
nnoremap <D-v> "+P
vnoremap <D-v> "-d"+P
nnoremap <D-s> :w<CR>
inoremap <D-s> <C-o>:w<CR>
nnoremap <D-w> :q<CR>
nnoremap <D-q> :qa<CR>
nnoremap <D-t> :tabe<CR>
nnoremap <D-S-T> :vs#<CR><C-w>T
nnoremap <D-a> ggVG
vnoremap <D-a> <ESC>ggVG
inoremap <D-a> <ESC>ggVG
nnoremap <D-f> /
nnoremap <D-g> n
nnoremap <D-S-G> N
vnoremap <D-x> "+x
endif
```
closes: #12698
Signed-off-by: Casey Tucker <dctucker@hotmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 25 Jan 2024 23:00:03 +0100 |
parents | 72ce5ca82a75 |
children |
rev | line source |
---|---|
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " This script generates the tables cmdidxs1[] and cmdidxs2[][] which, |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " given a Ex command, determine the first value to probe to find |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " a matching command in cmdnames[] based on the first character |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " and the first 2 characters of the command. |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " This is used to speed up lookup in cmdnames[]. |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " Script should be run every time new Ex commands are added in Vim, |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " from the src/vim directory, since it reads commands from "ex_cmds.h". |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let cmds = [] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 let skipped_cmds = 0 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
13 let lines = readfile('ex_cmds.h') |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
14 let idx = 0 |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
15 while idx < len(lines) |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
16 let line = lines[idx] |
17346
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
17 if line =~ '^EXCMD(CMD_' |
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
18 let m = matchlist(line, '^EXCMD(CMD_\S*,\s*"\([a-z][^"]*\)"') |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 if len(m) >= 2 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 let cmds += [ m[1] ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 else |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 let skipped_cmds += 1 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 endif |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
24 |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
25 let idx += 1 |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
26 let flags = lines[idx] |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
27 let idx += 1 |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
28 let addr_type = lines[idx] |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
29 |
17346
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
30 if flags =~ '\<EX_RANGE\>' |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
31 if addr_type =~ 'ADDR_NONE' |
17346
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
32 echoerr 'ex_cmds.h:' .. (idx - 1) .. ': Using EX_RANGE with ADDR_NONE: ' .. line |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
33 endif |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
34 else |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
35 if addr_type !~ 'ADDR_NONE' |
17346
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
36 echoerr 'ex_cmds.h:' .. (idx - 1) .. ': Missing ADDR_NONE: ' .. line |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
37 endif |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
38 endif |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
39 |
17346
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
40 if flags =~ '\<EX_DFLALL\>' && (addr_type =~ 'ADDR_OTHER' || addr_type =~ 'ADDR_NONE') |
72ce5ca82a75
patch 8.1.1672: "make cmdidxs" doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16475
diff
changeset
|
41 echoerr 'ex_cmds.h:' .. (idx - 1) .. ': Missing misplaced EX_DFLALL: ' .. line |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
42 endif |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 endif |
16475
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
44 let idx += 1 |
854fb0ad4be6
patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents:
11374
diff
changeset
|
45 endwhile |
11374
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 let cmdidxs1 = {} |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 let cmdidxs2 = {} |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 for i in range(len(cmds) - 1, 0, -1) |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 let cmd = cmds[i] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 let c1 = cmd[0] " First character of command |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 let c2 = cmd[1] " Second character of command (if any) |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 let cmdidxs1{c1} = i |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 if c2 >= 'a' && c2 <= 'z' |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 let cmdidxs2{c1}{c2} = i |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 endif |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 endfor |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let output = [ '/* Automatically generated code by create_cmdidxs.vim' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 let output += [ ' *' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 let output += [ ' * Table giving the index of the first command in cmdnames[] to lookup' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 let output += [ ' * based on the first letter of a command.' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 let output += [ ' */' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 let output += [ 'static const unsigned short cmdidxs1[26] =' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 let output += [ '{' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 let a_to_z = map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)') |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 for c1 in a_to_z |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 let line = ' /* ' . c1 . ' */ ' . cmdidxs1{c1} . ((c1 == 'z') ? '' : ',') |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 let output += [ line ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 endfor |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 let output += [ '};' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 let output += [ '' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 let output += [ '/*' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 let output += [ ' * Table giving the index of the first command in cmdnames[] to lookup' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 let output += [ ' * based on the first 2 letters of a command.' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 let output += [ ' * Values in cmdidxs2[c1][c2] are relative to cmdidxs1[c1] so that they' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 let output += [ ' * fit in a byte.' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 let output += [ ' */' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 let output += [ 'static const unsigned char cmdidxs2[26][26] =' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 let output += [ '{ /* a b c d e f g h i j k l m n o p q r s t u v w x y z */' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 for c1 in a_to_z |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 let line = ' /* ' . c1 . ' */ {' |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 for c2 in a_to_z |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 if exists('cmdidxs2{c1}{c2}') |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 let line .= printf('%3d', cmdidxs2{c1}{c2} - cmdidxs1{c1}) |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 else |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 let line .= ' 0' |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 endif |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 let line .= (c2 == 'z') ? '' : ',' |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 endfor |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 let line .= ' }' . ((c1 == 'z') ? '' : ',') |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 let output += [ line ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 endfor |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 let output += [ '};' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 let output += [ '' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 let output += [ 'static const int command_count = ' . (len(cmds) + skipped_cmds) . ';' ] |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 call writefile(output, "ex_cmdidxs.h") |
889da8649221
patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 quit |