4 * Copyright (C) 2014-2016, Lazaros Koromilas <lostd@2f30.org>
5 * Copyright (C) 2014-2016, Dimitris Papastamos <sin@2f30.org>
6 * Copyright (C) 2016-2023, Arun Prakash Jana <engineerarun@gmail.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #define CONTROL(c) ((c) & 0x1f)
46 /* Supported actions */
127 /* Associate a pressed key to an action */
129 wint_t sym; /* Key pressed */
130 enum action act; /* Action */
133 static struct key bindings[] = {
135 { KEY_LEFT, SEL_BACK },
137 /* Inside or select */
138 { KEY_ENTER, SEL_OPEN },
140 /* Pure navigate inside */
141 { KEY_RIGHT, SEL_NAV_IN },
145 { KEY_DOWN, SEL_NEXT },
148 { KEY_UP, SEL_PREV },
150 { KEY_NPAGE, SEL_PGDN },
152 { KEY_PPAGE, SEL_PGUP },
154 { CONTROL('D'), SEL_CTRL_D },
156 { CONTROL('U'), SEL_CTRL_U },
158 { KEY_HOME, SEL_HOME },
160 { CONTROL('A'), SEL_HOME },
162 { KEY_END, SEL_END },
164 { CONTROL('E'), SEL_END },
165 /* Go to first file */
167 /* Jump to an entry number/offset */
169 { CONTROL('Y'), SEL_YOUNG },
172 /* Initial directory */
173 { '@', SEL_CDBEGIN },
174 /* Last visited dir */
180 { CONTROL('_'), SEL_BMOPEN },
181 /* Connect to server over SSHFS */
183 /* Cycle contexts in forward direction */
185 /* Cycle contexts in reverse direction */
186 { KEY_BTAB, SEL_CYCLER },
187 /* Go to/create context N */
198 /* Mark a path to visit later */
200 /* Create a bookmark */
204 /* Toggle filter mode */
205 { CONTROL('N'), SEL_MFLTR },
206 /* Toggle hide .dot files */
208 /* Detailed listing */
212 { CONTROL('F'), SEL_STATS },
213 /* Toggle executable status */
216 { 'z', SEL_ARCHIVE },
219 { CONTROL('T'), SEL_SORT },
221 { CONTROL('L'), SEL_REDRAW },
222 /* Select current file path */
225 /* Toggle select multiple files */
227 /* Select all files in current dir */
229 /* Invert selection in current dir */
231 /* List, edit selection */
232 { 'E', SEL_SELEDIT },
233 /* Copy from selection buffer */
235 { CONTROL('P'), SEL_CP },
236 /* Move from selection buffer */
238 { CONTROL('V'), SEL_MV },
239 /* Copy/move from selection buffer and rename */
241 { CONTROL('W'), SEL_CPMVAS },
242 /* Delete from selection buffer */
244 { CONTROL('X'), SEL_RM },
245 /* Open in a custom application */
246 { 'o', SEL_OPENWITH },
247 { CONTROL('O'), SEL_OPENWITH },
248 /* Create a new file */
250 /* Show rename prompt */
251 { CONTROL('R'), SEL_RENAME },
252 /* Rename contents of current dir */
253 { 'r', SEL_RENAMEMUL },
254 /* Disconnect a SSHFS mount point */
258 /* Toggle auto-advance on file open */
259 { CONTROL('J'), SEL_AUTONEXT },
262 { KEY_F(4), SEL_EDIT },
264 { KEY_F(3), SEL_VIEW },
267 /* Show total size of listed selection */
268 { 'S', SEL_SELSIZE },
271 { CONTROL(']'), SEL_SHELL },
274 /* Show command prompt */
278 /* Manage sessions */
279 { 's', SEL_SESSIONS },
283 { 'T', SEL_TIMETYPE },
285 { 'q', SEL_QUITCTX },
286 /* Change dir on quit */
287 { CONTROL('G'), SEL_QUITCD },
289 { CONTROL('Q'), SEL_QUIT },
290 /* Quit with an error code */
291 { 'Q', SEL_QUITERR },
293 { KEY_MOUSE, SEL_CLICK },