Skip to content

Commit

Permalink
Merge pull request mobile-shell#1059 from stanspas/dim-and-strikethrough
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrouhard committed Aug 20, 2023
2 parents 1105d48 + a1cca09 commit fcafbb5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/terminal/terminalframebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,17 @@ void Renditions::set_rendition( color_type num )
return;
}

bool value = num < 9;
bool value = num < 10;
switch ( num ) {
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:
Expand All @@ -505,6 +511,10 @@ void Renditions::set_rendition( color_type num )
case 28:
set_attribute( invisible, value );
break;
case 9:
case 29:
set_attribute( strikethrough, value );
break;
default:
break; /* ignore unknown rendition */
}
Expand Down Expand Up @@ -536,6 +546,8 @@ 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 ) )
Expand All @@ -546,6 +558,8 @@ std::string Renditions::sgr( void ) const
ret.append( ";7" );
if ( get_attribute( invisible ) )
ret.append( ";8" );
if ( get_attribute( strikethrough ) )
ret.append( ";9" );

if ( foreground_color ) {
// Since foreground_color is a 25-bit field, it is promoted to an int when
Expand Down
1 change: 1 addition & 0 deletions src/terminal/terminalframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Renditions
blink,
inverse,
invisible,
strikethrough,
SIZE
} attribute_type;

Expand Down
4 changes: 4 additions & 0 deletions src/tests/emulation-attributes.test
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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 All @@ -128,6 +130,8 @@ baseline()
test_true_color 7
echo "Invisible:"
test_true_color 8
echo "Strikethrough:"
test_true_color 9
echo "Bold, italic and underline:"
test_true_color 1 3 4
;;
Expand Down

0 comments on commit fcafbb5

Please sign in to comment.