]> git.mdlowis.com Git - projs/tide.git/commitdiff
Added GoTo tag to mirror ctrl+g functionality
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 1 May 2017 00:53:34 +0000 (20:53 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 1 May 2017 00:53:34 +0000 (20:53 -0400)
TODO.md
docs/xedit.1
docs/xedit.1.md
xedit.c

diff --git a/TODO.md b/TODO.md
index 0aea04ec4f9098cea757eeff5f75a2f5850d99ce..a8a93d3e6a92b092720285e99ca7709415eae5f0 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -3,7 +3,6 @@
 Up Next:
 
 * refactor x11.c and win.c
-* Add a GoTo tag for ctags lookup and line number jump (or right click magic?)
 * Add keyboard shortcut to highlight the thing under the cursor
 * Make Fn keys execute nth command in the tags buffer
 * Run commands in the background and don't block the main thread.
index 030f3377abc26c8b8ce6c8c43e7e51f17cd7a0a8..dfb531e36d6ed43da957bc4492fee8c0fdd48930 100644 (file)
@@ -232,6 +232,10 @@ Toggle the line\-ending style for the buffers contents between LF and CRLF
 Find the next occurrence of the selected text\.
 .
 .TP
+\fBGoTo [arg]\fR
+Jump to a specific line number or symbol\.
+.
+.TP
 \fBIndent\fR
 Toggle the autoindent feature on or off\.
 .
index 52fc42fc61b6c40e041f472089f6ee5f7005c16c..c0548f9e16a6f3f621cc006fca92e5a54b40a132 100644 (file)
@@ -219,6 +219,8 @@ search operation to be applied in the opposite direction of the previous.
     Toggle the line-ending style for the buffers contents between LF and CRLF
 * `Find [term]`:
     Find the next occurrence of the selected text.
+* `GoTo [arg]`:
+    Jump to a specific line number or symbol.
 * `Indent`:
     Toggle the autoindent feature on or off.
 * `Paste`:
diff --git a/xedit.c b/xedit.c
index 17ccab1368c16ce314b9b86fc66c1ffb805e3762..c0dafa64f94299e1d1f613962d9986ee9c7d6535 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -287,7 +287,7 @@ static void redo(void) {
     view_redo(win_view(FOCUSED));
 }
 
-static void tag_save(char* arg) {
+static void saveas(char* arg) {
     if (arg) {
         char* path = win_buf(EDIT)->path;
         win_buf(EDIT)->path = stringdup(arg);
@@ -381,17 +381,21 @@ static void complete(void) {
     free(PickTagCmd[3]);
 }
 
-static void goto_ctag(void) {
-    char* str = view_getctx(win_view(FOCUSED));
-    if (str) {
-        size_t line = strtoul(str, NULL, 0);
+static void jump_to(char* arg) {
+    if (arg) {
+        size_t line = strtoul(arg, NULL, 0);
         if (line) {
             view_setln(win_view(EDIT), line);
             win_setregion(EDIT);
         } else {
-            pick_symbol(str);
+            pick_symbol(arg);
         }
     }
+}
+
+static void goto_ctag(void) {
+    char* str = view_getctx(win_view(FOCUSED));
+    jump_to(str);
     free(str);
 }
 
@@ -446,13 +450,14 @@ static void newline(void) {
 static Tag Builtins[] = {
     { .tag = "Quit",   .action.noarg = quit     },
     { .tag = "Save",   .action.noarg = save     },
-    { .tag = "SaveAs", .action.arg   = tag_save },
+    { .tag = "SaveAs", .action.arg   = saveas   },
     { .tag = "Cut",    .action.noarg = cut      },
     { .tag = "Copy",   .action.noarg = copy     },
     { .tag = "Paste",  .action.noarg = paste    },
     { .tag = "Undo",   .action.noarg = tag_undo },
     { .tag = "Redo",   .action.noarg = tag_redo },
     { .tag = "Find",   .action.arg   = find     },
+    { .tag = "GoTo",   .action.arg   = jump_to  },
     { .tag = "Tabs",   .action.noarg = tabs     },
     { .tag = "Indent", .action.noarg = indent   },
     { .tag = "Eol",    .action.noarg = eol_mode },