feat: new version of st with scrollwheel sup

master
Toerd@archlinux 5 years ago
parent 2e2895a8a6
commit abd783625b

@ -1,6 +1,6 @@
## Why does st not handle utmp entries?
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
@ -15,13 +15,6 @@ you can manually run `tic -sx st.info`.
* Some programs dont complain about the lacking st description and default to
another terminal. In that case see the question about terminfo.
## I get some weird glitches/visual bug on _random program_!
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
you a list of available terminals, but youll most likely switch between xterm,
st or st-256color. The default value for TERM can be changed in config.h
(TNAME).
## How do I scroll back up?
Using a terminal multiplexer.
@ -104,7 +97,7 @@ St is emulating the Linux way of handling backspace being delete and delete bein
backspace.
This is an issue that was discussed in suckless mailing list
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
terminal users wants its backspace to be how he feels it:
Well, I am going to comment why I want to change the behaviour
@ -163,5 +156,40 @@ terminal users wants its backspace to be how he feels it:
Apply [1].
[1] http://st.suckless.org/patches/delkey
[1] https://st.suckless.org/patches/delkey
## Why do images not work in st (in programs such as w3m)?
This is a terrible hack that overdraws an image on top of the terminal emulator
window. It also relies on a very specific way the terminal draws it's contents.
A more proper (but limited way) would be using sixels. Which st doesn't
support.
## BadLength X error in Xft when trying to render emoji
Xft makes st crash when rendering color emojis with the following error:
"X Error of failed request: BadLength (poly request too large or internal Xlib length error)"
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 20 (RenderAddGlyphs)
Serial number of failed request: 1595
Current serial number in output stream: 1818"
This is a known bug in Xft (not st) which happens on some platforms and
combination of particular fonts and fontconfig settings.
See also:
https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6
https://bugs.freedesktop.org/show_bug.cgi?id=107534
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
The solution is to remove color emoji fonts or disable this in the fontconfig
XML configuration. As an ugly workaround (which may work only on newer
fontconfig versions (FC_COLOR)), the following code can be used to mask color
fonts:
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
Please don't bother reporting this bug to st, but notify the upstream Xft
developers about fixing this bug.

@ -22,7 +22,7 @@ config.h:
$(CC) $(STCFLAGS) -c $<
st.o: config.h st.h win.h
x.o: arg.h st.h win.h
x.o: arg.h config.h st.h win.h
$(OBJ): config.h config.mk

