summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2007-05-03 15:49:19 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2007-05-03 15:49:19 +0000
commit7c84b6fc2ed23987e04a812d7ff3d12aadc3a83d (patch)
tree4e007fbd1e2a224311b566ee069420cd59674520
parentb8380772e24bdb58a53bbd4c84356477347600d1 (diff)
downloadirssi-7c84b6fc2ed23987e04a812d7ff3d12aadc3a83d.zip
Add common IS_PRINTABLE macro.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4474 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/fe-text/gui-entry.c2
-rw-r--r--src/fe-text/statusbar.c4
-rw-r--r--src/fe-text/term.h2
-rw-r--r--src/fe-text/textbuffer-view.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c
index 6c265b51..0c3fce98 100644
--- a/src/fe-text/gui-entry.c
+++ b/src/fe-text/gui-entry.c
@@ -232,7 +232,7 @@ static void gui_entry_draw_from(GUI_ENTRY_REC *entry, int pos)
if (entry->hidden)
term_addch(root_window, ' ');
- else if (*p >= 32 && (*p < 0x7F || *p > 0x9F))
+ else if (IS_PRINTABLE(*p))
term_add_unichar(root_window, *p);
else {
term_set_color(root_window, ATTR_RESET|ATTR_REVERSE);
diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c
index 9f1b09b0..2e54f067 100644
--- a/src/fe-text/statusbar.c
+++ b/src/fe-text/statusbar.c
@@ -661,9 +661,7 @@ static char *reverse_controls(const char *str)
out = g_string_new(NULL);
while (*str != '\0') {
- if ((unsigned char) *str < 32 ||
- (term_type == TERM_TYPE_8BIT &&
- (unsigned char) (*str & 0x7f) < 32)) {
+ if (!IS_PRINTABLE((unsigned char) *str)) {
/* control char */
g_string_sprintfa(out, "%%8%c%%8",
'A'-1 + (*str & 0x7f));
diff --git a/src/fe-text/term.h b/src/fe-text/term.h
index b5103c14..07d917c8 100644
--- a/src/fe-text/term.h
+++ b/src/fe-text/term.h
@@ -22,6 +22,8 @@ typedef struct _TERM_WINDOW TERM_WINDOW;
typedef guint32 unichar;
+#define IS_PRINTABLE(c) (((c) & ~0x80) >= 32)
+
extern TERM_WINDOW *root_window;
extern int term_width, term_height;
extern int term_use_colors, term_type, term_detached;
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index 8ffbfcd8..93b21966 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -451,7 +451,7 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
xpos += char_width;
if (xpos <= term_width) {
- if ((chr & ~0x80) >= 32) {
+ if (IS_PRINTABLE(chr)) {
for (; text < end; text++)
term_addch(view->window, *text);
term_addch(view->window, *text);