From: Michael D. Lowis Date: Thu, 13 Sep 2018 19:33:18 +0000 (-0400) Subject: added indent/outdent key shortcuts using external command and new shortcut argument... X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=763673d323daa5dc0706aa711a38723b7b86ab7c;p=projs%2Ftide.git added indent/outdent key shortcuts using external command and new shortcut argument behavior --- diff --git a/TODO.md b/TODO.md index 6969033..2489948 100644 --- a/TODO.md +++ b/TODO.md @@ -2,14 +2,14 @@ BUGS: +* no copy indent * use transaction processing for joining lines * no analysis of line-endings or tabs in document -* no copy indent -* add arguments to keybindings -* mouse selection handling when mouse moves outside region * no magic right click * gap buffer does not handle UTF-8 currently * no trimming of trailing whitespace +* implement font toggling between monospace and proportional font +* mouse selection handling when mouse moves outside region Up Next: @@ -44,8 +44,6 @@ Maybe think about addressing these later: * add support for guidefiles * Shift+Insert should insert primary selection * Find shortcut should select previous word if current char is newline -* diagnostic messages can stack up if deselected and not resolved -* mouse click and hold on scroll bar should continually scroll # Auxillary Programs diff --git a/inc/win.h b/inc/win.h index 7bccab1..5cbf2b6 100644 --- a/inc/win.h +++ b/inc/win.h @@ -122,7 +122,8 @@ typedef enum { typedef struct { int mods; Rune key; - void (*action)(char*); + void (*fn)(char*); + char* arg; } KeyBinding; typedef struct { diff --git a/lib/x11.c b/lib/x11.c index 8102ad4..09f5696 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -379,7 +379,7 @@ static void xkeypress(XEvent* e) { bool any = (bind->mods == ModAny); bool oneplus = ((bind->mods == ModOneOrMore) && (mods & ModOneOrMore)); if (match && (exact || oneplus || any)) { - bind->action(NULL); + bind->fn(bind->arg); return; } } diff --git a/tide.c b/tide.c index aef945c..624ff2d 100644 --- a/tide.c +++ b/tide.c @@ -397,49 +397,51 @@ static Tag Builtins[] = { static KeyBinding Bindings[] = { /* Cursor Movements */ - { ModAny, KEY_HOME, cursor_home }, - { ModAny, KEY_END, cursor_end }, - { ModAny, KEY_UP, cursor_up }, - { ModAny, KEY_DOWN, cursor_dn }, - { ModAny, KEY_LEFT, cursor_left }, - { ModAny, KEY_RIGHT, cursor_right }, + { .mods = ModAny, .key = KEY_HOME, .fn = cursor_home }, + { .mods = ModAny, .key = KEY_END, .fn = cursor_end }, + { .mods = ModAny, .key = KEY_UP, .fn = cursor_up }, + { .mods = ModAny, .key = KEY_DOWN, .fn = cursor_dn }, + { .mods = ModAny, .key = KEY_LEFT, .fn = cursor_left }, + { .mods = ModAny, .key = KEY_RIGHT, .fn = cursor_right }, /* Standard Unix Shortcuts */ - { ModCtrl, 'u', del_to_bol }, - { ModCtrl, 'k', del_to_eol }, - { ModCtrl, 'w', del_to_bow }, - { ModCtrl, 'a', cursor_bol }, - { ModCtrl, 'e', cursor_eol }, + { .mods = ModCtrl, .key = 'u', .fn = del_to_bol }, + { .mods = ModCtrl, .key = 'k', .fn = del_to_eol }, + { .mods = ModCtrl, .key = 'w', .fn = del_to_bow }, + { .mods = ModCtrl, .key = 'a', .fn = cursor_bol }, + { .mods = ModCtrl, .key = 'e', .fn = cursor_eol }, /* Standard Text Editing Shortcuts */ - { ModCtrl, 's', put }, - { ModCtrl, 'z', undo }, - { ModCtrl, 'y', redo }, - { ModCtrl, 'x', cut }, - { ModCtrl, 'c', copy }, - { ModCtrl, 'v', paste }, - { ModCtrl, 'j', join_lines }, - { ModCtrl, 'l', select_line }, + { .mods = ModCtrl, .key = 's', .fn = put }, + { .mods = ModCtrl, .key = 'z', .fn = undo }, + { .mods = ModCtrl, .key = 'y', .fn = redo }, + { .mods = ModCtrl, .key = 'x', .fn = cut }, + { .mods = ModCtrl, .key = 'c', .fn = copy }, + { .mods = ModCtrl, .key = 'v', .fn = paste }, + { .mods = ModCtrl, .key = 'j', .fn = join_lines }, + { .mods = ModCtrl, .key = 'l', .fn = select_line }, + { .mods = ModCtrl, .key = '[', .fn = exec, .arg = "|i-" }, + { .mods = ModCtrl, .key = ']', .fn = exec, .arg = "|i+" }, /* Common Special Keys */ - { ModNone, KEY_PGUP, page_up }, - { ModNone, KEY_PGDN, page_dn }, - { ModAny, KEY_DELETE, delete }, - { ModAny, KEY_BACKSPACE, backspace }, + { .mods = ModNone, .key = KEY_PGUP, .fn = page_up }, + { .mods = ModNone, .key = KEY_PGDN, .fn = page_dn }, + { .mods = ModAny, .key = KEY_DELETE, .fn = delete }, + { .mods = ModAny, .key = KEY_BACKSPACE, .fn = backspace }, /* Implementation Specific */ - { ModNone, KEY_ESCAPE, select_prev }, - { ModCtrl, 't', change_focus }, - { ModCtrl, 'q', quit }, - { ModCtrl, 'h', highlight }, - { ModOneOrMore, 'f', search }, - { ModCtrl, 'd', execute }, - { ModOneOrMore, 'o', open_file }, - { ModCtrl, 'p', pick_ctag }, - { ModOneOrMore, 'g', goto_ctag }, - { ModCtrl, 'n', new_win }, - { ModOneOrMore, '\n', newline }, - { ModCtrl, ' ', complete }, + { .mods = ModNone, .key = KEY_ESCAPE, .fn = select_prev }, + { .mods = ModCtrl, .key = 't', .fn = change_focus }, + { .mods = ModCtrl, .key = 'q', .fn = quit }, + { .mods = ModCtrl, .key = 'h', .fn = highlight }, + { .mods = ModOneOrMore, .key = 'f', .fn = search }, + { .mods = ModCtrl, .key = 'd', .fn = execute }, + { .mods = ModOneOrMore, .key = 'o', .fn = open_file }, + { .mods = ModCtrl, .key = 'p', .fn = pick_ctag }, + { .mods = ModOneOrMore, .key = 'g', .fn = goto_ctag }, + { .mods = ModCtrl, .key = 'n', .fn = new_win }, + { .mods = ModOneOrMore, .key = '\n', .fn = newline }, + { .mods = ModCtrl, .key = ' ', .fn = complete }, { 0, 0, 0 } };