add moving left/right in input using arrow keys

This commit is contained in:
speedie 2023-03-20 11:59:04 +01:00
parent ef859739f8
commit ba5af9883b
3 changed files with 16 additions and 6 deletions

View file

@ -39,6 +39,10 @@ static Key keys[] = {
*
* mode modifier key function argument */
{ 1, 0, XK_Escape, switchmode, {0} },
{ 1, 0, XK_Up, move, {.i = 1 } },
{ 1, 0, XK_Down, move, {.i = 2 } },
{ 1, 0, XK_Left, move, {.i = 3 } },
{ 1, 0, XK_Right, move, {.i = 4 } },
/* normal mode
*
@ -80,8 +84,10 @@ static Key keys[] = {
{ 0, SHIFT, XK_g, moveend, {0} },
{ 0, 0, XK_Next, movenext, {0} },
{ 0, 0, XK_Prior, moveprev, {0} },
{ 0, MODIFIER1, XK_b, moveword, {.i = -1 } },
{ 0, MODIFIER1, XK_f, moveword, {.i = +1 } },
{ 0, SHIFT, XK_Left, moveword, {.i = -1 } },
{ 0, SHIFT, XK_Right, moveword, {.i = +1 } },
{ 0, 0, XK_Left, movecursor, {.i = -1 } },
{ 0, 0, XK_Right, movecursor, {.i = +1 } },
{ 0, MODIFIER1, XK_p, navhistory, {.i = -1 } },
{ 0, MODIFIER1, XK_n, navhistory, {.i = +1 } },
@ -92,9 +98,5 @@ static Key keys[] = {
{ -1, 0, XK_Tab, complete, {0} },
{ -1, CONTROL, XK_v, paste, {.i = 1 } }, /* primary buffer */
{ -1, CONTROL|SHIFT, XK_v, paste, {.i = 2 } },
{ -1, 0, XK_Up, move, {.i = 1 } },
{ -1, 0, XK_Down, move, {.i = 2 } },
{ -1, 0, XK_Left, move, {.i = 3 } },
{ -1, 0, XK_Right, move, {.i = 4 } },
{ -1, 0, XK_BackSpace, backspace, {0} },
};

View file

@ -200,6 +200,13 @@ moveword(const Arg *arg)
drawmenu();
}
void
movecursor(const Arg *arg)
{
cursor = arg->i ? nextrune(+1) : nextrune(-1);
drawmenu();
}
void
backspace(const Arg *arg)
{

View file

@ -16,6 +16,7 @@ static void restoresel(const Arg *arg);
static void clear(const Arg *arg);
static void viewhist(const Arg *arg);
static void moveword(const Arg *arg);
static void movecursor(const Arg *arg);
static void navhistory(const Arg *arg);
static void backspace(const Arg *arg);
static void selectitem(const Arg *arg);