Line | Count | Source (jump to first uncovered line) |
1 | | /* $OpenBSD$ */ |
2 | | |
3 | | /* |
4 | | * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> |
5 | | * |
6 | | * Permission to use, copy, modify, and distribute this software for any |
7 | | * purpose with or without fee is hereby granted, provided that the above |
8 | | * copyright notice and this permission notice appear in all copies. |
9 | | * |
10 | | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | | * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER |
15 | | * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
16 | | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | | */ |
18 | | |
19 | | #include <sys/types.h> |
20 | | |
21 | | #include <ctype.h> |
22 | | #include <stdlib.h> |
23 | | #include <string.h> |
24 | | |
25 | | #include "tmux.h" |
26 | | |
27 | | #define DEFAULT_SESSION_MENU \ |
28 | | " 'Next' 'n' {switch-client -n}" \ |
29 | | " 'Previous' 'p' {switch-client -p}" \ |
30 | | " ''" \ |
31 | | " 'Renumber' 'N' {move-window -r}" \ |
32 | | " 'Rename' 'n' {command-prompt -I \"#S\" {rename-session -- '%%'}}" \ |
33 | | " ''" \ |
34 | | " 'New Session' 's' {new-session}" \ |
35 | | " 'New Window' 'w' {new-window}" |
36 | | #define DEFAULT_WINDOW_MENU \ |
37 | | " '#{?#{>:#{session_windows},1},,-}Swap Left' 'l' {swap-window -t:-1}" \ |
38 | | " '#{?#{>:#{session_windows},1},,-}Swap Right' 'r' {swap-window -t:+1}" \ |
39 | | " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-window}" \ |
40 | | " ''" \ |
41 | | " 'Kill' 'X' {kill-window}" \ |
42 | | " 'Respawn' 'R' {respawn-window -k}" \ |
43 | | " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \ |
44 | | " 'Rename' 'n' {command-prompt -FI \"#W\" {rename-window -t '#{window_id}' -- '%%'}}" \ |
45 | | " ''" \ |
46 | | " 'New After' 'w' {new-window -a}" \ |
47 | | " 'New At End' 'W' {new-window}" |
48 | | #define DEFAULT_PANE_MENU \ |
49 | | " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Top,}' '<' {send -X history-top}" \ |
50 | | " '#{?#{m/r:(copy|view)-mode,#{pane_mode}},Go To Bottom,}' '>' {send -X history-bottom}" \ |
51 | | " ''" \ |
52 | | " '#{?mouse_word,Search For #[underscore]#{=/9/...:mouse_word},}' 'C-r' {if -F '#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}' 'copy-mode -t='; send -Xt= search-backward -- \"#{q:mouse_word}\"}" \ |
53 | | " '#{?mouse_word,Type #[underscore]#{=/9/...:mouse_word},}' 'C-y' {copy-mode -q; send-keys -l -- \"#{q:mouse_word}\"}" \ |
54 | | " '#{?mouse_word,Copy #[underscore]#{=/9/...:mouse_word},}' 'c' {copy-mode -q; set-buffer -- \"#{q:mouse_word}\"}" \ |
55 | | " '#{?mouse_line,Copy Line,}' 'l' {copy-mode -q; set-buffer -- \"#{q:mouse_line}\"}" \ |
56 | | " ''" \ |
57 | | " '#{?mouse_hyperlink,Type #[underscore]#{=/9/...:mouse_hyperlink},}' 'C-h' {copy-mode -q; send-keys -l -- \"#{q:mouse_hyperlink}\"}" \ |
58 | | " '#{?mouse_hyperlink,Copy #[underscore]#{=/9/...:mouse_hyperlink},}' 'h' {copy-mode -q; set-buffer -- \"#{q:mouse_hyperlink}\"}" \ |
59 | | " ''" \ |
60 | | " 'Horizontal Split' 'h' {split-window -h}" \ |
61 | | " 'Vertical Split' 'v' {split-window -v}" \ |
62 | | " ''" \ |
63 | | " '#{?#{>:#{window_panes},1},,-}Swap Up' 'u' {swap-pane -U}" \ |
64 | | " '#{?#{>:#{window_panes},1},,-}Swap Down' 'd' {swap-pane -D}" \ |
65 | | " '#{?pane_marked_set,,-}Swap Marked' 's' {swap-pane}" \ |
66 | | " ''" \ |
67 | | " 'Kill' 'X' {kill-pane}" \ |
68 | | " 'Respawn' 'R' {respawn-pane -k}" \ |
69 | | " '#{?pane_marked,Unmark,Mark}' 'm' {select-pane -m}" \ |
70 | | " '#{?#{>:#{window_panes},1},,-}#{?window_zoomed_flag,Unzoom,Zoom}' 'z' {resize-pane -Z}" |
71 | | |
72 | | static int key_bindings_cmp(struct key_binding *, struct key_binding *); |
73 | | RB_GENERATE_STATIC(key_bindings, key_binding, entry, key_bindings_cmp); |
74 | | static int key_table_cmp(struct key_table *, struct key_table *); |
75 | | RB_GENERATE_STATIC(key_tables, key_table, entry, key_table_cmp); |
76 | | static struct key_tables key_tables = RB_INITIALIZER(&key_tables); |
77 | | |
78 | | static int |
79 | | key_table_cmp(struct key_table *table1, struct key_table *table2) |
80 | 0 | { |
81 | 0 | return (strcmp(table1->name, table2->name)); |
82 | 0 | } |
83 | | |
84 | | static int |
85 | | key_bindings_cmp(struct key_binding *bd1, struct key_binding *bd2) |
86 | 0 | { |
87 | 0 | if (bd1->key < bd2->key) |
88 | 0 | return (-1); |
89 | 0 | if (bd1->key > bd2->key) |
90 | 0 | return (1); |
91 | 0 | return (0); |
92 | 0 | } |
93 | | |
94 | | static void |
95 | | key_bindings_free(struct key_binding *bd) |
96 | 0 | { |
97 | 0 | cmd_list_free(bd->cmdlist); |
98 | 0 | free((void *)bd->note); |
99 | 0 | free(bd); |
100 | 0 | } |
101 | | |
102 | | struct key_table * |
103 | | key_bindings_get_table(const char *name, int create) |
104 | 0 | { |
105 | 0 | struct key_table table_find, *table; |
106 | |
|
107 | 0 | table_find.name = name; |
108 | 0 | table = RB_FIND(key_tables, &key_tables, &table_find); |
109 | 0 | if (table != NULL || !create) |
110 | 0 | return (table); |
111 | | |
112 | 0 | table = xmalloc(sizeof *table); |
113 | 0 | table->name = xstrdup(name); |
114 | 0 | RB_INIT(&table->key_bindings); |
115 | 0 | RB_INIT(&table->default_key_bindings); |
116 | |
|
117 | 0 | table->references = 1; /* one reference in key_tables */ |
118 | 0 | RB_INSERT(key_tables, &key_tables, table); |
119 | |
|
120 | 0 | return (table); |
121 | 0 | } |
122 | | |
123 | | struct key_table * |
124 | | key_bindings_first_table(void) |
125 | 0 | { |
126 | 0 | return (RB_MIN(key_tables, &key_tables)); |
127 | 0 | } |
128 | | |
129 | | struct key_table * |
130 | | key_bindings_next_table(struct key_table *table) |
131 | 0 | { |
132 | 0 | return (RB_NEXT(key_tables, &key_tables, table)); |
133 | 0 | } |
134 | | |
135 | | void |
136 | | key_bindings_unref_table(struct key_table *table) |
137 | 0 | { |
138 | 0 | struct key_binding *bd; |
139 | 0 | struct key_binding *bd1; |
140 | |
|
141 | 0 | if (--table->references != 0) |
142 | 0 | return; |
143 | | |
144 | 0 | RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) { |
145 | 0 | RB_REMOVE(key_bindings, &table->key_bindings, bd); |
146 | 0 | key_bindings_free(bd); |
147 | 0 | } |
148 | 0 | RB_FOREACH_SAFE(bd, key_bindings, &table->default_key_bindings, bd1) { |
149 | 0 | RB_REMOVE(key_bindings, &table->default_key_bindings, bd); |
150 | 0 | key_bindings_free(bd); |
151 | 0 | } |
152 | |
|
153 | 0 | free((void *)table->name); |
154 | 0 | free(table); |
155 | 0 | } |
156 | | |
157 | | struct key_binding * |
158 | | key_bindings_get(struct key_table *table, key_code key) |
159 | 0 | { |
160 | 0 | struct key_binding bd; |
161 | |
|
162 | 0 | bd.key = key; |
163 | 0 | return (RB_FIND(key_bindings, &table->key_bindings, &bd)); |
164 | 0 | } |
165 | | |
166 | | struct key_binding * |
167 | | key_bindings_get_default(struct key_table *table, key_code key) |
168 | 0 | { |
169 | 0 | struct key_binding bd; |
170 | |
|
171 | 0 | bd.key = key; |
172 | 0 | return (RB_FIND(key_bindings, &table->default_key_bindings, &bd)); |
173 | 0 | } |
174 | | |
175 | | struct key_binding * |
176 | | key_bindings_first(struct key_table *table) |
177 | 0 | { |
178 | 0 | return (RB_MIN(key_bindings, &table->key_bindings)); |
179 | 0 | } |
180 | | |
181 | | struct key_binding * |
182 | | key_bindings_next(__unused struct key_table *table, struct key_binding *bd) |
183 | 0 | { |
184 | 0 | return (RB_NEXT(key_bindings, &table->key_bindings, bd)); |
185 | 0 | } |
186 | | |
187 | | void |
188 | | key_bindings_add(const char *name, key_code key, const char *note, int repeat, |
189 | | struct cmd_list *cmdlist) |
190 | 0 | { |
191 | 0 | struct key_table *table; |
192 | 0 | struct key_binding *bd; |
193 | 0 | char *s; |
194 | |
|
195 | 0 | table = key_bindings_get_table(name, 1); |
196 | |
|
197 | 0 | bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS); |
198 | 0 | if (cmdlist == NULL) { |
199 | 0 | if (bd != NULL) { |
200 | 0 | if (note != NULL) { |
201 | 0 | free((void *)bd->note); |
202 | 0 | bd->note = xstrdup(note); |
203 | 0 | } |
204 | 0 | if (repeat) |
205 | 0 | bd->flags |= KEY_BINDING_REPEAT; |
206 | 0 | } |
207 | 0 | return; |
208 | 0 | } |
209 | 0 | if (bd != NULL) { |
210 | 0 | RB_REMOVE(key_bindings, &table->key_bindings, bd); |
211 | 0 | key_bindings_free(bd); |
212 | 0 | } |
213 | |
|
214 | 0 | bd = xcalloc(1, sizeof *bd); |
215 | 0 | bd->key = (key & ~KEYC_MASK_FLAGS); |
216 | 0 | if (note != NULL) |
217 | 0 | bd->note = xstrdup(note); |
218 | 0 | RB_INSERT(key_bindings, &table->key_bindings, bd); |
219 | |
|
220 | 0 | if (repeat) |
221 | 0 | bd->flags |= KEY_BINDING_REPEAT; |
222 | 0 | bd->cmdlist = cmdlist; |
223 | |
|
224 | 0 | s = cmd_list_print(bd->cmdlist, 0); |
225 | 0 | log_debug("%s: %#llx %s = %s", __func__, bd->key, |
226 | 0 | key_string_lookup_key(bd->key, 1), s); |
227 | 0 | free(s); |
228 | 0 | } |
229 | | |
230 | | void |
231 | | key_bindings_remove(const char *name, key_code key) |
232 | 0 | { |
233 | 0 | struct key_table *table; |
234 | 0 | struct key_binding *bd; |
235 | |
|
236 | 0 | table = key_bindings_get_table(name, 0); |
237 | 0 | if (table == NULL) |
238 | 0 | return; |
239 | | |
240 | 0 | bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS); |
241 | 0 | if (bd == NULL) |
242 | 0 | return; |
243 | | |
244 | 0 | log_debug("%s: %#llx %s", __func__, bd->key, |
245 | 0 | key_string_lookup_key(bd->key, 1)); |
246 | |
|
247 | 0 | RB_REMOVE(key_bindings, &table->key_bindings, bd); |
248 | 0 | key_bindings_free(bd); |
249 | |
|
250 | 0 | if (RB_EMPTY(&table->key_bindings) && |
251 | 0 | RB_EMPTY(&table->default_key_bindings)) { |
252 | 0 | RB_REMOVE(key_tables, &key_tables, table); |
253 | 0 | key_bindings_unref_table(table); |
254 | 0 | } |
255 | 0 | } |
256 | | |
257 | | void |
258 | | key_bindings_reset(const char *name, key_code key) |
259 | 0 | { |
260 | 0 | struct key_table *table; |
261 | 0 | struct key_binding *bd, *dd; |
262 | |
|
263 | 0 | table = key_bindings_get_table(name, 0); |
264 | 0 | if (table == NULL) |
265 | 0 | return; |
266 | | |
267 | 0 | bd = key_bindings_get(table, key & ~KEYC_MASK_FLAGS); |
268 | 0 | if (bd == NULL) |
269 | 0 | return; |
270 | | |
271 | 0 | dd = key_bindings_get_default(table, bd->key); |
272 | 0 | if (dd == NULL) { |
273 | 0 | key_bindings_remove(name, bd->key); |
274 | 0 | return; |
275 | 0 | } |
276 | | |
277 | 0 | cmd_list_free(bd->cmdlist); |
278 | 0 | bd->cmdlist = dd->cmdlist; |
279 | 0 | bd->cmdlist->references++; |
280 | |
|
281 | 0 | free((void *)bd->note); |
282 | 0 | if (dd->note != NULL) |
283 | 0 | bd->note = xstrdup(dd->note); |
284 | 0 | else |
285 | 0 | bd->note = NULL; |
286 | 0 | bd->flags = dd->flags; |
287 | 0 | } |
288 | | |
289 | | void |
290 | | key_bindings_remove_table(const char *name) |
291 | 0 | { |
292 | 0 | struct key_table *table; |
293 | 0 | struct client *c; |
294 | |
|
295 | 0 | table = key_bindings_get_table(name, 0); |
296 | 0 | if (table != NULL) { |
297 | 0 | RB_REMOVE(key_tables, &key_tables, table); |
298 | 0 | key_bindings_unref_table(table); |
299 | 0 | } |
300 | 0 | TAILQ_FOREACH(c, &clients, entry) { |
301 | 0 | if (c->keytable == table) |
302 | 0 | server_client_set_key_table(c, NULL); |
303 | 0 | } |
304 | 0 | } |
305 | | |
306 | | void |
307 | | key_bindings_reset_table(const char *name) |
308 | 0 | { |
309 | 0 | struct key_table *table; |
310 | 0 | struct key_binding *bd, *bd1; |
311 | |
|
312 | 0 | table = key_bindings_get_table(name, 0); |
313 | 0 | if (table == NULL) |
314 | 0 | return; |
315 | 0 | if (RB_EMPTY(&table->default_key_bindings)) { |
316 | 0 | key_bindings_remove_table(name); |
317 | 0 | return; |
318 | 0 | } |
319 | 0 | RB_FOREACH_SAFE(bd, key_bindings, &table->key_bindings, bd1) |
320 | 0 | key_bindings_reset(name, bd->key); |
321 | 0 | } |
322 | | |
323 | | static enum cmd_retval |
324 | | key_bindings_init_done(__unused struct cmdq_item *item, __unused void *data) |
325 | 0 | { |
326 | 0 | struct key_table *table; |
327 | 0 | struct key_binding *bd, *new_bd; |
328 | |
|
329 | 0 | RB_FOREACH(table, key_tables, &key_tables) { |
330 | 0 | RB_FOREACH(bd, key_bindings, &table->key_bindings) { |
331 | 0 | new_bd = xcalloc(1, sizeof *bd); |
332 | 0 | new_bd->key = bd->key; |
333 | 0 | if (bd->note != NULL) |
334 | 0 | new_bd->note = xstrdup(bd->note); |
335 | 0 | new_bd->flags = bd->flags; |
336 | 0 | new_bd->cmdlist = bd->cmdlist; |
337 | 0 | new_bd->cmdlist->references++; |
338 | 0 | RB_INSERT(key_bindings, &table->default_key_bindings, |
339 | 0 | new_bd); |
340 | 0 | } |
341 | 0 | } |
342 | 0 | return (CMD_RETURN_NORMAL); |
343 | 0 | } |
344 | | |
345 | | void |
346 | | key_bindings_init(void) |
347 | 0 | { |
348 | 0 | static const char *const defaults[] = { |
349 | | /* Prefix keys. */ |
350 | 0 | "bind -N 'Send the prefix key' C-b { send-prefix }", |
351 | 0 | "bind -N 'Rotate through the panes' C-o { rotate-window }", |
352 | 0 | "bind -N 'Suspend the current client' C-z { suspend-client }", |
353 | 0 | "bind -N 'Select next layout' Space { next-layout }", |
354 | 0 | "bind -N 'Break pane to a new window' ! { break-pane }", |
355 | 0 | "bind -N 'Split window vertically' '\"' { split-window }", |
356 | 0 | "bind -N 'List all paste buffers' '#' { list-buffers }", |
357 | 0 | "bind -N 'Rename current session' '$' { command-prompt -I'#S' { rename-session -- '%%' } }", |
358 | 0 | "bind -N 'Split window horizontally' % { split-window -h }", |
359 | 0 | "bind -N 'Kill current window' & { confirm-before -p\"kill-window #W? (y/n)\" kill-window }", |
360 | 0 | "bind -N 'Prompt for window index to select' \"'\" { command-prompt -T window-target -pindex { select-window -t ':%%' } }", |
361 | 0 | "bind -N 'Switch to previous client' ( { switch-client -p }", |
362 | 0 | "bind -N 'Switch to next client' ) { switch-client -n }", |
363 | 0 | "bind -N 'Rename current window' , { command-prompt -I'#W' { rename-window -- '%%' } }", |
364 | 0 | "bind -N 'Delete the most recent paste buffer' - { delete-buffer }", |
365 | 0 | "bind -N 'Move the current window' . { command-prompt -T target { move-window -t '%%' } }", |
366 | 0 | "bind -N 'Describe key binding' '/' { command-prompt -kpkey { list-keys -1N '%%' } }", |
367 | 0 | "bind -N 'Select window 0' 0 { select-window -t:=0 }", |
368 | 0 | "bind -N 'Select window 1' 1 { select-window -t:=1 }", |
369 | 0 | "bind -N 'Select window 2' 2 { select-window -t:=2 }", |
370 | 0 | "bind -N 'Select window 3' 3 { select-window -t:=3 }", |
371 | 0 | "bind -N 'Select window 4' 4 { select-window -t:=4 }", |
372 | 0 | "bind -N 'Select window 5' 5 { select-window -t:=5 }", |
373 | 0 | "bind -N 'Select window 6' 6 { select-window -t:=6 }", |
374 | 0 | "bind -N 'Select window 7' 7 { select-window -t:=7 }", |
375 | 0 | "bind -N 'Select window 8' 8 { select-window -t:=8 }", |
376 | 0 | "bind -N 'Select window 9' 9 { select-window -t:=9 }", |
377 | 0 | "bind -N 'Prompt for a command' : { command-prompt }", |
378 | 0 | "bind -N 'Move to the previously active pane' \\; { last-pane }", |
379 | 0 | "bind -N 'Choose a paste buffer from a list' = { choose-buffer -Z }", |
380 | 0 | "bind -N 'List key bindings' ? { list-keys -N }", |
381 | 0 | "bind -N 'Choose and detach a client from a list' D { choose-client -Z }", |
382 | 0 | "bind -N 'Spread panes out evenly' E { select-layout -E }", |
383 | 0 | "bind -N 'Switch to the last client' L { switch-client -l }", |
384 | 0 | "bind -N 'Clear the marked pane' M { select-pane -M }", |
385 | 0 | "bind -N 'Enter copy mode' [ { copy-mode }", |
386 | 0 | "bind -N 'Paste the most recent paste buffer' ] { paste-buffer -p }", |
387 | 0 | "bind -N 'Create a new window' c { new-window }", |
388 | 0 | "bind -N 'Detach the current client' d { detach-client }", |
389 | 0 | "bind -N 'Search for a pane' f { command-prompt { find-window -Z -- '%%' } }", |
390 | 0 | "bind -N 'Display window information' i { display-message }", |
391 | 0 | "bind -N 'Select the previously current window' l { last-window }", |
392 | 0 | "bind -N 'Toggle the marked pane' m { select-pane -m }", |
393 | 0 | "bind -N 'Select the next window' n { next-window }", |
394 | 0 | "bind -N 'Select the next pane' o { select-pane -t:.+ }", |
395 | 0 | "bind -N 'Customize options' C { customize-mode -Z }", |
396 | 0 | "bind -N 'Select the previous window' p { previous-window }", |
397 | 0 | "bind -N 'Display pane numbers' q { display-panes }", |
398 | 0 | "bind -N 'Redraw the current client' r { refresh-client }", |
399 | 0 | "bind -N 'Choose a session from a list' s { choose-tree -Zs }", |
400 | 0 | "bind -N 'Show a clock' t { clock-mode }", |
401 | 0 | "bind -N 'Choose a window from a list' w { choose-tree -Zw }", |
402 | 0 | "bind -N 'Kill the active pane' x { confirm-before -p\"kill-pane #P? (y/n)\" kill-pane }", |
403 | 0 | "bind -N 'Zoom the active pane' z { resize-pane -Z }", |
404 | 0 | "bind -N 'Swap the active pane with the pane above' '{' { swap-pane -U }", |
405 | 0 | "bind -N 'Swap the active pane with the pane below' '}' { swap-pane -D }", |
406 | 0 | "bind -N 'Show messages' '~' { show-messages }", |
407 | 0 | "bind -N 'Enter copy mode and scroll up' PPage { copy-mode -u }", |
408 | 0 | "bind -N 'Select the pane above the active pane' -r Up { select-pane -U }", |
409 | 0 | "bind -N 'Select the pane below the active pane' -r Down { select-pane -D }", |
410 | 0 | "bind -N 'Select the pane to the left of the active pane' -r Left { select-pane -L }", |
411 | 0 | "bind -N 'Select the pane to the right of the active pane' -r Right { select-pane -R }", |
412 | 0 | "bind -N 'Set the even-horizontal layout' M-1 { select-layout even-horizontal }", |
413 | 0 | "bind -N 'Set the even-vertical layout' M-2 { select-layout even-vertical }", |
414 | 0 | "bind -N 'Set the main-horizontal layout' M-3 { select-layout main-horizontal }", |
415 | 0 | "bind -N 'Set the main-vertical layout' M-4 { select-layout main-vertical }", |
416 | 0 | "bind -N 'Select the tiled layout' M-5 { select-layout tiled }", |
417 | 0 | "bind -N 'Set the main-horizontal-mirrored layout' M-6 { select-layout main-horizontal-mirrored }", |
418 | 0 | "bind -N 'Set the main-vertical-mirrored layout' M-7 { select-layout main-vertical-mirrored }", |
419 | 0 | "bind -N 'Select the next window with an alert' M-n { next-window -a }", |
420 | 0 | "bind -N 'Rotate through the panes in reverse' M-o { rotate-window -D }", |
421 | 0 | "bind -N 'Select the previous window with an alert' M-p { previous-window -a }", |
422 | 0 | "bind -N 'Move the visible part of the window up' -r S-Up { refresh-client -U 10 }", |
423 | 0 | "bind -N 'Move the visible part of the window down' -r S-Down { refresh-client -D 10 }", |
424 | 0 | "bind -N 'Move the visible part of the window left' -r S-Left { refresh-client -L 10 }", |
425 | 0 | "bind -N 'Move the visible part of the window right' -r S-Right { refresh-client -R 10 }", |
426 | 0 | "bind -N 'Reset so the visible part of the window follows the cursor' -r DC { refresh-client -c }", |
427 | 0 | "bind -N 'Resize the pane up by 5' -r M-Up { resize-pane -U 5 }", |
428 | 0 | "bind -N 'Resize the pane down by 5' -r M-Down { resize-pane -D 5 }", |
429 | 0 | "bind -N 'Resize the pane left by 5' -r M-Left { resize-pane -L 5 }", |
430 | 0 | "bind -N 'Resize the pane right by 5' -r M-Right { resize-pane -R 5 }", |
431 | 0 | "bind -N 'Resize the pane up' -r C-Up { resize-pane -U }", |
432 | 0 | "bind -N 'Resize the pane down' -r C-Down { resize-pane -D }", |
433 | 0 | "bind -N 'Resize the pane left' -r C-Left { resize-pane -L }", |
434 | 0 | "bind -N 'Resize the pane right' -r C-Right { resize-pane -R }", |
435 | | |
436 | | /* Menu keys */ |
437 | 0 | "bind -N 'Display window menu' < { display-menu -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU " }", |
438 | 0 | "bind -N 'Display pane menu' > { display-menu -xP -yP -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", |
439 | | |
440 | | |
441 | | /* Mouse button 1 down on pane. */ |
442 | 0 | "bind -n MouseDown1Pane { select-pane -t=; send -M }", |
443 | | |
444 | | /* Mouse button 1 drag on pane. */ |
445 | 0 | "bind -n MouseDrag1Pane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -M } }", |
446 | | |
447 | | /* Mouse wheel up on pane. */ |
448 | 0 | "bind -n WheelUpPane { if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -e } }", |
449 | | |
450 | | /* Mouse button 2 down on pane. */ |
451 | 0 | "bind -n MouseDown2Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { paste -p } }", |
452 | | |
453 | | /* Mouse button 1 double click on pane. */ |
454 | 0 | "bind -n DoubleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-word; run -d0.3; send -X copy-pipe-and-cancel } }", |
455 | | |
456 | | /* Mouse button 1 triple click on pane. */ |
457 | 0 | "bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel } }", |
458 | | |
459 | | /* Mouse button 1 drag on border. */ |
460 | 0 | "bind -n MouseDrag1Border { resize-pane -M }", |
461 | | |
462 | | /* Mouse button 1 down on status line. */ |
463 | 0 | "bind -n MouseDown1Status { select-window -t= }", |
464 | | |
465 | | /* Mouse wheel down on status line. */ |
466 | 0 | "bind -n WheelDownStatus { next-window }", |
467 | | |
468 | | /* Mouse wheel up on status line. */ |
469 | 0 | "bind -n WheelUpStatus { previous-window }", |
470 | | |
471 | | /* Mouse button 3 down on status left. */ |
472 | 0 | "bind -n MouseDown3StatusLeft { display-menu -t= -xM -yW -T '#[align=centre]#{session_name}' " DEFAULT_SESSION_MENU " }", |
473 | 0 | "bind -n M-MouseDown3StatusLeft { display-menu -t= -xM -yW -T '#[align=centre]#{session_name}' " DEFAULT_SESSION_MENU " }", |
474 | | |
475 | | /* Mouse button 3 down on status line. */ |
476 | 0 | "bind -n MouseDown3Status { display-menu -t= -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU "}", |
477 | 0 | "bind -n M-MouseDown3Status { display-menu -t= -xW -yW -T '#[align=centre]#{window_index}:#{window_name}' " DEFAULT_WINDOW_MENU "}", |
478 | | |
479 | | /* Mouse button 3 down on pane. */ |
480 | 0 | "bind -n MouseDown3Pane { if -Ft= '#{||:#{mouse_any_flag},#{&&:#{pane_in_mode},#{?#{m/r:(copy|view)-mode,#{pane_mode}},0,1}}}' { select-pane -t=; send -M } { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " } }", |
481 | 0 | "bind -n M-MouseDown3Pane { display-menu -t= -xM -yM -T '#[align=centre]#{pane_index} (#{pane_id})' " DEFAULT_PANE_MENU " }", |
482 | | |
483 | | /* Mouse on scrollbar. */ |
484 | 0 | "bind -n MouseDown1ScrollbarUp { copy-mode -u }", |
485 | 0 | "bind -n MouseDown1ScrollbarDown { copy-mode -d }", |
486 | 0 | "bind -n MouseDrag1ScrollbarSlider { copy-mode -S }", |
487 | | |
488 | | /* Copy mode (emacs) keys. */ |
489 | 0 | "bind -Tcopy-mode C-Space { send -X begin-selection }", |
490 | 0 | "bind -Tcopy-mode C-a { send -X start-of-line }", |
491 | 0 | "bind -Tcopy-mode C-c { send -X cancel }", |
492 | 0 | "bind -Tcopy-mode C-e { send -X end-of-line }", |
493 | 0 | "bind -Tcopy-mode C-f { send -X cursor-right }", |
494 | 0 | "bind -Tcopy-mode C-b { send -X cursor-left }", |
495 | 0 | "bind -Tcopy-mode C-g { send -X clear-selection }", |
496 | 0 | "bind -Tcopy-mode C-k { send -X copy-pipe-end-of-line-and-cancel }", |
497 | 0 | "bind -Tcopy-mode C-n { send -X cursor-down }", |
498 | 0 | "bind -Tcopy-mode C-p { send -X cursor-up }", |
499 | 0 | "bind -Tcopy-mode C-r { command-prompt -T search -ip'(search up)' -I'#{pane_search_string}' { send -X search-backward-incremental -- '%%' } }", |
500 | 0 | "bind -Tcopy-mode C-s { command-prompt -T search -ip'(search down)' -I'#{pane_search_string}' { send -X search-forward-incremental -- '%%' } }", |
501 | 0 | "bind -Tcopy-mode C-v { send -X page-down }", |
502 | 0 | "bind -Tcopy-mode C-w { send -X copy-pipe-and-cancel }", |
503 | 0 | "bind -Tcopy-mode Escape { send -X cancel }", |
504 | 0 | "bind -Tcopy-mode Space { send -X page-down }", |
505 | 0 | "bind -Tcopy-mode , { send -X jump-reverse }", |
506 | 0 | "bind -Tcopy-mode \\; { send -X jump-again }", |
507 | 0 | "bind -Tcopy-mode F { command-prompt -1p'(jump backward)' { send -X jump-backward -- '%%' } }", |
508 | 0 | "bind -Tcopy-mode N { send -X search-reverse }", |
509 | 0 | "bind -Tcopy-mode P { send -X toggle-position }", |
510 | 0 | "bind -Tcopy-mode R { send -X rectangle-toggle }", |
511 | 0 | "bind -Tcopy-mode T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward -- '%%' } }", |
512 | 0 | "bind -Tcopy-mode X { send -X set-mark }", |
513 | 0 | "bind -Tcopy-mode f { command-prompt -1p'(jump forward)' { send -X jump-forward -- '%%' } }", |
514 | 0 | "bind -Tcopy-mode g { command-prompt -p'(goto line)' { send -X goto-line -- '%%' } }", |
515 | 0 | "bind -Tcopy-mode n { send -X search-again }", |
516 | 0 | "bind -Tcopy-mode q { send -X cancel }", |
517 | 0 | "bind -Tcopy-mode r { send -X refresh-from-pane }", |
518 | 0 | "bind -Tcopy-mode t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward -- '%%' } }", |
519 | 0 | "bind -Tcopy-mode Home { send -X start-of-line }", |
520 | 0 | "bind -Tcopy-mode End { send -X end-of-line }", |
521 | 0 | "bind -Tcopy-mode MouseDown1Pane select-pane", |
522 | 0 | "bind -Tcopy-mode MouseDrag1Pane { select-pane; send -X begin-selection }", |
523 | 0 | "bind -Tcopy-mode MouseDragEnd1Pane { send -X copy-pipe-and-cancel }", |
524 | 0 | "bind -Tcopy-mode WheelUpPane { select-pane; send -N5 -X scroll-up }", |
525 | 0 | "bind -Tcopy-mode WheelDownPane { select-pane; send -N5 -X scroll-down }", |
526 | 0 | "bind -Tcopy-mode DoubleClick1Pane { select-pane; send -X select-word; run -d0.3; send -X copy-pipe-and-cancel }", |
527 | 0 | "bind -Tcopy-mode TripleClick1Pane { select-pane; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel }", |
528 | 0 | "bind -Tcopy-mode NPage { send -X page-down }", |
529 | 0 | "bind -Tcopy-mode PPage { send -X page-up }", |
530 | 0 | "bind -Tcopy-mode Up { send -X cursor-up }", |
531 | 0 | "bind -Tcopy-mode Down { send -X cursor-down }", |
532 | 0 | "bind -Tcopy-mode Left { send -X cursor-left }", |
533 | 0 | "bind -Tcopy-mode Right { send -X cursor-right }", |
534 | 0 | "bind -Tcopy-mode M-1 { command-prompt -Np'(repeat)' -I1 { send -N '%%' } }", |
535 | 0 | "bind -Tcopy-mode M-2 { command-prompt -Np'(repeat)' -I2 { send -N '%%' } }", |
536 | 0 | "bind -Tcopy-mode M-3 { command-prompt -Np'(repeat)' -I3 { send -N '%%' } }", |
537 | 0 | "bind -Tcopy-mode M-4 { command-prompt -Np'(repeat)' -I4 { send -N '%%' } }", |
538 | 0 | "bind -Tcopy-mode M-5 { command-prompt -Np'(repeat)' -I5 { send -N '%%' } }", |
539 | 0 | "bind -Tcopy-mode M-6 { command-prompt -Np'(repeat)' -I6 { send -N '%%' } }", |
540 | 0 | "bind -Tcopy-mode M-7 { command-prompt -Np'(repeat)' -I7 { send -N '%%' } }", |
541 | 0 | "bind -Tcopy-mode M-8 { command-prompt -Np'(repeat)' -I8 { send -N '%%' } }", |
542 | 0 | "bind -Tcopy-mode M-9 { command-prompt -Np'(repeat)' -I9 { send -N '%%' } }", |
543 | 0 | "bind -Tcopy-mode M-< { send -X history-top }", |
544 | 0 | "bind -Tcopy-mode M-> { send -X history-bottom }", |
545 | 0 | "bind -Tcopy-mode M-R { send -X top-line }", |
546 | 0 | "bind -Tcopy-mode M-b { send -X previous-word }", |
547 | 0 | "bind -Tcopy-mode C-M-b { send -X previous-matching-bracket }", |
548 | 0 | "bind -Tcopy-mode M-f { send -X next-word-end }", |
549 | 0 | "bind -Tcopy-mode C-M-f { send -X next-matching-bracket }", |
550 | 0 | "bind -Tcopy-mode M-m { send -X back-to-indentation }", |
551 | 0 | "bind -Tcopy-mode M-r { send -X middle-line }", |
552 | 0 | "bind -Tcopy-mode M-v { send -X page-up }", |
553 | 0 | "bind -Tcopy-mode M-w { send -X copy-pipe-and-cancel }", |
554 | 0 | "bind -Tcopy-mode M-x { send -X jump-to-mark }", |
555 | 0 | "bind -Tcopy-mode 'M-{' { send -X previous-paragraph }", |
556 | 0 | "bind -Tcopy-mode 'M-}' { send -X next-paragraph }", |
557 | 0 | "bind -Tcopy-mode M-Up { send -X halfpage-up }", |
558 | 0 | "bind -Tcopy-mode M-Down { send -X halfpage-down }", |
559 | 0 | "bind -Tcopy-mode C-Up { send -X scroll-up }", |
560 | 0 | "bind -Tcopy-mode C-Down { send -X scroll-down }", |
561 | | |
562 | | /* Copy mode (vi) keys. */ |
563 | 0 | "bind -Tcopy-mode-vi '#' { send -FX search-backward -- '#{copy_cursor_word}' }", |
564 | 0 | "bind -Tcopy-mode-vi * { send -FX search-forward -- '#{copy_cursor_word}' }", |
565 | 0 | "bind -Tcopy-mode-vi C-c { send -X cancel }", |
566 | 0 | "bind -Tcopy-mode-vi C-d { send -X halfpage-down }", |
567 | 0 | "bind -Tcopy-mode-vi C-e { send -X scroll-down }", |
568 | 0 | "bind -Tcopy-mode-vi C-b { send -X page-up }", |
569 | 0 | "bind -Tcopy-mode-vi C-f { send -X page-down }", |
570 | 0 | "bind -Tcopy-mode-vi C-h { send -X cursor-left }", |
571 | 0 | "bind -Tcopy-mode-vi C-j { send -X copy-pipe-and-cancel }", |
572 | 0 | "bind -Tcopy-mode-vi Enter { send -X copy-pipe-and-cancel }", |
573 | 0 | "bind -Tcopy-mode-vi C-u { send -X halfpage-up }", |
574 | 0 | "bind -Tcopy-mode-vi C-v { send -X rectangle-toggle }", |
575 | 0 | "bind -Tcopy-mode-vi C-y { send -X scroll-up }", |
576 | 0 | "bind -Tcopy-mode-vi Escape { send -X clear-selection }", |
577 | 0 | "bind -Tcopy-mode-vi Space { send -X begin-selection }", |
578 | 0 | "bind -Tcopy-mode-vi '$' { send -X end-of-line }", |
579 | 0 | "bind -Tcopy-mode-vi , { send -X jump-reverse }", |
580 | 0 | "bind -Tcopy-mode-vi / { command-prompt -T search -p'(search down)' { send -X search-forward -- '%%' } }", |
581 | 0 | "bind -Tcopy-mode-vi 0 { send -X start-of-line }", |
582 | 0 | "bind -Tcopy-mode-vi 1 { command-prompt -Np'(repeat)' -I1 { send -N '%%' } }", |
583 | 0 | "bind -Tcopy-mode-vi 2 { command-prompt -Np'(repeat)' -I2 { send -N '%%' } }", |
584 | 0 | "bind -Tcopy-mode-vi 3 { command-prompt -Np'(repeat)' -I3 { send -N '%%' } }", |
585 | 0 | "bind -Tcopy-mode-vi 4 { command-prompt -Np'(repeat)' -I4 { send -N '%%' } }", |
586 | 0 | "bind -Tcopy-mode-vi 5 { command-prompt -Np'(repeat)' -I5 { send -N '%%' } }", |
587 | 0 | "bind -Tcopy-mode-vi 6 { command-prompt -Np'(repeat)' -I6 { send -N '%%' } }", |
588 | 0 | "bind -Tcopy-mode-vi 7 { command-prompt -Np'(repeat)' -I7 { send -N '%%' } }", |
589 | 0 | "bind -Tcopy-mode-vi 8 { command-prompt -Np'(repeat)' -I8 { send -N '%%' } }", |
590 | 0 | "bind -Tcopy-mode-vi 9 { command-prompt -Np'(repeat)' -I9 { send -N '%%' } }", |
591 | 0 | "bind -Tcopy-mode-vi : { command-prompt -p'(goto line)' { send -X goto-line -- '%%' } }", |
592 | 0 | "bind -Tcopy-mode-vi \\; { send -X jump-again }", |
593 | 0 | "bind -Tcopy-mode-vi ? { command-prompt -T search -p'(search up)' { send -X search-backward -- '%%' } }", |
594 | 0 | "bind -Tcopy-mode-vi A { send -X append-selection-and-cancel }", |
595 | 0 | "bind -Tcopy-mode-vi B { send -X previous-space }", |
596 | 0 | "bind -Tcopy-mode-vi D { send -X copy-pipe-end-of-line-and-cancel }", |
597 | 0 | "bind -Tcopy-mode-vi E { send -X next-space-end }", |
598 | 0 | "bind -Tcopy-mode-vi F { command-prompt -1p'(jump backward)' { send -X jump-backward -- '%%' } }", |
599 | 0 | "bind -Tcopy-mode-vi G { send -X history-bottom }", |
600 | 0 | "bind -Tcopy-mode-vi H { send -X top-line }", |
601 | 0 | "bind -Tcopy-mode-vi J { send -X scroll-down }", |
602 | 0 | "bind -Tcopy-mode-vi K { send -X scroll-up }", |
603 | 0 | "bind -Tcopy-mode-vi L { send -X bottom-line }", |
604 | 0 | "bind -Tcopy-mode-vi M { send -X middle-line }", |
605 | 0 | "bind -Tcopy-mode-vi N { send -X search-reverse }", |
606 | 0 | "bind -Tcopy-mode-vi P { send -X toggle-position }", |
607 | 0 | "bind -Tcopy-mode-vi T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward -- '%%' } }", |
608 | 0 | "bind -Tcopy-mode-vi V { send -X select-line }", |
609 | 0 | "bind -Tcopy-mode-vi W { send -X next-space }", |
610 | 0 | "bind -Tcopy-mode-vi X { send -X set-mark }", |
611 | 0 | "bind -Tcopy-mode-vi ^ { send -X back-to-indentation }", |
612 | 0 | "bind -Tcopy-mode-vi b { send -X previous-word }", |
613 | 0 | "bind -Tcopy-mode-vi e { send -X next-word-end }", |
614 | 0 | "bind -Tcopy-mode-vi f { command-prompt -1p'(jump forward)' { send -X jump-forward -- '%%' } }", |
615 | 0 | "bind -Tcopy-mode-vi g { send -X history-top }", |
616 | 0 | "bind -Tcopy-mode-vi h { send -X cursor-left }", |
617 | 0 | "bind -Tcopy-mode-vi j { send -X cursor-down }", |
618 | 0 | "bind -Tcopy-mode-vi k { send -X cursor-up }", |
619 | 0 | "bind -Tcopy-mode-vi z { send -X scroll-middle }", |
620 | 0 | "bind -Tcopy-mode-vi l { send -X cursor-right }", |
621 | 0 | "bind -Tcopy-mode-vi n { send -X search-again }", |
622 | 0 | "bind -Tcopy-mode-vi o { send -X other-end }", |
623 | 0 | "bind -Tcopy-mode-vi q { send -X cancel }", |
624 | 0 | "bind -Tcopy-mode-vi r { send -X refresh-from-pane }", |
625 | 0 | "bind -Tcopy-mode-vi t { command-prompt -1p'(jump to forward)' { send -X jump-to-forward -- '%%' } }", |
626 | 0 | "bind -Tcopy-mode-vi v { send -X rectangle-toggle }", |
627 | 0 | "bind -Tcopy-mode-vi w { send -X next-word }", |
628 | 0 | "bind -Tcopy-mode-vi '{' { send -X previous-paragraph }", |
629 | 0 | "bind -Tcopy-mode-vi '}' { send -X next-paragraph }", |
630 | 0 | "bind -Tcopy-mode-vi % { send -X next-matching-bracket }", |
631 | 0 | "bind -Tcopy-mode-vi Home { send -X start-of-line }", |
632 | 0 | "bind -Tcopy-mode-vi End { send -X end-of-line }", |
633 | 0 | "bind -Tcopy-mode-vi MouseDown1Pane { select-pane }", |
634 | 0 | "bind -Tcopy-mode-vi MouseDrag1Pane { select-pane; send -X begin-selection }", |
635 | 0 | "bind -Tcopy-mode-vi MouseDragEnd1Pane { send -X copy-pipe-and-cancel }", |
636 | 0 | "bind -Tcopy-mode-vi WheelUpPane { select-pane; send -N5 -X scroll-up }", |
637 | 0 | "bind -Tcopy-mode-vi WheelDownPane { select-pane; send -N5 -X scroll-down }", |
638 | 0 | "bind -Tcopy-mode-vi DoubleClick1Pane { select-pane; send -X select-word; run -d0.3; send -X copy-pipe-and-cancel }", |
639 | 0 | "bind -Tcopy-mode-vi TripleClick1Pane { select-pane; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel }", |
640 | 0 | "bind -Tcopy-mode-vi BSpace { send -X cursor-left }", |
641 | 0 | "bind -Tcopy-mode-vi NPage { send -X page-down }", |
642 | 0 | "bind -Tcopy-mode-vi PPage { send -X page-up }", |
643 | 0 | "bind -Tcopy-mode-vi Up { send -X cursor-up }", |
644 | 0 | "bind -Tcopy-mode-vi Down { send -X cursor-down }", |
645 | 0 | "bind -Tcopy-mode-vi Left { send -X cursor-left }", |
646 | 0 | "bind -Tcopy-mode-vi Right { send -X cursor-right }", |
647 | 0 | "bind -Tcopy-mode-vi M-x { send -X jump-to-mark }", |
648 | 0 | "bind -Tcopy-mode-vi C-Up { send -X scroll-up }", |
649 | 0 | "bind -Tcopy-mode-vi C-Down { send -X scroll-down }", |
650 | 0 | }; |
651 | 0 | u_int i; |
652 | 0 | struct cmd_parse_result *pr; |
653 | |
|
654 | 0 | for (i = 0; i < nitems(defaults); i++) { |
655 | 0 | pr = cmd_parse_from_string(defaults[i], NULL); |
656 | 0 | if (pr->status != CMD_PARSE_SUCCESS) { |
657 | 0 | log_debug("%s", pr->error); |
658 | 0 | fatalx("bad default key: %s", defaults[i]); |
659 | 0 | } |
660 | 0 | cmdq_append(NULL, cmdq_get_command(pr->cmdlist, NULL)); |
661 | 0 | cmd_list_free(pr->cmdlist); |
662 | 0 | } |
663 | 0 | cmdq_append(NULL, cmdq_get_callback(key_bindings_init_done, NULL)); |
664 | 0 | } |
665 | | |
666 | | static enum cmd_retval |
667 | | key_bindings_read_only(struct cmdq_item *item, __unused void *data) |
668 | 0 | { |
669 | 0 | cmdq_error(item, "client is read-only"); |
670 | 0 | return (CMD_RETURN_ERROR); |
671 | 0 | } |
672 | | |
673 | | struct cmdq_item * |
674 | | key_bindings_dispatch(struct key_binding *bd, struct cmdq_item *item, |
675 | | struct client *c, struct key_event *event, struct cmd_find_state *fs) |
676 | 0 | { |
677 | 0 | struct cmdq_item *new_item; |
678 | 0 | struct cmdq_state *new_state; |
679 | 0 | int readonly, flags = 0; |
680 | |
|
681 | 0 | if (c == NULL || (~c->flags & CLIENT_READONLY)) |
682 | 0 | readonly = 1; |
683 | 0 | else |
684 | 0 | readonly = cmd_list_all_have(bd->cmdlist, CMD_READONLY); |
685 | 0 | if (!readonly) |
686 | 0 | new_item = cmdq_get_callback(key_bindings_read_only, NULL); |
687 | 0 | else { |
688 | 0 | if (bd->flags & KEY_BINDING_REPEAT) |
689 | 0 | flags |= CMDQ_STATE_REPEAT; |
690 | 0 | new_state = cmdq_new_state(fs, event, flags); |
691 | 0 | new_item = cmdq_get_command(bd->cmdlist, new_state); |
692 | 0 | cmdq_free_state(new_state); |
693 | 0 | } |
694 | 0 | if (item != NULL) |
695 | 0 | new_item = cmdq_insert_after(item, new_item); |
696 | 0 | else |
697 | 0 | new_item = cmdq_append(c, new_item); |
698 | 0 | return (new_item); |
699 | 0 | } |