@ -30,9 +30,9 @@ static float chscale = 1.0;
/*
* word delimiter string
*
* More advanced example: " `'\"()[]{}"
* More advanced example: L" `'\"()[]{}"
*/
char *worddelimiters = " ";
wchar_t *worddelimiters = L" ";
/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
@ -82,9 +82,6 @@ char *termname = "st-256color";
*/
unsigned int tabspaces = 8;
/* bg opacity */
unsigned int alpha = 0xcc;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
@ -112,7 +109,6 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */
"#cccccc",
"#555555",
"black",
};
@ -121,7 +117,7 @@ static const char *colorname[] = {
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 7;
unsigned int defaultbg = 257;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
@ -154,14 +150,24 @@ static unsigned int mousebg = 0;
*/
static unsigned int defaultattr = 11;
/*
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
static uint forcemousemod = ShiftMask;
/*
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* button mask string */
{ Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" },
/* mask button function argument release */
{ ShiftMask, Button4, kscrollup, {.i = 1} },
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
/* Internal keyboard shortcuts. */
@ -180,8 +186,8 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} },
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ TERMMOD, XK_I, iso14755, {.i = 0} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
};
@ -201,10 +207,6 @@ static Shortcut shortcuts[] = {
* * 0: no value
* * > 0: cursor application mode enabled
* * < 0: cursor application mode disabled
* crlf value
* * 0: no value
* * > 0: crlf mode is enabled
* * < 0: crlf mode is disabled
*
* Be careful with the order of the definitions because st searches in
* this table sequentially, so any XK_ANY_MOD must be in the last
@ -223,13 +225,6 @@ static KeySym mappedkeys[] = { -1 };
*/
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
/*
* Override mouse-select while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
static uint forceselmod = ShiftMask;
/*
* This is the huge key array which defines all compatibility to the Linux
* world. Please decide about changes wisely.

@ -5,8 +5,8 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char *font = "Iosevka:pixelsize=20:antialias=true:autohint=true";
static int borderpx = 2;
static char *font = "Cozette:antialias=true:autohint=true";
static int borderpx = 0;
/*
* What program is execed by st depends of these precedence rules:
@ -16,7 +16,7 @@ static int borderpx = 2;
* 4: value of shell in /etc/passwd
* 5: value of shell in config.h
*/
static char *shell = "/bin/bash";
static char *shell = "/bin/sh";
char *utmp = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
@ -30,9 +30,9 @@ static float chscale = 1.0;
/*
* word delimiter string
*
* More advanced example: " `'\"()[]{}"
* More advanced example: L" `'\"()[]{}"
*/
char *worddelimiters = " ";
wchar_t *worddelimiters = L" ";
/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
@ -82,59 +82,47 @@ char *termname = "st-256color";
*/
unsigned int tabspaces = 8;
/* bg opacity */
unsigned int alpha = 0xee;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
/* 8 normal colors */
[0] = "#282828", /* black */
[1] = "#fb4934", /* red */
[2] = "#b8bb26", /* green */
[3] = "#fabd2f", /* yellow */
[4] = "#83a599", /* blue */
[5] = "#d3869b", /* magenta */
[6] = "#17ccd5", /* cyan */
[7] = "#fdf4c1", /* white */
/* 8 bright colors */
[8] = "#504945", /* black */
[9] = "#fb4933", /* red */
[10] = "#73af00", /* green */
[11] = "#fabd2f", /* yellow */
[12] = "#83a598", /* blue */
[13] = "#d3869b", /* magenta */
[14] = "#17ccd5", /* cyan */
[15] = "#ffffc8", /* white */
};
const char *altcolorname[] = {
/* 8 normal colors */
[0] = "#fafafa", /* black */
[1] = "#ad1457", /* red */
[2] = "#26a69a", /* green */
[3] = "#ad1457", /* yellow */
[4] = "#81d4fa", /* blue */
[5] = "#ad1457", /* magenta */
[6] = "#26a69a", /* cyan */
[7] = "#cfd8dc", /* white */
/* 8 normal colors */
[0] = "#1d1f21", /* black */
[1] = "#cc6666", /* red */
[2] = "#b5bd68", /* green */
[3] = "#f0c674", /* yellow */
[4] = "#81a2be", /* blue */
[5] = "#b294bb", /* magenta */
[6] = "#8abeb7", /* cyan */
[7] = "#c5c8c6", /* white */
/* 8 bright colors */
[8] = "#37474f", /* black */
[9] = "#e91e63", /* red */
[10] = "#8bc34a", /* green */
[11] = "#e91e63", /* yellow */
[12] = "#03a9f4", /* blue */
[13] = "#e91e63", /* magenta */
[14] = "#009688", /* cyan */
[15] = "#263238", /* white */
[8] = "#969896", /* black */
[9] = "#cc6666", /* red */
[10] = "#b5bd68", /* green */
[11] = "#f0c674", /* yellow */
[12] = "#81a2be", /* blue */
[13] = "#b294bb", /* magenta */
[14] = "#8abeb7", /* cyan */
[15] = "#ffffff", /* white */
/* special colors */
[256] = "#1d1f21", /* background */
[257] = "#c5c8c6", /* foreground */
};
unsigned int defaultfg = 15;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 14;
static unsigned int defaultrcs = 15;
/*
* Default colors (colorname index)
* foreground, background, cursor
*/
unsigned int defaultfg = 257;
unsigned int defaultbg = 256;
static unsigned int defaultcs = 257;
static unsigned int defaultrcs = 256;
/*
* Colors used, when the specific fg == defaultfg. So in reverse mode this
* will reverse too. Another logic would only make the simple feature too
* complex.
*/
static unsigned int defaultitalic = 7;
static unsigned int defaultunderline = 7;
@ -167,38 +155,46 @@ static unsigned int mousebg = 0;
*/
static unsigned int defaultattr = 11;
/*
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
static uint forcemousemod = ShiftMask;
/*
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* button mask string */
{Button4, XK_ANY_MOD, "\031"},
{Button5, XK_ANY_MOD, "\005"},
/* mask button function argument release */
{ Mod1Mask, Button4, kscrollup, {.i = 1} },
{ Mod1Mask, Button5, kscrolldown, {.i = 1} },
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
/* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask | ShiftMask)
#define TERMMOD (ControlMask|ShiftMask)
static Shortcut shortcuts[] = {
/* mask keysym function argument */
{XK_ANY_MOD, XK_Break, sendbreak, {.i = 0}},
{ControlMask, XK_Print, toggleprinter, {.i = 0}},
{ShiftMask, XK_Print, printscreen, {.i = 0}},
{XK_ANY_MOD, XK_Print, printsel, {.i = 0}},
{TERMMOD, XK_Prior, zoom, {.f = +1}},
{TERMMOD, XK_Next, zoom, {.f = -1}},
{TERMMOD, XK_Home, zoomreset, {.f = 0}},
{TERMMOD, XK_C, clipcopy, {.i = 0}},
{TERMMOD, XK_V, clippaste, {.i = 0}},
{TERMMOD, XK_Y, selpaste, {.i = 0}},
{TERMMOD, XK_Num_Lock, numlock, {.i = 0}},
{TERMMOD, XK_I, iso14755, {.i = 0}},
{ShiftMask, XK_Page_Up, kscrollup, {.i = -1}},
{ShiftMask, XK_Page_Down, kscrolldown, {.i = -1}},
{XK_ANY_MOD, XK_F9, swapcolors, {.i = 0}},
/* mask keysym function argument */
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
{ TERMMOD, XK_Next, zoom, {.f = -1} },
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} },
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
};
/*
@ -216,10 +212,6 @@ static Shortcut shortcuts[] = {
* * 0: no value
* * > 0: cursor application mode enabled
* * < 0: cursor application mode disabled
* crlf value
* * 0: no value
* * > 0: crlf mode is enabled
* * < 0: crlf mode is disabled
*
* Be careful with the order of the definitions because st searches in
* this table sequentially, so any XK_ANY_MOD must be in the last
@ -230,236 +222,229 @@ static Shortcut shortcuts[] = {
* If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
* to be mapped below, add them to this array.
*/
static KeySym mappedkeys[] = {-1};
static KeySym mappedkeys[] = { -1 };
/*
* State bits to ignore when matching key or button events. By default,
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
*/
static uint ignoremod = Mod2Mask | XK_SWITCH_MOD;
/*
* Override mouse-select while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
static uint forceselmod = ShiftMask;
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
/*
* This is the huge key array which defines all compatibility to the Linux
* world. Please decide about changes wisely.
*/
static Key key[] = {
/* keysym mask string appkey appcursor */
{XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
{XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
{XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
{XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
{XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
{XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
{XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
{XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
{XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
{XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
{XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
{XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
{XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
{XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
{XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
{XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
{XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
{XK_KP_End, ControlMask, "\033[J", -1, 0},
{XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
{XK_KP_End, ShiftMask, "\033[K", -1, 0},
{XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
{XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
{XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
{XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
{XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
{XK_KP_Insert, ControlMask, "\033[L", -1, 0},
{XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
{XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{XK_KP_Delete, ControlMask, "\033[M", -1, 0},
{XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
{XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
{XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
{XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
{XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
{XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
{XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
{XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
{XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
{XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
{XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
{XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
{XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
{XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
{XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
{XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
{XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
{XK_Up, ShiftMask, "\033[1;2A", 0, 0},
{XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
{XK_Up, ShiftMask | Mod1Mask, "\033[1;4A", 0, 0},
{XK_Up, ControlMask, "\033[1;5A", 0, 0},
{XK_Up, ShiftMask | ControlMask, "\033[1;6A", 0, 0},
{XK_Up, ControlMask | Mod1Mask, "\033[1;7A", 0, 0},
{XK_Up, ShiftMask | ControlMask | Mod1Mask, "\033[1;8A", 0, 0},
{XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
{XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
{XK_Down, ShiftMask, "\033[1;2B", 0, 0},
{XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
{XK_Down, ShiftMask | Mod1Mask, "\033[1;4B", 0, 0},
{XK_Down, ControlMask, "\033[1;5B", 0, 0},
{XK_Down, ShiftMask | ControlMask, "\033[1;6B", 0, 0},
{XK_Down, ControlMask | Mod1Mask, "\033[1;7B", 0, 0},
{XK_Down, ShiftMask | ControlMask | Mod1Mask, "\033[1;8B", 0, 0},
{XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
{XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
{XK_Left, ShiftMask, "\033[1;2D", 0, 0},
{XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
{XK_Left, ShiftMask | Mod1Mask, "\033[1;4D", 0, 0},
{XK_Left, ControlMask, "\033[1;5D", 0, 0},
{XK_Left, ShiftMask | ControlMask, "\033[1;6D", 0, 0},
{XK_Left, ControlMask | Mod1Mask, "\033[1;7D", 0, 0},
{XK_Left, ShiftMask | ControlMask | Mod1Mask, "\033[1;8D", 0, 0},
{XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
{XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
{XK_Right, ShiftMask, "\033[1;2C", 0, 0},
{XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
{XK_Right, ShiftMask | Mod1Mask, "\033[1;4C", 0, 0},
{XK_Right, ControlMask, "\033[1;5C", 0, 0},
{XK_Right, ShiftMask | ControlMask, "\033[1;6C", 0, 0},
{XK_Right, ControlMask | Mod1Mask, "\033[1;7C", 0, 0},
{XK_Right, ShiftMask | ControlMask | Mod1Mask, "\033[1;8C", 0, 0},
{XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
{XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
{XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
{XK_Return, Mod1Mask, "\033\r", 0, 0},
{XK_Return, XK_ANY_MOD, "\r", 0, 0},
{XK_Insert, ShiftMask, "\033[4l", -1, 0},
{XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
{XK_Insert, ControlMask, "\033[L", -1, 0},
{XK_Insert, ControlMask, "\033[2;5~", +1, 0},
{XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{XK_Delete, ControlMask, "\033[M", -1, 0},
{XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{XK_Delete, ShiftMask, "\033[2K", -1, 0},
{XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
{XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{XK_Home, ShiftMask, "\033[2J", 0, -1},
{XK_Home, ShiftMask, "\033[1;2H", 0, +1},
{XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
{XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{XK_End, ControlMask, "\033[J", -1, 0},
{XK_End, ControlMask, "\033[1;5F", +1, 0},
{XK_End, ShiftMask, "\033[K", -1, 0},
{XK_End, ShiftMask, "\033[1;2F", +1, 0},
{XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
{XK_Prior, ControlMask, "\033[5;5~", 0, 0},
{XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
{XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{XK_Next, ControlMask, "\033[6;5~", 0, 0},
{XK_Next, ShiftMask, "\033[6;2~", 0, 0},
{XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{XK_F1, XK_NO_MOD, "\033OP", 0, 0},
{XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
{XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
{XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
{XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
{XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
{XK_F2, XK_NO_MOD, "\033OQ", 0, 0},
{XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
{XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
{XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
{XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
{XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
{XK_F3, XK_NO_MOD, "\033OR", 0, 0},
{XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
{XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
{XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
{XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
{XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
{XK_F4, XK_NO_MOD, "\033OS", 0, 0},
{XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
{XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
{XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
{XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
{XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
{XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
{XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
{XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
{XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
{XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
{XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
{XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
{XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
{XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
{XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
{XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
{XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
{XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
{XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
{XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
{XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
{XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
{XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
{XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
{XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
{XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
{XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
{XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
{XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
{XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
{XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
{XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
{XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
{XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
{XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
{XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
{XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
{XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
{XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
{XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
{XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
{XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
{XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
{XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
{XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
{XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
{XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
{XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
{XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
{XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
{XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
{XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
{XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
{XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
{XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
{XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
{XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
{XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
{XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
{XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
{XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
{XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
{XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
{XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
{XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
{XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
{XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
/* keysym mask string appkey appcursor */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0},
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0},
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0},
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0},
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_End, ControlMask, "\033[J", -1, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
};
/*
@ -470,13 +455,14 @@ static Key key[] = {
* If no match is found, regular selection is used.
*/
static uint selmasks[] = {
[SEL_RECTANGULAR] = Mod1Mask,
[SEL_RECTANGULAR] = Mod1Mask,
};
/*
* Printable characters in ASCII, used to estimate the advance width
* of single wide characters.
*/
static char ascii_printable[] = " !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~";
static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~";

@ -1,5 +1,5 @@
# st version
VERSION = 0.8.1
VERSION = 0.8.2
# Customize below to fit your system
@ -10,19 +10,26 @@ MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
PKG_CONFIG = pkg-config
# includes and libs
INCS = -I. -I/usr/include -I${X11INC} \
`pkg-config --cflags fontconfig` \
`pkg-config --cflags freetype2`
LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft -lXrender\
`pkg-config --libs fontconfig` \
`pkg-config --libs freetype2`
INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2`
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2`
# flags
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
# `pkg-config --libs fontconfig` \
# `pkg-config --libs freetype2`
# compiler and linker
# CC = c99

@ -159,10 +159,6 @@ Copy the selected text to the clipboard selection.
.TP
.B Ctrl-Shift-v
Paste from the clipboard selection.
.TP
.B Ctrl-Shift-i
Launch dmenu to enter a unicode codepoint and send the corresponding glyph
to st.
.SH CUSTOMIZATION
.B st
can be customized by creating a custom config.h and (re)compiling the source

@ -35,17 +35,17 @@
#define ESC_ARG_SIZ 16
#define STR_BUF_SIZ ESC_BUF_SIZ
#define STR_ARG_SIZ ESC_ARG_SIZ
#define HISTSIZE 2000
/* macros */
#define IS_SET(flag) ((term.mode & (flag)) != 0)
#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
#define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
/* constants */
#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
#define ISDELIM(u) (u && wcschr(worddelimiters, u))
#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
term.scr + HISTSIZE + 1) % HISTSIZE] : \
term.line[(y) - term.scr])
enum term_mode {
MODE_WRAP = 1 << 0,
@ -142,7 +142,7 @@ typedef struct {
/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
typedef struct {
char buf[ESC_BUF_SIZ]; /* raw string */
int len; /* raw string length */
size_t len; /* raw string length */
char priv;
int arg[ESC_ARG_SIZ];
int narg; /* nb of args */
@ -153,8 +153,9 @@ typedef struct {
/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
typedef struct {
char type; /* ESC type ... */
char buf[STR_BUF_SIZ]; /* raw string */
int len; /* raw string length */
char *buf; /* allocated raw string */
size_t siz; /* allocation size */
size_t len; /* raw string length */
char *args[STR_ARG_SIZ];
int narg; /* nb of args */
} STREscape;
@ -217,7 +218,6 @@ static void selsnap(int *, int *, int);
static size_t utf8decode(const char *, Rune *, size_t);
static Rune utf8decodebyte(char, size_t *);
static char utf8encodebyte(Rune, size_t);
static char *utf8strchr(char *, Rune);
static size_t utf8validate(Rune *, size_t);
static char *base64dec(const char *);
@ -259,10 +259,10 @@ xwrite(int fd, const char *s, size_t len)
void *
xmalloc(size_t len)
{
void *p = malloc(len);
void *p;
if (!p)
die("Out of memory\n");
if (!(p = malloc(len)))
die("malloc: %s\n", strerror(errno));
return p;
}
@ -271,7 +271,7 @@ void *
xrealloc(void *p, size_t len)
{
if ((p = realloc(p, len)) == NULL)
die("Out of memory\n");
die("realloc: %s\n", strerror(errno));
return p;
}
@ -280,7 +280,7 @@ char *
xstrdup(char *s)
{
if ((s = strdup(s)) == NULL)
die("Out of memory\n");
die("strdup: %s\n", strerror(errno));
return s;
}
@ -344,23 +344,6 @@ utf8encodebyte(Rune u, size_t i)
return utfbyte[i] | (u & ~utfmask[i]);
}
char *
utf8strchr(char *s, Rune u)
{
Rune r;
size_t i, j, len;
len = strlen(s);
for (i = 0, j = 0; i < len; i += j) {
if (!(j = utf8decode(&s[i], &r, len - i)))
break;
if (r == u)
return &(s[i]);
}
return NULL;
}
size_t
utf8validate(Rune *u, size_t i)
{
@ -391,7 +374,7 @@ char
base64dec_getc(const char **src)
{
while (**src && !isprint(**src)) (*src)++;
return *((*src)++);
return **src ? *((*src)++) : '='; /* emulate padding if string ends */
}
char *
@ -409,6 +392,10 @@ base64dec(const char *src)
int c = base64_digits[(unsigned char) base64dec_getc(&src)];
int d = base64_digits[(unsigned char) base64dec_getc(&src)];
/* invalid input. 'a' can be -1, e.g. if src is "\n" (c-str) */
if (a == -1 || b == -1)
break;
*dst++ = (a << 2) | ((b & 0x30) >> 4);
if (c == -1)
break;
@ -449,6 +436,7 @@ selstart(int col, int row, int snap)
selclear();
sel.mode = SEL_EMPTY;
sel.type = SEL_REGULAR;
sel.alt = IS_SET(MODE_ALTSCREEN);
sel.snap = snap;
sel.oe.x = sel.ob.x = col;
sel.oe.y = sel.ob.y = row;
@ -477,13 +465,12 @@ selextend(int col, int row, int type, int done)
oldsey = sel.ne.y;
oldtype = sel.type;
sel.alt = IS_SET(MODE_ALTSCREEN);
sel.oe.x = col;
sel.oe.y = row;
selnormalize();
sel.type = type;
if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY)
tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
sel.mode = done ? SEL_IDLE : SEL_READY;
@ -690,7 +677,7 @@ execsh(char *cmd, char **args)
errno = 0;
if ((pw = getpwuid(getuid())) == NULL) {
if (errno)
die("getpwuid:%s\n", strerror(errno));
die("getpwuid: %s\n", strerror(errno));
else
die("who are you?\n");
}
@ -733,13 +720,15 @@ sigchld(int a)
pid_t p;
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
if (pid != p)
return;
if (!WIFEXITED(stat) || WEXITSTATUS(stat))
die("child finished with error '%d'\n", stat);
if (WIFEXITED(stat) && WEXITSTATUS(stat))
die("child exited with status %d\n", WEXITSTATUS(stat));
else if (WIFSIGNALED(stat))
die("child terminated due to signal %d\n", WTERMSIG(stat));
exit(0);
}
@ -784,7 +773,8 @@ ttynew(char *line, char *cmd, char *out, char **args)
if (line) {
if ((cmdfd = open(line, O_RDWR)) < 0)
die("open line failed: %s\n", strerror(errno));
die("open line '%s' failed: %s\n",
line, strerror(errno));
dup2(cmdfd, 0);
stty(args);
return cmdfd;
@ -796,7 +786,7 @@ ttynew(char *line, char *cmd, char *out, char **args)
switch (pid = fork()) {
case -1:
die("fork failed\n");
die("fork failed: %s\n", strerror(errno));
break;
case 0:
close(iofd);
@ -808,9 +798,17 @@ ttynew(char *line, char *cmd, char *out, char **args)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
close(s);
close(m);
#ifdef __OpenBSD__
if (pledge("stdio getpw proc exec", NULL) == -1)
die("pledge\n");
#endif
execsh(cmd, args);
break;
default:
#ifdef __OpenBSD__
if (pledge("stdio rpath tty proc", NULL) == -1)
die("pledge\n");
#endif
close(s);
cmdfd = m;
signal(SIGCHLD, sigchld);
@ -829,7 +827,7 @@ ttyread(void)
/* append read bytes to unprocessed bytes */
if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
die("Couldn't read from shell: %s\n", strerror(errno));
die("couldn't read from shell: %s\n", strerror(errno));
buflen += ret;
written = twrite(buf, buflen, 0);
@ -838,9 +836,6 @@ ttyread(void)
if (buflen > 0)
memmove(buf, buf + written, buflen);
if (term.scr > 0 && term.scr < HISTSIZE-1)
term.scr++;
return ret;
}
@ -1094,7 +1089,6 @@ kscrollup(const Arg* a)
}
}
void
tscrolldown(int orig, int n, int copyhist)
{
@ -1119,7 +1113,8 @@ tscrolldown(int orig, int n, int copyhist)
term.line[i-n] = temp;
}
selscroll(orig, n);
if (term.scr == 0)
selscroll(orig, n);
}
void
@ -1137,6 +1132,9 @@ tscrollup(int orig, int n, int copyhist)
term.line[orig] = temp;
}
if (term.scr > 0 && term.scr < HISTSIZE)
term.scr = MIN(term.scr + n, HISTSIZE-1);
tclearregion(0, orig, term.col-1, orig+n-1);
tsetdirt(orig+n, term.bot);
@ -1146,7 +1144,8 @@ tscrollup(int orig, int n, int copyhist)
term.line[i+n] = temp;
}
selscroll(orig, -n);
if (term.scr == 0)
selscroll(orig, -n);
}
void
@ -1504,7 +1503,8 @@ tsetattr(int *attr, int l)
} else {
fprintf(stderr,
"erresc(default): gfx attr %d unknown\n",
attr[i]), csidump();
attr[i]);
csidump();
}
break;
}
@ -1624,6 +1624,7 @@ tsetmode(int priv, int set, int *args, int narg)
case 1015: /* urxvt mangled mouse mode; incompatible
and can be mistaken for other control
codes. */
break;
default:
fprintf(stderr,
"erresc: unknown private set/reset mode %d\n",
@ -1865,7 +1866,7 @@ csihandle(void)
void
csidump(void)
{
int i;
size_t i;
uint c;
fprintf(stderr, "ESC[");
@ -1895,7 +1896,7 @@ csireset(void)
void
strhandle(void)
{
char *p = NULL;
char *p = NULL, *dec;
int j, narg, par;
term.esc &= ~(ESC_STR_END|ESC_STR);
@ -1913,8 +1914,6 @@ strhandle(void)
return;
case 52:
if (narg > 2) {
char *dec;
dec = base64dec(strescseq.args[2]);
if (dec) {
xsetsel(dec);
@ -1932,7 +1931,10 @@ strhandle(void)
case 104: /* color reset, here p = NULL */
j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
if (xsetcolorname(j, p)) {
fprintf(stderr, "erresc: invalid color %s\n", p);
if (par == 104 && narg <= 1)
return; /* color reset without parameter */
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
j, p ? p : "(null)");
} else {
/*
* TODO if defaultbg color is changed, borders
@ -1982,7 +1984,7 @@ strparse(void)
void
strdump(void)
{
int i;
size_t i;
uint c;
fprintf(stderr, "ESC%c", strescseq.type);
@ -2009,7 +2011,10 @@ strdump(void)
void
strreset(void)
{
memset(&strescseq, 0, sizeof(strescseq));
strescseq = (STREscape){
.buf = xrealloc(strescseq.buf, STR_BUF_SIZ),
.siz = STR_BUF_SIZ,
};
}
void
@ -2029,28 +2034,6 @@ tprinter(char *s, size_t len)
}
}
void
iso14755(const Arg *arg)
{
FILE *p;
char *us, *e, codepoint[9], uc[UTF_SIZ];
unsigned long utf32;
if (!(p = popen(ISO14755CMD, "r")))
return;
us = fgets(codepoint, sizeof(codepoint), p);
pclose(p);
if (!us || *us == '\0' || *us == '-' || strlen(us) > 7)
return;
if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX ||
(*e != '\n' && *e != '\0'))
return;
ttywrite(uc, utf8encode(utf32, uc), 1);
}
void
toggleprinter(const Arg *arg)
{
@ -2335,7 +2318,7 @@ eschandle(uchar ascii)
case 'Z': /* DECID -- Identify Terminal */
ttywrite(vtiden, strlen(vtiden), 0);
break;
case 'c': /* RIS -- Reset to inital state */
case 'c': /* RIS -- Reset to initial state */
treset();
resettitle();
xloadcols();
@ -2406,7 +2389,6 @@ tputc(Rune u)
goto check_control_code;
}
if (IS_SET(MODE_SIXEL)) {
/* TODO: implement sixel mode */
return;
@ -2414,7 +2396,7 @@ tputc(Rune u)
if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
term.mode |= MODE_SIXEL;
if (strescseq.len+len >= sizeof(strescseq.buf)-1) {
if (strescseq.len+len >= strescseq.siz) {
/*
* Here is a bug in terminals. If the user never sends
* some code to stop the str or esc command, then st
@ -2428,7 +2410,10 @@ tputc(Rune u)
* term.esc = 0;
* strhandle();
*/
return;
if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2)
return;
strescseq.siz *= 2;
strescseq.buf = xrealloc(strescseq.buf, strescseq.siz);
}
memmove(&strescseq.buf[strescseq.len], c, len);
@ -2591,7 +2576,7 @@ tresize(int col, int row)
}
}
/* resize each r w to new width, zero-pad if needed */
/* resize each row to new width, zero-pad if needed */
for (i = 0; i < minrow; i++) {
term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph));
@ -2669,12 +2654,12 @@ draw(void)
cx--;
drawregion(0, 0, term.col, term.row);
if (term.scr == 0) {
if (term.scr == 0)
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
}
term.ocx = cx, term.ocy = term.c.y;
xfinishdraw();
xximspot(term.ocx, term.ocy);
}
void

@ -3,9 +3,6 @@
#include <stdint.h>
#include <sys/types.h>
/* Arbitrary size */
#define HISTSIZE 2000
/* macros */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
@ -22,8 +19,6 @@
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
#define IS_TRUECOL(x) (1 << 24 & (x))
#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - term.scr \
+ HISTSIZE + 1) % HISTSIZE] : term.line[(y) - term.scr])
enum glyph_attribute {
ATTR_NULL = 0,
@ -79,13 +74,15 @@ typedef union {
uint ui;
float f;
const void *v;
const char *s;
} Arg;
void die(const char *, ...);
void redraw(void);
void draw(void);
void iso14755(const Arg *);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);
@ -116,18 +113,13 @@ void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(char *);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
/* config.h globals */
extern char *utmp;
extern char *stty_args;
extern char *vtiden;
extern char *worddelimiters;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
extern char *termname;
extern int usealtcolors;
extern unsigned int tabspaces;
extern unsigned int alpha;
extern unsigned int defaultfg;
extern unsigned int defaultbg;

@ -189,10 +189,10 @@ st| simpleterm,
rmxx=\E[29m,
smxx=\E[9m,
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
Se,
Ss,
Tc,
Ms=\E]52;%p1%s;%p2%s\007,
Se=\E[2 q,
Ss=\E[%p1%d q,
st-256color| simpleterm with 256 colors,
use=st,

@ -36,3 +36,4 @@ void xsetmode(int, unsigned int);
void xsetpointermotion(int);
void xsetsel(char *);
int xstartdraw(void);
void xximspot(int, int);

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save