Class: AsciinemaWin::AnsiParser::StyleState
- Inherits:
-
Object
- Object
- AsciinemaWin::AnsiParser::StyleState
- Defined in:
- lib/asciinema_win/ansi_parser.rb
Overview
Current text style state
Instance Attribute Summary collapse
-
#bg ⇒ Integer?
Background color (ANSI code or 256-color index).
-
#bg_rgb ⇒ String?
RGB background (#rrggbb).
-
#bold ⇒ Boolean
Bold/bright text.
-
#fg ⇒ Integer?
Foreground color (ANSI code or 256-color index).
-
#fg_rgb ⇒ String?
RGB foreground (#rrggbb).
-
#italic ⇒ Boolean
Italic text.
-
#strikethrough ⇒ Boolean
Strikethrough text.
-
#underline ⇒ Boolean
Underlined text.
Instance Method Summary collapse
-
#effective_bg ⇒ Integer, ...
Get effective background color.
-
#effective_fg ⇒ Integer, ...
Get effective foreground color.
-
#initialize ⇒ StyleState
constructor
A new instance of StyleState.
-
#reset ⇒ void
Reset all attributes to default.
-
#to_styled_char(char) ⇒ StyledChar
Create a StyledChar from current state.
Constructor Details
#initialize ⇒ StyleState
Returns a new instance of StyleState.
58 59 60 |
# File 'lib/asciinema_win/ansi_parser.rb', line 58 def initialize reset end |
Instance Attribute Details
#bg ⇒ Integer?
Returns Background color (ANSI code or 256-color index).
38 39 40 |
# File 'lib/asciinema_win/ansi_parser.rb', line 38 def bg @bg end |
#bg_rgb ⇒ String?
Returns RGB background (#rrggbb).
56 57 58 |
# File 'lib/asciinema_win/ansi_parser.rb', line 56 def bg_rgb @bg_rgb end |
#bold ⇒ Boolean
Returns Bold/bright text.
41 42 43 |
# File 'lib/asciinema_win/ansi_parser.rb', line 41 def bold @bold end |
#fg ⇒ Integer?
Returns Foreground color (ANSI code or 256-color index).
35 36 37 |
# File 'lib/asciinema_win/ansi_parser.rb', line 35 def fg @fg end |
#fg_rgb ⇒ String?
Returns RGB foreground (#rrggbb).
53 54 55 |
# File 'lib/asciinema_win/ansi_parser.rb', line 53 def fg_rgb @fg_rgb end |
#italic ⇒ Boolean
Returns Italic text.
44 45 46 |
# File 'lib/asciinema_win/ansi_parser.rb', line 44 def italic @italic end |
#strikethrough ⇒ Boolean
Returns Strikethrough text.
50 51 52 |
# File 'lib/asciinema_win/ansi_parser.rb', line 50 def strikethrough @strikethrough end |
#underline ⇒ Boolean
Returns Underlined text.
47 48 49 |
# File 'lib/asciinema_win/ansi_parser.rb', line 47 def underline @underline end |
Instance Method Details
#effective_bg ⇒ Integer, ...
Get effective background color
86 87 88 |
# File 'lib/asciinema_win/ansi_parser.rb', line 86 def effective_bg bg_rgb || bg end |
#effective_fg ⇒ Integer, ...
Get effective foreground color
79 80 81 |
# File 'lib/asciinema_win/ansi_parser.rb', line 79 def effective_fg fg_rgb || fg end |
#reset ⇒ void
This method returns an undefined value.
Reset all attributes to default
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/asciinema_win/ansi_parser.rb', line 65 def reset @fg = nil @bg = nil @bold = false @italic = false @underline = false @strikethrough = false @fg_rgb = nil @bg_rgb = nil end |
#to_styled_char(char) ⇒ StyledChar
Create a StyledChar from current state
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/asciinema_win/ansi_parser.rb', line 94 def to_styled_char(char) StyledChar.new( char: char, fg: effective_fg, bg: effective_bg, bold: @bold, italic: @italic, underline: @underline, strikethrough: @strikethrough ) end |