aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {
62 int kbd_fd; 62 int kbd_fd;
63 unsigned width; 63 unsigned width;
64 unsigned height; 64 unsigned height;
65 char last_attr; 65 uint8_t last_attr;
66 int ioerror_count; 66 int ioerror_count;
67 int key_count; 67 int key_count;
68 int escape_count; 68 int escape_count;
@@ -112,17 +112,43 @@ static void screen_read_close(void)
112 112
113static void screen_char(char *data) 113static void screen_char(char *data)
114{ 114{
115 if (!BW && G.last_attr != ATTR(data)) { 115 uint8_t attr = ATTR(data);
116 // BLGCRMOW 116
117 if (!BW && G.last_attr != attr) {
118// Attribute layout for VGA compatible text videobuffer:
119// blinking text
120// |red bkgd
121// ||green bkgd
122// |||blue bkgd
123// vvvv
124// 00000000 <- lsb bit on the right
125// bold text / text 8th bit
126// red text
127// green text
128// blue text
129// TODO: apparently framebuffer-based console uses different layout
130// (bug? attempt to get 8th text bit in better position?)
131// red bkgd
132// |green bkgd
133// ||blue bkgd
134// vvv
135// 00000000 <- lsb bit on the right
136// bold text
137// red text
138// green text
139// blue text
140// text 8th bit
141 // converting RGB color bit triad to BGR:
117 static const char color[8] = "04261537"; 142 static const char color[8] = "04261537";
118 143
144 G.last_attr = attr;
119 printf("\033[%c;4%c;3%cm", 145 printf("\033[%c;4%c;3%cm",
120 (ATTR(data) & 8) ? '1' // bold 146 (attr & 8) ? '1' : '0', // bold text / reset all
121 : '0', // defaults 147 color[(attr >> 4) & 7], // bkgd color
122 color[(ATTR(data) >> 4) & 7], color[ATTR(data) & 7]); 148 color[attr & 7] // text color
123 G.last_attr = ATTR(data); 149 );
124 } 150 }
125 bb_putchar(CHAR(data)); 151 putchar(CHAR(data));
126} 152}
127 153
128#define clrscr() printf("\033[1;1H" "\033[0J") 154#define clrscr() printf("\033[1;1H" "\033[0J")