Class: Fatty::Renderer
- Inherits:
-
Object
show all
- Defined in:
- lib/fatty/renderer.rb,
lib/fatty/renderer/curses.rb,
lib/fatty/renderer/truecolor.rb
Overview
The Renderer class implements drawing the elements of a Fatty terminal
(output, input, alert, status, and popups) on the screen. There are two
ways of doing so: (1) using normal curses operations with curses-defined
pairs and (2) using ANSI codes to write with a Truecolor full-color
palette. This class is the base class for those two rendering methods and
provides methods common to them.
Defined Under Namespace
Classes: Curses, Truecolor
Constant Summary
collapse
- FRAME_STYLES =
{
ascii: { h: "-", v: "|" },
single: { h: "─", v: "│" },
double: { h: "═", v: "║" },
}.freeze
- CORNER_STYLES =
{
square: {
ascii: { tl: "+", tr: "+", bl: "+", br: "+" },
single: { tl: "┌", tr: "┐", bl: "└", br: "┘" },
double: { tl: "╔", tr: "╗", bl: "╚", br: "╝" },
},
rounded: {
single: { tl: "╭", tr: "╮", bl: "╰", br: "╯" },
},
}.freeze
"▶ "
" "
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(screen:, palette:, context:) ⇒ Renderer
Returns a new instance of Renderer.
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/fatty/renderer.rb', line 42
def initialize(screen:, palette:, context:)
@screen = screen
@palette = palette
@context = context
@last_status_state = nil
@last_alert_state = nil
@last_output_state = nil
@last_popup_state = nil
@last_prompt_popup_state = nil
@last_pager_field_state = nil
@theme_version = 0
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
40
41
42
|
# File 'lib/fatty/renderer.rb', line 40
def context
@context
end
|
#palette ⇒ Object
Returns the value of attribute palette.
40
41
42
|
# File 'lib/fatty/renderer.rb', line 40
def palette
@palette
end
|
#screen ⇒ Object
Returns the value of attribute screen.
40
41
42
|
# File 'lib/fatty/renderer.rb', line 40
def screen
@screen
end
|
#theme_version ⇒ Object
Returns the value of attribute theme_version.
40
41
42
|
# File 'lib/fatty/renderer.rb', line 40
def theme_version
@theme_version
end
|
Instance Method Details
#apply_theme!(theme) ⇒ Object
80
81
82
|
# File 'lib/fatty/renderer.rb', line 80
def clear_input_field(...)
raise NotImplementedError, "#{self.class} must implement #clear_input_field"
end
|
#hide_cursor ⇒ Object
114
115
|
# File 'lib/fatty/renderer.rb', line 114
def hide_cursor
end
|
#invalidate! ⇒ Object
104
105
106
107
108
109
110
111
112
|
# File 'lib/fatty/renderer.rb', line 104
def invalidate!
@last_output_state = nil
@last_input_state = nil
@last_alert_state = nil
@last_status_state = nil
@last_pager_field_state = nil
@last_popup_state = nil
@last_prompt_popup_state = nil
end
|
#render_alert ⇒ Object
100
101
102
|
# File 'lib/fatty/renderer.rb', line 100
def render_alert(...)
raise NotImplementedError, "#{self.class} must implement #render_alert"
end
|
76
77
78
|
# File 'lib/fatty/renderer.rb', line 76
def render_input_field(...)
raise NotImplementedError, "#{self.class} must implement #render_input_field"
end
|
#render_output ⇒ Object
68
69
70
|
# File 'lib/fatty/renderer.rb', line 68
def render_output(...)
raise NotImplementedError, "#{self.class} must implement #render_output"
end
|
88
89
90
|
# File 'lib/fatty/renderer.rb', line 88
def (...)
raise NotImplementedError, "#{self.class} must implement #render_pager_field"
end
|
92
93
94
|
# File 'lib/fatty/renderer.rb', line 92
def (...)
raise NotImplementedError, "#{self.class} must implement #render_popup"
end
|
96
97
98
|
# File 'lib/fatty/renderer.rb', line 96
def (...)
raise NotImplementedError, "#{self.class} must implement #render_prompt_popup"
end
|
#render_status ⇒ Object
72
73
74
|
# File 'lib/fatty/renderer.rb', line 72
def render_status(...)
raise NotImplementedError, "#{self.class} must implement #render_status"
end
|
#restore_cursor ⇒ Object
84
85
86
|
# File 'lib/fatty/renderer.rb', line 84
def restore_cursor(...)
raise NotImplementedError, "#{self.class} must implement #restore_cursor"
end
|
#show_cursor ⇒ Object
117
118
|
# File 'lib/fatty/renderer.rb', line 117
def show_cursor
end
|