From 8d2dcd9113c5d970cb336bee0efe73e7cdccc92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 13 Sep 2023 12:51:09 +0200 Subject: ColorizedString : small improvement --- lib/colonial_twilight/colorized_string.rb | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/colonial_twilight/colorized_string.rb b/lib/colonial_twilight/colorized_string.rb index 640bcca..db13bbd 100644 --- a/lib/colonial_twilight/colorized_string.rb +++ b/lib/colonial_twilight/colorized_string.rb @@ -18,12 +18,13 @@ class String @color_codes.default = 9 @color_modes = { default: 0, # Turn off all attributes - bold: 1, # Set bold mode - italic: 3, # Set italic mode - underline: 4, # Set underline mode - blink: 5, # Set blink mode - swap: 7, # Exchange foreground and background colors - hide: 8 # Hide text (foreground color would be the same as background) + bold: 1, + dim: 2, + italic: 3, + underline: 4, + blink: 5, + swap: 7, # Exchange foreground and background colors + hide: 8 # Hide text (foreground color would be the same as background) } @color_modes.default = 0 @syms = %i[fg bg mode] @@ -68,9 +69,18 @@ class String # replace all not ending reset with ascii code if self =~ START_CODE prev_start_code = ::Regexp.last_match(1) - code = "\033[#{prev_start_code};#{code}m" - s = sub(START_CODE, code).gsub(/(?