aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-05 11:42:29 -0700
committerPierre-Alexandre Meyer <pierre@mouraf.org>2009-09-05 11:42:29 -0700
commit71fb86d8596fb12a6ddf1d182116044406b2b8ca (patch)
tree6fce8b0c45d6ed3069ed5fac9d48744550a8694a /com32
parent000488937dfc3748dc287600c5f92f76880120ec (diff)
downloadsyslinux-71fb86d8596fb12a6ddf1d182116044406b2b8ca.tar.gz
syslinux-71fb86d8596fb12a6ddf1d182116044406b2b8ca.tar.xz
syslinux-71fb86d8596fb12a6ddf1d182116044406b2b8ca.zip
libansi: correctly reset attributes
When resetting the attributes, we were updating last_attr to the unknown value 0x300, which doesn't always work. For instance, when requesting reset and normal attributes, i.e. "\e[0;30;47m" with the previous attribute being "\e[1;30;47m", we where printing "\e[0;47m", which behaves like "\e[0;39;47m". This is incorrect. This patch adds a flag to explicitly set background and foreground colors after a reset. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
Diffstat (limited to 'com32')
-rw-r--r--com32/lib/sys/libansi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/com32/lib/sys/libansi.c b/com32/lib/sys/libansi.c
index bb2a220a..1c29aea0 100644
--- a/com32/lib/sys/libansi.c
+++ b/com32/lib/sys/libansi.c
@@ -121,6 +121,7 @@ static void cprint_vga2ansi(const char chr, const char attr)
char buf[16], *p;
if (attr != last_attr) {
+ bool reset = false;
p = buf;
*p++ = '\033';
*p++ = '[';
@@ -131,6 +132,7 @@ static void cprint_vga2ansi(const char chr, const char attr)
/* Reset last_attr to unknown to handle
* background/foreground attributes correctly */
last_attr = 0x300;
+ reset = true;
}
if (attr & 0x08) {
*p++ = '1';
@@ -140,12 +142,12 @@ static void cprint_vga2ansi(const char chr, const char attr)
*p++ = '4';
*p++ = ';';
}
- if ((attr ^ last_attr) & 0x07) {
+ if (reset || (attr ^ last_attr) & 0x07) {
*p++ = '3';
*p++ = ansi_char[attr & 7];
*p++ = ';';
}
- if ((attr ^ last_attr) & 0x70) {
+ if (reset || (attr ^ last_attr) & 0x70) {
*p++ = '4';
*p++ = ansi_char[(attr >> 4) & 7];
*p++ = ';';