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 */
125 /* Associate a pressed key to an action */
127 wint_t sym; /* Key pressed */
128 enum action act; /* Action */
131 static struct key bindings[] = {
133 { KEY_LEFT, SEL_BACK },
135 /* Inside or select */
136 { KEY_ENTER, SEL_OPEN },
138 /* Pure navigate inside */
139 { KEY_RIGHT, SEL_NAV_IN },
143 { KEY_DOWN, SEL_NEXT },
146 { KEY_UP, SEL_PREV },
148 { KEY_NPAGE, SEL_PGDN },
150 { KEY_PPAGE, SEL_PGUP },
152 { CONTROL('D'), SEL_CTRL_D },
154 { CONTROL('U'), SEL_CTRL_U },
156 { KEY_HOME, SEL_HOME },
158 { CONTROL('A'), SEL_HOME },
160 { KEY_END, SEL_END },
162 { CONTROL('E'), SEL_END },
163 /* Go to first file */
165 /* Jump to an entry number/offset */
169 /* Initial directory */
170 { '@', SEL_CDBEGIN },
171 /* Last visited dir */
177 { CONTROL('_'), SEL_BMOPEN },
178 /* Connect to server over SSHFS */
180 /* Cycle contexts in forward direction */
182 /* Cycle contexts in reverse direction */
183 { KEY_BTAB, SEL_CYCLER },
184 /* Go to/create context N */
195 /* Mark a path to visit later */
197 /* Create a bookmark */
201 /* Toggle filter mode */
202 { CONTROL('N'), SEL_MFLTR },
203 /* Toggle hide .dot files */
205 /* Detailed listing */
209 { CONTROL('F'), SEL_STATS },
210 /* Toggle executable status */
213 { 'z', SEL_ARCHIVE },
216 { CONTROL('T'), SEL_SORT },
218 { CONTROL('L'), SEL_REDRAW },
219 /* Select current file path */
222 /* Toggle select multiple files */
224 /* Select all files in current dir */
226 /* Invert selection in current dir */
228 /* List, edit selection */
229 { 'E', SEL_SELEDIT },
230 /* Copy from selection buffer */
232 { CONTROL('P'), SEL_CP },
233 /* Move from selection buffer */
235 { CONTROL('V'), SEL_MV },
236 /* Copy/move from selection buffer and rename */
238 { CONTROL('W'), SEL_CPMVAS },
239 /* Delete from selection buffer */
241 { CONTROL('X'), SEL_RM },
242 /* Open in a custom application */
243 { 'o', SEL_OPENWITH },
244 { CONTROL('O'), SEL_OPENWITH },
245 /* Create a new file */
247 /* Show rename prompt */
248 { CONTROL('R'), SEL_RENAME },
249 /* Rename contents of current dir */
250 { 'r', SEL_RENAMEMUL },
251 /* Disconnect a SSHFS mount point */
255 /* Toggle auto-advance on file open */
256 { CONTROL('J'), SEL_AUTONEXT },
261 /* Show total size of listed selection */
262 { 'S', SEL_SELSIZE },
265 { CONTROL(']'), SEL_SHELL },
268 /* Show command prompt */
272 /* Manage sessions */
273 { 's', SEL_SESSIONS },
277 { 'T', SEL_TIMETYPE },
279 { 'q', SEL_QUITCTX },
280 /* Change dir on quit */
281 { CONTROL('G'), SEL_QUITCD },
283 { CONTROL('Q'), SEL_QUIT },
284 /* Quit with an error code */
285 { 'Q', SEL_QUITERR },
287 { KEY_MOUSE, SEL_CLICK },