]> git.mdlowis.com Git - projs/tide.git/commitdiff
Tweaked right click behavior to always search the content region
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 4 Apr 2017 14:12:44 +0000 (10:12 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 4 Apr 2017 14:12:44 +0000 (10:12 -0400)
TODO.md
inc/edit.h
lib/view.c
xedit.c

diff --git a/TODO.md b/TODO.md
index 3bd142a3ea5d7b1783fd9a3fd35dba2e92dcb492..39cdd71c6c7342f875c56effc45e5412f7a28efe 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -9,13 +9,11 @@ Up Next:
 
 * check for file changes on save
 * check for file changes when window regains focus
-* Right click in tags region should search edit region
 * 100% coverage with unit and unit-integration tests
 * Add a SaveAs tag that takes an argument for the filename to save as
 * 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
 * right click to fetch file or line
-* selecting text should set PRIMARY x11 selection
 
 Straight-up Bugs:
 
index 445b46fd7ad6ec71d9656019e1e43376966d0f87..735c92fa5e7603883bf4f4f58f225ea667ab5811 100644 (file)
@@ -143,7 +143,6 @@ void view_byrune(View* view, int move, bool extsel);
 void view_byword(View* view, int move, bool extsel);
 void view_byline(View* view, int move, bool extsel);
 char* view_fetchcmd(View* view, size_t row, size_t col);
-void view_find(View* view, int dir, size_t row, size_t col);
 void view_findstr(View* view, int dir, char* str);
 void view_insert(View* view, bool indent, Rune rune);
 void view_delete(View* view, int dir, bool byword);
index ff04d6a56b76f7d2fa9684d6adf2a3da458ec42b..2a4de67b6f6568cec676e01aaf9f9a8efe91fd5e 100644 (file)
@@ -340,8 +340,7 @@ void view_select(View* view, size_t row, size_t col) {
     view_setcursor(view, row, col);
     Sel sel = view->selection;
     selcontext(view, &sel);
-    if (sel.end+1 < buf_end(&(view->buffer)))
-        sel.end++;
+    sel.end = buf_byrune(&(view->buffer), sel.end, RIGHT);
     view->selection = sel;
 }
 
@@ -365,25 +364,6 @@ char* view_fetchcmd(View* view, size_t row, size_t col) {
     return str;
 }
 
-void view_find(View* view, int dir, size_t row, size_t col) {
-    size_t off = getoffset(view, row, col);
-    if (off != SIZE_MAX) {
-        Sel sel = view->selection;
-        if (!num_selected(sel) || !in_selection(sel, off)) {
-            view_setcursor(view, row, col);
-            sel = view->selection;
-            selcontext(view, &sel);
-            buf_find(&(view->buffer), dir, &sel.beg, &sel.end);
-            sel.end++;
-        } else {
-            buf_find(&(view->buffer), dir, &sel.beg, &sel.end);
-        }
-        view->selection = sel;
-        view->sync_needed = true;
-        view->sync_center = true;
-    }
-}
-
 void view_findstr(View* view, int dir, char* str) {
     Sel sel = view->selection;
     buf_findstr(&(view->buffer), dir, str, &sel.beg, &sel.end);
diff --git a/xedit.c b/xedit.c
index c471b0206868390954da9a54cd1a01347be41ecf..fa4951e0d5cde0f163976f3229b343e9bcfc2569 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -180,9 +180,14 @@ void onmouseright(WinRegion id, size_t count, size_t row, size_t col) {
     } else {
         SearchDir *= (x11_keymodsset(ModShift) ? -1 : +1);
         free(SearchTerm);
-        view_find(win_view(id), SearchDir, row, col);
         SearchTerm = view_getstr(win_view(id), NULL);
-        win_warpptr(id);
+        Sel before = win_view(EDIT)->selection;
+        view_findstr(win_view(EDIT), SearchDir, SearchTerm);
+        Sel after = win_view(EDIT)->selection;
+        if (memcmp(&before, &after, sizeof(Sel))) {
+            win_setregion(EDIT);
+            win_warpptr(EDIT);
+        }
     }
 }
 
@@ -555,4 +560,3 @@ int main(int argc, char** argv) {
     return 0;
 }
 #endif
-