aboutsummaryrefslogtreecommitdiff
path: root/miscutils/conspy.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-24 17:50:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-24 17:50:00 +0200
commita54985b27919313e97a2b49fe4b5f87824886d92 (patch)
tree91a0ceccd0bc9977778a69ef67ad18bca44e8c5e /miscutils/conspy.c
parenta091d45c3beb767ce9cb530ab0a81aee1238495d (diff)
downloadbusybox-a54985b27919313e97a2b49fe4b5f87824886d92.tar.gz
conspy: document attribute byte format
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/conspy.c')
-rw-r--r--miscutils/conspy.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 0a5fdccad..b443c9133 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -62,7 +62,7 @@ struct globals {
int kbd_fd;
unsigned width;
unsigned height;
- char last_attr;
+ uint8_t last_attr;
int ioerror_count;
int key_count;
int escape_count;
@@ -112,17 +112,43 @@ static void screen_read_close(void)
static void screen_char(char *data)
{
- if (!BW && G.last_attr != ATTR(data)) {
- // BLGCRMOW
+ uint8_t attr = ATTR(data);
+
+ if (!BW && G.last_attr != attr) {
+// Attribute layout for VGA compatible text videobuffer:
+// blinking text
+// |red bkgd
+// ||green bkgd
+// |||blue bkgd
+// vvvv
+// 00000000 <- lsb bit on the right
+// bold text / text 8th bit
+// red text
+// green text
+// blue text
+// TODO: apparently framebuffer-based console uses different layout
+// (bug? attempt to get 8th text bit in better position?)
+// red bkgd
+// |green bkgd
+// ||blue bkgd
+// vvv
+// 00000000 <- lsb bit on the right
+// bold text
+// red text
+// green text
+// blue text
+// text 8th bit
+ // converting RGB color bit triad to BGR:
static const char color[8] = "04261537";
+ G.last_attr = attr;
printf("\033[%c;4%c;3%cm",
- (ATTR(data) & 8) ? '1' // bold
- : '0', // defaults
- color[(ATTR(data) >> 4) & 7], color[ATTR(data) & 7]);
- G.last_attr = ATTR(data);
+ (attr & 8) ? '1' : '0', // bold text / reset all
+ color[(attr >> 4) & 7], // bkgd color
+ color[attr & 7] // text color
+ );
}
- bb_putchar(CHAR(data));
+ putchar(CHAR(data));
}
#define clrscr() printf("\033[1;1H" "\033[0J")