From: Michael D. Lowis Date: Thu, 1 Dec 2016 20:14:42 +0000 (-0500) Subject: Implemented Ctrl+Home/End shortcuts X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a87612bb147fb3aaea2cb3b69084c30afe35888f;p=projs%2Ftide.git Implemented Ctrl+Home/End shortcuts --- diff --git a/Makefile b/Makefile index d3a56ad..48162b1 100644 --- 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 diff --git a/inc/edit.h b/inc/edit.h index c728659..a124935 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -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); diff --git a/libedit/view.c b/libedit/view.c index a8cf675..e3fdc7d 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -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 071196b..7351ace 100644 --- 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) {