From 481d45d0f8e0e5ee63a39f950660b7305ff88d5e Mon Sep 17 00:00:00 2001 From: Stanislav Spassov Date: Sat, 3 Aug 2019 19:32:57 +0200 Subject: [PATCH] Add support for ECMA-48 escape sequence for faint/half-bright ECMA-48 defines rendition mode 2 as: faint, decreased intensity or second colour Faint mode shares its inverse (22) with bold (1): normal colour or normal intensity (neither bold nor faint) The Renditions::attribute_type enum already included 'faint' but the value remained unused until now. Signed-off-by: Stanislav Spassov --- src/terminal/terminalframebuffer.cc | 8 +++++++- src/tests/emulation-attributes.test | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/terminal/terminalframebuffer.cc b/src/terminal/terminalframebuffer.cc index 2751f3b7d..ea7ad55ee 100644 --- a/src/terminal/terminalframebuffer.cc +++ b/src/terminal/terminalframebuffer.cc @@ -491,7 +491,12 @@ void Renditions::set_rendition( color_type num ) bool value = num < 9; switch ( num ) { - case 1: case 22: set_attribute(bold, value); break; + case 1: set_attribute(bold, value); break; + case 2: set_attribute(faint, value); break; + case 22: + set_attribute(bold, value); + set_attribute(faint, value); + break; case 3: case 23: set_attribute(italic, value); break; case 4: case 24: set_attribute(underlined, value); break; case 5: case 25: set_attribute(blink, value); break; @@ -526,6 +531,7 @@ std::string Renditions::sgr( void ) const ret.append( "\033[0" ); if ( get_attribute( bold ) ) ret.append( ";1" ); + if ( get_attribute( faint ) ) ret.append( ";2" ); if ( get_attribute( italic ) ) ret.append( ";3" ); if ( get_attribute( underlined ) ) ret.append( ";4" ); if ( get_attribute( blink ) ) ret.append( ";5" ); diff --git a/src/tests/emulation-attributes.test b/src/tests/emulation-attributes.test index e4ba2f3fe..336392c4f 100755 --- a/src/tests/emulation-attributes.test +++ b/src/tests/emulation-attributes.test @@ -110,6 +110,8 @@ baseline() test_true_color echo "Bold:" test_true_color 1 + echo "Faint:" + test_true_color 2 echo "Italic:" test_true_color 3 echo "Underline:"