]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed implementation bug in right-click search
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 4 Apr 2017 19:50:23 +0000 (15:50 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 4 Apr 2017 19:50:23 +0000 (15:50 -0400)
TODO.md
inc/edit.h
lib/view.c
xedit.c

diff --git a/TODO.md b/TODO.md
index 39cdd71c6c7342f875c56effc45e5412f7a28efe..8d87ad372785750b6e3a3550439ce6e1fc0ed86f 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,7 +2,8 @@
 
 Up Next:
 
-* Status line should omit characters from beginning of path to make file path fit
+* fix crash on saving read-only file
+
 * clipboard does not persist after exit
 * Run commands in the background and don't block the main thread.
 * Make Fn keys execute nth command in the tags buffer
@@ -14,6 +15,7 @@ Up Next:
 * 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
+* Status line should omit characters from beginning of path to make file path fit
 
 Straight-up Bugs:
 
index cfb0bc57107582284ce2ad14bc2d523b70a6963f..2a12642bd389eaadf0039804ee2132402249edad 100644 (file)
@@ -142,8 +142,8 @@ Row* view_getrow(View* view, size_t row);
 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_findstr(View* view, int dir, char* str);
+char* view_fetch(View* view, size_t row, size_t col);
+bool 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);
 void view_bol(View* view, bool extsel);
index 11ae3a2af32caa455061873f5288005cbb411ea2..22d543b5d1f76f03289ca6d21a783dc7a534be03 100644 (file)
@@ -348,7 +348,7 @@ size_t view_selsize(View* view) {
     return num_selected(view->selection);
 }
 
-char* view_fetchcmd(View* view, size_t row, size_t col) {
+char* view_fetch(View* view, size_t row, size_t col) {
    char* str = NULL;
     size_t off = getoffset(view, row, col);
     if (off != SIZE_MAX) {
@@ -364,12 +364,14 @@ char* view_fetchcmd(View* view, size_t row, size_t col) {
     return str;
 }
 
-void view_findstr(View* view, int dir, char* str) {
+bool view_findstr(View* view, int dir, char* str) {
     Sel sel = view->selection;
     buf_findstr(&(view->buffer), dir, str, &sel.beg, &sel.end);
+    bool found = (0 != memcmp(&sel, &(view->selection), sizeof(Sel)));
     view->selection = sel;
     view->sync_needed = true;
     view->sync_center = true;
+    return found;
 }
 
 void view_insert(View* view, bool indent, Rune rune) {
diff --git a/xedit.c b/xedit.c
index 53ab28e80c89a467b9d99b6688a07c6944ce3e84..9677ed80f169daec3c2fc962b77c5fea3a1a0e55 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -168,7 +168,7 @@ void onmousemiddle(WinRegion id, size_t count, size_t row, size_t col) {
     if (win_btnpressed(MOUSE_BTN_LEFT)) {
         cut();
     } else {
-        char* str = view_fetchcmd(win_view(id), row, col);
+        char* str = view_fetch(win_view(id), row, col);
         if (str) exec(str);
         free(str);
     }
@@ -180,11 +180,8 @@ void onmouseright(WinRegion id, size_t count, size_t row, size_t col) {
     } else {
         SearchDir *= (x11_keymodsset(ModShift) ? -1 : +1);
         free(SearchTerm);
-        SearchTerm = view_getstr(win_view(id), NULL);
-        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))) {
+        SearchTerm = view_fetch(win_view(id), row, col);
+        if (view_findstr(win_view(EDIT), SearchDir, SearchTerm)) {
             win_setregion(EDIT);
             win_warpptr(EDIT);
         }