My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

nnn.h 5.4 KiB

il y a 10 ans
il y a 7 ans
il y a 7 ans
il y a 7 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /* See LICENSE file for copyright and license details. */
  2. #define CONTROL(c) ((c) ^ 0x40)
  3. /* Supported actions */
  4. enum action {
  5. SEL_BACK = 1,
  6. SEL_GOIN,
  7. SEL_NEXT,
  8. SEL_PREV,
  9. SEL_PGDN,
  10. SEL_PGUP,
  11. SEL_HOME,
  12. SEL_END,
  13. SEL_CD,
  14. SEL_CDHOME,
  15. SEL_CDBEGIN,
  16. SEL_CDLAST,
  17. SEL_CDBM,
  18. SEL_PIN,
  19. SEL_VISIT,
  20. SEL_FLTR,
  21. SEL_MFLTR,
  22. SEL_SEARCH,
  23. SEL_TOGGLEDOT,
  24. SEL_DETAIL,
  25. SEL_STATS,
  26. SEL_MEDIA,
  27. SEL_FMEDIA,
  28. SEL_DFB,
  29. SEL_LIST,
  30. SEL_EXTRACT,
  31. SEL_FSIZE,
  32. SEL_BSIZE,
  33. SEL_MTIME,
  34. SEL_REDRAW,
  35. SEL_COPY,
  36. SEL_COPYMUL,
  37. SEL_QUOTE,
  38. SEL_OPEN,
  39. SEL_NEW,
  40. SEL_RENAME,
  41. SEL_RENAMEALL,
  42. SEL_HELP,
  43. SEL_RUN,
  44. SEL_RUNARG,
  45. SEL_CDQUIT,
  46. SEL_QUIT,
  47. };
  48. /* Associate a pressed key to an action */
  49. struct key {
  50. int sym; /* Key pressed */
  51. enum action act; /* Action */
  52. char *run; /* Program to run or program option */
  53. char *env; /* Environment variable to run */
  54. };
  55. /* Extension pattern and mime combination */
  56. struct assoc {
  57. char *regex; /* Regex to match on filename */
  58. char *mime; /* File type */
  59. };
  60. static struct assoc assocs[] = {
  61. { "\\.(c|cpp|h|log|md|py|rb|sh|txt)$", "text" },
  62. };
  63. static struct key bindings[] = {
  64. /* Back */
  65. { KEY_BACKSPACE, SEL_BACK, "", "" },
  66. { KEY_LEFT, SEL_BACK, "", "" },
  67. { 'h', SEL_BACK, "", "" },
  68. { CONTROL('H'), SEL_BACK, "", "" },
  69. /* Inside */
  70. { KEY_ENTER, SEL_GOIN, "", "" },
  71. { '\r', SEL_GOIN, "", "" },
  72. { KEY_RIGHT, SEL_GOIN, "", "" },
  73. { 'l', SEL_GOIN, "", "" },
  74. /* Next */
  75. { 'j', SEL_NEXT, "", "" },
  76. { KEY_DOWN, SEL_NEXT, "", "" },
  77. { CONTROL('N'), SEL_NEXT, "", "" },
  78. /* Previous */
  79. { 'k', SEL_PREV, "", "" },
  80. { KEY_UP, SEL_PREV, "", "" },
  81. { CONTROL('P'), SEL_PREV, "", "" },
  82. /* Page down */
  83. { KEY_NPAGE, SEL_PGDN, "", "" },
  84. { CONTROL('D'), SEL_PGDN, "", "" },
  85. /* Page up */
  86. { KEY_PPAGE, SEL_PGUP, "", "" },
  87. { CONTROL('U'), SEL_PGUP, "", "" },
  88. /* First entry */
  89. { KEY_HOME, SEL_HOME, "", "" },
  90. { 'g', SEL_HOME, "", "" },
  91. { CONTROL('A'), SEL_HOME, "", "" },
  92. { '^', SEL_HOME, "", "" },
  93. /* Last entry */
  94. { KEY_END, SEL_END, "", "" },
  95. { 'G', SEL_END, "", "" },
  96. { CONTROL('E'), SEL_END, "", "" },
  97. { '$', SEL_END, "", "" },
  98. /* Change dir */
  99. { 'c', SEL_CD, "", "" },
  100. /* HOME */
  101. { '~', SEL_CDHOME, "", "" },
  102. /* Initial directory */
  103. { '&', SEL_CDBEGIN, "", "" },
  104. /* Last visited dir */
  105. { '-', SEL_CDLAST, "", "" },
  106. /* Change dir using bookmark */
  107. { CONTROL('B'), SEL_CDBM, "", "" },
  108. /* Mark a path to visit later */
  109. { 'b', SEL_PIN, "", "" },
  110. /* Visit marked directory */
  111. { CONTROL('V'), SEL_VISIT, "", "" },
  112. /* Filter */
  113. { '/', SEL_FLTR, "", "" },
  114. /* Toggle filter mode */
  115. { KEY_IC, SEL_MFLTR, "", "" },
  116. { CONTROL('I'), SEL_MFLTR, "", "" },
  117. /* Desktop search */
  118. { CONTROL('_'), SEL_SEARCH, "", "" },
  119. /* Toggle hide .dot files */
  120. { '.', SEL_TOGGLEDOT, "", "" },
  121. /* Detailed listing */
  122. { 'd', SEL_DETAIL, "", "" },
  123. /* File details */
  124. { 'D', SEL_STATS, "", "" },
  125. /* Show media info short, run is hacked */
  126. { 'm', SEL_MEDIA, NULL, "" },
  127. /* Show media info full, run is hacked */
  128. { 'M', SEL_FMEDIA, "-f", "" },
  129. /* Open dir in desktop file manager */
  130. { 'o', SEL_DFB, "", "" },
  131. /* List archive */
  132. { 'F', SEL_LIST, "-l", "" },
  133. /* Extract archive */
  134. { CONTROL('F'), SEL_EXTRACT, "-x", "" },
  135. /* Toggle sort by size */
  136. { 's', SEL_FSIZE, "", "" },
  137. /* Sort by total block count including dir contents */
  138. { 'S', SEL_BSIZE, "", "" },
  139. { CONTROL('J'), SEL_BSIZE, "", "" },
  140. /* Toggle sort by time */
  141. { 't', SEL_MTIME, "", "" },
  142. /* Redraw window */
  143. { CONTROL('L'), SEL_REDRAW, "", "" },
  144. { KEY_F(5), SEL_REDRAW, "", "" }, /* Undocumented */
  145. /* Copy currently selected file path */
  146. { CONTROL('K'), SEL_COPY, "", "" },
  147. /* Toggle copy multiple file paths */
  148. { CONTROL('Y'), SEL_COPYMUL, "", "" },
  149. /* Toggle quote on while copy */
  150. { CONTROL('T'), SEL_QUOTE, "", "" },
  151. /* Open in a custom application */
  152. { CONTROL('O'), SEL_OPEN, "", "" },
  153. /* Create a new file */
  154. { 'n', SEL_NEW, "", "" },
  155. /* Show rename prompt */
  156. { CONTROL('R'), SEL_RENAME, "", "" },
  157. { KEY_F(2), SEL_RENAME, "", "" }, /* Undocumented */
  158. /* Rename contents of current dir */
  159. { 'R', SEL_RENAMEALL, "", "" },
  160. /* Show help */
  161. { '?', SEL_HELP, "", "" },
  162. /* Run command */
  163. { '!', SEL_RUN, "sh", "SHELL" },
  164. /* Run command with argument */
  165. { 'e', SEL_RUNARG, "vi", "EDITOR" },
  166. { 'p', SEL_RUNARG, "less", "PAGER" },
  167. /* Change dir on quit */
  168. { 'Q', SEL_CDQUIT, "", "" },
  169. { CONTROL('G'), SEL_CDQUIT, "", "" },
  170. /* Quit */
  171. { 'q', SEL_QUIT, "", "" },
  172. { CONTROL('X'), SEL_QUIT, "", "" },
  173. };