]> git.mdlowis.com Git - projs/tide.git/commitdiff
added indent/outdent key shortcuts using external command and new shortcut argument...
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 13 Sep 2018 19:33:18 +0000 (15:33 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 13 Sep 2018 19:33:18 +0000 (15:33 -0400)
TODO.md
inc/win.h
lib/x11.c
tide.c

diff --git a/TODO.md b/TODO.md
index 69690339feb1af87000ba17cf92c5dc5ac355e73..24899484aabdcde94999637081179e71eb64d616 100644 (file)
--- 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
 
index 7bccab16bc7521c32f43dc838d69689f7617c92c..5cbf2b6994c12003d8b59c9deaca5dcf8f901132 100644 (file)
--- 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 {
index 8102ad46b309c9a4dd4b7e7b619e05a61419b521..09f569692e53384397035ee078fe5fee7432d071 100644 (file)
--- 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 aef945c354f566dc0371d9771c0e5762d5b893aa..624ff2dda6a68603f6bcf1d0ecd1f21f455df1cd 100644 (file)
--- 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 }
 };