2015-11-20 17:36:40 +03:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2017-06-20 07:56:31 +03:00
|
|
|
#define CONTROL(c) ((c) ^ 0x40)
|
2014-10-21 14:35:08 +04:00
|
|
|
|
2017-06-20 07:56:31 +03:00
|
|
|
/* Supported actions */
|
|
|
|
enum action {
|
|
|
|
SEL_QUIT = 1,
|
|
|
|
SEL_CDQUIT,
|
|
|
|
SEL_BACK,
|
|
|
|
SEL_GOIN,
|
|
|
|
SEL_FLTR,
|
|
|
|
SEL_MFLTR,
|
|
|
|
SEL_SEARCH,
|
|
|
|
SEL_NEXT,
|
|
|
|
SEL_PREV,
|
|
|
|
SEL_PGDN,
|
|
|
|
SEL_PGUP,
|
|
|
|
SEL_HOME,
|
|
|
|
SEL_END,
|
|
|
|
SEL_CD,
|
|
|
|
SEL_CDHOME,
|
|
|
|
SEL_CDBEGIN,
|
|
|
|
SEL_CDLAST,
|
|
|
|
SEL_CDBM,
|
|
|
|
SEL_TOGGLEDOT,
|
|
|
|
SEL_DETAIL,
|
|
|
|
SEL_STATS,
|
|
|
|
SEL_MEDIA,
|
|
|
|
SEL_FMEDIA,
|
|
|
|
SEL_DFB,
|
|
|
|
SEL_FSIZE,
|
|
|
|
SEL_BSIZE,
|
|
|
|
SEL_MTIME,
|
|
|
|
SEL_REDRAW,
|
|
|
|
SEL_COPY,
|
|
|
|
SEL_HELP,
|
|
|
|
SEL_RUN,
|
|
|
|
SEL_RUNARG,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Associate a pressed key to an action */
|
|
|
|
struct key {
|
|
|
|
int sym; /* Key pressed */
|
|
|
|
enum action act; /* Action */
|
|
|
|
char *run; /* Program to run */
|
|
|
|
char *env; /* Environment variable to run */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Extension pattern and mime combination */
|
|
|
|
struct assoc {
|
|
|
|
char *regex; /* Regex to match on filename */
|
|
|
|
char *mime; /* File type */
|
|
|
|
};
|
2015-02-04 15:32:16 +03:00
|
|
|
|
2017-04-23 20:42:54 +03:00
|
|
|
static struct assoc assocs[] = {
|
|
|
|
{ "\\.(c|cpp|h|log|md|py|sh|txt)$", "text" },
|
2014-10-21 14:15:27 +04:00
|
|
|
};
|
2014-11-06 14:46:37 +03:00
|
|
|
|
2017-04-23 20:42:54 +03:00
|
|
|
static struct key bindings[] = {
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Quit */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'q', SEL_QUIT, "", "" },
|
2017-06-04 21:46:43 +03:00
|
|
|
{ CONTROL('Q'), SEL_QUIT, "", "" },
|
|
|
|
/* Change dir on quit */
|
2017-04-19 15:52:30 +03:00
|
|
|
{ 'Q', SEL_CDQUIT, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Back */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_BACKSPACE, SEL_BACK, "", "" },
|
|
|
|
{ KEY_LEFT, SEL_BACK, "", "" },
|
|
|
|
{ 'h', SEL_BACK, "", "" },
|
|
|
|
{ CONTROL('H'), SEL_BACK, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Inside */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_ENTER, SEL_GOIN, "", "" },
|
|
|
|
{ '\r', SEL_GOIN, "", "" },
|
|
|
|
{ KEY_RIGHT, SEL_GOIN, "", "" },
|
|
|
|
{ 'l', SEL_GOIN, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Filter */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ '/', SEL_FLTR, "", "" },
|
2017-06-04 02:19:16 +03:00
|
|
|
/* Toggle filter mode */
|
2017-06-04 09:15:17 +03:00
|
|
|
{ KEY_IC, SEL_MFLTR, "", "" },
|
2017-05-15 17:44:13 +03:00
|
|
|
/* Desktop search */
|
|
|
|
{ CONTROL('_'), SEL_SEARCH, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Next */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'j', SEL_NEXT, "", "" },
|
|
|
|
{ KEY_DOWN, SEL_NEXT, "", "" },
|
|
|
|
{ CONTROL('N'), SEL_NEXT, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Previous */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'k', SEL_PREV, "", "" },
|
|
|
|
{ KEY_UP, SEL_PREV, "", "" },
|
|
|
|
{ CONTROL('P'), SEL_PREV, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Page down */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_NPAGE, SEL_PGDN, "", "" },
|
|
|
|
{ CONTROL('D'), SEL_PGDN, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Page up */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_PPAGE, SEL_PGUP, "", "" },
|
|
|
|
{ CONTROL('U'), SEL_PGUP, "", "" },
|
2017-04-24 00:06:49 +03:00
|
|
|
/* First entry */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_HOME, SEL_HOME, "", "" },
|
2017-04-04 06:46:29 +03:00
|
|
|
{ 'g', SEL_HOME, "", "" },
|
2017-04-03 20:03:46 +03:00
|
|
|
{ CONTROL('A'), SEL_HOME, "", "" },
|
|
|
|
{ '^', SEL_HOME, "", "" },
|
2017-04-24 00:06:49 +03:00
|
|
|
/* Last entry */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ KEY_END, SEL_END, "", "" },
|
2017-04-04 06:46:29 +03:00
|
|
|
{ 'G', SEL_END, "", "" },
|
2017-04-03 20:03:46 +03:00
|
|
|
{ CONTROL('E'), SEL_END, "", "" },
|
|
|
|
{ '$', SEL_END, "", "" },
|
2014-11-06 14:46:37 +03:00
|
|
|
/* Change dir */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'c', SEL_CD, "", "" },
|
2017-04-08 11:16:03 +03:00
|
|
|
/* HOME */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ '~', SEL_CDHOME, "", "" },
|
2017-04-24 00:06:49 +03:00
|
|
|
/* Initial directory */
|
|
|
|
{ '&', SEL_CDBEGIN, "", "" },
|
2017-04-08 11:16:03 +03:00
|
|
|
/* Last visited dir */
|
2017-04-25 07:31:52 +03:00
|
|
|
{ '-', SEL_CDLAST, "", "" },
|
2017-06-11 07:15:50 +03:00
|
|
|
/* Change dir using bookmark */
|
|
|
|
{ 'b', SEL_CDBM, "", "" },
|
2016-02-25 17:54:41 +03:00
|
|
|
/* Toggle hide .dot files */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ '.', SEL_TOGGLEDOT, "", "" },
|
2017-03-29 23:21:52 +03:00
|
|
|
/* Detailed listing */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'd', SEL_DETAIL, "", "" },
|
2017-04-03 02:35:14 +03:00
|
|
|
/* File details */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 'D', SEL_STATS, "", "" },
|
2017-07-02 21:27:41 +03:00
|
|
|
/* Show media info short, run is hacked */
|
|
|
|
{ 'm', SEL_MEDIA, NULL, "" },
|
|
|
|
/* Show media info full, run is hacked */
|
|
|
|
{ 'M', SEL_FMEDIA, "-f", "" },
|
2017-04-12 19:48:03 +03:00
|
|
|
/* Open dir in desktop file manager */
|
|
|
|
{ 'o', SEL_DFB, "", "" },
|
2017-03-29 23:21:52 +03:00
|
|
|
/* Toggle sort by size */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 's', SEL_FSIZE, "", "" },
|
2017-06-22 07:09:17 +03:00
|
|
|
/* Sort by total block count including dir contents */
|
2017-07-02 21:27:41 +03:00
|
|
|
{ 'S', SEL_BSIZE, "", "" },
|
2015-02-05 18:53:50 +03:00
|
|
|
/* Toggle sort by time */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ 't', SEL_MTIME, "", "" },
|
|
|
|
{ CONTROL('L'), SEL_REDRAW, "", "" },
|
2017-06-25 07:33:30 +03:00
|
|
|
{ KEY_F(2), SEL_REDRAW, "", "" },
|
2017-03-30 18:47:00 +03:00
|
|
|
/* Copy currently selected file path */
|
2017-04-03 20:03:46 +03:00
|
|
|
{ CONTROL('K'), SEL_COPY, "", "" },
|
|
|
|
/* Show help */
|
|
|
|
{ '?', SEL_HELP, "", "" },
|
2015-03-12 17:12:01 +03:00
|
|
|
/* Run command */
|
2017-04-01 12:11:07 +03:00
|
|
|
{ '!', SEL_RUN, "sh", "SHELL" },
|
2015-03-12 17:12:01 +03:00
|
|
|
/* Run command with argument */
|
2017-04-01 12:11:07 +03:00
|
|
|
{ 'e', SEL_RUNARG, "vi", "EDITOR" },
|
|
|
|
{ 'p', SEL_RUNARG, "less", "PAGER" },
|
2014-11-06 14:46:37 +03:00
|
|
|
};
|