]> git.mdlowis.com Git - projs/tide.git/commitdiff
Implemented Ctrl+Home/End shortcuts
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Dec 2016 20:14:42 +0000 (15:14 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Dec 2016 20:14:42 +0000 (15:14 -0500)
Makefile
inc/edit.h
libedit/view.c
xedit.c

index d3a56adec65e0f0a149911fe37c33432c44d699c..48162b1ab9f3cd871449c63499555e056515cc9d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,7 @@ install: all
        cp xfilepick $(PREFIX)/bin
        cp xtagpick $(PREFIX)/bin
        cp xman $(PREFIX)/bin
+       cp edit $(PREFIX)/bin
 
 uninstall:
        rm -f $(PREFIX)/bin/xedit
@@ -37,6 +38,7 @@ uninstall:
        rm -f $(PREFIX)/bin/xfilepick
        rm -f $(PREFIX)/bin/xtagpick
        rm -f $(PREFIX)/bin/xman
+       rm -f $(PREFIX)/bin/edit
 
 test: unittests
        ./unittests
index c728659ab21272569e17aaa77a4863b0c564d669..a124935e1976d71f1706cc25e861d198d86ea747 100644 (file)
@@ -173,6 +173,8 @@ void view_insert(View* view, Rune rune);
 void view_delete(View* view, int dir, bool byword);
 void view_bol(View* view, bool extsel);
 void view_eol(View* view, bool extsel);
+void view_bof(View* view, bool extsel);
+void view_eof(View* view, bool extsel);
 void view_undo(View* view);
 void view_redo(View* view);
 void view_putstr(View* view, char* str);
index a8cf6757257043d86fd3e498e5956b0d4b04b5cd..e3fdc7df1d03f069fd80308f2a0683577637977f 100644 (file)
@@ -404,6 +404,22 @@ void view_eol(View* view, bool extsel) {
     view->sync_needed = true;
 }
 
+void view_bof(View* view, bool extsel) {
+    view->selection.end = 0;
+    if (!extsel)
+        view->selection.beg = view->selection.end;
+    view->selection.col = buf_getcol(&(view->buffer), view->selection.end);
+    view->sync_needed = true;
+}
+
+void view_eof(View* view, bool extsel) {
+    view->selection.end = buf_end(&(view->buffer));
+    if (!extsel)
+        view->selection.beg = view->selection.end;
+    view->selection.col = buf_getcol(&(view->buffer), view->selection.end);
+    view->sync_needed = true;
+}
+
 void view_undo(View* view) {
     view->selection.beg = view->selection.end = buf_undo(&(view->buffer), view->selection.end);
     view->selection.col = buf_getcol(&(view->buffer), view->selection.end);
diff --git a/xedit.c b/xedit.c
index 071196bf06c5b3c706c485e6e005dd64595bdef2..7351ace26bfa7501c414cfab6e77b1c24b69eaef 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -366,12 +366,18 @@ static void backspace(void) {
 
 static void cursor_home(void) {
     bool extsel = x11_keymodsset(ModShift);
-    view_bol(currview(), extsel);
+    if (x11_keymodsset(ModCtrl))
+        view_bof(currview(), extsel);
+    else
+        view_bol(currview(), extsel);
 }
 
 static void cursor_end(void) {
     bool extsel = x11_keymodsset(ModShift);
-    view_eol(currview(), extsel);
+    if (x11_keymodsset(ModCtrl))
+        view_eof(currview(), extsel);
+    else
+        view_eol(currview(), extsel);
 }
 
 static void cursor_up(void) {