Class: Charming::Internal::Terminal::MemoryBackend
- Inherits:
-
Object
- Object
- Charming::Internal::Terminal::MemoryBackend
- Includes:
- Adapter
- Defined in:
- lib/charming/internal/terminal/memory_backend.rb
Instance Attribute Summary collapse
-
#frames ⇒ Object
readonly
Returns the value of attribute frames.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
Instance Method Summary collapse
- #clear ⇒ Object
- #disable_mouse_tracking ⇒ Object
- #enable_mouse_tracking ⇒ Object
- #enter_alt_screen ⇒ Object
- #hide_cursor ⇒ Object
-
#initialize(events: [], width: 80, height: 24) ⇒ MemoryBackend
constructor
A new instance of MemoryBackend.
- #leave_alt_screen ⇒ Object
- #mouse_enabled? ⇒ Boolean
- #move_cursor(row, column) ⇒ Object
- #read_event(timeout: nil) ⇒ Object
- #show_cursor ⇒ Object
- #size ⇒ Object
- #write_frame(frame) ⇒ Object
- #write_lines(line_changes, frame: nil) ⇒ Object
Constructor Details
#initialize(events: [], width: 80, height: 24) ⇒ MemoryBackend
Returns a new instance of MemoryBackend.
11 12 13 14 15 16 17 18 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 11 def initialize(events: [], width: 80, height: 24) @events = events.dup @width = width @height = height @frames = [] @operations = [] @mouse_enabled = false end |
Instance Attribute Details
#frames ⇒ Object (readonly)
Returns the value of attribute frames.
9 10 11 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 9 def frames @frames end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
9 10 11 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 9 def operations @operations end |
Instance Method Details
#clear ⇒ Object
53 54 55 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 53 def clear @operations << :clear end |
#disable_mouse_tracking ⇒ Object
70 71 72 73 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 70 def disable_mouse_tracking @mouse_enabled = false @operations << :disable_mouse_tracking end |
#enable_mouse_tracking ⇒ Object
65 66 67 68 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 65 def enable_mouse_tracking @mouse_enabled = true @operations << :enable_mouse_tracking end |
#enter_alt_screen ⇒ Object
37 38 39 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 37 def enter_alt_screen @operations << :enter_alt_screen end |
#hide_cursor ⇒ Object
49 50 51 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 49 def hide_cursor @operations << :hide_cursor end |
#leave_alt_screen ⇒ Object
41 42 43 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 41 def leave_alt_screen @operations << :leave_alt_screen end |
#mouse_enabled? ⇒ Boolean
75 76 77 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 75 def mouse_enabled? @mouse_enabled end |
#move_cursor(row, column) ⇒ Object
57 58 59 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 57 def move_cursor(row, column) @operations << [:move_cursor, row, column] end |
#read_event(timeout: nil) ⇒ Object
20 21 22 23 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 20 def read_event(timeout: nil) @operations << [:read_event, timeout] @events.shift end |
#show_cursor ⇒ Object
45 46 47 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 45 def show_cursor @operations << :show_cursor end |
#size ⇒ Object
61 62 63 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 61 def size [@width, @height] end |
#write_frame(frame) ⇒ Object
25 26 27 28 29 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 25 def write_frame(frame) @current_frame = frame @frames << frame @operations << [:write_frame, frame] end |
#write_lines(line_changes, frame: nil) ⇒ Object
31 32 33 34 35 |
# File 'lib/charming/internal/terminal/memory_backend.rb', line 31 def write_lines(line_changes, frame: nil) @current_frame = frame || apply_line_changes(line_changes) @frames << @current_frame @operations << [:write_lines, line_changes] end |