]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed a minor bug in picktag and added a new shortcut for filename/filepath completio...
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 9 Jan 2019 14:32:11 +0000 (09:32 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 9 Jan 2019 14:32:11 +0000 (09:32 -0500)
TODO.md
bin/fcomplete [new file with mode: 0755]
bin/picktag
config.h
src/tide.c

diff --git a/TODO.md b/TODO.md
index 210eed7a50fe4dba6ac81214c8c694231d5ea32b..86a780865c6681c3359b411c54ac1968dc815240 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -9,7 +9,6 @@
 * registrar: should remove invalid windows from registry when detected
 * tide: Ctrl+D should not pass tag name as arg when executing tag commands
 * tide: gap buffer does not handle UTF-8 currently
-* filename/path completion shortcut
 * pick can return null if mouse clicked on empty row
 
 ## BACKLOG
diff --git a/bin/fcomplete b/bin/fcomplete
new file mode 100755 (executable)
index 0000000..2575387
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+orig="$1"
+path="${orig%/*}"
+file="${orig##*/}"
+[ "$path" == "$file" ] && path="."
+printf "%s" "$(find "$path" -path "$path/$file*" | pick "$path/$file")"
index 1508e9ed2df7b28c84cbbb1f5c59ec006d3f3125..73d41c29b381047214c347cea2ca54790ec31e2a 100755 (executable)
@@ -21,7 +21,9 @@ printtags(){
 }
 
 print(){
-    printf "%s" "$(printtags | pick "$TAG")"
+    tag="$(printtags | pick "$TAG")"
+    [ "" == "$tag" ] && tag="$TAG"
+    printf "%s" "$tag"
 }
 
 fetch(){
index 9dfd6a5d835e6b42553d142f2f6b8c9204aacef4..08ed519bb45be10a1b0ad56115fc6a66895a30b0 100644 (file)
--- a/config.h
+++ b/config.h
@@ -15,6 +15,7 @@ enum { /* Color Names */
 #define CMD_TIDE "!tide"
 #define CMD_PICKFILE "!pickfile ."
 #define CMD_COMPLETE "<picktag print tags"
+#define CMD_FCOMPLETE "<fcomplete"
 #define CMD_GOTO_TAG "!picktag fetch tags"
 
 /* Command used to open file in editor at a given line */
index 3ae0589e311c48ebd8d08bf18f61564fce6df3cb..c5f8c36cacb375e0107194ae5da9cf405426422c 100644 (file)
@@ -715,6 +715,13 @@ static void complete(char* arg) {
     cmd_execwitharg(CMD_COMPLETE, view_getstr(view));
 }
 
+static void fcomplete(char* arg) {
+    (void)arg;
+    View* view = win_view(FOCUSED);
+    view_selectobj(view, risfile);
+    cmd_execwitharg(CMD_FCOMPLETE, view_getstr(view));
+}
+
 static void jump_to(char* arg) {
     if (arg) {
         size_t line = strtoul(arg, NULL, 0);
@@ -861,18 +868,19 @@ static KeyBinding Bindings[] = {
     { .mods = ModCtrl|ModShift, .key = '?', .fn = lnexec, .arg = "|c-" },
 
     /* Implementation Specific */
-    { .mods = ModNone,      .key = KEY_ESCAPE, .fn = select_prev  },
-    { .mods = ModCtrl,      .key = 't',        .fn = change_focus },
-    { .mods = ModCtrl,      .key = 'q',        .fn = quit         },
-    { .mods = ModCtrl,      .key = 'h',        .fn = highlight    },
-    { .mods = ModOneOrMore, .key = 'f',        .fn = search       },
-    { .mods = ModCtrl,      .key = 'd',        .fn = execute      },
-    { .mods = ModOneOrMore, .key = 'o',        .fn = open_file    },
-    { .mods = ModCtrl,      .key = 'p',        .fn = pick_ctag    },
-    { .mods = ModOneOrMore, .key = 'g',        .fn = goto_ctag    },
-    { .mods = ModCtrl,      .key = 'n',        .fn = new_win      },
-    { .mods = ModOneOrMore, .key = '\n',       .fn = newline      },
-    { .mods = ModCtrl,      .key = ' ',        .fn = complete     },
+    { .mods = ModNone,          .key = KEY_ESCAPE, .fn = select_prev  },
+    { .mods = ModCtrl,          .key = 't',        .fn = change_focus },
+    { .mods = ModCtrl,          .key = 'q',        .fn = quit         },
+    { .mods = ModCtrl,          .key = 'h',        .fn = highlight    },
+    { .mods = ModOneOrMore,     .key = 'f',        .fn = search       },
+    { .mods = ModCtrl,          .key = 'd',        .fn = execute      },
+    { .mods = ModOneOrMore,     .key = 'o',        .fn = open_file    },
+    { .mods = ModCtrl,          .key = 'p',        .fn = pick_ctag    },
+    { .mods = ModOneOrMore,     .key = 'g',        .fn = goto_ctag    },
+    { .mods = ModCtrl,          .key = 'n',        .fn = new_win      },
+    { .mods = ModOneOrMore,     .key = '\n',       .fn = newline      },
+    { .mods = ModCtrl,          .key = ' ',        .fn = complete     },
+    { .mods = ModCtrl|ModShift, .key = ' ',        .fn = fcomplete    },
 
     { 0, 0, 0, 0 }
 };