]> git.mdlowis.com Git - projs/tide.git/commitdiff
goto ctag now selects based on context of nothing is selected
authorMichael D. Lowis <mike@mdlowis.com>
Sat, 3 Dec 2016 02:07:48 +0000 (21:07 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Sat, 3 Dec 2016 02:07:48 +0000 (21:07 -0500)
TODO.md
inc/edit.h
libedit/view.c
xedit.c

diff --git a/TODO.md b/TODO.md
index 396c7fc095d4153aa64c67b05f5dd4cf66a4a955..000eb3fb209ac8c4ecaca6e218fd46f3588b7111 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,6 +2,7 @@
 
 * disable autoindent when pasting text
 * update getstr to select context when selection is null
+* center find results and jumped to line on screen
 * 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
@@ -16,8 +17,6 @@
 # Internals and Miscellaneous
 
 * Calculate line numbers and keep up to date while editing
-* Implement ctags lookup and regeneration
-* Implement cscope lookup and regeneration
 
 # Auxillary Programs
 
index aef9150974cf399d8756b9663d92514a8eea318c..0ffca4fca226bd730c815952aee791783063dbb1 100644 (file)
@@ -156,6 +156,7 @@ void view_redo(View* view);
 void view_putstr(View* view, char* str);
 void view_append(View* view, char* str);
 char* view_getstr(View* view, Sel* sel);
+char* view_getctx(View* view);
 void view_scroll(View* view, int move);
 void view_scrollpage(View* view, int move);
 void view_setln(View* view, size_t line);
index 90d5f5a82c587a0f48f1d62ba0b32b8dc5e62fc7..814de2bc42505e0a48f6513b4744fbd699677448 100644 (file)
@@ -156,6 +156,7 @@ void view_init(View* view, char* file) {
     if (file) {
         view->selection.end = buf_load(&(view->buffer), file);
         view->selection.beg = view->selection.end;
+        view->sync_needed   = true;
     }
 }
 
@@ -494,6 +495,14 @@ char* view_getstr(View* view, Sel* range) {
     return str;
 }
 
+char* view_getctx(View* view) {
+    if (0 == num_selected(view->selection)) {
+        selcontext(view, &(view->selection));
+        view->selection.end++;
+    }
+    return view_getstr(view, NULL);
+}
+
 void view_scroll(View* view, int move) {
     int dir = (move < 0 ? -1 : 1);
     move *= dir;
diff --git a/xedit.c b/xedit.c
index 2184152ff1f6897e3501d28571d2612ac54ca4bc..048051e0cda287d5484ca0419f1c93c8e08734b7 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -514,7 +514,7 @@ static void open_file(void) {
 }
 
 static void goto_ctag(void) {
-    char* str = view_getstr(currview(), NULL);
+    char* str = view_getctx(currview());
     if (str) {
         PickTagCmd[2] = str;
         char* pick = cmdread(PickTagCmd, NULL);