From: Michael D. Lowis Date: Tue, 6 Dec 2016 17:20:44 +0000 (-0500) Subject: added logic to make home and ctrl+a move to the beginning of indented content or... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=c1b5c693da5d756f4e8d319a7da6100b33b5b9d2;p=projs%2Ftide.git added logic to make home and ctrl+a move to the beginning of indented content or beginning of line depending on context --- diff --git a/TODO.md b/TODO.md index a0f8077..f7b9bdf 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,5 @@ # Implementation Tweaks and Bug Fixes -* Home key should toggle between beginning of line and beginning of non-ws data * Expand tabs setting should be disabled if opened file contains tabs * Add tag for ctags lookup and line number jump * add a shortcut to autocomplete ctag diff --git a/libedit/view.c b/libedit/view.c index a55a314..e368e11 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -430,10 +430,19 @@ void view_delete(View* view, int dir, bool byword) { } void view_bol(View* view, bool extsel) { - view->selection.end = buf_bol(&(view->buffer), view->selection.end); + /* determine whether we are jumping to start of content or line */ + Buf* buf = &(view->buffer); + unsigned bol = buf_bol(buf, view->selection.end); + unsigned boi = bol; + for (; ' ' == buf_get(buf, boi) || '\t' == buf_get(buf, boi); boi++); + unsigned pos = view->selection.end; + pos = (pos == bol || pos > boi ? boi : bol); + + /* set the new cursor position */ + view->selection.end = pos; if (!extsel) view->selection.beg = view->selection.end; - view->selection.col = buf_getcol(&(view->buffer), view->selection.end); + view->selection.col = buf_getcol(buf, view->selection.end); view->sync_needed = true; }