workdir_cd(state_get_focused_frame()->workdir);
}
+static void handle_scroll_to_top(void) {
+ workdir_scroll_to_top(state_get_focused_frame()->workdir);
+}
+static void handle_scroll_to_bottom(void) {
+ workdir_scroll_to_bot(state_get_focused_frame()->workdir);
+}
+static void handle_page_up(void){
+ workdir_jump_up(state_get_focused_frame()->workdir);
+}
+static void handle_page_down(void){
+ workdir_jump_down(state_get_focused_frame()->workdir);
+}
+
+static void search_mode(void){
+}
+
static binding_t Default_Bindings[] = {
{ "a", &handle_aardvark },
{ "q", &handle_quit },
{ "\n", &handle_cd },
{ "wn", &screen_open },
{ "wc", &screen_close },
+ { "/", &search_mode },
+ { "gg", &handle_scroll_to_top },
+ { "G", &handle_scroll_to_bottom },
+ { "U", &handle_page_up },
+ { "D", &handle_page_down },
//{ "wj", NULL },
//{ "wk", NULL },
};
#include <stdbool.h>
#include "screen.h"
+typedef enum{ MODE_NORMAL, MODE_SEARCH } MODE;
+
bool state_get_running(void);
void state_set_running(bool val);
bool state_get_screen_dirty(void);
mem_release(cmd);
}
+void workdir_seek(WorkDir_T* wd, char* search){
+ int i = 0;
+ if(strcmp(((File_T*)vec_at(wd->vfiles, 0))->name, "..") == 0) i++;
+ while(i < vec_size(wd->vfiles) && strcmp(search, ((File_T*)vec_at(wd->vfiles, i))->name) < 0) i++;
+ wd->idx = i;
+}
+
+void workdir_scroll_to_top(WorkDir_T* wd){
+ wd->idx = 0;
+ state_set_screen_dirty(true);
+}
+
+void workdir_scroll_to_bot(WorkDir_T* wd){
+ wd->idx = vec_size(wd->vfiles) - 1;
+ state_set_screen_dirty(true);
+}
+
+void workdir_jump_up(WorkDir_T* wd){
+ wd->idx -= 20;
+ if(wd->idx < 0) wd->idx = 0;
+ state_set_screen_dirty(true);
+}
+
+void workdir_jump_down(WorkDir_T* wd){
+ wd->idx += 20;
+ if(wd->idx >= vec_size(wd->vfiles)) wd->idx = vec_size(wd->vfiles)-1;
+ state_set_screen_dirty(true);
+}
+
bool is_dir(char* path);
+void workdir_seek(WorkDir_T* wd, char* search);
+
+void workdir_scroll_to_top(WorkDir_T* wd);
+void workdir_scroll_to_bot(WorkDir_T* wd);
+void workdir_jump_down(WorkDir_T* wd);
+void workdir_jump_up(WorkDir_T* wd);
+
#endif /* WORKDIR_H */