mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
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.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
*/
|
*/
|
||||||
static MouseShortcut mshortcuts[] = {
|
static MouseShortcut mshortcuts[] = {
|
||||||
#if UNIVERSCROLL_PATCH
|
/* mask button function argument release screen */
|
||||||
/* mask button function argument release alt */
|
|
||||||
#else
|
|
||||||
/* mask button function argument release */
|
|
||||||
#endif // UNIVERSCROLL_PATCH
|
|
||||||
#if CLIPBOARD_PATCH
|
#if CLIPBOARD_PATCH
|
||||||
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
|
{ XK_ANY_MOD, Button2, clippaste, {.i = 0}, 1 },
|
||||||
#else
|
#else
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||||
#endif // CLIPBOARD_PATCH
|
#endif // CLIPBOARD_PATCH
|
||||||
#if SCROLLBACK_MOUSE_PATCH
|
#if SCROLLBACK_MOUSE_PATCH
|
||||||
{ ShiftMask, Button4, kscrollup, {.i = 1} },
|
{ ShiftMask, Button4, kscrollup, {.i = 1}, 0, S_PRI},
|
||||||
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
|
{ ShiftMask, Button5, kscrolldown, {.i = 1}, 0, S_PRI},
|
||||||
#elif UNIVERSCROLL_PATCH
|
#elif UNIVERSCROLL_PATCH
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;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, -1 },
|
{ XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, S_PRI },
|
||||||
#else
|
#else
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
||||||
#endif // SCROLLBACK_MOUSE_PATCH
|
#endif // SCROLLBACK_MOUSE_PATCH
|
||||||
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
{ XK_NO_MOD, Button4, kscrollup, {.i = 1} },
|
{ XK_NO_MOD, Button4, kscrollup, {.i = 1}, 0, S_PRI },
|
||||||
{ XK_NO_MOD, Button5, kscrolldown, {.i = 1} },
|
{ 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
|
#else
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||||
#endif // SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#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. */
|
/* Internal keyboard shortcuts. */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define TERMMOD (ControlMask|ShiftMask)
|
#define TERMMOD (ControlMask|ShiftMask)
|
||||||
@ -398,7 +383,7 @@ static char *setbgcolorcmd[] = { "/bin/sh", "-c",
|
|||||||
#endif // EXTERNALPIPE_PATCH
|
#endif // EXTERNALPIPE_PATCH
|
||||||
|
|
||||||
static Shortcut shortcuts[] = {
|
static Shortcut shortcuts[] = {
|
||||||
/* mask keysym function argument */
|
/* mask keysym function argument screen */
|
||||||
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
|
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
|
||||||
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
|
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
|
||||||
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
|
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
|
||||||
@ -409,8 +394,8 @@ static Shortcut shortcuts[] = {
|
|||||||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
||||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
||||||
#if SCROLLBACK_PATCH
|
#if SCROLLBACK_PATCH
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1}, S_PRI },
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1}, S_PRI },
|
||||||
#endif // SCROLLBACK_PATCH
|
#endif // SCROLLBACK_PATCH
|
||||||
#if CLIPBOARD_PATCH
|
#if CLIPBOARD_PATCH
|
||||||
{ TERMMOD, XK_Y, clippaste, {.i = 0} },
|
{ TERMMOD, XK_Y, clippaste, {.i = 0} },
|
||||||
|
@ -20,9 +20,6 @@
|
|||||||
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
#include "scrollback.c"
|
#include "scrollback.c"
|
||||||
#endif
|
#endif
|
||||||
#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
|
||||||
#include "universcroll.c"
|
|
||||||
#endif
|
|
||||||
#if SIXEL_PATCH
|
#if SIXEL_PATCH
|
||||||
#include "sixel_st.c"
|
#include "sixel_st.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
||||||
#include "scrollback.h"
|
#include "scrollback.h"
|
||||||
#endif
|
#endif
|
||||||
#if UNIVERSCROLL_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
|
|
||||||
#include "universcroll.h"
|
|
||||||
#endif
|
|
||||||
#if SIXEL_PATCH
|
#if SIXEL_PATCH
|
||||||
#include "sixel_st.h"
|
#include "sixel_st.h"
|
||||||
#endif
|
#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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
tisaltscr(void)
|
||||||
|
{
|
||||||
|
return IS_SET(MODE_ALTSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tsetdirt(int top, int bot)
|
tsetdirt(int top, int bot)
|
||||||
{
|
{
|
||||||
|
15
st.h
15
st.h
@ -88,6 +88,13 @@ enum drawing_mode {
|
|||||||
};
|
};
|
||||||
#endif // WIDE_GLYPHS_PATCH
|
#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 {
|
enum selection_mode {
|
||||||
SEL_IDLE = 0,
|
SEL_IDLE = 0,
|
||||||
SEL_EMPTY = 1,
|
SEL_EMPTY = 1,
|
||||||
@ -251,6 +258,7 @@ typedef struct {
|
|||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
void (*func)(const Arg *);
|
void (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
|
int screen;
|
||||||
} Shortcut;
|
} Shortcut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -258,10 +266,8 @@ typedef struct {
|
|||||||
uint button;
|
uint button;
|
||||||
void (*func)(const Arg *);
|
void (*func)(const Arg *);
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
uint release;
|
uint release;
|
||||||
#if UNIVERSCROLL_PATCH
|
int screen;
|
||||||
int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
|
|
||||||
#endif // UNIVERSCROLL_PATCH
|
|
||||||
} MouseShortcut;
|
} MouseShortcut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -309,6 +315,7 @@ void sendbreak(const Arg *);
|
|||||||
void toggleprinter(const Arg *);
|
void toggleprinter(const Arg *);
|
||||||
|
|
||||||
int tattrset(int);
|
int tattrset(int);
|
||||||
|
int tisaltscr(void);
|
||||||
void tnew(int, int);
|
void tnew(int, int);
|
||||||
void tresize(int, int);
|
void tresize(int, int);
|
||||||
#if VIM_BROWSE_PATCH
|
#if VIM_BROWSE_PATCH
|
||||||
|
25
x.c
25
x.c
@ -345,29 +345,15 @@ int
|
|||||||
mouseaction(XEvent *e, uint release)
|
mouseaction(XEvent *e, uint release)
|
||||||
{
|
{
|
||||||
MouseShortcut *ms;
|
MouseShortcut *ms;
|
||||||
|
int screen = tisaltscr() ? S_ALT : S_PRI;
|
||||||
|
|
||||||
/* ignore Button<N>mask for Button<N> - it's set on release */
|
/* ignore Button<N>mask for Button<N> - it's set on release */
|
||||||
uint state = e->xbutton.state & ~buttonmask(e->xbutton.button);
|
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++) {
|
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
||||||
if (ms->release == release &&
|
if (ms->release == release &&
|
||||||
ms->button == e->xbutton.button &&
|
ms->button == e->xbutton.button &&
|
||||||
#if UNIVERSCROLL_PATCH
|
(!ms->screen || (ms->screen == screen)) &&
|
||||||
(!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
|
|
||||||
#endif // UNIVERSCROLL_PATCH
|
|
||||||
(match(ms->mod, state) || /* exact or forced */
|
(match(ms->mod, state) || /* exact or forced */
|
||||||
match(ms->mod, state & ~forcemousemod))) {
|
match(ms->mod, state & ~forcemousemod))) {
|
||||||
ms->func(&(ms->arg));
|
ms->func(&(ms->arg));
|
||||||
@ -3112,7 +3098,7 @@ kpress(XEvent *ev)
|
|||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
char buf[64], *customkey;
|
char buf[64], *customkey;
|
||||||
int len;
|
int len, screen;
|
||||||
Rune c;
|
Rune c;
|
||||||
Status status;
|
Status status;
|
||||||
Shortcut *bp;
|
Shortcut *bp;
|
||||||
@ -3165,9 +3151,12 @@ kpress(XEvent *ev)
|
|||||||
}
|
}
|
||||||
#endif // VIM_BROWSE_PATCH
|
#endif // VIM_BROWSE_PATCH
|
||||||
|
|
||||||
|
screen = tisaltscr() ? S_ALT : S_PRI;
|
||||||
|
|
||||||
/* 1. shortcuts */
|
/* 1. shortcuts */
|
||||||
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
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));
|
bp->func(&(bp->arg));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user