From: Michael D. Lowis Date: Wed, 21 Dec 2016 17:51:42 +0000 (-0500) Subject: Focus follows mouse between regions and the initial content in the tag line can no... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=420cfc106493be4d47f22919f49ce2e980a19c6f;p=projs%2Ftide.git Focus follows mouse between regions and the initial content in the tag line can no longer be undone --- diff --git a/TODO.md b/TODO.md index ca6e2db..f2760e1 100644 --- 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: diff --git a/inc/edit.h b/inc/edit.h index 5006c78..e27e661 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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); diff --git a/inc/x11.h b/inc/x11.h index 62453b8..b5fda7e 100644 --- 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 { diff --git a/libedit/buf.c b/libedit/buf.c index 6f0d228..5262827 100644 --- a/libedit/buf.c +++ b/libedit/buf.c @@ -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) { diff --git a/libx/x11.c b/libx/x11.c index 50cba33..1232adb 100644 --- a/libx/x11.c +++ b/libx/x11.c @@ -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 1871a9b..0dde8b2 100644 --- 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);