]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed click handling for gutter and scroll region
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 22 Jun 2017 14:48:55 +0000 (10:48 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 22 Jun 2017 14:48:55 +0000 (10:48 -0400)
TODO.md
lib/win.c
tests/lib/buf.c

diff --git a/TODO.md b/TODO.md
index 62d1e621adee6c14841ca5c924c6934f0ef7485a..2af79101d8c332021d5ff6d96b9afa4bb1b7bc76 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,6 +2,7 @@
 
 Up Next:
 
+* highlighting is broken for comments partially off screen (again)
 * implement transaction control in buf.c
 * highlight all matches of search term
 * highlight classes of identifiers
@@ -11,7 +12,7 @@ Up Next:
 * move by words is inconsistent. Example:
     var infoId = 'readerinfo'+reader.id;
 * ignore the menu key or map it to control
-   
+
 The Future:
 
 * Ctrl+/ shortcut to comment/uncomment based on syntax
index 4d5baadcde71b8b43ef7a9bace83a361f0101dfc..9aed482a804d0431ba55bd5094ad499b008f4cf2 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -354,9 +354,9 @@ static void onmousedrag(int state, int x, int y) {
 }
 
 static void onmousebtn(int btn, bool pressed, int x, int y) {
-    if (x < Regions[Focused].x)
-        x = Regions[Focused].x;
     WinRegion id = getregion(x, y);
+    if (id == FOCUSED && x < Regions[Focused].x)
+        x = Regions[Focused].x, id = getregion(x, y);
     size_t row = (y-Regions[id].y) / x11_font_height(Font);
     size_t col = (x-Regions[id].x) / x11_font_width(Font);
 
index f9555ac4e1855df4b8bf8fdecdaca5474ce68172..566cebd7b4f7de2dbdd820d5618e9c6aa6497fab 100644 (file)
@@ -20,13 +20,13 @@ static void set_buffer_text(char* str) {
 
 static bool buf_text_eq(char* str) {
     for (unsigned i = 0; i < buf_end(&TestBuf); i++) {
-        printf("'%c'", buf_get(&TestBuf, i));
+        //printf("'%c'", buf_get(&TestBuf, i));
         if ((Rune)*(str++) != buf_get(&TestBuf, i)) {
-            printf("\n");
+            //printf("\n");
             return false;
         }
     }
-    printf("\n");
+    //printf("\n");
     return true;
 }
 
@@ -51,7 +51,7 @@ TEST_SUITE(BufferTests) {
         CHECK(buf.errfn       == (void*)0x12345678);
         CHECK(buf.nlines      == 0);
     }
-    
+
     TEST(buf_init shoud free old buffer and reinitialize) {
         Buf buf = {0};
         buf_init(&buf, onerror);
@@ -72,7 +72,7 @@ TEST_SUITE(BufferTests) {
         CHECK(buf.errfn       == (void*)0x12345678);
         CHECK(buf.nlines      == 0);
     }
-    
+
     /* Loading
      *************************************************************************/
     TEST(buf_load should load a UTF-8 file from disk) {
@@ -91,7 +91,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.nlines      == 998);
         CHECK(!strcmp(TestBuf.path, "testdocs/lorem.txt"));
     }
-    
+
     TEST(buf_load should load a non UTF-8 file from disk) {
         buf_init(&TestBuf, NULL);
         size_t pos = buf_load(&TestBuf, "testdocs/waf");
@@ -108,7 +108,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.nlines      == 169);
         CHECK(!strcmp(TestBuf.path, "testdocs/waf"));
     }
-    
+
     TEST(buf_load should load a file from disk and jump to a specific line) {
         buf_init(&TestBuf, NULL);
         size_t pos = buf_load(&TestBuf, "testdocs/lorem.txt:2");
@@ -125,7 +125,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.nlines      == 998);
         CHECK(!strcmp(TestBuf.path, "testdocs/lorem.txt"));
     }
-    
+
     TEST(buf_load should remove ./ from file path) {
         buf_init(&TestBuf, NULL);
         size_t pos = buf_load(&TestBuf, "./testdocs/lorem.txt");
@@ -142,7 +142,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.nlines      == 998);
         CHECK(!strcmp(TestBuf.path, "testdocs/lorem.txt"));
     }
-    
+
     TEST(buf_reload should reload the file from disk) {
         buf_init(&TestBuf, NULL);
         buf_load(&TestBuf, "testdocs/waf");
@@ -160,7 +160,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.nlines      == 998);
         CHECK(!strcmp(TestBuf.path, "testdocs/lorem.txt"));
     }
-    
+
     /* Saving
      *************************************************************************/
     TEST(buf_save should save a UTF-8 file to disk) {
@@ -170,7 +170,7 @@ TEST_SUITE(BufferTests) {
         buf_save(&TestBuf);
         CHECK(TestBuf.modified == false);
     }
-    
+
     TEST(buf_save should save a non UTF-8 file to disk) {
         buf_init(&TestBuf, NULL);
         buf_load(&TestBuf, "testdocs/waf");
@@ -178,7 +178,7 @@ TEST_SUITE(BufferTests) {
         buf_save(&TestBuf);
         CHECK(TestBuf.modified == false);
     }
-    
+
     TEST(buf_save should save a file to disk with unix line endings) {
         buf_init(&TestBuf, NULL);
         buf_load(&TestBuf, "testdocs/lf.txt");
@@ -186,7 +186,7 @@ TEST_SUITE(BufferTests) {
         buf_save(&TestBuf);
         CHECK(TestBuf.modified == false);
     }
-    
+
     TEST(buf_save should save a file to disk with dos line endings) {
         buf_init(&TestBuf, NULL);
         buf_load(&TestBuf, "testdocs/crlf.txt");
@@ -194,7 +194,7 @@ TEST_SUITE(BufferTests) {
         buf_save(&TestBuf);
         CHECK(TestBuf.modified == false);
     }
-    
+
     TEST(buf_save should make sure unix file ends witn newline) {
         buf_init(&TestBuf, NULL);
         buf_load(&TestBuf, "testdocs/lf.txt");
@@ -269,7 +269,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.modified == true);
         CHECK(TestBuf.redo == NULL);
     }
-    
+
     TEST(buf_insert should expand tabs) {
         set_buffer_text("");
         TestBuf.expand_tabs = true;
@@ -278,7 +278,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.modified == true);
         CHECK(TestBuf.redo == NULL);
     }
-    
+
     TEST(buf_insert should copy indent) {
         set_buffer_text("    ");
         TestBuf.copy_indent = true;
@@ -298,7 +298,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.modified == true);
         CHECK(TestBuf.redo == NULL);
     }
-    
+
     TEST(buf_delete should delete second char) {
         set_buffer_text("abc");
         buf_delete(&TestBuf, 1, 2);
@@ -306,7 +306,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.modified == true);
         CHECK(TestBuf.redo == NULL);
     }
-    
+
     TEST(buf_delete should delete third char) {
         set_buffer_text("abc");
         buf_delete(&TestBuf, 2, 3);
@@ -337,7 +337,7 @@ TEST_SUITE(BufferTests) {
         CHECK(TestBuf.redo != NULL);
         CHECK(TestBuf.undo == NULL);
     }
-    
+
     TEST(buf_undo should undo a delete) {
         Sel sel;
         set_buffer_text("a");