From 0607324bcf18e186aeedd4b5549db5314e5aaf3d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Fri, 26 May 2017 22:07:52 -0400 Subject: [PATCH] added shortcut to select all --- TODO.md | 1 - inc/shortcuts.h | 6 ++++++ tide.c | 45 +++++++++++++++++++++++---------------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/TODO.md b/TODO.md index eeba371..dde7a24 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ Up Next: * Change PageUp/Dn to move cursor by screenfuls -* Add Ctrl+Shift+A shortcut to select all * move by words is inconsistent. Example: var infoId = 'readerinfo'+reader.id; * Add a way to CD using a builtin (buffers will track original dir) diff --git a/inc/shortcuts.h b/inc/shortcuts.h index a2bece2..a3a6258 100644 --- a/inc/shortcuts.h +++ b/inc/shortcuts.h @@ -4,6 +4,12 @@ static void select_line(void) { view_selctx(view); } +static void select_all(void) { + View* view = win_view(FOCUSED); + view->selection.beg = 0; + view->selection.end = buf_end(&(view->buffer)); +} + static void join_lines(void) { View* view = win_view(FOCUSED); view_eol(view, false); diff --git a/tide.c b/tide.c index e91798a..ad45db0 100644 --- a/tide.c +++ b/tide.c @@ -363,7 +363,7 @@ static void eol_mode(void) { } static void new_win(void) { - cmd_exec("!edit"); + cmd_exec("!tide"); } static void newline(void) { @@ -432,14 +432,15 @@ static KeyBinding Bindings[] = { { ModCtrl, 'e', cursor_eol }, /* Standard Text Editing Shortcuts */ - { ModCtrl, 's', save }, - { ModCtrl, 'z', undo }, - { ModCtrl, 'y', redo }, - { ModCtrl, 'x', cut }, - { ModCtrl, 'c', copy }, - { ModCtrl, 'v', paste }, - { ModCtrl, 'j', join_lines }, - { ModCtrl, 'l', select_line }, + { ModCtrl, 's', save }, + { ModCtrl, 'z', undo }, + { ModCtrl, 'y', redo }, + { ModCtrl, 'x', cut }, + { ModCtrl, 'c', copy }, + { ModCtrl, 'v', paste }, + { ModCtrl, 'j', join_lines }, + { ModCtrl, 'l', select_line }, + { ModCtrl|ModShift, 'a', select_all }, /* Block Indent */ { ModCtrl, '[', del_indent }, @@ -464,18 +465,18 @@ static KeyBinding Bindings[] = { { ModOneOrMore, '9', jumpmark }, /* Implementation Specific */ - { ModNone, KEY_ESCAPE, select_prev }, - { ModCtrl, 't', change_focus }, - { ModCtrl, 'q', quit }, - { ModCtrl, 'h', highlight }, - { ModOneOrMore, 'f', search }, - { ModCtrl, 'd', execute }, - { ModCtrl, 'o', open_file }, - { ModCtrl, 'p', pick_ctag }, - { ModOneOrMore, 'g', goto_ctag }, - { ModCtrl, 'n', new_win }, - { ModOneOrMore, '\n', newline }, - { ModCtrl, ' ', complete }, + { ModNone, KEY_ESCAPE, select_prev }, + { ModCtrl, 't', change_focus }, + { ModCtrl, 'q', quit }, + { ModCtrl, 'h', highlight }, + { ModOneOrMore, 'f', search }, + { ModCtrl, 'd', execute }, + { ModCtrl, 'o', open_file }, + { ModCtrl, 'p', pick_ctag }, + { ModOneOrMore, 'g', goto_ctag }, + { ModCtrl, 'n', new_win }, + { ModOneOrMore, '\n', newline }, + { ModCtrl, ' ', complete }, { 0, 0, 0 } }; @@ -581,7 +582,7 @@ int main(int argc, char** argv) { if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL"); if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh"; /* Create the window and enter the event loop */ - win_window("edit", ondiagmsg); + win_window("tide", ondiagmsg); char* tags = getenv("EDITTAGS"); win_settext(TAGS, (tags ? tags : DefaultTags)); win_setruler(RulePosition); -- 2.52.0