Adding key and mouse binding option to control whether they apply to primary screen, alt screen or both ref. #81
This commit is contained in:
parent
89ced627cd
commit
34cd955f14
39
config.def.h
39
config.def.h
|
@ -339,48 +339,33 @@ static uint forcemousemod = ShiftMask;
|
|||
* Beware that overloading Button1 will disable the selection.
|
||||
*/
|
||||
static MouseShortcut mshortcuts[] = {
|
||||
#if UNIVERSCROLL_PATCH
|
||||
/* mask button function argument release alt */
|
||||
#else
|
||||
/* mask button function argument release */
|
||||
#endif // UNIVERSCROLL_PATCH
|
||||
/* mask button function argument release screen */
|
||||
#if CLIPBOARD_PATCH
|
||||
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
|
||||
#else
|
||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||
#endif // CLIPBOARD_PATCH
|
||||
#if SCROLLBACK_MOUSE_PATCH
|
||||
{ ShiftMask, Button4, kscrollup, {.i = 1} },
|
||||
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
|
||||
{ ShiftMask, Button4, kscrollup, {.i = 1}, 0, S_PRI},
|
||||
{ ShiftMask, Button5, kscrolldown, {.i = 1}, 0, S_PRI},
|
||||
#elif UNIVERSCROLL_PATCH
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, -1 },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, -1 },
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, S_PRI },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, S_PRI },
|
||||
#else
|
||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
||||
#endif // SCROLLBACK_MOUSE_PATCH
|
||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
{ XK_NO_MOD, Button4, kscrollup, {.i = 1} },
|
||||
{ XK_NO_MOD, Button5, kscrolldown, {.i = 1} },
|
||||
{ XK_NO_MOD, Button4, kscrollup, {.i = 1}, 0, S_PRI },
|
||||
{ XK_NO_MOD, Button5, kscrolldown, {.i = 1}, 0, S_PRI },
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"}, 0, S_ALT },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"}, 0, S_ALT },
|
||||
#else
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
};
|
||||
|
||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
static MouseShortcut maltshortcuts[] = {
|
||||
/* mask button function argument release */
|
||||
#if CLIPBOARD_PATCH
|
||||
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
|
||||
#else
|
||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||
#endif // CLIPBOARD_PATCH
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||
};
|
||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
|
||||
/* Internal keyboard shortcuts. */
|
||||
#define MODKEY Mod1Mask
|
||||
#define TERMMOD (ControlMask|ShiftMask)
|
||||
|
@ -398,7 +383,7 @@ static char *setbgcolorcmd[] = { "/bin/sh", "-c",
|
|||
#endif // EXTERNALPIPE_PATCH
|
||||
|
||||
static Shortcut shortcuts[] = {
|
||||
/* mask keysym function argument */
|
||||
/* mask keysym function argument screen */
|
||||
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
|
||||
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
|
||||
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
|
||||
|
@ -409,8 +394,8 @@ static Shortcut shortcuts[] = {
|
|||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
||||
#if SCROLLBACK_PATCH
|
||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1}, S_PRI },
|
||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1}, S_PRI },
|
||||
#endif // SCROLLBACK_PATCH
|
||||
#if CLIPBOARD_PATCH
|
||||
{ TERMMOD, XK_Y, clippaste, {.i = 0} },
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
#include "scrollback.c"
|
||||
#endif
|
||||
#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
#include "universcroll.c"
|
||||
#endif
|
||||
#if SIXEL_PATCH
|
||||
#include "sixel_st.c"
|
||||
#endif
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
#include "scrollback.h"
|
||||
#endif
|
||||
#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
#include "universcroll.h"
|
||||
#endif
|
||||
#if SIXEL_PATCH
|
||||
#include "sixel_st.h"
|
||||
#endif
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
int
|
||||
tisaltscr(void)
|
||||
{
|
||||
return IS_SET(MODE_ALTSCREEN);
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
int tisaltscr(void);
|
6
st.c
6
st.c
|
@ -1266,6 +1266,12 @@ tattrset(int attr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
tisaltscr(void)
|
||||
{
|
||||
return IS_SET(MODE_ALTSCREEN);
|
||||
}
|
||||
|
||||
void
|
||||
tsetdirt(int top, int bot)
|
||||
{
|
||||
|
|
13
st.h
13
st.h
|
@ -88,6 +88,13 @@ enum drawing_mode {
|
|||
};
|
||||
#endif // WIDE_GLYPHS_PATCH
|
||||
|
||||
/* Used to control which screen(s) keybindings and mouse shortcuts apply to. */
|
||||
enum screen {
|
||||
S_PRI = -1, /* primary screen */
|
||||
S_ALL = 0, /* both primary and alt screen */
|
||||
S_ALT = 1 /* alternate screen */
|
||||
};
|
||||
|
||||
enum selection_mode {
|
||||
SEL_IDLE = 0,
|
||||
SEL_EMPTY = 1,
|
||||
|
@ -251,6 +258,7 @@ typedef struct {
|
|||
KeySym keysym;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
int screen;
|
||||
} Shortcut;
|
||||
|
||||
typedef struct {
|
||||
|
@ -259,9 +267,7 @@ typedef struct {
|
|||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
uint release;
|
||||
#if UNIVERSCROLL_PATCH
|
||||
int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
|
||||
#endif // UNIVERSCROLL_PATCH
|
||||
int screen;
|
||||
} MouseShortcut;
|
||||
|
||||
typedef struct {
|
||||
|
@ -309,6 +315,7 @@ void sendbreak(const Arg *);
|
|||
void toggleprinter(const Arg *);
|
||||
|
||||
int tattrset(int);
|
||||
int tisaltscr(void);
|
||||
void tnew(int, int);
|
||||
void tresize(int, int);
|
||||
#if VIM_BROWSE_PATCH
|
||||
|
|
25
x.c
25
x.c
|
@ -345,29 +345,15 @@ int
|
|||
mouseaction(XEvent *e, uint release)
|
||||
{
|
||||
MouseShortcut *ms;
|
||||
int screen = tisaltscr() ? S_ALT : S_PRI;
|
||||
|
||||
/* ignore Button<N>mask for Button<N> - it's set on release */
|
||||
uint state = e->xbutton.state & ~buttonmask(e->xbutton.button);
|
||||
|
||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
if (tisaltscr())
|
||||
for (ms = maltshortcuts; ms < maltshortcuts + LEN(maltshortcuts); ms++) {
|
||||
if (ms->release == release &&
|
||||
ms->button == e->xbutton.button &&
|
||||
(match(ms->mod, state) || /* exact or forced */
|
||||
match(ms->mod, state & ~forcemousemod))) {
|
||||
ms->func(&(ms->arg));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
||||
if (ms->release == release &&
|
||||
ms->button == e->xbutton.button &&
|
||||
#if UNIVERSCROLL_PATCH
|
||||
(!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
|
||||
#endif // UNIVERSCROLL_PATCH
|
||||
(!ms->screen || (ms->screen == screen)) &&
|
||||
(match(ms->mod, state) || /* exact or forced */
|
||||
match(ms->mod, state & ~forcemousemod))) {
|
||||
ms->func(&(ms->arg));
|
||||
|
@ -3112,7 +3098,7 @@ kpress(XEvent *ev)
|
|||
XKeyEvent *e = &ev->xkey;
|
||||
KeySym ksym;
|
||||
char buf[64], *customkey;
|
||||
int len;
|
||||
int len, screen;
|
||||
Rune c;
|
||||
Status status;
|
||||
Shortcut *bp;
|
||||
|
@ -3165,9 +3151,12 @@ kpress(XEvent *ev)
|
|||
}
|
||||
#endif // VIM_BROWSE_PATCH
|
||||
|
||||
screen = tisaltscr() ? S_ALT : S_PRI;
|
||||
|
||||
/* 1. shortcuts */
|
||||
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
||||
if (ksym == bp->keysym && match(bp->mod, e->state)) {
|
||||
if (ksym == bp->keysym && match(bp->mod, e->state) &&
|
||||
(!bp->screen || bp->screen == screen)) {
|
||||
bp->func(&(bp->arg));
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue