summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2017-09-17 19:28:31 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2017-09-17 19:46:06 +0200
commit9b7cfb7c8d8d337554ad7c5995ce75fac52c7d54 (patch)
treed2984feb328e1c2a05c80c75d1dd8032dafbb95b
parent997bb3428312779a6f5af0264fa772407184ec17 (diff)
downloadratpoison-9b7cfb7c8d8d337554ad7c5995ce75fac52c7d54.zip
Move utf8_locale to its own file
So that we can easily use it from tests.
-rw-r--r--src/Makefile.am4
-rw-r--r--src/data.h1
-rw-r--r--src/editor.h7
-rw-r--r--src/globals.c4
-rw-r--r--src/main.c4
-rw-r--r--src/manage.c4
-rw-r--r--src/ratpoison.h1
-rw-r--r--src/utf8.c3
-rw-r--r--src/utf8.h6
9 files changed, 23 insertions, 11 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7f4a673..beb2278 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,6 +69,8 @@ ratpoison_SOURCES = actions.c \
screen.c \
split.c \
split.h \
+ utf8.c \
+ utf8.h \
window.c \
window.h
@@ -83,6 +85,6 @@ check_PROGRAMS = format_test
format_test_SOURCES = actions.c bar.c completions.c editor.c events.c format.c \
frame.c globals.c group.c history.c hook.c input.c \
linkedlist.c manage.c number.c sbuf.c screen.c split.c \
- window.c xrandr.c
+ window.c xrandr.c utf8.c utf8.h
format_test_CPPFLAGS = $(AM_CPPFLAGS) -DRUN_FORMAT_TEST
format_test_LDADD = $(ratpoison_LDADD)
diff --git a/src/data.h b/src/data.h
index 6816422..f959ab9 100644
--- a/src/data.h
+++ b/src/data.h
@@ -262,7 +262,6 @@ struct rp_defaults
XFontSet font;
char *font_string;
- int utf8_locale;
char *fgcolor_string;
char *bgcolor_string;
diff --git a/src/editor.h b/src/editor.h
index 445cd82..be79b6c 100644
--- a/src/editor.h
+++ b/src/editor.h
@@ -21,6 +21,7 @@
#ifndef _RATPOISON_EDITOR_H
#define _RATPOISON_EDITOR_H 1
+#include "utf8.h"
typedef enum edit_status
{
@@ -34,9 +35,9 @@ typedef enum edit_status
} edit_status;
/* UTF-8 handling macros */
-#define RP_IS_UTF8_CHAR(c) (defaults.utf8_locale && (c) & 0xC0)
-#define RP_IS_UTF8_START(c) (defaults.utf8_locale && ((c) & 0xC0) == 0xC0)
-#define RP_IS_UTF8_CONT(c) (defaults.utf8_locale && ((c) & 0xC0) == 0x80)
+#define RP_IS_UTF8_CHAR(c) (utf8_locale && (c) & 0xC0)
+#define RP_IS_UTF8_START(c) (utf8_locale && ((c) & 0xC0) == 0xC0)
+#define RP_IS_UTF8_CONT(c) (utf8_locale && ((c) & 0xC0) == 0x80)
/* Input line functions */
rp_input_line *input_line_new (char *prompt, char *preinput, int history_id, enum completion_styles style, completion_fn fn);
diff --git a/src/globals.c b/src/globals.c
index 69f86bd..5f4350d 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -316,7 +316,7 @@ rp_draw_string (rp_screen *s, Drawable d, int style, int x, int y,
return;
}
- if (defaults.utf8_locale)
+ if (utf8_locale)
{
XftDrawStringUtf8 (draw, style == STYLE_NORMAL ? &s->xft_fg_color :
&s->xft_bg_color, s->xft_font, x, y,
@@ -349,7 +349,7 @@ rp_text_width (rp_screen *s, char *string, int count)
if (s->xft_font)
{
XGlyphInfo extents;
- if (defaults.utf8_locale)
+ if (utf8_locale)
XftTextExtentsUtf8 (dpy, s->xft_font, (FcChar8*) string, count, &extents);
else
XftTextExtents8 (dpy, s->xft_font, (FcChar8*) string, count, &extents);
diff --git a/src/main.c b/src/main.c
index a287258..e1875fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -268,10 +268,10 @@ init_defaults (void)
#endif
#ifdef HAVE_LANGINFO_CODESET
- defaults.utf8_locale = !strcmp (nl_langinfo (CODESET), "UTF-8");
+ utf8_locale = !strcmp (nl_langinfo (CODESET), "UTF-8");
#endif
PRINT_DEBUG (("UTF-8 locale detected: %s\n",
- defaults.utf8_locale ? "yes" : "no"));
+ utf8_locale ? "yes" : "no"));
defaults.fgcolor_string = xstrdup ("black");
defaults.bgcolor_string = xstrdup ("white");
diff --git a/src/manage.c b/src/manage.c
index 073235f..1440fab 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -184,7 +184,7 @@ get_wmname (Window w)
/* If current encoding is UTF-8, try to use the window's _NET_WM_NAME ewmh
property */
- if (defaults.utf8_locale)
+ if (utf8_locale)
{
Atom type = None;
unsigned long nitems, bytes_after;
@@ -231,7 +231,7 @@ get_wmname (Window w)
_NET_WM_NAME don't bother making their WM_NAME available as
UTF8_STRING (but only as either STRING or COMPOUND_TEXT).
Let's try anyway. */
- if (defaults.utf8_locale && text_prop.encoding == xa_utf8_string)
+ if (utf8_locale && text_prop.encoding == xa_utf8_string)
{
ret = Xutf8TextPropertyToTextList (dpy, &text_prop, &cl, &n);
PRINT_DEBUG (("Xutf8TextPropertyToTextList: %s\n",
diff --git a/src/ratpoison.h b/src/ratpoison.h
index 06cdfce..fc12d7d 100644
--- a/src/ratpoison.h
+++ b/src/ratpoison.h
@@ -91,6 +91,7 @@ do { \
#include "hook.h"
#include "xrandr.h"
#include "format.h"
+#include "utf8.h"
void set_extents_of_fontset (XFontSet font);
XFontSet load_query_font_set (Display *disp, const char *fontset_name);
diff --git a/src/utf8.c b/src/utf8.c
new file mode 100644
index 0000000..bb53d57
--- /dev/null
+++ b/src/utf8.c
@@ -0,0 +1,3 @@
+#include "utf8.h"
+
+int utf8_locale;
diff --git a/src/utf8.h b/src/utf8.h
new file mode 100644
index 0000000..10cec7f
--- /dev/null
+++ b/src/utf8.h
@@ -0,0 +1,6 @@
+#ifndef UTF8_H
+#define UTF8_H
+
+extern int utf8_locale;
+
+#endif