mirror of
https://github.com/pikami/st.git
synced 2025-06-08 08:10:05 +01:00
Compare commits
No commits in common. "pikami" and "0.8" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
st
|
|
||||||
st.o
|
|
||||||
x.o
|
|
110
FAQ
110
FAQ
@ -1,7 +1,6 @@
|
|||||||
## Why does st not handle utmp entries?
|
## Why does st not handle utmp entries?
|
||||||
|
|
||||||
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
|
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
|
||||||
|
|
||||||
|
|
||||||
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
||||||
|
|
||||||
@ -9,7 +8,6 @@ It means that st doesn’t have any terminfo entry on your system. Chances are
|
|||||||
you did not `make install`. If you just want to test it without installing it,
|
you did not `make install`. If you just want to test it without installing it,
|
||||||
you can manually run `tic -sx st.info`.
|
you can manually run `tic -sx st.info`.
|
||||||
|
|
||||||
|
|
||||||
## Nothing works, and nothing is said about an unknown terminal!
|
## Nothing works, and nothing is said about an unknown terminal!
|
||||||
|
|
||||||
* Some programs just assume they’re running in xterm i.e. they don’t rely on
|
* Some programs just assume they’re running in xterm i.e. they don’t rely on
|
||||||
@ -17,21 +15,19 @@ you can manually run `tic -sx st.info`.
|
|||||||
* Some programs don’t complain about the lacking st description and default to
|
* Some programs don’t complain about the lacking st description and default to
|
||||||
another terminal. In that case see the question about terminfo.
|
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 you’ll 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?
|
## How do I scroll back up?
|
||||||
|
|
||||||
* Using a terminal multiplexer.
|
Using a terminal multiplexer.
|
||||||
* `st -e tmux` using C-b [
|
|
||||||
* `st -e screen` using C-a ESC
|
|
||||||
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
|
|
||||||
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
|
|
||||||
|
|
||||||
|
|
||||||
## I would like to have utmp and/or scroll functionality by default
|
|
||||||
|
|
||||||
You can add the absolute path of both programs in your config.h file. You only
|
|
||||||
have to modify the value of utmp and scroll variables.
|
|
||||||
|
|
||||||
|
* `st -e tmux` using C-b [
|
||||||
|
* `st -e screen` using C-a ESC
|
||||||
|
|
||||||
## Why doesn't the Del key work in some programs?
|
## Why doesn't the Del key work in some programs?
|
||||||
|
|
||||||
@ -88,14 +84,12 @@ If you are using zsh, then read the zsh FAQ
|
|||||||
|
|
||||||
Putting these lines into your .zshrc will fix the problems.
|
Putting these lines into your .zshrc will fix the problems.
|
||||||
|
|
||||||
|
|
||||||
## How can I use meta in 8bit mode?
|
## How can I use meta in 8bit mode?
|
||||||
|
|
||||||
St supports meta in 8bit mode, but the default terminfo entry doesn't
|
St supports meta in 8bit mode, but the default terminfo entry doesn't
|
||||||
use this capability. If you want it, you have to use the 'st-meta' value
|
use this capability. If you want it, you have to use the 'st-meta' value
|
||||||
in TERM.
|
in TERM.
|
||||||
|
|
||||||
|
|
||||||
## I cannot compile st in OpenBSD
|
## I cannot compile st in OpenBSD
|
||||||
|
|
||||||
OpenBSD lacks librt, despite it being mandatory in POSIX
|
OpenBSD lacks librt, despite it being mandatory in POSIX
|
||||||
@ -104,14 +98,13 @@ If you want to compile st for OpenBSD you have to remove -lrt from config.mk, an
|
|||||||
st will compile without any loss of functionality, because all the functions are
|
st will compile without any loss of functionality, because all the functions are
|
||||||
included in libc on this platform.
|
included in libc on this platform.
|
||||||
|
|
||||||
|
|
||||||
## The Backspace Case
|
## The Backspace Case
|
||||||
|
|
||||||
St is emulating the Linux way of handling backspace being delete and delete being
|
St is emulating the Linux way of handling backspace being delete and delete being
|
||||||
backspace.
|
backspace.
|
||||||
|
|
||||||
This is an issue that was discussed in suckless mailing list
|
This is an issue that was discussed in suckless mailing list
|
||||||
<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
||||||
terminal users wants its backspace to be how he feels it:
|
terminal users wants its backspace to be how he feels it:
|
||||||
|
|
||||||
Well, I am going to comment why I want to change the behaviour
|
Well, I am going to comment why I want to change the behaviour
|
||||||
@ -166,88 +159,9 @@ terminal users wants its backspace to be how he feels it:
|
|||||||
[1] http://www.ibb.net/~anne/keyboard.html
|
[1] http://www.ibb.net/~anne/keyboard.html
|
||||||
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
|
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
|
||||||
|
|
||||||
|
|
||||||
## But I really want the old grumpy behaviour of my terminal
|
## But I really want the old grumpy behaviour of my terminal
|
||||||
|
|
||||||
Apply [1].
|
Apply [1].
|
||||||
|
|
||||||
[1] https://st.suckless.org/patches/delkey
|
[1] http://st.suckless.org/patches/delkey
|
||||||
|
|
||||||
|
|
||||||
## Why do images not work in st using the w3m image hack?
|
|
||||||
|
|
||||||
w3mimg uses a hack that draws an image on top of the terminal emulator Drawable
|
|
||||||
window. The hack relies on the terminal to use a single buffer to draw its
|
|
||||||
contents directly.
|
|
||||||
|
|
||||||
st uses double-buffered drawing so the image is quickly replaced and may show a
|
|
||||||
short flicker effect.
|
|
||||||
|
|
||||||
Below is a patch example to change st double-buffering to a single Drawable
|
|
||||||
buffer.
|
|
||||||
|
|
||||||
diff --git a/x.c b/x.c
|
|
||||||
--- a/x.c
|
|
||||||
+++ b/x.c
|
|
||||||
@@ -732,10 +732,6 @@ xresize(int col, int row)
|
|
||||||
win.tw = col * win.cw;
|
|
||||||
win.th = row * win.ch;
|
|
||||||
|
|
||||||
- XFreePixmap(xw.dpy, xw.buf);
|
|
||||||
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
|
||||||
- DefaultDepth(xw.dpy, xw.scr));
|
|
||||||
- XftDrawChange(xw.draw, xw.buf);
|
|
||||||
xclear(0, 0, win.w, win.h);
|
|
||||||
|
|
||||||
/* resize to new width */
|
|
||||||
@@ -1148,8 +1144,7 @@ xinit(int cols, int rows)
|
|
||||||
gcvalues.graphics_exposures = False;
|
|
||||||
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
|
|
||||||
&gcvalues);
|
|
||||||
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
|
||||||
- DefaultDepth(xw.dpy, xw.scr));
|
|
||||||
+ xw.buf = xw.win;
|
|
||||||
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
|
||||||
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
|
||||||
|
|
||||||
@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2)
|
|
||||||
void
|
|
||||||
xfinishdraw(void)
|
|
||||||
{
|
|
||||||
- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
|
|
||||||
- win.h, 0, 0);
|
|
||||||
XSetForeground(xw.dpy, dc.gc,
|
|
||||||
dc.col[IS_SET(MODE_REVERSE)?
|
|
||||||
defaultfg : defaultbg].pixel);
|
|
||||||
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
As of 2022-09-05 this now seems to be finally fixed in libXft 2.3.5:
|
|
||||||
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
|
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2014-2022 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
||||||
© 2018 Devin J. Pohly <djpohly at gmail dot com>
|
© 2018 Devin J. Pohly <djpohly at gmail dot com>
|
||||||
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
|
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
|
||||||
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
|
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
|
||||||
|
2
Makefile
2
Makefile
@ -22,7 +22,7 @@ config.h:
|
|||||||
$(CC) $(STCFLAGS) -c $<
|
$(CC) $(STCFLAGS) -c $<
|
||||||
|
|
||||||
st.o: config.h st.h win.h
|
st.o: config.h st.h win.h
|
||||||
x.o: arg.h config.h st.h win.h
|
x.o: arg.h st.h win.h
|
||||||
|
|
||||||
$(OBJ): config.h config.mk
|
$(OBJ): config.h config.mk
|
||||||
|
|
||||||
|
22
arg.h
22
arg.h
@ -21,30 +21,28 @@ extern char *argv0;
|
|||||||
argc--;\
|
argc--;\
|
||||||
break;\
|
break;\
|
||||||
}\
|
}\
|
||||||
int i_;\
|
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
||||||
for (i_ = 1, brk_ = 0, argv_ = argv;\
|
argv[0][0] && !brk_;\
|
||||||
argv[0][i_] && !brk_;\
|
argv[0]++) {\
|
||||||
i_++) {\
|
|
||||||
if (argv_ != argv)\
|
if (argv_ != argv)\
|
||||||
break;\
|
break;\
|
||||||
argc_ = argv[0][i_];\
|
argc_ = argv[0][0];\
|
||||||
switch (argc_)
|
switch (argc_)
|
||||||
|
|
||||||
#define ARGEND }\
|
#define ARGEND }\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARGC() argc_
|
#define ARGC() argc_
|
||||||
|
|
||||||
#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
((x), abort(), (char *)0) :\
|
((x), abort(), (char *)0) :\
|
||||||
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
(&argv[0][i_+1]) :\
|
(&argv[0][1]) :\
|
||||||
(argc--, argv++, argv[0])))
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
(char *)0 :\
|
(char *)0 :\
|
||||||
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
(&argv[0][i_+1]) :\
|
(&argv[0][1]) :\
|
||||||
(argc--, argv++, argv[0])))
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
64
config.def.h
64
config.def.h
@ -11,15 +11,13 @@ static int borderpx = 2;
|
|||||||
/*
|
/*
|
||||||
* What program is execed by st depends of these precedence rules:
|
* What program is execed by st depends of these precedence rules:
|
||||||
* 1: program passed with -e
|
* 1: program passed with -e
|
||||||
* 2: scroll and/or utmp
|
* 2: utmp option
|
||||||
* 3: SHELL environment variable
|
* 3: SHELL environment variable
|
||||||
* 4: value of shell in /etc/passwd
|
* 4: value of shell in /etc/passwd
|
||||||
* 5: value of shell in config.h
|
* 5: value of shell in config.h
|
||||||
*/
|
*/
|
||||||
static char *shell = "/bin/sh";
|
static char *shell = "/bin/sh";
|
||||||
char *utmp = NULL;
|
char *utmp = NULL;
|
||||||
/* scroll program: to enable use a string like "scroll" */
|
|
||||||
char *scroll = NULL;
|
|
||||||
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
/* identification sequence returned in DA and DECID */
|
||||||
@ -32,9 +30,9 @@ static float chscale = 1.0;
|
|||||||
/*
|
/*
|
||||||
* word delimiter string
|
* word delimiter string
|
||||||
*
|
*
|
||||||
* More advanced example: L" `'\"()[]{}"
|
* More advanced example: " `'\"()[]{}"
|
||||||
*/
|
*/
|
||||||
wchar_t *worddelimiters = L" ";
|
char *worddelimiters = " ";
|
||||||
|
|
||||||
/* selection timeouts (in milliseconds) */
|
/* selection timeouts (in milliseconds) */
|
||||||
static unsigned int doubleclicktimeout = 300;
|
static unsigned int doubleclicktimeout = 300;
|
||||||
@ -43,18 +41,9 @@ static unsigned int tripleclicktimeout = 600;
|
|||||||
/* alt screens */
|
/* alt screens */
|
||||||
int allowaltscreen = 1;
|
int allowaltscreen = 1;
|
||||||
|
|
||||||
/* allow certain non-interactive (insecure) window operations such as:
|
/* frames per second st should at maximum draw to the screen */
|
||||||
setting the clipboard text */
|
static unsigned int xfps = 120;
|
||||||
int allowwindowops = 0;
|
static unsigned int actionfps = 30;
|
||||||
|
|
||||||
/*
|
|
||||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
|
||||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
|
||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
|
||||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
|
||||||
*/
|
|
||||||
static double minlatency = 8;
|
|
||||||
static double maxlatency = 33;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
||||||
@ -120,8 +109,6 @@ static const char *colorname[] = {
|
|||||||
/* more colors can be added after 255 to use with DefaultXX */
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#cccccc",
|
"#cccccc",
|
||||||
"#555555",
|
"#555555",
|
||||||
"gray90", /* default foreground colour */
|
|
||||||
"black", /* default background colour */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -129,9 +116,9 @@ static const char *colorname[] = {
|
|||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor, reverse cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
*/
|
*/
|
||||||
unsigned int defaultfg = 258;
|
unsigned int defaultfg = 7;
|
||||||
unsigned int defaultbg = 259;
|
unsigned int defaultbg = 0;
|
||||||
unsigned int defaultcs = 256;
|
static unsigned int defaultcs = 256;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 257;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -163,26 +150,14 @@ static unsigned int mousebg = 0;
|
|||||||
*/
|
*/
|
||||||
static unsigned int defaultattr = 11;
|
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.
|
* Internal mouse shortcuts.
|
||||||
* Beware that overloading Button1 will disable the selection.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
*/
|
*/
|
||||||
static MouseShortcut mshortcuts[] = {
|
static MouseShortcut mshortcuts[] = {
|
||||||
/* mask button function argument release */
|
/* button mask string */
|
||||||
{ XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
|
{ Button4, XK_ANY_MOD, "\031" },
|
||||||
{ XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 },
|
{ Button5, XK_ANY_MOD, "\005" },
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Internal keyboard shortcuts. */
|
/* Internal keyboard shortcuts. */
|
||||||
@ -201,10 +176,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} },
|
||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
{ TERMMOD, XK_I, iso14755, {.i = 0} },
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -222,6 +195,10 @@ static Shortcut shortcuts[] = {
|
|||||||
* * 0: no value
|
* * 0: no value
|
||||||
* * > 0: cursor application mode enabled
|
* * > 0: cursor application mode enabled
|
||||||
* * < 0: cursor application mode disabled
|
* * < 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
|
* 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
|
* this table sequentially, so any XK_ANY_MOD must be in the last
|
||||||
@ -240,6 +217,13 @@ static KeySym mappedkeys[] = { -1 };
|
|||||||
*/
|
*/
|
||||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
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
|
* This is the huge key array which defines all compatibility to the Linux
|
||||||
* world. Please decide about changes wisely.
|
* world. Please decide about changes wisely.
|
||||||
|
478
config.h
478
config.h
@ -1,478 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* appearance
|
|
||||||
*
|
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
|
||||||
*/
|
|
||||||
static char *font = "Liberation Mono:pixelsize=18:antialias=true:autohint=true";
|
|
||||||
static int borderpx = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What program is execed by st depends of these precedence rules:
|
|
||||||
* 1: program passed with -e
|
|
||||||
* 2: scroll and/or utmp
|
|
||||||
* 3: SHELL environment variable
|
|
||||||
* 4: value of shell in /etc/passwd
|
|
||||||
* 5: value of shell in config.h
|
|
||||||
*/
|
|
||||||
static char *shell = "/bin/sh";
|
|
||||||
char *utmp = NULL;
|
|
||||||
/* scroll program: to enable use a string like "scroll" */
|
|
||||||
char *scroll = NULL;
|
|
||||||
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
|
||||||
char *vtiden = "\033[?6c";
|
|
||||||
|
|
||||||
/* Kerning / character bounding-box multipliers */
|
|
||||||
static float cwscale = 1.0;
|
|
||||||
static float chscale = 1.0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* word delimiter string
|
|
||||||
*
|
|
||||||
* More advanced example: L" `'\"()[]{}"
|
|
||||||
*/
|
|
||||||
wchar_t *worddelimiters = L" ";
|
|
||||||
|
|
||||||
/* selection timeouts (in milliseconds) */
|
|
||||||
static unsigned int doubleclicktimeout = 300;
|
|
||||||
static unsigned int tripleclicktimeout = 600;
|
|
||||||
|
|
||||||
/* alt screens */
|
|
||||||
int allowaltscreen = 1;
|
|
||||||
|
|
||||||
/* allow certain non-interactive (insecure) window operations such as:
|
|
||||||
setting the clipboard text */
|
|
||||||
int allowwindowops = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
|
||||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
|
||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
|
||||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
|
||||||
*/
|
|
||||||
static double minlatency = 8;
|
|
||||||
static double maxlatency = 33;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
|
||||||
* attribute.
|
|
||||||
*/
|
|
||||||
static unsigned int blinktimeout = 800;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* thickness of underline and bar cursors
|
|
||||||
*/
|
|
||||||
static unsigned int cursorthickness = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
|
|
||||||
* it
|
|
||||||
*/
|
|
||||||
static int bellvolume = 0;
|
|
||||||
|
|
||||||
/* default TERM value */
|
|
||||||
char *termname = "st-256color";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* spaces per tab
|
|
||||||
*
|
|
||||||
* When you are changing this value, don't forget to adapt the »it« value in
|
|
||||||
* the st.info and appropriately install the st.info in the environment where
|
|
||||||
* you use this st version.
|
|
||||||
*
|
|
||||||
* it#$tabspaces,
|
|
||||||
*
|
|
||||||
* Secondly make sure your kernel is not expanding tabs. When running `stty
|
|
||||||
* -a` »tab0« should appear. You can tell the terminal to not expand tabs by
|
|
||||||
* running following command:
|
|
||||||
*
|
|
||||||
* stty tabs
|
|
||||||
*/
|
|
||||||
unsigned int tabspaces = 8;
|
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
|
||||||
static const char *colorname[] = {
|
|
||||||
/* 8 normal colors */
|
|
||||||
"black",
|
|
||||||
"red3",
|
|
||||||
"green3",
|
|
||||||
"yellow3",
|
|
||||||
"blue2",
|
|
||||||
"magenta3",
|
|
||||||
"cyan3",
|
|
||||||
"gray90",
|
|
||||||
|
|
||||||
/* 8 bright colors */
|
|
||||||
"gray50",
|
|
||||||
"red",
|
|
||||||
"green",
|
|
||||||
"yellow",
|
|
||||||
"#5c5cff",
|
|
||||||
"magenta",
|
|
||||||
"cyan",
|
|
||||||
"white",
|
|
||||||
|
|
||||||
[255] = 0,
|
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
|
||||||
"#cccccc",
|
|
||||||
"#555555",
|
|
||||||
"gray90", /* default foreground colour */
|
|
||||||
"black", /* default background colour */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colors (colorname index)
|
|
||||||
* foreground, background, cursor, reverse cursor
|
|
||||||
*/
|
|
||||||
unsigned int defaultfg = 258;
|
|
||||||
unsigned int defaultbg = 259;
|
|
||||||
unsigned int defaultcs = 256;
|
|
||||||
static unsigned int defaultrcs = 257;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default shape of cursor
|
|
||||||
* 2: Block ("█")
|
|
||||||
* 4: Underline ("_")
|
|
||||||
* 6: Bar ("|")
|
|
||||||
* 7: Snowman ("☃")
|
|
||||||
*/
|
|
||||||
static unsigned int cursorshape = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default columns and rows numbers
|
|
||||||
*/
|
|
||||||
|
|
||||||
static unsigned int cols = 80;
|
|
||||||
static unsigned int rows = 24;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colour and shape of the mouse cursor
|
|
||||||
*/
|
|
||||||
static unsigned int mouseshape = XC_xterm;
|
|
||||||
static unsigned int mousefg = 7;
|
|
||||||
static unsigned int mousebg = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color used to display font attributes when fontconfig selected a font which
|
|
||||||
* doesn't match the ones requested.
|
|
||||||
*/
|
|
||||||
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[] = {
|
|
||||||
/* mask button function argument release */
|
|
||||||
{ XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
|
|
||||||
{ XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 },
|
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Internal keyboard shortcuts. */
|
|
||||||
#define MODKEY Mod1Mask
|
|
||||||
#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} },
|
|
||||||
{ 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} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Special keys (change & recompile st.info accordingly)
|
|
||||||
*
|
|
||||||
* Mask value:
|
|
||||||
* * Use XK_ANY_MOD to match the key no matter modifiers state
|
|
||||||
* * Use XK_NO_MOD to match the key alone (no modifiers)
|
|
||||||
* appkey value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: keypad application mode enabled
|
|
||||||
* * = 2: term.numlock = 1
|
|
||||||
* * < 0: keypad application mode disabled
|
|
||||||
* appcursor value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: cursor application mode enabled
|
|
||||||
* * < 0: cursor application mode 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
|
|
||||||
* position for a key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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},
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Selection types' masks.
|
|
||||||
* Use the same masks as usual.
|
|
||||||
* Button1Mask is always unset, to make masks match between ButtonPress.
|
|
||||||
* ButtonRelease and MotionNotify.
|
|
||||||
* If no match is found, regular selection is used.
|
|
||||||
*/
|
|
||||||
static uint selmasks[] = {
|
|
||||||
[SEL_RECTANGULAR] = Mod1Mask,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Printable characters in ASCII, used to estimate the advance width
|
|
||||||
* of single wide characters.
|
|
||||||
*/
|
|
||||||
static char ascii_printable[] =
|
|
||||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
|
||||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
||||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
24
config.mk
24
config.mk
@ -1,5 +1,5 @@
|
|||||||
# st version
|
# st version
|
||||||
VERSION = 0.9
|
VERSION = 0.8
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
@ -10,27 +10,19 @@ MANPREFIX = $(PREFIX)/share/man
|
|||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
PKG_CONFIG = pkg-config
|
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I$(X11INC) \
|
INCS = -I$(X11INC) \
|
||||||
`$(PKG_CONFIG) --cflags fontconfig` \
|
`pkg-config --cflags fontconfig` \
|
||||||
`$(PKG_CONFIG) --cflags freetype2`
|
`pkg-config --cflags freetype2`
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||||
`$(PKG_CONFIG) --libs fontconfig` \
|
`pkg-config --libs fontconfig` \
|
||||||
`$(PKG_CONFIG) --libs freetype2`
|
`pkg-config --libs freetype2`
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||||
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
|
STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
|
||||||
STLDFLAGS = $(LIBS) $(LDFLAGS)
|
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`
|
|
||||||
#MANPREFIX = ${PREFIX}/man
|
|
||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
# CC = c99
|
# CC = c99
|
||||||
|
|
||||||
|
7
st.1
7
st.1
@ -159,6 +159,10 @@ Copy the selected text to the clipboard selection.
|
|||||||
.TP
|
.TP
|
||||||
.B Ctrl-Shift-v
|
.B Ctrl-Shift-v
|
||||||
Paste from the clipboard selection.
|
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
|
.SH CUSTOMIZATION
|
||||||
.B st
|
.B st
|
||||||
can be customized by creating a custom config.h and (re)compiling the source
|
can be customized by creating a custom config.h and (re)compiling the source
|
||||||
@ -170,8 +174,7 @@ See the LICENSE file for the terms of redistribution.
|
|||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR tabbed (1),
|
.BR tabbed (1),
|
||||||
.BR utmp (1),
|
.BR utmp (1),
|
||||||
.BR stty (1),
|
.BR stty (1)
|
||||||
.BR scroll (1)
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
See the TODO file in the distribution.
|
See the TODO file in the distribution.
|
||||||
|
|
||||||
|
14
st.h
14
st.h
@ -74,27 +74,24 @@ typedef union {
|
|||||||
uint ui;
|
uint ui;
|
||||||
float f;
|
float f;
|
||||||
const void *v;
|
const void *v;
|
||||||
const char *s;
|
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
void die(const char *, ...);
|
void die(const char *, ...);
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
void draw(void);
|
void draw(void);
|
||||||
|
|
||||||
void kscrolldown(const Arg *);
|
void iso14755(const Arg *);
|
||||||
void kscrollup(const Arg *);
|
|
||||||
void printscreen(const Arg *);
|
void printscreen(const Arg *);
|
||||||
void printsel(const Arg *);
|
void printsel(const Arg *);
|
||||||
void sendbreak(const Arg *);
|
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);
|
||||||
void tsetdirtattr(int);
|
void tsetdirtattr(int);
|
||||||
void ttyhangup(void);
|
void ttyhangup(void);
|
||||||
int ttynew(const char *, char *, const char *, char **);
|
int ttynew(char *, char *, char *, char **);
|
||||||
size_t ttyread(void);
|
size_t ttyread(void);
|
||||||
void ttyresize(int, int);
|
void ttyresize(int, int);
|
||||||
void ttywrite(const char *, size_t, int);
|
void ttywrite(const char *, size_t, int);
|
||||||
@ -112,18 +109,15 @@ size_t utf8encode(Rune, char *);
|
|||||||
|
|
||||||
void *xmalloc(size_t);
|
void *xmalloc(size_t);
|
||||||
void *xrealloc(void *, size_t);
|
void *xrealloc(void *, size_t);
|
||||||
char *xstrdup(const char *);
|
char *xstrdup(char *);
|
||||||
|
|
||||||
/* config.h globals */
|
/* config.h globals */
|
||||||
extern char *utmp;
|
extern char *utmp;
|
||||||
extern char *scroll;
|
|
||||||
extern char *stty_args;
|
extern char *stty_args;
|
||||||
extern char *vtiden;
|
extern char *vtiden;
|
||||||
extern wchar_t *worddelimiters;
|
extern char *worddelimiters;
|
||||||
extern int allowaltscreen;
|
extern int allowaltscreen;
|
||||||
extern int allowwindowops;
|
|
||||||
extern char *termname;
|
extern char *termname;
|
||||||
extern unsigned int tabspaces;
|
extern unsigned int tabspaces;
|
||||||
extern unsigned int defaultfg;
|
extern unsigned int defaultfg;
|
||||||
extern unsigned int defaultbg;
|
extern unsigned int defaultbg;
|
||||||
extern unsigned int defaultcs;
|
|
||||||
|
37
st.info
37
st.info
@ -1,4 +1,4 @@
|
|||||||
st-mono| simpleterm monocolor,
|
st| simpleterm,
|
||||||
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||||
am,
|
am,
|
||||||
bce,
|
bce,
|
||||||
@ -10,7 +10,7 @@ st-mono| simpleterm monocolor,
|
|||||||
civis=\E[?25l,
|
civis=\E[?25l,
|
||||||
clear=\E[H\E[2J,
|
clear=\E[H\E[2J,
|
||||||
cnorm=\E[?12l\E[?25h,
|
cnorm=\E[?12l\E[?25h,
|
||||||
colors#2,
|
colors#8,
|
||||||
cols#80,
|
cols#80,
|
||||||
cr=^M,
|
cr=^M,
|
||||||
csr=\E[%i%p1%d;%p2%dr,
|
csr=\E[%i%p1%d;%p2%dr,
|
||||||
@ -158,7 +158,6 @@ st-mono| simpleterm monocolor,
|
|||||||
rc=\E8,
|
rc=\E8,
|
||||||
rev=\E[7m,
|
rev=\E[7m,
|
||||||
ri=\EM,
|
ri=\EM,
|
||||||
rin=\E[%p1%dT,
|
|
||||||
ritm=\E[23m,
|
ritm=\E[23m,
|
||||||
rmacs=\E(B,
|
rmacs=\E(B,
|
||||||
rmcup=\E[?1049l,
|
rmcup=\E[?1049l,
|
||||||
@ -169,8 +168,13 @@ st-mono| simpleterm monocolor,
|
|||||||
rs1=\Ec,
|
rs1=\Ec,
|
||||||
rs2=\E[4l\E>\E[?1034l,
|
rs2=\E[4l\E>\E[?1034l,
|
||||||
sc=\E7,
|
sc=\E7,
|
||||||
sitm=\E[3m,
|
setab=\E[4%p1%dm,
|
||||||
|
setaf=\E[3%p1%dm,
|
||||||
|
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||||
|
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||||
sgr0=\E[0m,
|
sgr0=\E[0m,
|
||||||
|
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
||||||
|
sitm=\E[3m,
|
||||||
smacs=\E(0,
|
smacs=\E(0,
|
||||||
smcup=\E[?1049h,
|
smcup=\E[?1049h,
|
||||||
smir=\E[4h,
|
smir=\E[4h,
|
||||||
@ -184,22 +188,11 @@ st-mono| simpleterm monocolor,
|
|||||||
# XTerm extensions
|
# XTerm extensions
|
||||||
rmxx=\E[29m,
|
rmxx=\E[29m,
|
||||||
smxx=\E[9m,
|
smxx=\E[9m,
|
||||||
# disabled rep for now: causes some issues with older ncurses versions.
|
|
||||||
# rep=%p1%c\E[%p2%{1}%-%db,
|
|
||||||
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
||||||
|
Se,
|
||||||
|
Ss,
|
||||||
Tc,
|
Tc,
|
||||||
Ms=\E]52;%p1%s;%p2%s\007,
|
Ms=\E]52;%p1%s;%p2%s\007,
|
||||||
Se=\E[2 q,
|
|
||||||
Ss=\E[%p1%d q,
|
|
||||||
|
|
||||||
st| simpleterm,
|
|
||||||
use=st-mono,
|
|
||||||
colors#8,
|
|
||||||
setab=\E[4%p1%dm,
|
|
||||||
setaf=\E[3%p1%dm,
|
|
||||||
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
|
||||||
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
|
||||||
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
|
||||||
|
|
||||||
st-256color| simpleterm with 256 colors,
|
st-256color| simpleterm with 256 colors,
|
||||||
use=st,
|
use=st,
|
||||||
@ -227,13 +220,3 @@ st-meta-256color| simpleterm with meta key and 256 colors,
|
|||||||
smm=\E[?1034h,
|
smm=\E[?1034h,
|
||||||
rs2=\E[4l\E>\E[?1034h,
|
rs2=\E[4l\E>\E[?1034h,
|
||||||
is2=\E[4l\E>\E[?1034h,
|
is2=\E[4l\E>\E[?1034h,
|
||||||
|
|
||||||
st-bs| simpleterm with backspace as backspace,
|
|
||||||
use=st,
|
|
||||||
kbs=\010,
|
|
||||||
kdch1=\177,
|
|
||||||
|
|
||||||
st-bs-256color| simpleterm with backspace as backspace and 256colors,
|
|
||||||
use=st-256color,
|
|
||||||
kbs=\010,
|
|
||||||
kdch1=\177,
|
|
||||||
|
3
win.h
3
win.h
@ -30,12 +30,9 @@ void xdrawline(Line, int, int, int);
|
|||||||
void xfinishdraw(void);
|
void xfinishdraw(void);
|
||||||
void xloadcols(void);
|
void xloadcols(void);
|
||||||
int xsetcolorname(int, const char *);
|
int xsetcolorname(int, const char *);
|
||||||
int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *);
|
|
||||||
void xseticontitle(char *);
|
|
||||||
void xsettitle(char *);
|
void xsettitle(char *);
|
||||||
int xsetcursor(int);
|
int xsetcursor(int);
|
||||||
void xsetmode(int, unsigned int);
|
void xsetmode(int, unsigned int);
|
||||||
void xsetpointermotion(int);
|
void xsetpointermotion(int);
|
||||||
void xsetsel(char *);
|
void xsetsel(char *);
|
||||||
int xstartdraw(void);
|
int xstartdraw(void);
|
||||||
void xximspot(int, int);
|
|
||||||
|
518
x.c
518
x.c
@ -15,7 +15,7 @@
|
|||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
|
|
||||||
char *argv0;
|
static char *argv0;
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
@ -29,12 +29,9 @@ typedef struct {
|
|||||||
} Shortcut;
|
} Shortcut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint mod;
|
uint b;
|
||||||
uint button;
|
uint mask;
|
||||||
void (*func)(const Arg *);
|
char *s;
|
||||||
const Arg arg;
|
|
||||||
uint release;
|
|
||||||
int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
|
|
||||||
} MouseShortcut;
|
} MouseShortcut;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -49,7 +46,7 @@ typedef struct {
|
|||||||
/* X modifiers */
|
/* X modifiers */
|
||||||
#define XK_ANY_MOD UINT_MAX
|
#define XK_ANY_MOD UINT_MAX
|
||||||
#define XK_NO_MOD 0
|
#define XK_NO_MOD 0
|
||||||
#define XK_SWITCH_MOD (1<<13|1<<14)
|
#define XK_SWITCH_MOD (1<<13)
|
||||||
|
|
||||||
/* function definitions used in config.h */
|
/* function definitions used in config.h */
|
||||||
static void clipcopy(const Arg *);
|
static void clipcopy(const Arg *);
|
||||||
@ -59,7 +56,6 @@ static void selpaste(const Arg *);
|
|||||||
static void zoom(const Arg *);
|
static void zoom(const Arg *);
|
||||||
static void zoomabs(const Arg *);
|
static void zoomabs(const Arg *);
|
||||||
static void zoomreset(const Arg *);
|
static void zoomreset(const Arg *);
|
||||||
static void ttysend(const Arg *);
|
|
||||||
|
|
||||||
/* config.h for applying patches and the configuration. */
|
/* config.h for applying patches and the configuration. */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -94,13 +90,9 @@ typedef struct {
|
|||||||
Window win;
|
Window win;
|
||||||
Drawable buf;
|
Drawable buf;
|
||||||
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
|
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
|
||||||
Atom xembed, wmdeletewin, netwmname, netwmiconname, netwmpid;
|
Atom xembed, wmdeletewin, netwmname, netwmpid;
|
||||||
struct {
|
|
||||||
XIM xim;
|
XIM xim;
|
||||||
XIC xic;
|
XIC xic;
|
||||||
XPoint spot;
|
|
||||||
XVaNestedList spotlist;
|
|
||||||
} ime;
|
|
||||||
Draw draw;
|
Draw draw;
|
||||||
Visual *vis;
|
Visual *vis;
|
||||||
XSetWindowAttributes attrs;
|
XSetWindowAttributes attrs;
|
||||||
@ -147,17 +139,13 @@ static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
|
|||||||
static void xdrawglyph(Glyph, int, int);
|
static void xdrawglyph(Glyph, int, int);
|
||||||
static void xclear(int, int, int, int);
|
static void xclear(int, int, int, int);
|
||||||
static int xgeommasktogravity(int);
|
static int xgeommasktogravity(int);
|
||||||
static int ximopen(Display *);
|
|
||||||
static void ximinstantiate(Display *, XPointer, XPointer);
|
|
||||||
static void ximdestroy(XIM, XPointer, XPointer);
|
|
||||||
static int xicdestroy(XIC, XPointer, XPointer);
|
|
||||||
static void xinit(int, int);
|
static void xinit(int, int);
|
||||||
static void cresize(int, int);
|
static void cresize(int, int);
|
||||||
static void xresize(int, int);
|
static void xresize(int, int);
|
||||||
static void xhints(void);
|
static void xhints(void);
|
||||||
static int xloadcolor(int, const char *, Color *);
|
static int xloadcolor(int, const char *, Color *);
|
||||||
static int xloadfont(Font *, FcPattern *);
|
static int xloadfont(Font *, FcPattern *);
|
||||||
static void xloadfonts(const char *, double);
|
static void xloadfonts(char *, double);
|
||||||
static void xunloadfont(Font *);
|
static void xunloadfont(Font *);
|
||||||
static void xunloadfonts(void);
|
static void xunloadfonts(void);
|
||||||
static void xsetenv(void);
|
static void xsetenv(void);
|
||||||
@ -172,8 +160,6 @@ static void kpress(XEvent *);
|
|||||||
static void cmessage(XEvent *);
|
static void cmessage(XEvent *);
|
||||||
static void resize(XEvent *);
|
static void resize(XEvent *);
|
||||||
static void focus(XEvent *);
|
static void focus(XEvent *);
|
||||||
static uint buttonmask(uint);
|
|
||||||
static int mouseaction(XEvent *, uint);
|
|
||||||
static void brelease(XEvent *);
|
static void brelease(XEvent *);
|
||||||
static void bpress(XEvent *);
|
static void bpress(XEvent *);
|
||||||
static void bmotion(XEvent *);
|
static void bmotion(XEvent *);
|
||||||
@ -237,9 +223,8 @@ typedef struct {
|
|||||||
} Fontcache;
|
} Fontcache;
|
||||||
|
|
||||||
/* Fontcache is an array now. A new font will be appended to the array. */
|
/* Fontcache is an array now. A new font will be appended to the array. */
|
||||||
static Fontcache *frc = NULL;
|
static Fontcache frc[16];
|
||||||
static int frclen = 0;
|
static int frclen = 0;
|
||||||
static int frccap = 0;
|
|
||||||
static char *usedfont = NULL;
|
static char *usedfont = NULL;
|
||||||
static double usedfontsize = 0;
|
static double usedfontsize = 0;
|
||||||
static double defaultfontsize = 0;
|
static double defaultfontsize = 0;
|
||||||
@ -253,15 +238,15 @@ static char *opt_line = NULL;
|
|||||||
static char *opt_name = NULL;
|
static char *opt_name = NULL;
|
||||||
static char *opt_title = NULL;
|
static char *opt_title = NULL;
|
||||||
|
|
||||||
static uint buttons; /* bit field of pressed buttons */
|
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||||
|
|
||||||
void
|
void
|
||||||
clipcopy(const Arg *dummy)
|
clipcopy(const Arg *dummy)
|
||||||
{
|
{
|
||||||
Atom clipboard;
|
Atom clipboard;
|
||||||
|
|
||||||
|
if (xsel.clipboard != NULL)
|
||||||
free(xsel.clipboard);
|
free(xsel.clipboard);
|
||||||
xsel.clipboard = NULL;
|
|
||||||
|
|
||||||
if (xsel.primary != NULL) {
|
if (xsel.primary != NULL) {
|
||||||
xsel.clipboard = xstrdup(xsel.primary);
|
xsel.clipboard = xstrdup(xsel.primary);
|
||||||
@ -323,12 +308,6 @@ zoomreset(const Arg *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ttysend(const Arg *arg)
|
|
||||||
{
|
|
||||||
ttywrite(arg->s, strlen(arg->s), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
evcol(XEvent *e)
|
evcol(XEvent *e)
|
||||||
{
|
{
|
||||||
@ -349,7 +328,7 @@ void
|
|||||||
mousesel(XEvent *e, int done)
|
mousesel(XEvent *e, int done)
|
||||||
{
|
{
|
||||||
int type, seltype = SEL_REGULAR;
|
int type, seltype = SEL_REGULAR;
|
||||||
uint state = e->xbutton.state & ~(Button1Mask | forcemousemod);
|
uint state = e->xbutton.state & ~(Button1Mask | forceselmod);
|
||||||
|
|
||||||
for (type = 1; type < LEN(selmasks); ++type) {
|
for (type = 1; type < LEN(selmasks); ++type) {
|
||||||
if (match(selmasks[type], state)) {
|
if (match(selmasks[type], state)) {
|
||||||
@ -365,68 +344,59 @@ mousesel(XEvent *e, int done)
|
|||||||
void
|
void
|
||||||
mousereport(XEvent *e)
|
mousereport(XEvent *e)
|
||||||
{
|
{
|
||||||
int len, btn, code;
|
int len, x = evcol(e), y = evrow(e),
|
||||||
int x = evcol(e), y = evrow(e);
|
button = e->xbutton.button, state = e->xbutton.state;
|
||||||
int state = e->xbutton.state;
|
|
||||||
char buf[40];
|
char buf[40];
|
||||||
static int ox, oy;
|
static int ox, oy;
|
||||||
|
|
||||||
if (e->type == MotionNotify) {
|
/* from urxvt */
|
||||||
|
if (e->xbutton.type == MotionNotify) {
|
||||||
if (x == ox && y == oy)
|
if (x == ox && y == oy)
|
||||||
return;
|
return;
|
||||||
if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
|
if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
|
||||||
return;
|
return;
|
||||||
/* MODE_MOUSEMOTION: no reporting if no button is pressed */
|
/* MOUSE_MOTION: no reporting if no button is pressed */
|
||||||
if (IS_SET(MODE_MOUSEMOTION) && buttons == 0)
|
if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3)
|
||||||
return;
|
return;
|
||||||
/* Set btn to lowest-numbered pressed button, or 12 if no
|
|
||||||
* buttons are pressed. */
|
button = oldbutton + 32;
|
||||||
for (btn = 1; btn <= 11 && !(buttons & (1<<(btn-1))); btn++)
|
ox = x;
|
||||||
;
|
oy = y;
|
||||||
code = 32;
|
|
||||||
} else {
|
} else {
|
||||||
btn = e->xbutton.button;
|
if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) {
|
||||||
/* Only buttons 1 through 11 can be encoded */
|
button = 3;
|
||||||
if (btn < 1 || btn > 11)
|
} else {
|
||||||
return;
|
button -= Button1;
|
||||||
if (e->type == ButtonRelease) {
|
if (button >= 3)
|
||||||
|
button += 64 - 3;
|
||||||
|
}
|
||||||
|
if (e->xbutton.type == ButtonPress) {
|
||||||
|
oldbutton = button;
|
||||||
|
ox = x;
|
||||||
|
oy = y;
|
||||||
|
} else if (e->xbutton.type == ButtonRelease) {
|
||||||
|
oldbutton = 3;
|
||||||
/* MODE_MOUSEX10: no button release reporting */
|
/* MODE_MOUSEX10: no button release reporting */
|
||||||
if (IS_SET(MODE_MOUSEX10))
|
if (IS_SET(MODE_MOUSEX10))
|
||||||
return;
|
return;
|
||||||
/* Don't send release events for the scroll wheel */
|
if (button == 64 || button == 65)
|
||||||
if (btn == 4 || btn == 5)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
code = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ox = x;
|
|
||||||
oy = y;
|
|
||||||
|
|
||||||
/* Encode btn into code. If no button is pressed for a motion event in
|
|
||||||
* MODE_MOUSEMANY, then encode it as a release. */
|
|
||||||
if ((!IS_SET(MODE_MOUSESGR) && e->type == ButtonRelease) || btn == 12)
|
|
||||||
code += 3;
|
|
||||||
else if (btn >= 8)
|
|
||||||
code += 128 + btn - 8;
|
|
||||||
else if (btn >= 4)
|
|
||||||
code += 64 + btn - 4;
|
|
||||||
else
|
|
||||||
code += btn - 1;
|
|
||||||
|
|
||||||
if (!IS_SET(MODE_MOUSEX10)) {
|
if (!IS_SET(MODE_MOUSEX10)) {
|
||||||
code += ((state & ShiftMask ) ? 4 : 0)
|
button += ((state & ShiftMask ) ? 4 : 0)
|
||||||
+ ((state & Mod1Mask ) ? 8 : 0) /* meta key: alt */
|
+ ((state & Mod4Mask ) ? 8 : 0)
|
||||||
+ ((state & ControlMask) ? 16 : 0);
|
+ ((state & ControlMask) ? 16 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SET(MODE_MOUSESGR)) {
|
if (IS_SET(MODE_MOUSESGR)) {
|
||||||
len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c",
|
len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c",
|
||||||
code, x+1, y+1,
|
button, x+1, y+1,
|
||||||
e->type == ButtonRelease ? 'm' : 'M');
|
e->xbutton.type == ButtonRelease ? 'm' : 'M');
|
||||||
} else if (x < 223 && y < 223) {
|
} else if (x < 223 && y < 223) {
|
||||||
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
|
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
|
||||||
32+code, 32+x+1, 32+y+1);
|
32+button, 32+x+1, 32+y+1);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -434,58 +404,27 @@ mousereport(XEvent *e)
|
|||||||
ttywrite(buf, len, 0);
|
ttywrite(buf, len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint
|
|
||||||
buttonmask(uint button)
|
|
||||||
{
|
|
||||||
return button == Button1 ? Button1Mask
|
|
||||||
: button == Button2 ? Button2Mask
|
|
||||||
: button == Button3 ? Button3Mask
|
|
||||||
: button == Button4 ? Button4Mask
|
|
||||||
: button == Button5 ? Button5Mask
|
|
||||||
: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
mouseaction(XEvent *e, uint release)
|
|
||||||
{
|
|
||||||
MouseShortcut *ms;
|
|
||||||
|
|
||||||
/* ignore Button<N>mask for Button<N> - it's set on release */
|
|
||||||
uint state = e->xbutton.state & ~buttonmask(e->xbutton.button);
|
|
||||||
|
|
||||||
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
|
||||||
if (ms->release == release &&
|
|
||||||
ms->button == e->xbutton.button &&
|
|
||||||
(!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
|
|
||||||
(match(ms->mod, state) || /* exact or forced */
|
|
||||||
match(ms->mod, state & ~forcemousemod))) {
|
|
||||||
ms->func(&(ms->arg));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bpress(XEvent *e)
|
bpress(XEvent *e)
|
||||||
{
|
{
|
||||||
int btn = e->xbutton.button;
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
|
MouseShortcut *ms;
|
||||||
int snap;
|
int snap;
|
||||||
|
|
||||||
if (1 <= btn && btn <= 11)
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
|
||||||
buttons |= 1 << (btn-1);
|
|
||||||
|
|
||||||
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
|
|
||||||
mousereport(e);
|
mousereport(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaction(e, 0))
|
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
||||||
|
if (e->xbutton.button == ms->b
|
||||||
|
&& match(ms->mask, e->xbutton.state)) {
|
||||||
|
ttywrite(ms->s, strlen(ms->s), 1);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (btn == Button1) {
|
if (e->xbutton.button == Button1) {
|
||||||
/*
|
/*
|
||||||
* If the user clicks below predefined timeouts specific
|
* If the user clicks below predefined timeouts specific
|
||||||
* snapping behaviour is exposed.
|
* snapping behaviour is exposed.
|
||||||
@ -679,9 +618,6 @@ selrequest(XEvent *e)
|
|||||||
void
|
void
|
||||||
setsel(char *str, Time t)
|
setsel(char *str, Time t)
|
||||||
{
|
{
|
||||||
if (!str)
|
|
||||||
return;
|
|
||||||
|
|
||||||
free(xsel.primary);
|
free(xsel.primary);
|
||||||
xsel.primary = str;
|
xsel.primary = str;
|
||||||
|
|
||||||
@ -699,26 +635,21 @@ xsetsel(char *str)
|
|||||||
void
|
void
|
||||||
brelease(XEvent *e)
|
brelease(XEvent *e)
|
||||||
{
|
{
|
||||||
int btn = e->xbutton.button;
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
|
||||||
|
|
||||||
if (1 <= btn && btn <= 11)
|
|
||||||
buttons &= ~(1 << (btn-1));
|
|
||||||
|
|
||||||
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
|
|
||||||
mousereport(e);
|
mousereport(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaction(e, 1))
|
if (e->xbutton.button == Button2)
|
||||||
return;
|
selpaste(NULL);
|
||||||
if (btn == Button1)
|
else if (e->xbutton.button == Button1)
|
||||||
mousesel(e, 1);
|
mousesel(e, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bmotion(XEvent *e)
|
bmotion(XEvent *e)
|
||||||
{
|
{
|
||||||
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forcemousemod)) {
|
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
|
||||||
mousereport(e);
|
mousereport(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -738,8 +669,6 @@ cresize(int width, int height)
|
|||||||
|
|
||||||
col = (win.w - 2 * borderpx) / win.cw;
|
col = (win.w - 2 * borderpx) / win.cw;
|
||||||
row = (win.h - 2 * borderpx) / win.ch;
|
row = (win.h - 2 * borderpx) / win.ch;
|
||||||
col = MAX(1, col);
|
|
||||||
row = MAX(1, row);
|
|
||||||
|
|
||||||
tresize(col, row);
|
tresize(col, row);
|
||||||
xresize(col, row);
|
xresize(col, row);
|
||||||
@ -749,8 +678,8 @@ cresize(int width, int height)
|
|||||||
void
|
void
|
||||||
xresize(int col, int row)
|
xresize(int col, int row)
|
||||||
{
|
{
|
||||||
win.tw = col * win.cw;
|
win.tw = MAX(1, col * win.cw);
|
||||||
win.th = row * win.ch;
|
win.th = MAX(1, row * win.ch);
|
||||||
|
|
||||||
XFreePixmap(xw.dpy, xw.buf);
|
XFreePixmap(xw.dpy, xw.buf);
|
||||||
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
@ -799,37 +728,24 @@ xloadcols(void)
|
|||||||
static int loaded;
|
static int loaded;
|
||||||
Color *cp;
|
Color *cp;
|
||||||
|
|
||||||
|
dc.collen = MAX(LEN(colorname), 256);
|
||||||
|
dc.col = xmalloc(dc.collen * sizeof(Color));
|
||||||
|
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
|
||||||
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
|
||||||
} else {
|
|
||||||
dc.collen = MAX(LEN(colorname), 256);
|
|
||||||
dc.col = xmalloc(dc.collen * sizeof(Color));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < dc.collen; i++)
|
for (i = 0; i < dc.collen; i++)
|
||||||
if (!xloadcolor(i, NULL, &dc.col[i])) {
|
if (!xloadcolor(i, NULL, &dc.col[i])) {
|
||||||
if (colorname[i])
|
if (colorname[i])
|
||||||
die("could not allocate color '%s'\n", colorname[i]);
|
die("Could not allocate color '%s'\n", colorname[i]);
|
||||||
else
|
else
|
||||||
die("could not allocate color %d\n", i);
|
die("Could not allocate color %d\n", i);
|
||||||
}
|
}
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
|
|
||||||
{
|
|
||||||
if (!BETWEEN(x, 0, dc.collen))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
*r = dc.col[x].color.red >> 8;
|
|
||||||
*g = dc.col[x].color.green >> 8;
|
|
||||||
*b = dc.col[x].color.blue >> 8;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
xsetcolorname(int x, const char *name)
|
xsetcolorname(int x, const char *name)
|
||||||
{
|
{
|
||||||
@ -838,6 +754,7 @@ xsetcolorname(int x, const char *name)
|
|||||||
if (!BETWEEN(x, 0, dc.collen))
|
if (!BETWEEN(x, 0, dc.collen))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
if (!xloadcolor(x, name, &ncolor))
|
if (!xloadcolor(x, name, &ncolor))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -868,17 +785,15 @@ xhints(void)
|
|||||||
|
|
||||||
sizeh = XAllocSizeHints();
|
sizeh = XAllocSizeHints();
|
||||||
|
|
||||||
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
|
sizeh->flags = PSize | PResizeInc | PBaseSize;
|
||||||
sizeh->height = win.h;
|
sizeh->height = win.h;
|
||||||
sizeh->width = win.w;
|
sizeh->width = win.w;
|
||||||
sizeh->height_inc = win.ch;
|
sizeh->height_inc = win.ch;
|
||||||
sizeh->width_inc = win.cw;
|
sizeh->width_inc = win.cw;
|
||||||
sizeh->base_height = 2 * borderpx;
|
sizeh->base_height = 2 * borderpx;
|
||||||
sizeh->base_width = 2 * borderpx;
|
sizeh->base_width = 2 * borderpx;
|
||||||
sizeh->min_height = win.ch + 2 * borderpx;
|
|
||||||
sizeh->min_width = win.cw + 2 * borderpx;
|
|
||||||
if (xw.isfixed) {
|
if (xw.isfixed) {
|
||||||
sizeh->flags |= PMaxSize;
|
sizeh->flags |= PMaxSize | PMinSize;
|
||||||
sizeh->min_width = sizeh->max_width = win.w;
|
sizeh->min_width = sizeh->max_width = win.w;
|
||||||
sizeh->min_height = sizeh->max_height = win.h;
|
sizeh->min_height = sizeh->max_height = win.h;
|
||||||
}
|
}
|
||||||
@ -951,7 +866,7 @@ xloadfont(Font *f, FcPattern *pattern)
|
|||||||
if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
|
if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
|
||||||
&haveattr) != XftResultMatch) || haveattr < wantattr) {
|
&haveattr) != XftResultMatch) || haveattr < wantattr) {
|
||||||
f->badslant = 1;
|
f->badslant = 1;
|
||||||
fputs("font slant does not match\n", stderr);
|
fputs("st: font slant does not match\n", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,7 +875,7 @@ xloadfont(Font *f, FcPattern *pattern)
|
|||||||
if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
|
if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
|
||||||
&haveattr) != XftResultMatch) || haveattr != wantattr) {
|
&haveattr) != XftResultMatch) || haveattr != wantattr) {
|
||||||
f->badweight = 1;
|
f->badweight = 1;
|
||||||
fputs("font weight does not match\n", stderr);
|
fputs("st: font weight does not match\n", stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -983,18 +898,19 @@ xloadfont(Font *f, FcPattern *pattern)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xloadfonts(const char *fontstr, double fontsize)
|
xloadfonts(char *fontstr, double fontsize)
|
||||||
{
|
{
|
||||||
FcPattern *pattern;
|
FcPattern *pattern;
|
||||||
double fontval;
|
double fontval;
|
||||||
|
|
||||||
if (fontstr[0] == '-')
|
if (fontstr[0] == '-') {
|
||||||
pattern = XftXlfdParse(fontstr, False, False);
|
pattern = XftXlfdParse(fontstr, False, False);
|
||||||
else
|
} else {
|
||||||
pattern = FcNameParse((const FcChar8 *)fontstr);
|
pattern = FcNameParse((FcChar8 *)fontstr);
|
||||||
|
}
|
||||||
|
|
||||||
if (!pattern)
|
if (!pattern)
|
||||||
die("can't open font %s\n", fontstr);
|
die("st: can't open font %s\n", fontstr);
|
||||||
|
|
||||||
if (fontsize > 1) {
|
if (fontsize > 1) {
|
||||||
FcPatternDel(pattern, FC_PIXEL_SIZE);
|
FcPatternDel(pattern, FC_PIXEL_SIZE);
|
||||||
@ -1020,7 +936,7 @@ xloadfonts(const char *fontstr, double fontsize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (xloadfont(&dc.font, pattern))
|
if (xloadfont(&dc.font, pattern))
|
||||||
die("can't open font %s\n", fontstr);
|
die("st: can't open font %s\n", fontstr);
|
||||||
|
|
||||||
if (usedfontsize < 0) {
|
if (usedfontsize < 0) {
|
||||||
FcPatternGetDouble(dc.font.match->pattern,
|
FcPatternGetDouble(dc.font.match->pattern,
|
||||||
@ -1037,17 +953,17 @@ xloadfonts(const char *fontstr, double fontsize)
|
|||||||
FcPatternDel(pattern, FC_SLANT);
|
FcPatternDel(pattern, FC_SLANT);
|
||||||
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
|
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
|
||||||
if (xloadfont(&dc.ifont, pattern))
|
if (xloadfont(&dc.ifont, pattern))
|
||||||
die("can't open font %s\n", fontstr);
|
die("st: can't open font %s\n", fontstr);
|
||||||
|
|
||||||
FcPatternDel(pattern, FC_WEIGHT);
|
FcPatternDel(pattern, FC_WEIGHT);
|
||||||
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
|
FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
|
||||||
if (xloadfont(&dc.ibfont, pattern))
|
if (xloadfont(&dc.ibfont, pattern))
|
||||||
die("can't open font %s\n", fontstr);
|
die("st: can't open font %s\n", fontstr);
|
||||||
|
|
||||||
FcPatternDel(pattern, FC_SLANT);
|
FcPatternDel(pattern, FC_SLANT);
|
||||||
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
|
FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
|
||||||
if (xloadfont(&dc.bfont, pattern))
|
if (xloadfont(&dc.bfont, pattern))
|
||||||
die("can't open font %s\n", fontstr);
|
die("st: can't open font %s\n", fontstr);
|
||||||
|
|
||||||
FcPatternDestroy(pattern);
|
FcPatternDestroy(pattern);
|
||||||
}
|
}
|
||||||
@ -1074,60 +990,6 @@ xunloadfonts(void)
|
|||||||
xunloadfont(&dc.ibfont);
|
xunloadfont(&dc.ibfont);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
ximopen(Display *dpy)
|
|
||||||
{
|
|
||||||
XIMCallback imdestroy = { .client_data = NULL, .callback = ximdestroy };
|
|
||||||
XICCallback icdestroy = { .client_data = NULL, .callback = xicdestroy };
|
|
||||||
|
|
||||||
xw.ime.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
|
|
||||||
if (xw.ime.xim == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (XSetIMValues(xw.ime.xim, XNDestroyCallback, &imdestroy, NULL))
|
|
||||||
fprintf(stderr, "XSetIMValues: "
|
|
||||||
"Could not set XNDestroyCallback.\n");
|
|
||||||
|
|
||||||
xw.ime.spotlist = XVaCreateNestedList(0, XNSpotLocation, &xw.ime.spot,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (xw.ime.xic == NULL) {
|
|
||||||
xw.ime.xic = XCreateIC(xw.ime.xim, XNInputStyle,
|
|
||||||
XIMPreeditNothing | XIMStatusNothing,
|
|
||||||
XNClientWindow, xw.win,
|
|
||||||
XNDestroyCallback, &icdestroy,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
if (xw.ime.xic == NULL)
|
|
||||||
fprintf(stderr, "XCreateIC: Could not create input context.\n");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ximinstantiate(Display *dpy, XPointer client, XPointer call)
|
|
||||||
{
|
|
||||||
if (ximopen(dpy))
|
|
||||||
XUnregisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
|
|
||||||
ximinstantiate, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ximdestroy(XIM xim, XPointer client, XPointer call)
|
|
||||||
{
|
|
||||||
xw.ime.xim = NULL;
|
|
||||||
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
|
|
||||||
ximinstantiate, NULL);
|
|
||||||
XFree(xw.ime.spotlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
xicdestroy(XIC xim, XPointer client, XPointer call)
|
|
||||||
{
|
|
||||||
xw.ime.xic = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xinit(int cols, int rows)
|
xinit(int cols, int rows)
|
||||||
{
|
{
|
||||||
@ -1138,13 +1000,13 @@ xinit(int cols, int rows)
|
|||||||
XColor xmousefg, xmousebg;
|
XColor xmousefg, xmousebg;
|
||||||
|
|
||||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
die("can't open display\n");
|
die("Can't open display\n");
|
||||||
xw.scr = XDefaultScreen(xw.dpy);
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
if (!FcInit())
|
if (!FcInit())
|
||||||
die("could not init fontconfig.\n");
|
die("Could not init fontconfig.\n");
|
||||||
|
|
||||||
usedfont = (opt_font == NULL)? font : opt_font;
|
usedfont = (opt_font == NULL)? font : opt_font;
|
||||||
xloadfonts(usedfont, 0);
|
xloadfonts(usedfont, 0);
|
||||||
@ -1165,7 +1027,7 @@ xinit(int cols, int rows)
|
|||||||
xw.attrs.background_pixel = dc.col[defaultbg].pixel;
|
xw.attrs.background_pixel = dc.col[defaultbg].pixel;
|
||||||
xw.attrs.border_pixel = dc.col[defaultbg].pixel;
|
xw.attrs.border_pixel = dc.col[defaultbg].pixel;
|
||||||
xw.attrs.bit_gravity = NorthWestGravity;
|
xw.attrs.bit_gravity = NorthWestGravity;
|
||||||
xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask
|
xw.attrs.event_mask = FocusChangeMask | KeyPressMask
|
||||||
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
|
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
|
||||||
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
xw.attrs.colormap = xw.cmap;
|
xw.attrs.colormap = xw.cmap;
|
||||||
@ -1193,10 +1055,22 @@ xinit(int cols, int rows)
|
|||||||
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
|
xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
|
||||||
|
|
||||||
/* input methods */
|
/* input methods */
|
||||||
if (!ximopen(xw.dpy)) {
|
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||||
XRegisterIMInstantiateCallback(xw.dpy, NULL, NULL, NULL,
|
XSetLocaleModifiers("@im=local");
|
||||||
ximinstantiate, NULL);
|
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
|
||||||
|
XSetLocaleModifiers("@im=");
|
||||||
|
if ((xw.xim = XOpenIM(xw.dpy,
|
||||||
|
NULL, NULL, NULL)) == NULL) {
|
||||||
|
die("XOpenIM failed. Could not open input"
|
||||||
|
" device.\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
|
||||||
|
| XIMStatusNothing, XNClientWindow, xw.win,
|
||||||
|
XNFocusWindow, xw.win, NULL);
|
||||||
|
if (xw.xic == NULL)
|
||||||
|
die("XCreateIC failed. Could not obtain input method.\n");
|
||||||
|
|
||||||
/* white cursor, black outline */
|
/* white cursor, black outline */
|
||||||
cursor = XCreateFontCursor(xw.dpy, mouseshape);
|
cursor = XCreateFontCursor(xw.dpy, mouseshape);
|
||||||
@ -1219,7 +1093,6 @@ xinit(int cols, int rows)
|
|||||||
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
|
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
|
||||||
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
|
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
|
||||||
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
|
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
|
||||||
xw.netwmiconname = XInternAtom(xw.dpy, "_NET_WM_ICON_NAME", False);
|
|
||||||
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
|
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
|
||||||
|
|
||||||
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
|
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
|
||||||
@ -1228,8 +1101,8 @@ xinit(int cols, int rows)
|
|||||||
|
|
||||||
win.mode = MODE_NUMLOCK;
|
win.mode = MODE_NUMLOCK;
|
||||||
resettitle();
|
resettitle();
|
||||||
xhints();
|
|
||||||
XMapWindow(xw.dpy, xw.win);
|
XMapWindow(xw.dpy, xw.win);
|
||||||
|
xhints();
|
||||||
XSync(xw.dpy, False);
|
XSync(xw.dpy, False);
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1);
|
clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1);
|
||||||
@ -1339,10 +1212,13 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
|
|||||||
fontpattern = FcFontSetMatch(0, fcsets, 1,
|
fontpattern = FcFontSetMatch(0, fcsets, 1,
|
||||||
fcpattern, &fcres);
|
fcpattern, &fcres);
|
||||||
|
|
||||||
/* Allocate memory for the new cache entry. */
|
/*
|
||||||
if (frclen >= frccap) {
|
* Overwrite or create the new cache entry.
|
||||||
frccap += 16;
|
*/
|
||||||
frc = xrealloc(frc, frccap * sizeof(Fontcache));
|
if (frclen >= LEN(frc)) {
|
||||||
|
frclen = LEN(frc) - 1;
|
||||||
|
XftFontClose(xw.dpy, frc[frclen].font);
|
||||||
|
frc[frclen].unicodep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
frc[frclen].font = XftFontOpenPattern(xw.dpy,
|
frc[frclen].font = XftFontOpenPattern(xw.dpy,
|
||||||
@ -1495,12 +1371,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|||||||
|
|
||||||
/* Render underline and strikethrough. */
|
/* Render underline and strikethrough. */
|
||||||
if (base.mode & ATTR_UNDERLINE) {
|
if (base.mode & ATTR_UNDERLINE) {
|
||||||
XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1,
|
XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
|
||||||
width, 1);
|
width, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.mode & ATTR_STRUCK) {
|
if (base.mode & ATTR_STRUCK) {
|
||||||
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
|
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
|
||||||
width, 1);
|
width, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1560,9 +1436,8 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
|||||||
/* draw the new one */
|
/* draw the new one */
|
||||||
if (IS_SET(MODE_FOCUSED)) {
|
if (IS_SET(MODE_FOCUSED)) {
|
||||||
switch (win.cursor) {
|
switch (win.cursor) {
|
||||||
case 7: /* st extension */
|
case 7: /* st extension: snowman (U+2603) */
|
||||||
g.u = 0x2603; /* snowman (U+2603) */
|
g.u = 0x2603;
|
||||||
/* FALLTHROUGH */
|
|
||||||
case 0: /* Blinking Block */
|
case 0: /* Blinking Block */
|
||||||
case 1: /* Blinking Block (Default) */
|
case 1: /* Blinking Block (Default) */
|
||||||
case 2: /* Steady Block */
|
case 2: /* Steady Block */
|
||||||
@ -1613,29 +1488,14 @@ xsetenv(void)
|
|||||||
setenv("WINDOWID", buf, 1);
|
setenv("WINDOWID", buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xseticontitle(char *p)
|
|
||||||
{
|
|
||||||
XTextProperty prop;
|
|
||||||
DEFAULT(p, opt_title);
|
|
||||||
|
|
||||||
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
|
||||||
&prop) != Success)
|
|
||||||
return;
|
|
||||||
XSetWMIconName(xw.dpy, xw.win, &prop);
|
|
||||||
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
|
|
||||||
XFree(prop.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xsettitle(char *p)
|
xsettitle(char *p)
|
||||||
{
|
{
|
||||||
XTextProperty prop;
|
XTextProperty prop;
|
||||||
DEFAULT(p, opt_title);
|
DEFAULT(p, "st");
|
||||||
|
|
||||||
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
||||||
&prop) != Success)
|
&prop);
|
||||||
return;
|
|
||||||
XSetWMName(xw.dpy, xw.win, &prop);
|
XSetWMName(xw.dpy, xw.win, &prop);
|
||||||
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
|
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
|
||||||
XFree(prop.value);
|
XFree(prop.value);
|
||||||
@ -1688,18 +1548,6 @@ xfinishdraw(void)
|
|||||||
defaultfg : defaultbg].pixel);
|
defaultfg : defaultbg].pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xximspot(int x, int y)
|
|
||||||
{
|
|
||||||
if (xw.ime.xic == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
xw.ime.spot.x = borderpx + x * win.cw;
|
|
||||||
xw.ime.spot.y = borderpx + (y + 1) * win.ch;
|
|
||||||
|
|
||||||
XSetICValues(xw.ime.xic, XNPreeditAttributes, xw.ime.spotlist, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
expose(XEvent *ev)
|
expose(XEvent *ev)
|
||||||
{
|
{
|
||||||
@ -1739,7 +1587,8 @@ xsetmode(int set, unsigned int flags)
|
|||||||
int
|
int
|
||||||
xsetcursor(int cursor)
|
xsetcursor(int cursor)
|
||||||
{
|
{
|
||||||
if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
|
DEFAULT(cursor, 1);
|
||||||
|
if (!BETWEEN(cursor, 0, 6))
|
||||||
return 1;
|
return 1;
|
||||||
win.cursor = cursor;
|
win.cursor = cursor;
|
||||||
return 0;
|
return 0;
|
||||||
@ -1773,15 +1622,13 @@ focus(XEvent *ev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (ev->type == FocusIn) {
|
if (ev->type == FocusIn) {
|
||||||
if (xw.ime.xic)
|
XSetICFocus(xw.xic);
|
||||||
XSetICFocus(xw.ime.xic);
|
|
||||||
win.mode |= MODE_FOCUSED;
|
win.mode |= MODE_FOCUSED;
|
||||||
xseturgency(0);
|
xseturgency(0);
|
||||||
if (IS_SET(MODE_FOCUS))
|
if (IS_SET(MODE_FOCUS))
|
||||||
ttywrite("\033[I", 3, 0);
|
ttywrite("\033[I", 3, 0);
|
||||||
} else {
|
} else {
|
||||||
if (xw.ime.xic)
|
XUnsetICFocus(xw.xic);
|
||||||
XUnsetICFocus(xw.ime.xic);
|
|
||||||
win.mode &= ~MODE_FOCUSED;
|
win.mode &= ~MODE_FOCUSED;
|
||||||
if (IS_SET(MODE_FOCUS))
|
if (IS_SET(MODE_FOCUS))
|
||||||
ttywrite("\033[O", 3, 0);
|
ttywrite("\033[O", 3, 0);
|
||||||
@ -1835,8 +1682,8 @@ void
|
|||||||
kpress(XEvent *ev)
|
kpress(XEvent *ev)
|
||||||
{
|
{
|
||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym = NoSymbol;
|
KeySym ksym;
|
||||||
char buf[64], *customkey;
|
char buf[32], *customkey;
|
||||||
int len;
|
int len;
|
||||||
Rune c;
|
Rune c;
|
||||||
Status status;
|
Status status;
|
||||||
@ -1845,13 +1692,7 @@ kpress(XEvent *ev)
|
|||||||
if (IS_SET(MODE_KBDLOCK))
|
if (IS_SET(MODE_KBDLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xw.ime.xic) {
|
len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status);
|
||||||
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
|
|
||||||
if (status == XBufferOverflow)
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
|
|
||||||
}
|
|
||||||
/* 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)) {
|
||||||
@ -1884,6 +1725,7 @@ kpress(XEvent *ev)
|
|||||||
ttywrite(buf, len, 1);
|
ttywrite(buf, len, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cmessage(XEvent *e)
|
cmessage(XEvent *e)
|
||||||
{
|
{
|
||||||
@ -1919,9 +1761,10 @@ run(void)
|
|||||||
XEvent ev;
|
XEvent ev;
|
||||||
int w = win.w, h = win.h;
|
int w = win.w, h = win.h;
|
||||||
fd_set rfd;
|
fd_set rfd;
|
||||||
int xfd = XConnectionNumber(xw.dpy), ttyfd, xev, drawing;
|
int xfd = XConnectionNumber(xw.dpy), xev, blinkset = 0, dodraw = 0;
|
||||||
struct timespec seltv, *tv, now, lastblink, trigger;
|
int ttyfd;
|
||||||
double timeout;
|
struct timespec drawtimeout, *tv = NULL, now, last, lastblink;
|
||||||
|
long deltatime;
|
||||||
|
|
||||||
/* Waiting for window mapping */
|
/* Waiting for window mapping */
|
||||||
do {
|
do {
|
||||||
@ -1942,31 +1785,51 @@ run(void)
|
|||||||
ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
|
ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
|
||||||
cresize(w, h);
|
cresize(w, h);
|
||||||
|
|
||||||
for (timeout = -1, drawing = 0, lastblink = (struct timespec){0};;) {
|
clock_gettime(CLOCK_MONOTONIC, &last);
|
||||||
|
lastblink = last;
|
||||||
|
|
||||||
|
for (xev = actionfps;;) {
|
||||||
FD_ZERO(&rfd);
|
FD_ZERO(&rfd);
|
||||||
FD_SET(ttyfd, &rfd);
|
FD_SET(ttyfd, &rfd);
|
||||||
FD_SET(xfd, &rfd);
|
FD_SET(xfd, &rfd);
|
||||||
|
|
||||||
if (XPending(xw.dpy))
|
|
||||||
timeout = 0; /* existing events might not set xfd */
|
|
||||||
|
|
||||||
seltv.tv_sec = timeout / 1E3;
|
|
||||||
seltv.tv_nsec = 1E6 * (timeout - 1E3 * seltv.tv_sec);
|
|
||||||
tv = timeout >= 0 ? &seltv : NULL;
|
|
||||||
|
|
||||||
if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
|
if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
die("select failed: %s\n", strerror(errno));
|
die("select failed: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
if (FD_ISSET(ttyfd, &rfd)) {
|
||||||
|
|
||||||
if (FD_ISSET(ttyfd, &rfd))
|
|
||||||
ttyread();
|
ttyread();
|
||||||
|
if (blinktimeout) {
|
||||||
|
blinkset = tattrset(ATTR_BLINK);
|
||||||
|
if (!blinkset)
|
||||||
|
MODBIT(win.mode, 0, MODE_BLINK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xev = 0;
|
if (FD_ISSET(xfd, &rfd))
|
||||||
|
xev = actionfps;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
drawtimeout.tv_sec = 0;
|
||||||
|
drawtimeout.tv_nsec = (1000 * 1E6)/ xfps;
|
||||||
|
tv = &drawtimeout;
|
||||||
|
|
||||||
|
dodraw = 0;
|
||||||
|
if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
|
||||||
|
tsetdirtattr(ATTR_BLINK);
|
||||||
|
win.mode ^= MODE_BLINK;
|
||||||
|
lastblink = now;
|
||||||
|
dodraw = 1;
|
||||||
|
}
|
||||||
|
deltatime = TIMEDIFF(now, last);
|
||||||
|
if (deltatime > 1000 / (xev ? xfps : actionfps)) {
|
||||||
|
dodraw = 1;
|
||||||
|
last = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dodraw) {
|
||||||
while (XPending(xw.dpy)) {
|
while (XPending(xw.dpy)) {
|
||||||
xev = 1;
|
|
||||||
XNextEvent(xw.dpy, &ev);
|
XNextEvent(xw.dpy, &ev);
|
||||||
if (XFilterEvent(&ev, None))
|
if (XFilterEvent(&ev, None))
|
||||||
continue;
|
continue;
|
||||||
@ -1974,45 +1837,30 @@ run(void)
|
|||||||
(handler[ev.type])(&ev);
|
(handler[ev.type])(&ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* To reduce flicker and tearing, when new content or event
|
|
||||||
* triggers drawing, we first wait a bit to ensure we got
|
|
||||||
* everything, and if nothing new arrives - we draw.
|
|
||||||
* We start with trying to wait minlatency ms. If more content
|
|
||||||
* arrives sooner, we retry with shorter and shorter periods,
|
|
||||||
* and eventually draw even without idle after maxlatency ms.
|
|
||||||
* Typically this results in low latency while interacting,
|
|
||||||
* maximum latency intervals during `cat huge.txt`, and perfect
|
|
||||||
* sync with periodic updates from animations/key-repeats/etc.
|
|
||||||
*/
|
|
||||||
if (FD_ISSET(ttyfd, &rfd) || xev) {
|
|
||||||
if (!drawing) {
|
|
||||||
trigger = now;
|
|
||||||
drawing = 1;
|
|
||||||
}
|
|
||||||
timeout = (maxlatency - TIMEDIFF(now, trigger)) \
|
|
||||||
/ maxlatency * minlatency;
|
|
||||||
if (timeout > 0)
|
|
||||||
continue; /* we have time, try to find idle */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* idle detected or maxlatency exhausted -> draw */
|
|
||||||
timeout = -1;
|
|
||||||
if (blinktimeout && tattrset(ATTR_BLINK)) {
|
|
||||||
timeout = blinktimeout - TIMEDIFF(now, lastblink);
|
|
||||||
if (timeout <= 0) {
|
|
||||||
if (-timeout > blinktimeout) /* start visible */
|
|
||||||
win.mode |= MODE_BLINK;
|
|
||||||
win.mode ^= MODE_BLINK;
|
|
||||||
tsetdirtattr(ATTR_BLINK);
|
|
||||||
lastblink = now;
|
|
||||||
timeout = blinktimeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
XFlush(xw.dpy);
|
XFlush(xw.dpy);
|
||||||
drawing = 0;
|
|
||||||
|
if (xev && !FD_ISSET(xfd, &rfd))
|
||||||
|
xev--;
|
||||||
|
if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
|
||||||
|
if (blinkset) {
|
||||||
|
if (TIMEDIFF(now, lastblink) \
|
||||||
|
> blinktimeout) {
|
||||||
|
drawtimeout.tv_nsec = 1000;
|
||||||
|
} else {
|
||||||
|
drawtimeout.tv_nsec = (1E6 * \
|
||||||
|
(blinktimeout - \
|
||||||
|
TIMEDIFF(now,
|
||||||
|
lastblink)));
|
||||||
|
}
|
||||||
|
drawtimeout.tv_sec = \
|
||||||
|
drawtimeout.tv_nsec / 1E9;
|
||||||
|
drawtimeout.tv_nsec %= (long)1E9;
|
||||||
|
} else {
|
||||||
|
tv = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2034,7 +1882,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
xw.l = xw.t = 0;
|
xw.l = xw.t = 0;
|
||||||
xw.isfixed = False;
|
xw.isfixed = False;
|
||||||
xsetcursor(cursorshape);
|
win.cursor = cursorshape;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -2074,19 +1922,19 @@ main(int argc, char *argv[])
|
|||||||
opt_embed = EARGF(usage());
|
opt_embed = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
die("%s " VERSION "\n", argv0);
|
die("%s " VERSION " (c) 2010-2016 st engineers\n", argv0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
run:
|
run:
|
||||||
if (argc > 0) /* eat all remaining arguments */
|
if (argc > 0) {
|
||||||
|
/* eat all remaining arguments */
|
||||||
opt_cmd = argv;
|
opt_cmd = argv;
|
||||||
|
if (!opt_title && !opt_line)
|
||||||
if (!opt_title)
|
opt_title = basename(xstrdup(argv[0]));
|
||||||
opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
|
}
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
cols = MAX(cols, 1);
|
cols = MAX(cols, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user