From 481d45d0f8e0e5ee63a39f950660b7305ff88d5e Mon Sep 17 00:00:00 2001 From: Stanislav Spassov Date: Sat, 3 Aug 2019 19:32:57 +0200 Subject: [PATCH 1/2] 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:" From a1cca0995b1cfba86eb6cf93db86d0c7c20850f8 Mon Sep 17 00:00:00 2001 From: Stanislav Spassov Date: Sat, 3 Aug 2019 19:34:43 +0200 Subject: [PATCH 2/2] Add support for ECMA-48 escape sequence for crossed-out/strikethrough 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 --- src/terminal/terminalframebuffer.cc | 4 +++- src/terminal/terminalframebuffer.h | 2 +- src/tests/emulation-attributes.test | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/terminal/terminalframebuffer.cc b/src/terminal/terminalframebuffer.cc index ea7ad55ee..344b8749f 100644 --- a/src/terminal/terminalframebuffer.cc +++ b/src/terminal/terminalframebuffer.cc @@ -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; @@ -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 */ } } @@ -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 ) ) { diff --git a/src/terminal/terminalframebuffer.h b/src/terminal/terminalframebuffer.h index de9386977..3ecd1e80a 100644 --- a/src/terminal/terminalframebuffer.h +++ b/src/terminal/terminalframebuffer.h @@ -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; diff --git a/src/tests/emulation-attributes.test b/src/tests/emulation-attributes.test index 336392c4f..c2e716ef1 100755 --- a/src/tests/emulation-attributes.test +++ b/src/tests/emulation-attributes.test @@ -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 ;;