};
static WinRegion Focused = EDIT;
static Region Regions[NREGIONS] = {0};
-KeyBinding* Keys = NULL;
+static Rune LastKey;
+static KeyBinding* Keys = NULL;
static void win_init(void (*errfn)(char*)) {
for (int i = 0; i < SCROLL; i++)
Ruler = ruler;
}
+Rune win_getkey(void) {
+ return LastKey;
+}
+
void win_setkeys(KeyBinding* bindings) {
Keys = bindings;
}
}
static void oninput(int mods, Rune key) {
+ LastKey = key;
/* mask of modifiers we don't care about */
- mods = mods & (ModCtrl|ModAlt|ModShift);
+ mods = mods & (ModCtrl|ModShift|ModAlt);
/* handle the proper line endings */
if (key == '\r') key = '\n';
/* search for a key binding entry */
uint32_t mkey = tolower(key);
for (KeyBinding* bind = Keys; bind && bind->key; bind++) {
- if ((mkey == bind->key) && (bind->mods == ModAny || bind->mods == mods)) {
+ bool match = (mkey == bind->key);
+ bool exact = (bind->mods == mods);
+ bool any = (bind->mods == ModAny);
+ bool oneplus = ((bind->mods == ModOneOrMore) && (mods & ModOneOrMore));
+ if (match && (exact || oneplus || any)) {
bind->action();
return;
}
static Tag Builtins[];
static int SearchDir = DOWN;
static char* SearchTerm = NULL;
+static size_t Marks[10] = {0};
/* Tag/Cmd Execution
******************************************************************************/
view_insert(view, true, '\n');
}
-void highlight(void) {
+static void highlight(void) {
view_selctx(win_view(FOCUSED));
}
+static void jumpmark(void) {
+ int mark = (win_getkey() - '0');
+ assert(mark < 10);
+ if (x11_keymodsset(ModAlt))
+ Marks[mark] = win_view(FOCUSED)->selection.end;
+ else
+ view_jumpto(win_view(FOCUSED), false, Marks[mark]);
+}
+
/* Main Routine
******************************************************************************/
static Tag Builtins[] = {
{ ModAny, KEY_DELETE, delete },
{ ModAny, KEY_BACKSPACE, backspace },
+ /* Marks Handling */
+ { ModOneOrMore, '0', jumpmark },
+ { ModOneOrMore, '1', jumpmark },
+ { ModOneOrMore, '2', jumpmark },
+ { ModOneOrMore, '3', jumpmark },
+ { ModOneOrMore, '4', jumpmark },
+ { ModOneOrMore, '5', jumpmark },
+ { ModOneOrMore, '6', jumpmark },
+ { ModOneOrMore, '7', jumpmark },
+ { ModOneOrMore, '8', jumpmark },
+ { ModOneOrMore, '9', jumpmark },
+
/* Implementation Specific */
{ ModNone, KEY_ESCAPE, select_prev },
{ ModCtrl, 't', change_focus },
{ ModCtrl, 'q', quit },
{ ModCtrl, 'h', highlight },
- { ModCtrl, 'f', search },
- { ModCtrl|ModShift, 'f', search },
- { ModCtrl|ModAlt, 'f', search },
- { ModCtrl|ModAlt|ModShift, 'f', search },
+ { ModOneOrMore, 'f', search },
{ ModCtrl, 'd', execute },
{ ModCtrl, 'o', open_file },
{ ModCtrl, 'p', pick_ctag },
- { ModCtrl, 'g', goto_ctag },
- { ModCtrl|ModShift, 'g', goto_ctag },
+ { ModOneOrMore, 'g', goto_ctag },
{ ModCtrl, 'n', new_win },
- { ModCtrl, '\n', newline },
- { ModCtrl|ModShift, '\n', newline },
+ { ModOneOrMore, '\n', newline },
{ ModCtrl, ' ', complete },
{ 0, 0, 0 }
};