Skip to content

Commit

Permalink
Add support for ECMA-48 escape sequence for faint/half-bright
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Stanislav Spassov committed Aug 3, 2019
1 parent b1da700 commit 481d45d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/terminal/terminalframebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" );
Expand Down
2 changes: 2 additions & 0 deletions src/tests/emulation-attributes.test
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down

0 comments on commit 481d45d

Please sign in to comment.