1@import url("resource:///org/gnome/builder/keybindings/shared.css");
2
3@binding-set builder-emacs-text-entry
4{
5  bind "<ctrl>b" { "move-cursor" (logical-positions, -1, 0) };
6  bind "<shift><ctrl>b" { "move-cursor" (logical-positions, -1, 1) };
7  bind "<ctrl>f" { "move-cursor" (logical-positions, 1, 0) };
8  bind "<shift><ctrl>f" { "move-cursor" (logical-positions, 1, 1) };
9
10  bind "<alt>b" { "move-cursor" (words, -1, 0) };
11  bind "<shift><alt>b" { "move-cursor" (words, -1, 1) };
12  bind "<alt>f" { "move-cursor" (words, 1, 0) };
13  bind "<shift><alt>f" { "move-cursor" (words, 1, 1) };
14
15  bind "<ctrl>a" { "move-cursor" (paragraph-ends, -1, 0) };
16  bind "<shift><ctrl>a" { "move-cursor" (paragraph-ends, -1, 1) };
17  bind "<ctrl>e" { "move-cursor" (paragraph-ends, 1, 0) };
18  bind "<shift><ctrl>e" { "move-cursor" (paragraph-ends, 1, 1) };
19
20  bind "<ctrl>w" { "cut-clipboard" () };
21  bind "<alt>w" { "copy-clipboard" () };
22  bind "<ctrl>y" { "paste-clipboard" () };
23
24  bind "<ctrl>d" { "delete-from-cursor" (chars, 1) };
25  bind "<alt>d" { "delete-from-cursor" (word-ends, 1) };
26  bind "<ctrl>k" { "delete-from-cursor" (paragraph-ends, 1) };
27  bind "<alt>backslash" { "delete-from-cursor" (whitespace, 1) };
28
29  bind "<alt>space" { "delete-from-cursor" (whitespace, 1)
30                      "insert-at-cursor" (" ") };
31  bind "<alt>KP_Space" { "delete-from-cursor" (whitespace, 1)
32                         "insert-at-cursor" (" ")  };
33}
34
35/*
36 * Bindings for GtkTextView
37 */
38@binding-set builder-emacs-text-view
39{
40  bind "<ctrl>p" { "move-cursor" (display-lines, -1, 0) };
41  bind "<shift><ctrl>p" { "move-cursor" (display-lines, -1, 1) };
42  bind "<ctrl>n" { "move-cursor" (display-lines, 1, 0) };
43  bind "<shift><ctrl>n" { "move-cursor" (display-lines, 1, 1) };
44
45  bind "<ctrl>space" { "set-anchor" () };
46  bind "<ctrl>KP_Space" { "set-anchor" () };
47}
48
49@binding-set builder-emacs-source-view
50{
51  bind "Escape" { "clear-search" ()
52                  "clear-modifier" ()
53                  "clear-selection" ()
54                  "clear-count" ()
55                  "clear-snippets" ()
56                  "hide-completion" ()
57                  "remove-cursors" () };
58  bind "<ctrl><shift>e" { "add-cursor" (column) };
59  bind "<ctrl><shift>d" { "add-cursor" (match) };
60  bind "<ctrl>x" { "set-mode" ("emacs-x", transient) };
61  bind "<ctrl>c" { "set-mode" ("emacs-c", transient) };
62  bind "<ctrl>underscore" { "clear-count" ()
63                            "clear-selection" ()
64                            "remove-cursors" ()
65                            "undo" () };
66  bind "<alt>x" { "action" ("win", "show-command-bar", "") };
67  bind "<ctrl>r" { "action" ("editor-page", "find", "") };
68  bind "<ctrl>s" { "action" ("editor-page", "find", "") };
69  bind "<alt>dollar" { "action" ("spellcheck", "spellcheck", "") };
70  bind "<alt>period" { "goto-definition" () };
71  bind "<alt>n" { "move-error" (down) };
72  bind "<alt>p" { "move-error" (up) };
73  bind "<ctrl>j" { "action" ("grid", "focus-neighbor", "3") };
74  bind "<shift><ctrl>j" { "action" ("frame", "split-page", "''") };
75  bind "F2" { "clear-selection" ()
76              "movement" (previous-word-end, 0, 1, 1)
77              "movement" (next-word-start, 0, 1, 0)
78              "movement" (next-word-end, 1, 0, 1)
79              "request-documentation" ()
80              "clear-count" ()
81              "clear-selection" () };
82
83  bind "<ctrl>minus" { "decrease-font-size" () };
84  bind "<ctrl>plus" { "increase-font-size" () };
85  bind "<ctrl>KP_Subtract" { "decrease-font-size" () };
86  bind "<ctrl>KP_Add" { "increase-font-size" () };
87  bind "<ctrl>equal" { "increase-font-size" () };
88  bind "<ctrl>0" { "reset-font-size" () };
89
90  bind "<ctrl>Right" { "movement" (next-sub-word-start, 0, 0, 0) };
91  bind "<ctrl>Left" { "movement" (previous-sub-word-start, 0, 0, 0) };
92  bind "<ctrl><shift>Right" { "movement" (next-sub-word-start, 1, 0, 0) };
93  bind "<ctrl><shift>Left" { "movement" (previous-sub-word-start, 1, 0, 0) };
94
95  /* allow entering raw code */
96  bind "<ctrl>q" { "capture-modifier" ()
97                   "insert-modifier" (0)
98                   "clear-modifier" () };
99
100  /* swap between header/source */
101  bind "<alt>o" { "action" ("win", "find-other-file", "") };
102
103  /* cycle "tabs" */
104  bind "<ctrl><alt>Page_Up" { "action" ("frame", "previous-page", "") };
105  bind "<ctrl><alt>KP_Page_Up" { "action" ("frame", "previous-page", "") };
106  bind "<ctrl><alt>Page_Down" { "action" ("frame", "next-page", "") };
107  bind "<ctrl><alt>KP_Page_Down" { "action" ("frame", "next-page", "") };
108
109  bind "<alt>0" { "append-to-count" (0) };
110  bind "<alt>1" { "append-to-count" (1) };
111  bind "<alt>2" { "append-to-count" (2) };
112  bind "<alt>3" { "append-to-count" (3) };
113  bind "<alt>4" { "append-to-count" (4) };
114  bind "<alt>5" { "append-to-count" (5) };
115  bind "<alt>6" { "append-to-count" (6) };
116  bind "<alt>7" { "append-to-count" (7) };
117  bind "<alt>8" { "append-to-count" (8) };
118  bind "<alt>9" { "append-to-count" (9) };
119
120  /* Add back emoji */
121  bind "<ctrl>semicolon" { "insert-emoji" () };
122
123  bind "<ctrl>m" { "insert-at-cursor" ("\n") };
124}
125
126@binding-set builder-emacs-source-view-has-indenter
127{
128  bind "Tab" { "reindent" () };
129}
130
131@binding-set builder-emacs-source-view-x
132{
133  bind "<ctrl>c" { "action" ("app", "quit", "") };
134  bind "0" { "action" ("frame", "close-page", "") };
135  bind "k" { "action" ("frame", "close-page", "") };
136  bind "<ctrl>f" { "action" ("workbench", "open", "") };
137  bind "<ctrl>s" { "action" ("editor-page", "save", "") };
138  bind "s" { "action" ("win", "save-all", "") };
139  bind "<ctrl>b" { "action" ("frame", "show-list", "") };
140  bind "<ctrl>w" { "action" ("editor-page", "save-as", "") };
141  bind "u" { "clear-count" ()
142             "clear-selection" ()
143             "remove-cursors" ()
144             "redo" () };
145  bind "2" { "action" ("frame", "split-page", "''") };
146  bind "3" { "action" ("frame", "open-in-new-frame", "''") };
147  bind "o" { "action" ("grid", "focus-neighbor", "0") };
148  bind "grave" { "move-error" (down) };
149  bind "h" { "select-all" (1) };
150  bind "<ctrl>space" { "action" ("history", "move-previous-edit", "") };
151}
152
153@binding-set builder-emacs-source-view-c
154{
155  bind "<ctrl>f" { "format-selection" () };
156}
157
158/*
159 * Bindings for GtkTreeView
160 */
161@binding-set builder-emacs-tree-view
162{
163  bind "<ctrl>s" { "start-interactive-search" () };
164  bind "<ctrl>f" { "move-cursor" (logical-positions, 1) };
165  bind "<ctrl>b" { "move-cursor" (logical-positions, -1) };
166}
167
168@binding-set builder-emacs-list-box
169{
170  bind "<ctrl>f" { "move-cursor" (display-lines, 1) };
171  bind "<ctrl>b" { "move-cursor" (display-lines, -1) };
172}
173
174@binding-set builder-emacs-editor-search
175{
176  bind "<ctrl>r" { "action" ("frame", "previous-search-result", "") };
177  bind "<ctrl>s" { "action" ("frame", "next-search-result", "") };
178}
179
180frame.gb-search-frame entry {
181  -gtk-key-bindings: builder-emacs-editor-search,
182                     builder-emacs-text-entry;
183}
184
185entry {
186  -gtk-key-bindings: builder-emacs-text-entry;
187}
188
189textview {
190  -gtk-key-bindings: builder-emacs-text-entry, builder-emacs-text-view;
191}
192
193.sourceview,
194idesourceviewmode.default
195{
196  -IdeSourceViewMode-repeat-insert-with-count: true;
197
198  -gtk-key-bindings: builder-emacs-text-entry, builder-emacs-source-view, builder-emacs-text-view;
199}
200
201.sourceview,
202idesourceviewmode.default.has-indenter
203{
204  -IdeSourceViewMode-repeat-insert-with-count: true;
205
206  -gtk-key-bindings: builder-emacs-text-entry,
207                     builder-emacs-source-view-has-indenter,
208                     builder-emacs-source-view,
209                     builder-emacs-text-view;
210}
211
212idesourceviewmode.emacs-x {
213  -IdeSourceViewMode-display-name: "C-x";
214
215  -gtk-key-bindings: builder-emacs-source-view-x;
216}
217
218idesourceviewmode.emacs-c {
219  -IdeSourceViewMode-display-name: "C-c";
220
221  -gtk-key-bindings: builder-emacs-source-view-c;
222}
223
224treeview {
225  -gtk-key-bindings: builder-emacs-tree-view;
226}
227
228listbox {
229  -gtk-key-bindings: builder-emacs-list-box;
230}
231
232treeview.project-tree {
233  -gtk-key-bindings: builder-emacs-tree-view;
234}
235