Xinqi Bao's Git
projects
/
dmenu.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
reverted setlocale() call
[dmenu.git]
/
dmenu.c
diff --git
a/dmenu.c
b/dmenu.c
index
a799f14
..
18f2a56
100644
(file)
--- a/
dmenu.c
+++ b/
dmenu.c
@@
-1,6
+1,7
@@
/* See LICENSE file for copyright and license details. */
#define _BSD_SOURCE
#include <ctype.h>
/* See LICENSE file for copyright and license details. */
#define _BSD_SOURCE
#include <ctype.h>
+#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@
-213,8
+214,8
@@
drawmenu(void) {
void
drawtext(const char *text, unsigned long col[ColLast]) {
void
drawtext(const char *text, unsigned long col[ColLast]) {
- int i, x, y, h, len, olen;
char buf[256];
char buf[256];
+ int i, x, y, h, len, olen;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
XSetForeground(dpy, dc.gc, col[ColBG]);
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
XSetForeground(dpy, dc.gc, col[ColBG]);
@@
-226,7
+227,7
@@
drawtext(const char *text, unsigned long col[ColLast]) {
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
x = dc.x + (h / 2);
/* shorten text if necessary */
y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
x = dc.x + (h / 2);
/* shorten text if necessary */
- for(len = MIN(olen, sizeof buf); len && textnw(
buf
, len) > dc.w - h; len--);
+ for(len = MIN(olen, sizeof buf); len && textnw(
text
, len) > dc.w - h; len--);
if(!len)
return;
memcpy(buf, text, len);
if(!len)
return;
memcpy(buf, text, len);
@@
-280,8
+281,6
@@
initfont(const char *fontstr) {
if(!fontstr || fontstr[0] == '\0')
eprint("error, cannot load font: '%s'\n", fontstr);
missing = NULL;
if(!fontstr || fontstr[0] == '\0')
eprint("error, cannot load font: '%s'\n", fontstr);
missing = NULL;
- if(dc.font.set)
- XFreeFontSet(dpy, dc.font.set);
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
if(missing)
XFreeStringList(missing);
dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
if(missing)
XFreeStringList(missing);
@@
-707,7
+706,7
@@
main(int argc, char *argv[]) {
else
eprint("usage: dmenu [-i] [-b] [-fn <font>] [-nb <color>] [-nf <color>]\n"
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
else
eprint("usage: dmenu [-i] [-b] [-fn <font>] [-nb <color>] [-nf <color>]\n"
" [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
- if(!XSupportsLocale())
+ if(!
setlocale(LC_CTYPE, "") || !
XSupportsLocale())
fprintf(stderr, "warning: no locale support\n");
if(!(dpy = XOpenDisplay(0)))
eprint("dmenu: cannot open display\n");
fprintf(stderr, "warning: no locale support\n");
if(!(dpy = XOpenDisplay(0)))
eprint("dmenu: cannot open display\n");