]> git.mdlowis.com Git - archive/afm.git/commitdiff
cursorjumping & beginnings of seeking
authorabellenir <a@bellenir.com>
Sat, 26 Jul 2014 07:28:41 +0000 (07:28 +0000)
committerabellenir <a@bellenir.com>
Sat, 26 Jul 2014 07:28:41 +0000 (07:28 +0000)
source/input.c
source/state.h
source/workdir.c
source/workdir.h

index f64621cbadf2132017abee6477706d6d37af111b..00c712a78d8951726f1f5491a4b5284b66e5d973 100644 (file)
@@ -33,6 +33,22 @@ static void handle_cd(void) {
     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 },
@@ -41,6 +57,11 @@ static binding_t Default_Bindings[] = {
     { "\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 },
 };
index 92d89d60db23127951df0c1322f4285a0a7ed92e..1da0923d9b54f76c2eab5cde70c1a818547f1f09 100644 (file)
@@ -10,6 +10,8 @@
 #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);
index 4f6b9dc3b17965e09a3da6345138ea86ca5b8761..ab40d4f01ce48839336f8e9ce050559612dc2475 100644 (file)
@@ -149,3 +149,32 @@ void workdir_ls(WorkDir_T* wd){
     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);
+}
+
index caf0bf37f37e64ed050cd808c52b4b38e2b297ae..531fa7365a049b92d64b6b6ee1c9ac198b310a6c 100644 (file)
@@ -36,4 +36,11 @@ void workdir_ls(WorkDir_T*);
 
 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 */