]> git.mdlowis.com Git - projs/tide.git/commitdiff
Focus follows mouse between regions and the initial content in the tag line can no...
authorMichael D. Lowis <mike.lowis@gentex.com>
Wed, 21 Dec 2016 17:51:42 +0000 (12:51 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Wed, 21 Dec 2016 17:51:42 +0000 (12:51 -0500)
TODO.md
inc/edit.h
inc/x11.h
libedit/buf.c
libx/x11.c
xedit.c

diff --git a/TODO.md b/TODO.md
index ca6e2dbc3f32da8c4c02913ced91a275498df261..f2760e1b310f6615e7c59aec93c90e52f33564e6 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -1,25 +1,24 @@
 # Implementation Tweaks and Bug Fixes
 
-* Indent on first line of buffer causes infinite loop
+* Should not be able to undo initial tag line text insertion
 * block selection should handle brace-balancing
-* Add a GoTo tag for ctags lookup and line number jump
+* Indent on first line of buffer causes infinite loop
 * 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
 * Add a ctrl+space shortcut to autocomplete ctag
 * Use select to check for error strings in exec.c
-* Should not be able to undo initial tag line text insertion
 * check for file changes on save
-* backspace should delete indent if preceded by whitespace
 * context sensitive selection of words, commands, line numbers, or filenames.
 
 Nice to haves: 
 
-* focus should follow mouse between regions
 * Expand tabs setting should be disabled if opened file contains tabs
 * Add a tools dir to namespace utility scripts only useful inside the editor
 * shift+click to extend selection
 * implement command diffing logic to optimize the undo/redo log
 * add command line flags to toggle options (Tabs, Indent, etc..)
 * check for file changes when window regains focus
+* backspace should delete indent if preceded by whitespace
 
 Need to reproduce:
 
index 5006c788ada380d4a4b9896e03234ff84c5c363b..e27e6612fbcc6decba03fe0ec5cb8aac5a6779c3 100644 (file)
@@ -68,6 +68,7 @@ unsigned buf_change(Buf* buf, unsigned beg, unsigned end);
 void buf_undo(Buf* buf, Sel* sel);
 void buf_redo(Buf* buf, Sel* sel);
 void buf_loglock(Buf* buf);
+void buf_logclear(Buf* buf);
 
 bool buf_iseol(Buf* buf, unsigned pos);
 unsigned buf_bol(Buf* buf, unsigned pos);
index 62453b8c3c66b3ad65cd708285e1cdb49ab812a2..b5fda7e7bd6ee1976c566cac11f9313f2bcf4465 100644 (file)
--- a/inc/x11.h
+++ b/inc/x11.h
@@ -11,7 +11,7 @@ typedef enum {
     MOUSE_BTN_WHEELUP   = 3,
     MOUSE_BTN_WHEELDOWN = 4,
     MOUSE_BTN_NONE      = 5,
-    MOUSE_BTN_COUNT     = 5
+    MOUSE_BTN_COUNT     = 6
 } MouseBtn;
 
 typedef struct {
index 6f0d228f849cf57b9e04e81b3b31c451e67e8d51..526282747a513fe54ff6e85e0fd549fd22113c3f 100644 (file)
@@ -97,18 +97,6 @@ static void buf_resize(Buf* buf, size_t sz) {
     *buf = copy;
 }
 
-static void clear_redo(Buf* buf) {
-    Log* log = buf->redo;
-    while (log) {
-        Log* deadite = log;
-        log = deadite->next;
-        if (!deadite->insert)
-            free(deadite->data.del.runes);
-        free(deadite);
-    }
-    buf->redo = NULL;
-}
-
 static void delete(Buf* buf, unsigned off) {
     syncgap(buf, off);
     buf->gapend++;
@@ -183,8 +171,7 @@ static void swaplog(Buf* buf, Log** from, Log** to, Sel* sel) {
 void buf_init(Buf* buf) {
     /* cleanup old data if there is any */
     if (buf->bufstart) free(buf->bufstart);
-    if (buf->undo) log_clear(&(buf->undo));
-    if (buf->redo) log_clear(&(buf->redo));
+    buf_logclear(buf);
     
     /* reset the state to defaults */
     buf->modified    = false;
@@ -284,13 +271,13 @@ unsigned buf_insert(Buf* buf, bool fmt, unsigned off, Rune rune) {
         for (; beg < end; beg++)
             off = buf_insert(buf, true, off, buf_get(buf, beg));
     }
-    clear_redo(buf);
+    log_clear(&(buf->redo));
     return off;
 }
 
 unsigned buf_delete(Buf* buf, unsigned beg, unsigned end) {
     buf->modified = true;
-    clear_redo(buf);
+    log_clear(&(buf->redo));
     for (unsigned i = end-beg; i > 0; i--) {
         Rune r = buf_get(buf, beg);
         log_delete(buf, &(buf->undo), beg, &r, 1);
@@ -338,6 +325,11 @@ void buf_loglock(Buf* buf) {
         buf->transid++;
 }
 
+void buf_logclear(Buf* buf) {
+    log_clear(&(buf->redo));
+    log_clear(&(buf->undo));
+}
+
 /*****************************************************************************/
 
 bool buf_iseol(Buf* buf, unsigned off) {
index 50cba338f5229c4096ca4f484ebd17fe20baf55d..1232adbb25870aa9848ea05830d6c67224d314d8 100644 (file)
@@ -109,6 +109,7 @@ void x11_window(char* name, int width, int height) {
         | ButtonPressMask
         | ButtonReleaseMask
         | ButtonMotionMask
+        | PointerMotionMask
         | KeyPressMask
         | ExposureMask
         | FocusChangeMask);
diff --git a/xedit.c b/xedit.c
index 1871a9be7db8b3fa6debdc437063e33f72a85b81..0dde8b26b2775511a064a14930b3632730765d3f 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -194,6 +194,7 @@ int main(int argc, char** argv) {
     /* load the buffer views */
     view_init(getview(TAGS), NULL);
     view_putstr(getview(TAGS), DEFAULT_TAGS);
+    buf_logclear(getbuf(TAGS));
     view_init(getview(EDIT), (argc > 1 ? argv[1] : NULL));
     /* initialize the display engine */
     x11_init(&Config);
@@ -213,15 +214,12 @@ static void mouse_handler(MouseAct act, MouseBtn btn, int x, int y) {
     size_t col = (x-Regions[id].x) / x11_font_width(Font);
     if (act == MOUSE_ACT_MOVE) {
         if (MouseBtns[MOUSE_BTN_LEFT].pressed) {
-            view_setcursor(getview(id), row, col);
-            MouseBtns[MOUSE_BTN_LEFT].pressed = false;
-            MouseBtns[MOUSE_BTN_LEFT].count = 0;
-        } else if (MouseBtns[MOUSE_BTN_LEFT].region < id) {
-            //view_scroll(getview(MouseBtns[MOUSE_BTN_LEFT].region), +1);
-        } else if (MouseBtns[MOUSE_BTN_LEFT].region > id) {
-            //view_scroll(getview(MouseBtns[MOUSE_BTN_LEFT].region), -1);
-        } else {
-            view_selext(getview(id), row, col);
+            if (MouseBtns[MOUSE_BTN_LEFT].count == 1) {
+                view_setcursor(getview(id), row, col);
+                MouseBtns[MOUSE_BTN_LEFT].count = 0;
+            } else {
+                view_selext(getview(id), row, col);
+            }
         }
     } else {
         MouseBtns[btn].pressed = (act == MOUSE_ACT_DOWN);