Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Style cleanup.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
37bec70
..
c16e45d
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-441,6
+441,7
@@
static int isfullutf8(char *, int);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
static ssize_t xwrite(int, char *, size_t);
static void *xmalloc(size_t);
static void *xrealloc(void *, size_t);
+static char *xstrdup(char *s);
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
static void (*handler[LASTEvent])(XEvent *) = {
[KeyPress] = kpress,
@@
-529,6
+530,16
@@
xrealloc(void *p, size_t len) {
return p;
}
return p;
}
+char *
+xstrdup(char *s) {
+ char *p = strdup(s);
+
+ if (!p)
+ die("Out of memory\n");
+
+ return p;
+}
+
int
utf8decode(char *s, long *u) {
uchar c;
int
utf8decode(char *s, long *u) {
uchar c;
@@
-2790,7
+2801,8
@@
xhints(void) {
sizeh->min_height = sizeh->max_height = xw.fh;
}
sizeh->min_height = sizeh->max_height = xw.fh;
}
- XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm, &class);
+ XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
+ &class);
XFree(sizeh);
}
XFree(sizeh);
}
@@
-3079,6
+3091,7
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
if(base.fg == defaultfg)
base.fg = defaultunderline;
}
if(base.fg == defaultfg)
base.fg = defaultunderline;
}
+
if(IS_TRUECOL(base.fg)) {
colfg.alpha = 0xffff;
colfg.red = TRUERED(base.fg);
if(IS_TRUECOL(base.fg)) {
colfg.alpha = 0xffff;
colfg.red = TRUERED(base.fg);
@@
-3101,8
+3114,6
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
bg = &dc.col[base.bg];
}
bg = &dc.col[base.bg];
}
-
-
if(base.mode & ATTR_BOLD) {
if(BETWEEN(base.fg, 0, 7)) {
/* basic system colors */
if(base.mode & ATTR_BOLD) {
if(BETWEEN(base.fg, 0, 7)) {
/* basic system colors */
@@
-3132,7
+3143,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
colfg.green = ~fg->color.green;
colfg.blue = ~fg->color.blue;
colfg.alpha = fg->color.alpha;
colfg.green = ~fg->color.green;
colfg.blue = ~fg->color.blue;
colfg.alpha = fg->color.alpha;
- XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &revfg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg,
+ &revfg);
fg = &revfg;
}
fg = &revfg;
}
@@
-3143,7
+3155,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
colbg.green = ~bg->color.green;
colbg.blue = ~bg->color.blue;
colbg.alpha = bg->color.alpha;
colbg.green = ~bg->color.green;
colbg.blue = ~bg->color.blue;
colbg.alpha = bg->color.alpha;
- XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &revbg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg,
+ &revbg);
bg = &revbg;
}
}
bg = &revbg;
}
}
@@
-3223,7
+3236,7
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
u8fblen += u8cblen;
}
if(doesexist) {
u8fblen += u8cblen;
}
if(doesexist) {
- if
(oneatatime)
+ if(oneatatime)
continue;
break;
}
continue;
break;
}
@@
-3246,6
+3259,8
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
* Nothing was found in the cache. Now use
* some dozen of Fontconfig calls to get the
* font for one single character.
* Nothing was found in the cache. Now use
* some dozen of Fontconfig calls to get the
* font for one single character.
+ *
+ * Xft and fontconfig are design failures.
*/
fcpattern = FcPatternDuplicate(font->pattern);
fccharset = FcCharSetCreate();
*/
fcpattern = FcPatternDuplicate(font->pattern);
fccharset = FcCharSetCreate();
@@
-3289,6
+3304,12
@@
xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
xp += xw.cw * wcwidth(u8char);
}
xp += xw.cw * wcwidth(u8char);
}
+ /*
+ * This is how the loop above actually should be. Why does the
+ * application have to care about font details?
+ *
+ * I have to repeat: Xft and Fontconfig are design failures.
+ */
/*
XftDrawStringUtf8(xw.draw, fg, font->set, winx,
winy + font->ascent, (FcChar8 *)s, bytelen);
/*
XftDrawStringUtf8(xw.draw, fg, font->set, winx,
winy + font->ascent, (FcChar8 *)s, bytelen);
@@
-3789,7
+3810,7
@@
main(int argc, char *argv[]) {
if(argc > 1) {
opt_cmd = &argv[1];
if(argv[1] != NULL && opt_title == NULL) {
if(argc > 1) {
opt_cmd = &argv[1];
if(argv[1] != NULL && opt_title == NULL) {
- titles = strdup(argv[1]);
+ titles =
x
strdup(argv[1]);
opt_title = basename(titles);
}
}
opt_title = basename(titles);
}
}