Add ctrl + u/d jumps

This commit is contained in:
Piotr Marendowski 2024-03-11 21:24:54 +01:00
parent cd2366fab1
commit 7ab7641572
2 changed files with 22 additions and 3 deletions

View file

@ -11,7 +11,7 @@ Consider this project incomplete and WIP!
| Feature | Ported | Dropped | Added | | Feature | Ported | Dropped | Added |
|---------|:------:|:-------:|:-----:| |---------|:------:|:-------:|:-----:|
| Standard movement | X | | | | Standard movement | X | | |
| Advanced movement (jumps) | | | | | Advanced movement (jumps) | X | | |
| Searching | | | | | Searching | | | |
| File preview | | | X | | File preview | | | X |
| Sorting | | | | | Sorting | | | |

23
ccc.c
View file

@ -11,6 +11,7 @@
#define ESC 0x1B /* \e or \033 */ #define ESC 0x1B /* \e or \033 */
#define PH 1 /* panel height */ #define PH 1 /* panel height */
#define JUMP_NUM 14 /* how long ctrl + u/d jump are */
typedef struct { typedef struct {
WINDOW *window; WINDOW *window;
@ -92,23 +93,41 @@ int main(int argc, char** argv)
if (focus == 0) focus++; if (focus == 0) focus++;
else if (focus == 1) focus--; else if (focus == 1) focus--;
break; break;
/* jump up */
case '\x15':
if ((current_selection - JUMP_NUM) > 0)
current_selection -= JUMP_NUM;
else
current_selection = 0;
highlight_current_line();
break;
/* go up */ /* go up */
case 'k': case 'k':
if (current_selection > 0) if (current_selection > 0)
current_selection--; current_selection--;
highlight_current_line();
break;
/* jump down */
case '\x04':
if ((current_selection + JUMP_NUM) < (files_len() - 1))
current_selection += JUMP_NUM;
else
current_selection = (files_len() - 1);
highlight_current_line(); highlight_current_line();
break; break;
/* go down */ /* go down */
case 'j': case 'j':
if (current_selection < files_len() - 1) if (current_selection < (files_len() - 1))
current_selection++; current_selection++;
highlight_current_line(); highlight_current_line();
break; break;
/* jump to the bottom */ /* jump to the bottom */
case 'G': case 'G':
current_selection = files_len() - 1; current_selection = (files_len() - 1);
highlight_current_line(); highlight_current_line();
break; break;
/* jump to the top */ /* jump to the top */