[ekg2-commit] ekg2: old.c (HEAD) [darkjames]
CVS commit
cvs w toxygen.net
Nie, 20 Sty 2008, 21:34:17 CET
Module name: ekg2
Changes by: darkjames 2008-01-20 21:34:15
Modified files:
old.c
Log message:
move common code, which translates fstring attributes to ncurses attributes,
to new function fstring_attr2ncurses_attr()
Index: old.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/ncurses/old.c,v
diff -d -u -r1.169 -r1.170
--- old.c 17 Jan 2008 16:35:36 -0000 1.169
+++ old.c 20 Jan 2008 20:34:14 -0000 1.170
@@ -883,6 +883,27 @@
ncurses_screen_height = height;
}
+static inline int fstring_attr2ncurses_attr(short chattr) {
+ int attr = A_NORMAL;
+
+ if ((chattr & 64))
+ attr |= A_BOLD;
+
+ if ((chattr & 256))
+ attr |= A_BLINK;
+
+ if (!(chattr & 128))
+ attr |= color_pair(chattr & 7, 0, config_display_transparent ? COLOR_BLACK: (chattr>>3)&7);
+
+ if ((chattr & 512))
+ attr |= A_UNDERLINE;
+
+ if ((chattr & 1024))
+ attr |= A_REVERSE;
+
+ return attr;
+}
+
/*
* ncurses_redraw()
*
@@ -978,40 +999,25 @@
wattrset(n->window, A_NORMAL);
for (x = 0; l->ts && l->ts[x] && x < l->ts_len; x++) {
- int attr = A_NORMAL;
- short chattr = l->ts_attr[x];
unsigned char ch = (unsigned char) l->ts[x];
+ int attr = fstring_attr2ncurses_attr(l->ts_attr[x]);
- if ((chattr & 64))
- attr |= A_BOLD;
-
- if ((chattr & 256))
- attr |= A_BLINK;
-
- if (!(chattr & 128))
- attr |= color_pair(chattr & 7, 0,
- config_display_transparent?COLOR_BLACK:
- (chattr>>3)&7);
-
- if ((chattr & 512))
- attr |= A_UNDERLINE;
-
- if ((chattr & 1024))
- attr |= A_REVERSE;
if (ch < 32) {
ch += 64;
attr |= A_REVERSE;
}
+
if (ch > 127 && ch < 160) {
ch = '?';
attr |= A_REVERSE;
}
+
wattrset(n->window, attr);
mvwaddch(n->window, top + y, left + x, ch);
}
for (x = 0; x < l->prompt_len + l->len; x++) {
- int attr = A_NORMAL;
CHAR_T ch;
+ int attr;
short chattr;
if (x < l->prompt_len) {
if (!l->prompt_str)
@@ -1023,38 +1029,24 @@
ch = l->str[x - l->prompt_len];
chattr = l->attr[x - l->prompt_len];
}
- if ((chattr & 64))
- attr |= A_BOLD;
-
- if ((chattr & 256))
- attr |= A_BLINK;
- if (!(chattr & 128))
- attr |= color_pair(chattr & 7, 0,
- config_display_transparent?COLOR_BLACK:
- (chattr>>3)&7);
-
- if ((chattr & 512))
- attr |= A_UNDERLINE;
+ attr = fstring_attr2ncurses_attr(chattr);
- if ((chattr & 1024))
- attr |= A_REVERSE;
if (ch < 32) {
ch += 64;
attr |= A_REVERSE;
}
- if (
+
+ if (ch > 127 && ch < 160 &&
#if USE_UNICODE
-#warning "XXX ?"
- !config_use_unicode &&
+ !config_use_unicode &&
#endif
- config_use_iso &&
- ch > 127 && ch < 160
- )
+ config_use_iso)
{
ch = '?';
attr |= A_REVERSE;
}
+
wattrset(n->window, attr);
if (l->margin_left != -1 && x >= l->margin_left)
x_real = x - l->margin_left + config_margin_size;
Więcej informacji o liście dyskusyjnej ekg2-commit