Skip to content

Commit

Permalink
Add support for ECMA-48 escape sequence for crossed-out/strikethrough
Browse files Browse the repository at this point in the history
ECMA-48 defines rendition mode 9 as:
  crossed-out (characters still legible but marked as to be deleted),
and mode 29 as the inverse:
  not crossed out

Modern terminals (including xterm, tmux, libvte, etc.) support rendering
strikethrough. Further, ncurses since version 6.1 includes the smxx/rmxx
user-defined terminal capabilities in the tmux and xterm-basic
databases.

Note that the new attribute still fits in the eight bits allocated for
Renditions::attributes, so there is no need to increase the size of Cell.

Signed-off-by: Stanislav Spassov <[email protected]>
  • Loading branch information
Stanislav Spassov committed Aug 5, 2019
1 parent 481d45d commit a1cca09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/terminal/terminalframebuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ 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;
Expand All @@ -502,6 +502,7 @@ void Renditions::set_rendition( color_type num )
case 5: case 25: set_attribute(blink, value); break;
case 7: case 27: set_attribute(inverse, value); break;
case 8: 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 @@ -537,6 +538,7 @@ std::string Renditions::sgr( void ) const
if ( get_attribute( blink ) ) ret.append( ";5" );
if ( get_attribute( inverse ) ) ret.append( ";7" );
if ( get_attribute( invisible ) ) ret.append( ";8" );
if ( get_attribute( strikethrough ) ) ret.append( ";9" );

if ( foreground_color ) {
if ( is_true_color( foreground_color ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/terminalframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Terminal {

class Renditions {
public:
typedef enum { bold, faint, italic, underlined, blink, inverse, invisible, SIZE } attribute_type;
typedef enum { bold, faint, italic, underlined, blink, inverse, invisible, strikethrough, SIZE } attribute_type;

private:
static const uint64_t true_color_mask = 0x1000000;
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 @@ -122,6 +122,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 a1cca09

Please sign in to comment.