]> git.mdlowis.com Git - projs/tide.git/commitdiff
added logic to make home and ctrl+a move to the beginning of indented content or...
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 6 Dec 2016 17:20:44 +0000 (12:20 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 6 Dec 2016 17:20:44 +0000 (12:20 -0500)
TODO.md
libedit/view.c

diff --git a/TODO.md b/TODO.md
index a0f8077f81b0cbffad99616ad0eaa8cfd8aa3f1b..f7b9bdf10402dd159a02a8e420e081b9532869af 100644 (file)
--- 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
index a55a3142ddcc4c6becf46b6d4816ff6bc6e55a3e..e368e11b06e1b1e98a3aabe9f61d85e4141c9ee1 100644 (file)
@@ -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;
 }