---
arg.h | 9 +-
config.def.h | 47 +++++-----
st.c | 72 +++++++++-------
x.c | 236 +++++++++++++++++++++++++++------------------------
4 files changed, 194 insertions(+), 170 deletions(-)
diff --git a/arg.h b/arg.h
index 1715b88..1988a32 100644
--- a/arg.h
+++ b/arg.h
@@ -10,9 +10,8 @@ static char *argv0;
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
- argv[0] && argv[0][0] == '-'\
- && argv[0][1];\
- argc--, argv++) {\
+ argv[0] && argv[0][0] == '-' &&\
+ argv[0][1]; argc--, argv++) {\
char argc_;\
char **argv_;\
int brk_;\
@@ -23,8 +22,8 @@ static char *argv0;
}\
int i_;\
for (i_ = 1, brk_ = 0, argv_ = argv;\
- argv[0][i_] && !brk_;\
- i_++) {\
+ argv[0][i_] && !brk_;\
+ i_++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][i_];\
diff --git a/config.def.h b/config.def.h
index 2b01cfc..d7f34c6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
/*
- * appearance
+ * Appearance.
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
@@ -9,7 +9,7 @@ static const char *font = "Liberation
Mono:pixelsize=12:antialias=true:autohint=
static int borderpx = 2;
/*
- * What program is execed by st depends of these precedence rules:
+ * What program is executed by st depends on these precedence rules:
* 1: program passed with -e
* 2: utmp option
* 3: SHELL environment variable
@@ -20,59 +20,58 @@ static char shell[] = "/bin/sh";
char *utmp = NULL;
const 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. */
const char *vtiden = "\033[?6c";
-/* Kerning / character bounding-box multipliers */
+/* Kerning / character bounding-box multipliers. */
static float cwscale = 1.0;
static float chscale = 1.0;
/*
- * word delimiter string
+ * Word delimiter string.
*
* More advanced example: " `'\"()[]{}"
*/
const char *worddelimiters = " ";
-/* selection timeouts (in milliseconds) */
+/* Selection timeouts (in milliseconds). */
static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;
/*
- * set to nonzero if you want to clear the selection when you select something
- * different in another window
+ * Set to nonzero if you want to clear the selection when you select something
+ * different in another window.
*/
#define SELCLEAR 0
/* alt screens */
int allowaltscreen = 1;
-/* frames per second st should at maximum draw to the screen */
+/* Frames per second st should at maximum draw to the screen. */
static unsigned int xfps = 120;
static unsigned int actionfps = 30;
/*
- * blinking timeout (set to 0 to disable blinking) for the terminal blinking
+ * Blinking timeout (set to 0 to disable blinking) for the terminal blinking
* attribute.
*/
static unsigned int blinktimeout = 800;
/*
- * thickness of underline and bar cursors
+ * 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
+ * Bell volume - must be a value between -100 and 100. Use 0 for disabling it.
*/
static int bellvolume = 0;
-/* default TERM value */
+/* Default TERM value. */
char termname[] = "st-256color";
/*
- * spaces per tab
+ * 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
@@ -88,7 +87,7 @@ char termname[] = "st-256color";
*/
unsigned int tabspaces = 8;
-/* Terminal colors (16 first used in escape sequence) */
+/* Terminal colors (16 first used in escape sequence). */
static const char *colorname[] = {
/* 8 normal colors */
"black",
@@ -119,7 +118,7 @@ static const char *colorname[] = {
/*
- * Default colors (colorname index)
+ * Default colors (colorname index).
* foreground, background, cursor, reverse cursor
*/
unsigned int defaultfg = 7;
@@ -128,7 +127,7 @@ static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
/*
- * Default shape of cursor
+ * Default shape of cursor.
* 2: Block ("█")
* 4: Underline ("_")
* 6: Bar ("|")
@@ -137,14 +136,14 @@ static unsigned int defaultrcs = 257;
static unsigned int cursorshape = 2;
/*
- * Default columns and rows numbers
+ * Default column and row numbers.
*/
static unsigned int cols = 80;
static unsigned int rows = 24;
/*
- * Default colour and shape of the mouse cursor
+ * Default color and shape of the mouse cursor.
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
@@ -187,7 +186,7 @@ static const Shortcut shortcuts[] = {
};
/*
- * Special keys (change & recompile st.info accordingly)
+ * Special keys (change & recompile st.info accordingly).
*
* Mask value:
* * Use XK_ANY_MOD to match the key no matter modifiers state
@@ -231,7 +230,7 @@ static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
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 with the Linux
* world. Please decide about changes wisely.
*/
static Key key[] = {
@@ -459,8 +458,8 @@ static uint selmasks[] = {
};
/*
- * Printable characters in ASCII, used to estimate the advance width
- * of single wide characters.
+ * Printable characters in ASCII, used to estimate the advance width of single
+ * wide characters.
*/
static const char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
diff --git a/st.c b/st.c
index 8020abf..8b36762 100644
--- a/st.c
+++ b/st.c
@@ -519,7 +519,7 @@ int
selected(int x, int y)
{
if (sel.mode == SEL_EMPTY || sel.ob.x == -1 ||
- sel.alt != IS_SET(MODE_ALTSCREEN))
+ sel.alt != IS_SET(MODE_ALTSCREEN))
return 0;
if (sel.type == SEL_RECTANGULAR)
@@ -566,8 +566,9 @@ selsnap(int *x, int *y, int direction)
Glyph *gp = &term.line[newy][newx];
int delim = ISDELIM(gp->u);
- if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
- || (delim && gp->u != prevgp->u)))
+ if (!(gp->mode & ATTR_WDUMMY) &&
+ (delim != prevdelim ||
+ (delim && gp->u != prevgp->u)))
break;
*x = newx;
@@ -585,15 +586,15 @@ selsnap(int *x, int *y, int direction)
*x = (direction < 0) ? 0 : term.col - 1;
if (direction < 0) {
for (; *y > 0; *y += direction) {
- if (!(term.line[*y-1][term.col-1].mode
- & ATTR_WRAP)) {
+ if (!(term.line[*y-1][term.col-1].mode &
+ ATTR_WRAP)) {
break;
}
}
} else if (direction > 0) {
for (; *y < term.row-1; *y += direction) {
- if (!(term.line[*y][term.col-1].mode
- & ATTR_WRAP)) {
+ if (!(term.line[*y][term.col-1].mode &
+ ATTR_WRAP)) {
break;
}
}
@@ -652,7 +653,8 @@ getsel(void)
* st.
* FIXME: Fix the computer world.
*/
- if ((y < sel.ne.y || lastx >= linelen) && !(last->mode &
ATTR_WRAP))
+ if ((y < sel.ne.y || lastx >= linelen) &&
+ !(last->mode & ATTR_WRAP))
*ptr++ = '\n';
}
*ptr = 0;
@@ -728,7 +730,8 @@ sigchld(UNUSED int a)
pid_t p;
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
- die("waiting for pid %jd failed: %s\n", (intmax_t)pid,
strerror(errno));
+ die("waiting for pid %jd failed: %s\n",
+ (intmax_t)pid, strerror(errno));
if (pid != p)
return;
@@ -773,7 +776,7 @@ ttynew(const char *line, char *cmd, const char *out, char
*const *args)
if (out) {
term.mode |= MODE_PRINT;
iofd = (!strcmp(out, "-")) ?
- 1 : open(out, O_WRONLY | O_CREAT, 0666);
+ 1 : open(out, O_WRONLY | O_CREAT, 0666);
if (iofd < 0) {
fprintf(stderr, "Error opening %s:%s\n",
out, strerror(errno));
@@ -907,7 +910,7 @@ ttywriteraw(const char *s, size_t n)
* default of 256. This seems to be a reasonable value
* for a serial line. Bigger values might clog the I/O.
*/
- if ((r = write(cmdfd, s, (n < lim)? n : lim)) < 0)
+ if ((r = write(cmdfd, s, (n < lim) ? n : lim)) < 0)
goto write_error;
if ((size_t)r < n) {
/*
@@ -1108,8 +1111,10 @@ selscroll(int orig, int n)
if (sel.ob.x == -1)
return;
- if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig,
term.bot)) {
- if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) {
+ if (BETWEEN(sel.ob.y, orig, term.bot) ||
+ BETWEEN(sel.oe.y, orig, term.bot)) {
+ if ((sel.ob.y += n) > term.bot ||
+ (sel.oe.y += n) < term.top) {
selclear();
return;
}
@@ -1201,22 +1206,22 @@ tmoveto(int x, int y)
void
tsetchar(Rune u, Glyph *attr, int x, int y)
{
- static const char *vt100_0[62] = { /* 0x41 - 0x7e */
- "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
- 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
- 0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
- 0, 0, 0, 0, 0, 0, 0, " ", /* X - _ */
+ static const char *vt100_0[62] = { /* 0x41 - 0x7e */
+ "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
+ 0, 0, 0, 0, 0, 0, 0, " ", /* X - _ */
"◆", "▒", "␉", "␌", "␍", "␊", "°", "±", /* ` - g */
"", "␋", "┘", "┐", "┌", "└", "┼", "⎺", /* h - o */
"⎻", "─", "⎼", "⎽", "├", "┤", "┴", "┬", /* p - w */
- "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */
+ "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */
};
/*
* The table is proudly stolen from rxvt.
*/
if (term.trantbl[term.charset] == CS_GRAPHIC0 &&
- BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41])
+ BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41])
utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ);
if (term.line[y][x].mode & ATTR_WIDE) {
@@ -1706,7 +1711,7 @@ csihandle(void)
tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
if (term.c.y < term.row-1) {
tclearregion(0, term.c.y+1, term.col-1,
- term.row-1);
+ term.row-1);
}
break;
case 1: /* above */
@@ -1757,7 +1762,7 @@ csihandle(void)
case 'X': /* ECH -- Erase <n> char */
DEFAULT(csiescseq.arg[0], 1);
tclearregion(term.c.x, term.c.y,
- term.c.x + csiescseq.arg[0] - 1, term.c.y);
+ term.c.x + csiescseq.arg[0] - 1, term.c.y);
break;
case 'P': /* DCH -- Delete <n> char */
DEFAULT(csiescseq.arg[0], 1);
@@ -1780,7 +1785,7 @@ csihandle(void)
case 'n': /* DSR – Device Status Report (cursor position) */
if (csiescseq.arg[0] == 6) {
len = snprintf(buf, sizeof(buf),"\033[%i;%iR",
- term.c.y+1, term.c.x+1);
+ term.c.y+1, term.c.x+1);
ttywrite(buf, len, 0);
}
break;
@@ -1869,7 +1874,8 @@ strhandle(void)
xsetsel(dec);
xclipcopy();
} else {
- fprintf(stderr, "erresc: invalid
base64\n");
+ fprintf(stderr,
+ "erresc: invalid base64\n");
}
}
return;
@@ -1882,7 +1888,9 @@ strhandle(void)
if (narg > 1) {
j = strtoul(strescseq.args[1], NULL, 10);
} else if (narg <= 1 || xsetcolorname(j, p)) {
- fprintf(stderr, "erresc: invalid color %s\n",
p);
+ fprintf(stderr,
+ "erresc: invalid color %s\n",
+ p);
} else {
/*
* TODO if defaultbg color is changed, borders
@@ -2282,7 +2290,7 @@ eschandle(uchar ascii)
break;
default:
fprintf(stderr, "erresc: unknown sequence ESC 0x%02X '%c'\n",
- (uchar) ascii, isprint(ascii)? ascii:'.');
+ (uchar)ascii, isprint(ascii) ? ascii:'.');
break;
}
return 1;
@@ -2318,7 +2326,7 @@ tputc(Rune u)
*/
if (term.esc & ESC_STR) {
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
- ISCONTROLC1(u)) {
+ ISCONTROLC1(u)) {
term.esc &= ~(ESC_START|ESC_STR|ESC_DCS);
if (IS_SET(MODE_SIXEL)) {
/* TODO: render sixel */;
@@ -2374,9 +2382,8 @@ check_control_code:
} else if (term.esc & ESC_START) {
if (term.esc & ESC_CSI) {
csiescseq.buf[csiescseq.len++] = u;
- if (BETWEEN(u, 0x40, 0x7E)
- || csiescseq.len >= \
- sizeof(csiescseq.buf)-1) {
+ if (BETWEEN(u, 0x40, 0x7E) ||
+ csiescseq.len >= sizeof(csiescseq.buf)-1) {
term.esc = 0;
csiparse();
csihandle();
@@ -2411,7 +2418,8 @@ check_control_code:
}
if (IS_SET(MODE_INSERT) && term.c.x+width < term.col)
- memmove(gp+width, gp, (term.col - term.c.x - width) *
sizeof(Glyph));
+ memmove(gp+width, gp,
+ (term.col - term.c.x - width) * sizeof(Glyph));
if (term.c.x+width > term.col) {
tnewline(1);
@@ -2584,7 +2592,7 @@ draw(void)
drawregion(0, 0, term.col, term.row);
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
- term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
term.ocx = cx, term.ocy = term.c.y;
xfinishdraw();
}
diff --git a/x.c b/x.c
index c558788..99ffc11 100644
--- a/x.c
+++ b/x.c
@@ -96,8 +96,8 @@ typedef struct {
XSetWindowAttributes attrs;
int scr;
int isfixed; /* is fixed geometry? */
- int l, t; /* left and top offset */
- int gm; /* geometry mask */
+ int l, t; /* left and top offset */
+ int gm; /* geometry mask */
} XWindow;
typedef struct {
@@ -231,14 +231,14 @@ static const char *usedfont = NULL;
static double usedfontsize = 0;
static double defaultfontsize = 0;
-static char *opt_class = NULL;
+static char *opt_class = NULL;
static char *const *opt_cmd = NULL;
static const char *opt_embed = NULL;
static const char *opt_font = NULL;
static const char *opt_io = NULL;
static const char *opt_line = NULL;
-static char *opt_name = NULL;
-static char *opt_title = NULL;
+static char *opt_name = NULL;
+static char *opt_title = NULL;
static int oldbutton = 3; /* button event on startup: 3 = release */
@@ -264,7 +264,7 @@ clippaste(UNUSED const Arg *dummy)
clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
- xw.win, CurrentTime);
+ xw.win, CurrentTime);
}
void
@@ -365,7 +365,8 @@ mousereport(XEvent *e)
ox = x;
oy = y;
} else {
- if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease)
{
+ if (!IS_SET(MODE_MOUSESGR) &&
+ e->xbutton.type == ButtonRelease) {
button = 3;
} else {
button -= Button1;
@@ -394,11 +395,11 @@ mousereport(XEvent *e)
if (IS_SET(MODE_MOUSESGR)) {
len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c",
- button, x+1, y+1,
- e->xbutton.type == ButtonRelease ? 'm' : 'M');
+ button, x+1, y+1,
+ e->xbutton.type == ButtonRelease ? 'm' : 'M');
} else if (x < 223 && y < 223) {
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
- 32+button, 32+x+1, 32+y+1);
+ 32+button, 32+x+1, 32+y+1);
} else {
return;
}
@@ -418,8 +419,8 @@ bpress(XEvent *e)
}
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
- if (e->xbutton.button == ms->b
- && match(ms->mask, e->xbutton.state)) {
+ if (e->xbutton.button == ms->b &&
+ match(ms->mask, e->xbutton.state)) {
ttywrite(ms->s, strlen(ms->s), 1);
return;
}
@@ -455,8 +456,8 @@ propnotify(XEvent *e)
xpev = &e->xproperty;
if (xpev->state == PropertyNewValue &&
- (xpev->atom == XA_PRIMARY ||
- xpev->atom == clipboard)) {
+ (xpev->atom == XA_PRIMARY ||
+ xpev->atom == clipboard)) {
selnotify(e);
}
}
@@ -482,9 +483,8 @@ selnotify(XEvent *e)
do {
if (XGetWindowProperty(xw.dpy, xw.win, property, ofs,
- BUFSIZ/4, False, AnyPropertyType,
- &type, &format, &nitems, &rem,
- &data)) {
+ BUFSIZ/4, False, AnyPropertyType,
+ &type, &format, &nitems, &rem, &data)) {
fprintf(stderr, "Clipboard allocation failed\n");
return;
}
@@ -498,7 +498,7 @@ selnotify(XEvent *e)
*/
MODBIT(xw.attrs.event_mask, 0, PropertyChangeMask);
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask,
- &xw.attrs);
+ &xw.attrs);
}
if (type == incratom) {
@@ -509,7 +509,7 @@ selnotify(XEvent *e)
*/
MODBIT(xw.attrs.event_mask, 1, PropertyChangeMask);
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask,
- &xw.attrs);
+ &xw.attrs);
/*
* Deleting the property is the transfer start signal.
@@ -587,8 +587,8 @@ selrequest(XEvent *e)
/* respond with the supported type */
string = xsel.xtarget;
XChangeProperty(xsre->display, xsre->requestor, xsre->property,
- XA_ATOM, 32, PropModeReplace,
- (uchar *) &string, 1);
+ XA_ATOM, 32, PropModeReplace,
+ (uchar *) &string, 1);
xev.property = xsre->property;
} else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) {
/*
@@ -602,15 +602,15 @@ selrequest(XEvent *e)
seltext = xsel.clipboard;
} else {
fprintf(stderr,
- "Unhandled clipboard selection 0x%lx\n",
- xsre->selection);
+ "Unhandled clipboard selection 0x%lx\n",
+ xsre->selection);
return;
}
if (seltext != NULL) {
XChangeProperty(xsre->display, xsre->requestor,
- xsre->property, xsre->target,
- 8, PropModeReplace,
- (uchar *)seltext, strlen(seltext));
+ xsre->property, xsre->target,
+ 8, PropModeReplace,
+ (uchar *)seltext, strlen(seltext));
xev.property = xsre->property;
}
}
@@ -693,7 +693,7 @@ xresize(int col, int row)
XFreePixmap(xw.dpy, xw.buf);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
+ DefaultDepth(xw.dpy, xw.scr));
XftDrawChange(xw.draw, xw.buf);
xclear(0, 0, win.w, win.h);
@@ -781,15 +781,15 @@ void
xclear(int x1, int y1, int x2, int y2)
{
XftDrawRect(xw.draw,
- &dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg],
- x1, y1, x2-x1, y2-y1);
+ &dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg],
+ x1, y1, x2-x1, y2-y1);
}
void
xhints(void)
{
- XClassHint class = {opt_name ? opt_name : (char *)termname,
- opt_class ? opt_class : (char *)termname};
+ XClassHint class = {opt_name ? opt_name : termname,
+ opt_class ? opt_class : termname};
XWMHints wm = {.flags = InputHint, .input = 1};
XSizeHints *sizeh;
@@ -817,7 +817,7 @@ xhints(void)
}
XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
- &class);
+ &class);
XFree(sizeh);
}
@@ -876,7 +876,8 @@ xloadfont(Font *f, FcPattern *pattern)
* slant but gave us one anyway. Try to mitigate.
*/
if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
- &haveattr) != XftResultMatch) || haveattr < wantattr) {
+ &haveattr) != XftResultMatch) ||
+ haveattr < wantattr) {
f->badslant = 1;
fputs("font slant does not match\n", stderr);
}
@@ -885,15 +886,16 @@ xloadfont(Font *f, FcPattern *pattern)
if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) ==
XftResultMatch)) {
if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
- &haveattr) != XftResultMatch) || haveattr != wantattr) {
+ &haveattr) != XftResultMatch) ||
+ haveattr != wantattr) {
f->badweight = 1;
fputs("font weight does not match\n", stderr);
}
}
XftTextExtentsUtf8(xw.dpy, f->match,
- (const FcChar8 *) ascii_printable,
- strlen(ascii_printable), &extents);
+ (const FcChar8 *) ascii_printable,
+ strlen(ascii_printable), &extents);
f->set = NULL;
f->pattern = configured;
@@ -932,10 +934,10 @@ xloadfonts(const char *fontstr, double fontsize)
usedfontsize = fontsize;
} else {
if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
- FcResultMatch) {
+ FcResultMatch) {
usedfontsize = fontval;
} else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) ==
- FcResultMatch) {
+ FcResultMatch) {
usedfontsize = -1;
} else {
/*
@@ -1021,7 +1023,7 @@ xinit(void)
if (!FcInit())
die("could not init fontconfig.\n");
- usedfont = (opt_font == NULL)? font : opt_font;
+ usedfont = (opt_font == NULL) ? font : opt_font;
xloadfonts(usedfont, 0);
/* colors */
@@ -1040,24 +1042,30 @@ xinit(void)
xw.attrs.background_pixel = dc.col[defaultbg].pixel;
xw.attrs.border_pixel = dc.col[defaultbg].pixel;
xw.attrs.bit_gravity = NorthWestGravity;
- xw.attrs.event_mask = FocusChangeMask | KeyPressMask
- | ExposureMask | VisibilityChangeMask | StructureNotifyMask
- | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
+ xw.attrs.event_mask = FocusChangeMask |
+ KeyPressMask |
+ ExposureMask |
+ VisibilityChangeMask |
+ StructureNotifyMask |
+ ButtonMotionMask |
+ ButtonPressMask |
+ ButtonReleaseMask;
xw.attrs.colormap = xw.cmap;
if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
parent = XRootWindow(xw.dpy, xw.scr);
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr),
InputOutput,
- xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
- | CWEventMask | CWColormap, &xw.attrs);
+ win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr),
+ InputOutput, xw.vis,
+ CWBackPixel | CWBorderPixel | CWBitGravity
+ | CWEventMask | CWColormap,
+ &xw.attrs);
memset(&gcvalues, 0, sizeof(gcvalues));
gcvalues.graphics_exposures = False;
- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
- &gcvalues);
+ dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, &gcvalues);
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
- DefaultDepth(xw.dpy, xw.scr));
+ DefaultDepth(xw.dpy, xw.scr));
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
@@ -1072,16 +1080,17 @@ xinit(void)
XSetLocaleModifiers("@im=local");
if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
XSetLocaleModifiers("@im=");
- if ((xw.xim = XOpenIM(xw.dpy,
- NULL, NULL, NULL)) == NULL) {
+ if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL))
+ == NULL) {
die("XOpenIM failed. Could not open input"
- " device.\n");
+ " device.\n");
}
}
}
- xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
- | XIMStatusNothing, XNClientWindow,
xw.win,
- XNFocusWindow, xw.win, NULL);
+ 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");
@@ -1110,7 +1119,7 @@ xinit(void)
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
- PropModeReplace, (uchar *)&thispid, 1);
+ PropModeReplace, (uchar *)&thispid, 1);
win.mode = MODE_NUMLOCK;
resettitle();
@@ -1128,9 +1137,13 @@ xinit(void)
}
int
-xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len,
int x, int y)
+xmakeglyphfontspecs(XftGlyphFontSpec *specs,
+ const Glyph *glyphs,
+ size_t len, int x, int y)
{
- float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp,
yp;
+ float winx = borderpx + x * win.cw;
+ float winy = borderpx + y * win.ch;
+ float xp, yp;
ushort prevmode = USHRT_MAX;
Font *dcfont = &dc.font;
int frcflags = FRC_NORMAL;
@@ -1199,7 +1212,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph
*glyphs, size_t len, in
if (f >= frclen) {
if (!dcfont->set)
dcfont->set = FcFontSort(0, dcfont->pattern,
- 1, 0, &fcres);
+ 1, 0, &fcres);
fcsets[0] = dcfont->set;
/*
@@ -1213,16 +1226,14 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const
Glyph *glyphs, size_t len, in
fccharset = FcCharSetCreate();
FcCharSetAddChar(fccharset, rune);
- FcPatternAddCharSet(fcpattern, FC_CHARSET,
- fccharset);
+ FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
FcPatternAddBool(fcpattern, FC_SCALABLE, 1);
- FcConfigSubstitute(0, fcpattern,
- FcMatchPattern);
+ FcConfigSubstitute(0, fcpattern, FcMatchPattern);
FcDefaultSubstitute(fcpattern);
fontpattern = FcFontSetMatch(0, fcsets, 1,
- fcpattern, &fcres);
+ fcpattern, &fcres);
/*
* Overwrite or create the new cache entry.
@@ -1234,10 +1245,10 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const
Glyph *glyphs, size_t len, in
}
frc[frclen].font = XftFontOpenPattern(xw.dpy,
- fontpattern);
+ fontpattern);
if (!frc[frclen].font)
die("XftFontOpenPattern failed seeking fallback
font: %s\n",
- strerror(errno));
+ strerror(errno));
frc[frclen].flags = frcflags;
frc[frclen].unicodep = rune;
@@ -1262,11 +1273,14 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const
Glyph *glyphs, size_t len, in
}
void
-xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x,
int y)
+xdrawglyphfontspecs(const XftGlyphFontSpec *specs,
+ Glyph base,
+ int len, int x, int y)
{
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
- int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
- width = charlen * win.cw;
+ int winx = borderpx + x * win.cw;
+ int winy = borderpx + y * win.ch;
+ int width = charlen * win.cw;
Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
XRenderColor colfg, colbg;
XRectangle r;
@@ -1276,7 +1290,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph
base, int len, int x, i
if (dc.ibfont.badslant || dc.ibfont.badweight)
base.fg = defaultattr;
} else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
- (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
+ (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
base.fg = defaultattr;
}
@@ -1315,7 +1329,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph
base, int len, int x, i
colfg.blue = ~fg->color.blue;
colfg.alpha = fg->color.alpha;
XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg,
- &revfg);
+ &revfg);
fg = &revfg;
}
@@ -1327,7 +1341,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph
base, int len, int x, i
colbg.blue = ~bg->color.blue;
colbg.alpha = bg->color.alpha;
XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg,
- &revbg);
+ &revbg);
bg = &revbg;
}
}
@@ -1355,13 +1369,15 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs,
Glyph base, int len, int x, i
/* Intelligent cleaning up of the borders. */
if (x == 0) {
- xclear(0, (y == 0)? 0 : winy, borderpx,
- winy + win.ch +
- ((winy + win.ch >= borderpx + win.th)? win.h : 0));
+ xclear(0, (y == 0) ? 0 : winy, borderpx,
+ winy + win.ch +
+ ((winy + win.ch >= borderpx + win.th) ?
+ win.h : 0));
}
if (winx + width >= borderpx + win.tw) {
- xclear(winx + width, (y == 0)? 0 : winy, win.w,
- ((winy + win.ch >= borderpx + win.th)? win.h : (winy +
win.ch)));
+ xclear(winx + width, (y == 0) ? 0 : winy, win.w,
+ ((winy + win.ch >= borderpx + win.th) ?
+ win.h : (winy + win.ch)));
}
if (y == 0)
xclear(winx, 0, winx + width, borderpx);
@@ -1384,12 +1400,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs,
Glyph base, int len, int x, i
/* Render underline and strikethrough. */
if (base.mode & ATTR_UNDERLINE) {
XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
- width, 1);
+ width, 1);
}
if (base.mode & ATTR_STRUCK) {
XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
- width, 1);
+ width, 1);
}
/* Reset clip to none. */
@@ -1459,36 +1475,36 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy,
Glyph og)
case 3: /* Blinking Underline */
case 4: /* Steady Underline */
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - \
- cursorthickness,
- win.cw, cursorthickness);
+ borderpx + cx * win.cw,
+ borderpx + (cy + 1) * win.ch - \
+ cursorthickness,
+ win.cw, cursorthickness);
break;
case 5: /* Blinking bar */
case 6: /* Steady bar */
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
- cursorthickness, win.ch);
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ cursorthickness, win.ch);
break;
}
} else {
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
- win.cw - 1, 1);
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ win.cw - 1, 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
- 1, win.ch - 1);
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ 1, win.ch - 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + (cx + 1) * win.cw - 1,
- borderpx + cy * win.ch,
- 1, win.ch - 1);
+ borderpx + (cx + 1) * win.cw - 1,
+ borderpx + cy * win.ch,
+ 1, win.ch - 1);
XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - 1,
- win.cw, 1);
+ borderpx + cx * win.cw,
+ borderpx + (cy + 1) * win.ch - 1,
+ win.cw, 1);
}
}
@@ -1553,10 +1569,10 @@ void
xfinishdraw(void)
{
XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
- win.h, 0, 0);
+ win.h, 0, 0);
XSetForeground(xw.dpy, dc.gc,
- dc.col[IS_SET(MODE_REVERSE)?
- defaultfg : defaultbg].pixel);
+ dc.col[IS_SET(MODE_REVERSE) ?
+ defaultfg : defaultbg].pixel);
}
void
@@ -1679,7 +1695,6 @@ kmap(KeySym k, uint state)
continue;
if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2)
continue;
-
if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor
> 0)
continue;
@@ -1750,7 +1765,8 @@ cmessage(XEvent *e)
} else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
win.mode &= ~MODE_FOCUSED;
}
- } else if (e->xclient.data.l[0] >= 0 && (Atom)(e->xclient.data.l[0]) ==
xw.wmdeletewin) {
+ } else if (e->xclient.data.l[0] >= 0 &&
+ (Atom)(e->xclient.data.l[0]) == xw.wmdeletewin) {
ttyhangup();
exit(EXIT_SUCCESS);
}
@@ -1803,7 +1819,8 @@ run(void)
FD_SET(ttyfd, &rfd);
FD_SET(xfd, &rfd);
- 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)
continue;
die("select failed: %s\n", strerror(errno));
@@ -1855,16 +1872,17 @@ run(void)
if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
if (blinkset) {
if (TIMEDIFF(now, lastblink) \
- > blinktimeout) {
+ > blinktimeout) {
drawtimeout.tv_nsec = 1000;
} else {
drawtimeout.tv_nsec = (1E6 * \
- (blinktimeout - \
- TIMEDIFF(now,
- lastblink)));
+ (blinktimeout - \
+ TIMEDIFF(now,
+ lastblink)
+ ));
}
drawtimeout.tv_sec = \
- drawtimeout.tv_nsec / 1E9;
+ drawtimeout.tv_nsec / 1E9;
drawtimeout.tv_nsec %= (long)1E9;
} else {
tv = NULL;
@@ -1910,7 +1928,7 @@ main(int argc, char *argv[])
break;
case 'g':
xw.gm = XParseGeometry(EARGF(usage()),
- &xw.l, &xw.t, &cols, &rows);
+ &xw.l, &xw.t, &cols, &rows);
break;
case 'i':
xw.isfixed = 1;
--
2.20.1