From: Michael D. Lowis Date: Thu, 15 Jun 2017 20:18:43 +0000 (-0400) Subject: Updated TODO and fixed line tracking in buf.c X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=34ff265e0c790bedb21eae729428dc5522c571cb;p=projs%2Ftide.git Updated TODO and fixed line tracking in buf.c --- diff --git a/TODO.md b/TODO.md index 17e013a..aad1b53 100644 --- 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; diff --git a/lib/buf.c b/lib/buf.c index 0e2e5b3..9050732 100644 --- 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;