summaryrefslogtreecommitdiffstats
path: root/source/keyb.c
blob: 71aedd3e7fc93f1cdac8893b37f3f1b22120f3a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#include <config.h>
#include <string.h>
#include "rofi.h"
#include "x11-helper.h"
#include "xrmoptions.h"

typedef struct
{
    unsigned int modmask;
    xkb_keysym_t keysym;
    gboolean     release;
} KeyBinding;

typedef struct
{
    const char *name;
    char       *keystr;
    int        num_bindings;
    KeyBinding *kb;
} ActionBindingEntry;

typedef struct
{
    KeyBindingAction id;
    char             *name;
    char             *keybinding;
    char             *comment;
} DefaultBinding;

/**
 * Data structure holding all the action keybinding.
 */
ActionBindingEntry abe[NUM_ABE];

/**
 * LIST OF DEFAULT SETTINGS
 */
DefaultBinding bindings[NUM_ABE] =
{
    { .id = PASTE_PRIMARY,           .name = "kb-primary-paste",           .keybinding = "Control+V,Shift+Insert",                    .comment = "Paste primary selection"                                         },
    { .id = PASTE_SECONDARY,         .name = "kb-secondary-paste",         .keybinding = "Control+v,Insert",                          .comment = "Paste clipboard"                                                 },
    { .id = CLEAR_LINE,              .name = "kb-clear-line",              .keybinding = "Control+w",                                 .comment = "Clear input line"                                                },
    { .id = MOVE_FRONT,              .name = "kb-move-front",              .keybinding = "Control+a",                                 .comment = "Beginning of line"                                               },
    { .id = MOVE_END,                .name = "kb-move-end",                .keybinding = "Control+e",                                 .comment = "End of line"                                                     },
    { .id = MOVE_WORD_BACK,          .name = "kb-move-word-back",          .keybinding = "Alt+b",                                     .comment = "Move back one word"                                              },
    { .id = MOVE_WORD_FORWARD,       .name = "kb-move-word-forward",       .keybinding = "Alt+f",                                     .comment = "Move forward one word"                                           },
    { .id = MOVE_CHAR_BACK,          .name = "kb-move-char-back",          .keybinding = "Left,Control+b",                            .comment = "Move back one char"                                              },
    { .id = MOVE_CHAR_FORWARD,       .name = "kb-move-char-forward",       .keybinding = "Right,Control+f",                           .comment = "Move forward one char"                                           },
    { .id = REMOVE_WORD_BACK,        .name = "kb-remove-word-back",        .keybinding = "Control+Alt+h,Control+BackSpace",           .comment = "Delete previous word"                                            },
    { .id = REMOVE_WORD_FORWARD,     .name = "kb-remove-word-forward",     .keybinding = "Control+Alt+d",                             .comment = "Delete next word"                                                },
    { .id = REMOVE_CHAR_FORWARD,     .name = "kb-remove-char-forward",     .keybinding = "Delete,Control+d",                          .comment = "Delete next char"                                                },
    { .id = REMOVE_CHAR_BACK,        .name = "kb-remove-char-back",        .keybinding = "BackSpace,Control+h",                       .comment = "Delete previous char"                                            },
    { .id = REMOVE_TO_EOL,           .name = "kb-remove-to-eol",           .keybinding = "Control+k",                                 .comment = "Delete till the end of line"                                     },
    { .id = REMOVE_TO_SOL,           .name = "kb-remove-to-sol",           .keybinding = "Control+u",                                 .comment = "Delete till the start of line"                                   },
    { .id = ACCEPT_ENTRY,            .name = "kb-accept-entry",            .keybinding = "Control+j,Control+m,Return,KP_Enter",       .comment = "Accept entry"                                                    },
    { .id = ACCEPT_CUSTOM,           .name = "kb-accept-custom",           .keybinding = "Control+Return",                            .comment = "Use entered text as command (in ssh/run modi)"                   },
    { .id = ACCEPT_ALT,              .name = "kb-accept-alt",              .keybinding = "Shift+Return",                              .comment = "Use alternate accept command."                                   },
    { .id = DELETE_ENTRY,            .name = "kb-delete-entry",            .keybinding = "Shift+Delete",                              .comment = "Delete entry from history"                                       },
    { .id = MODE_NEXT,               .name = "kb-mode-next",               .keybinding = "Shift+Right,Control+Tab",                   .comment = "Switch to the next mode."                                        },
    { .id = MODE_PREVIOUS,           .name = "kb-mode-previous",           .keybinding = "Shift+Left,Control+Shift+Tab",              .comment = "Switch to the previous mode."                                    },
    { .id = ROW_LEFT,                .name = "kb-row-left",                .keybinding = "Control+Page_Up",                           .comment = "Go to the previous column"                                       },
    { .id = ROW_RIGHT,               .name = "kb-row-right",               .keybinding = "Control+Page_Down",                         .comment = "Go to the next column"                                           },
    { .id = ROW_UP,                  .name = "kb-row-up",                  .keybinding = "Up,Control+p,Shift+Tab,Shift+ISO_Left_Tab", .comment = "Select previous entry"                                           },
    { .id = ROW_DOWN,                .name = "kb-row-down",                .keybinding = "Down,Control+n",                            .comment = "Select next entry"                                               },
    { .id = ROW_TAB,                 .name = "kb-row-tab",                 .keybinding = "Tab",                                       .comment = "Go to next row, if one left, accept it, if no left next mode."   },
    { .id = PAGE_PREV,               .name = "kb-page-prev",               .keybinding = "Page_Up",                                   .comment = "Go to the previous page"                                         },
    { .id = PAGE_NEXT,               .name = "kb-page-next",               .keybinding = "Page_Down",                                 .comment = "Go to the next page"                                             },
    { .id = ROW_FIRST,               .name = "kb-row-first",               .keybinding = "Home,KP_Home",                              .comment = "Go to the first entry"                                           },
    { .id = ROW_LAST,                .name = "kb-row-last",                .keybinding = "End,KP_End",                                .comment = "Go to the last entry"                                            },
    { .id = ROW_SELECT,              .name = "kb-row-select",              .keybinding = "Control+space",                             .comment = "Set selected item as input text"                                 },
    { .id = SCREENSHOT,              .name = "kb-screenshot",              .keybinding = "Alt+S",                                     .comment = "Take a screenshot of the rofi window"                            },
    { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave",                          .comment = "Toggle case sensitivity"                                         },
    { .id = TOGGLE_SORT,             .name = "kb-toggle-sort",             .keybinding = "Alt+grave",                                 .comment = "Toggle sort"                                                     },
    { .id = CANCEL,                  .name = "kb-cancel",                  .keybinding = "Escape,Control+g,Control+bracketleft",      .comment = "Quit rofi"                                                       },
    { .id = CUSTOM_1,                .name = "kb-custom-1",                .keybinding = "Alt+1",                                     .comment = "Custom keybinding 1"                                             },
    { .id = CUSTOM_2,                .name = "kb-custom-2",                .keybinding = "Alt+2",                                     .comment = "Custom keybinding 2"                                             },
    { .id = CUSTOM_3,                .name = "kb-custom-3",                .keybinding = "Alt+3",                                     .comment = "Custom keybinding 3"                                             },
    { .id = CUSTOM_4,                .name = "kb-custom-4",                .keybinding = "Alt+4",                                     .comment = "Custom keybinding 4"                                             },
    { .id = CUSTOM_5,                .name = "kb-custom-5",                .keybinding = "Alt+5",                                     .comment = "Custom Keybinding 5"                                             },
    { .id = CUSTOM_6,                .name = "kb-custom-6",                .keybinding = "Alt+6",                                     .comment = "Custom keybinding 6"                                             },
    { .id = CUSTOM_7,                .name = "kb-custom-7",                .keybinding = "Alt+7",                                     .comment = "Custom Keybinding 7"