From: Michael D. Lowis Date: Thu, 27 Sep 2018 02:47:10 +0000 (-0400) Subject: fixed logic for snapping selection to beginning and end of selected lines X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=68ab0f49f2acddaa479dc8bf0b0af0e72859ae4d;p=projs%2Ftide.git fixed logic for snapping selection to beginning and end of selected lines --- diff --git a/TODO.md b/TODO.md index e0b1657..d3bdb41 100644 --- a/TODO.md +++ b/TODO.md @@ -1,13 +1,14 @@ # Issue List -BUGS: +## STAGING * no magic right click * implement mouse warping on search, jump to line, and focus change * gap buffer does not handle UTF-8 currently * mouse selection handling when mouse moves outside region +* Line - Get the current line number(s) containing the selection -Up Next: +## BACKLOG * move mouse handlers back into tide.c * Add matching logic for "", '', ``, and <> @@ -16,7 +17,6 @@ Up Next: Tags: * Clear - Clear the current window's edit buffer -* Line - Get the current line number(s) containing the selection * Kill - Kill a background command * ID - Get window id of the X window * Zerox - Create a copy of the window diff --git a/tide.c b/tide.c index b16dd31..d5ae95b 100644 --- a/tide.c +++ b/tide.c @@ -103,11 +103,15 @@ static void select_line(char* arg) { Buf* buf = win_buf(FOCUSED); if (buf->selection.beg <= buf->selection.end) { buf->selection.beg = buf_bol(buf, buf->selection.beg); - buf->selection.end = buf_eol(buf, buf->selection.end); - buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT); + if (!buf_iseol(buf, buf->selection.end)) { + buf->selection.end = buf_eol(buf, buf->selection.end); + buf->selection.end = buf_byrune(buf, buf->selection.end, RIGHT); + } } else { - buf->selection.beg = buf_eol(buf, buf->selection.beg); - buf->selection.beg = buf_byrune(buf, buf->selection.beg, RIGHT); + if (!buf_iseol(buf, buf->selection.beg)) { + buf->selection.beg = buf_eol(buf, buf->selection.beg); + buf->selection.beg = buf_byrune(buf, buf->selection.beg, RIGHT); + } buf->selection.end = buf_bol(buf, buf->selection.end); } } @@ -391,8 +395,7 @@ static void highlight(char* arg) { } static void lnexec(char* cmd) { - if (!view_selsize(win_view(FOCUSED))) - select_line(NULL); + select_line(NULL); exec(cmd); }