summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/Terminal/Terminal.cpp46
-rw-r--r--Applications/Terminal/Terminal.h27
2 files changed, 66 insertions, 7 deletions
diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp
index 2b987e8b21..4e568dab07 100644
--- a/Applications/Terminal/Terminal.cpp
+++ b/Applications/Terminal/Terminal.cpp
@@ -16,6 +16,8 @@
#include <sys/ioctl.h>
//#define TERMINAL_DEBUG
+byte Terminal::Attribute::default_foreground_color = 7;
+byte Terminal::Attribute::default_background_color = 0;
Terminal::Terminal(int ptm_fd, RetainPtr<CConfigFile> config)
: m_ptm_fd(ptm_fd)
@@ -157,8 +159,34 @@ void Terminal::escape$m(const ParamVector& params)
m_current_attribute.reset();
break;
case 1:
- // Bold
- //m_current_attribute.bold = true;
+ m_current_attribute.flags |= Attribute::Bold;
+ break;
+ case 3:
+ m_current_attribute.flags |= Attribute::Italic;
+ break;
+ case 4:
+ m_current_attribute.flags |= Attribute::Underline;
+ break;
+ case 5:
+ m_current_attribute.flags |= Attribute::Blink;
+ break;
+ case 7:
+ m_current_attribute.flags |= Attribute::Negative;
+ break;
+ case 22:
+ m_current_attribute.flags &= ~Attribute::Bold;
+ break;
+ case 23:
+ m_current_attribute.flags &= ~Attribute::Italic;
+ break;
+ case 24:
+ m_current_attribute.flags &= ~Attribute::Underline;
+ break;
+ case 25:
+ m_current_attribute.flags &= ~Attribute::Blink;
+ break;
+ case 27:
+ m_current_attribute.flags &= ~Attribute::Negative;
break;
case 30:
case 31:
@@ -169,8 +197,14 @@ void Terminal::escape$m(const ParamVector& params)
case 36:
case 37:
// Foreground color
+ if (m_current_attribute.flags & Attribute::Bold)
+ param += 8;
m_current_attribute.foreground_color = param - 30;
break;
+ case 39:
+ // reset foreground
+ m_current_attribute.foreground_color = Attribute::default_foreground_color;
+ break;
case 40:
case 41:
case 42:
@@ -180,8 +214,16 @@ void Terminal::escape$m(const ParamVector& params)
case 46:
case 47:
// Background color
+ if (m_current_attribute.flags & Attribute::Bold)
+ param += 8;
m_current_attribute.background_color = param - 40;
break;
+ case 49:
+ // reset background
+ m_current_attribute.background_color = Attribute::default_background_color;
+ break;
+ default:
+ dbgprintf("FIXME: escape$m: p: %u\n", param);
}
}
}
diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h
index 4a84165256..13b3440cfd 100644
--- a/Applications/Terminal/Terminal.h
+++ b/Applications/Terminal/Terminal.h
@@ -77,18 +77,35 @@ private:
struct Attribute {
Attribute() { reset(); }
+
+ static byte default_foreground_color;
+ static byte default_background_color;
+
void reset()
{
- foreground_color = 7;
- background_color = 0;
- //bold = false;
+ foreground_color = default_foreground_color;
+ background_color = default_background_color;
+ flags = Flags::NoAttributes;
}
byte foreground_color;
byte background_color;
- //bool bold : 1;
+
+ enum Flags {
+ NoAttributes = 0x00,
+ Bold = 0x01,
+ Italic = 0x02,
+ Underline = 0x04,
+ Negative = 0x08,
+ Blink = 0x10,
+ };
+
+ // TODO: it would be really nice if we had a helper for enums that
+ // exposed bit ops for class enums...
+ int flags = Flags::NoAttributes;
+
bool operator==(const Attribute& other) const
{
- return foreground_color == other.foreground_color && background_color == other.background_color;
+ return foreground_color == other.foreground_color && background_color == other.background_color && flags == other.flags;
}
bool operator!=(const Attribute& other) const
{