]> git.mdlowis.com Git - projs/tide.git/commitdiff
implemented goto ctag function
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 3 Dec 2016 01:42:26 +0000 (20:42 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 3 Dec 2016 01:42:26 +0000 (20:42 -0500)
TODO.md
inc/edit.h
libedit/view.c
xedit.c
xtagpick

diff --git a/TODO.md b/TODO.md
index c15d465b2d22f20b8dca86e6c0f990f59900a4c5..396c7fc095d4153aa64c67b05f5dd4cf66a4a955 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,4 +1,7 @@
 # Implementation Tweaks and Bug Fixes
+
+* disable autoindent when pasting text
+* update getstr to select context when selection is null
 * Use select to check for error strings in exec.c
 * Should not be able to undo initial tag line text insertion
 * Disallow scrolling past end of buffer
index d7b659766452e983b442e797d1dd75075edff515..aef9150974cf399d8756b9663d92514a8eea318c 100644 (file)
@@ -158,6 +158,7 @@ void view_append(View* view, char* str);
 char* view_getstr(View* view, Sel* sel);
 void view_scroll(View* view, int move);
 void view_scrollpage(View* view, int move);
+void view_setln(View* view, size_t line);
 
 /* Command Executions
  *****************************************************************************/
index b3e918d3f883bd70933c88acb5a68449f8e222e3..90d5f5a82c587a0f48f1d62ba0b32b8dc5e62fc7 100644 (file)
@@ -509,3 +509,9 @@ void view_scrollpage(View* view, int move) {
     move = (move < 0 ? -1 : 1) * view->nrows;
     view_scroll(view, move);
 }
+
+void view_setln(View* view, size_t line) {
+    view->selection.end = buf_setln(&(view->buffer), line);
+    view->selection.beg = view->selection.end;
+    view->sync_needed   = true;
+}
diff --git a/xedit.c b/xedit.c
index 95d8c6f8f26e4ca7b6b172bf6b5519afe8693e2c..2184152ff1f6897e3501d28571d2612ac54ca4bc 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -49,6 +49,7 @@ static void search(void);
 static void execute(void);
 static void find(char* arg);
 static void open_file(void);
+static void goto_ctag(void);
 
 // Tag/Cmd Execution
 static Tag* tag_lookup(char* cmd);
@@ -146,7 +147,7 @@ static KeyBinding Bindings[] = {
     { ModCtrl, 'd',        execute      },
     { ModCtrl, 'o',        open_file    },
     //{ ModCtrl, 'p',        find_ctag    },
-    //{ ModCtrl, 'g',        goto_ctag    },
+    { ModCtrl, 'g',        goto_ctag    },
 };
 
 /* External Commands
@@ -160,6 +161,7 @@ static char* PasteCmd[] = { "xsel", "-bo", NULL };
 #endif
 static char* ShellCmd[] = { "/bin/sh", "-c", NULL, NULL };
 static char* PickFileCmd[] = { "xfilepick", ".", NULL };
+static char* PickTagCmd[] = { "xtagpick", "tags", NULL, NULL };
 static char* OpenCmd[] = { "xedit", NULL, NULL };
 static char* SedCmd[] = { "sed", "-e", NULL, NULL };
 
@@ -511,6 +513,25 @@ static void open_file(void) {
     free(file);
 }
 
+static void goto_ctag(void) {
+    char* str = view_getstr(currview(), NULL);
+    if (str) {
+        PickTagCmd[2] = str;
+        char* pick = cmdread(PickTagCmd, NULL);
+        if (pick) {
+            Buf* buf = getbuf(EDIT);
+            if (0 == strncmp(buf->path, pick, strlen(buf->path))) {
+                view_setln(getview(EDIT), strtoul(strrchr(pick, ':')+1, NULL, 0));
+                Focused = EDIT;
+            } else {
+                OpenCmd[1] = pick;
+                cmdrun(OpenCmd, NULL);
+            }
+        }
+    }
+    free(str);
+}
+
 /* Tag/Cmd Execution
  *****************************************************************************/
 static Tag* tag_lookup(char* cmd) {
index 6fb656aa198580db8d7a05c5cf27b0091e6821bb..15c4d06c4fdb50d5a972bc022b99decc3149653b 100755 (executable)
--- a/xtagpick
+++ b/xtagpick
@@ -7,7 +7,7 @@ if [ "" == "$TAG" ] || [ "" == "$TAGFILE" ]; then
     exit 1
 fi
 
-awk -vTAG="$TAG" '
+awk -v TAG="$TAG" '
 BEGIN { FS = "[\t]+" }
 ($1 == TAG) {
     matchstr = $3