VENE: basic keybinds

This commit is contained in:
Venelin Dechkov
2026-02-25 12:10:04 +02:00
parent 7175c4880b
commit 129c6b712b
+34 -12
View File
@@ -342,34 +342,38 @@ keypress(XKeyEvent *ev)
if (ev->state & ControlMask) {
switch(ksym) {
case XK_a: ksym = XK_Home; break;
case XK_h:
case XK_b: ksym = XK_Left; break;
case XK_c: ksym = XK_Escape; break;
case XK_d: ksym = XK_Delete; break;
case XK_e: ksym = XK_End; break;
case XK_l:
case XK_f: ksym = XK_Right; break;
case XK_g: ksym = XK_Escape; break;
case XK_h: ksym = XK_BackSpace; break;
// case XK_h: ksym = XK_BackSpace; break;
case XK_i: ksym = XK_Tab; break;
case XK_j: /* fallthrough */
case XK_J: /* fallthrough */
case XK_m: /* fallthrough */
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
case XK_j: /* fallthrough */
case XK_J: /* fallthrough */
case XK_n: ksym = XK_Down; break;
case XK_k:
case XK_p: ksym = XK_Up; break;
case XK_k: /* delete right */
case XK_w:
// case XK_k: /* delete right */
text[cursor] = '\0';
match();
break;
case XK_u: /* delete left */
insert(NULL, 0 - cursor);
break;
case XK_w: /* delete word */
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
break;
// case XK_w: /* delete word */
// while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
// insert(NULL, nextrune(-1) - cursor);
// while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
// insert(NULL, nextrune(-1) - cursor);
// break;
case XK_y: /* paste selection */
case XK_Y:
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
@@ -394,18 +398,36 @@ keypress(XKeyEvent *ev)
}
} else if (ev->state & Mod1Mask) {
switch(ksym) {
case XK_h:
case XK_b:
movewordedge(-1);
goto draw;
case XK_l:
case XK_f:
movewordedge(+1);
goto draw;
case XK_g: ksym = XK_Home; break;
case XK_G: ksym = XK_End; break;
case XK_h: ksym = XK_Up; break;
// case XK_h: ksym = XK_Up; break;
case XK_j: ksym = XK_Next; break;
case XK_k: ksym = XK_Prior; break;
case XK_l: ksym = XK_Down; break;
// case XK_l: ksym = XK_Down; break;
case XK_BackSpace:
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
goto draw;
case XK_d: // forward delete word
while (text[cursor] != '\0' && strchr(worddelimiters, text[cursor])) { // delete space
cursor = nextrune(+1);
insert(NULL, nextrune(-1) - cursor);
}
while (text[cursor] != '\0' && !strchr(worddelimiters, text[cursor])) { // delete word
cursor = nextrune(+1);
insert(NULL, nextrune(-1) - cursor);
}
goto draw;
default:
return;
}