]> git.mdlowis.com Git - projs/tide.git/commitdiff
Updated TODO and fixed line tracking in buf.c
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 15 Jun 2017 20:18:43 +0000 (16:18 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 15 Jun 2017 20:18:43 +0000 (16:18 -0400)
TODO.md
lib/buf.c

diff --git a/TODO.md b/TODO.md
index 17e013a2593a9acc3303aa9813b461a041e9f7ec..aad1b5315f0779f912bd720ef8e9fa312dcfcc3b 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -2,11 +2,15 @@
 
 Up Next:
 
+* Update click time to 500ms
+* ignore the menu key or map it to control
+* clicking or dragging the mouse out of bounds should still update the selection
+* implement transaction control in buf.c
+* implement X resources config file
 * highlight classes of identifiers
 * Add a way to CD using a builtin (buffers will track original dir)
 * shortcut to jump to previous edit
 * add command line flags to toggle options (Tabs, Indent, etc..)
-* implement X resources config file
 * move by words is inconsistent. Example:
     var infoId = 'readerinfo'+reader.id;
 
index 0e2e5b301f3322de4c3b7fde9c3c07fe062e800e..9050732b43e85f265c8f56a5dae515eeb3f486a7 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -146,7 +146,6 @@ size_t buf_end(Buf* buf) {
 size_t buf_insert(Buf* buf, bool fmt, size_t off, Rune rune) {
     bool is_eol = (rune == '\n' || rune == RUNE_CRLF);
     buf->modified = true;
-    if (is_eol) buf->nlines++;
     if (fmt && buf->expand_tabs && rune == '\t') {
         size_t n = (TabWidth - ((off - buf_bol(buf, off)) % TabWidth));
         log_insert(buf, &(buf->undo), off, off+n);
@@ -174,7 +173,6 @@ size_t buf_delete(Buf* buf, size_t beg, size_t end) {
     for (size_t i = end-beg; i > 0; i--) {
         Rune r = buf_get(buf, beg);
         bool is_eol = (r == '\n' || r == RUNE_CRLF);
-        if (is_eol) buf->nlines--;
         log_delete(buf, &(buf->undo), beg, &r, 1);
         delete(buf, beg);
     }
@@ -551,6 +549,9 @@ static void buf_resize(Buf* buf, size_t sz) {
 }
 
 static void delete(Buf* buf, size_t off) {
+    Rune rune = buf_get(buf, off);
+    if (rune == RUNE_CRLF || rune == '\n')
+        buf->nlines--;
     syncgap(buf, off);
     buf->gapend++;
 }
@@ -558,6 +559,7 @@ static void delete(Buf* buf, size_t off) {
 static size_t insert(Buf* buf, size_t off, Rune rune) {
     size_t rcount = 1;
     syncgap(buf, off);
+    if (rune == '\n') buf->nlines++;
     if (buf->crlf && rune == '\n' && buf_get(buf, off-1) == '\r') {
         rcount = 0;
         *(buf->gapstart-1) = RUNE_CRLF;