Class: Echoes::Tab
- Inherits:
-
Object
- Object
- Echoes::Tab
- Defined in:
- lib/echoes/tab.rb
Instance Attribute Summary collapse
-
#pane_tree ⇒ Object
readonly
Returns the value of attribute pane_tree.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#active_pane ⇒ Object
— Active pane delegation (backward compatibility) —.
-
#alive? ⇒ Boolean
— Lifecycle —.
- #close ⇒ Object
- #close_active_pane ⇒ Object
-
#initialize(command:, rows:, cols:, cwd: nil, embedded: false, editor_file: nil) ⇒ Tab
constructor
A new instance of Tab.
- #next_pane ⇒ Object
- #panes ⇒ Object
- #parser ⇒ Object
- #prev_pane ⇒ Object
- #pty_pid ⇒ Object
- #pty_read ⇒ Object
- #pty_write ⇒ Object
- #read_available_output(max = 16384) ⇒ Object
- #resize(rows, cols) ⇒ Object
- #screen ⇒ Object
- #scroll_accum ⇒ Object
- #scroll_accum=(val) ⇒ Object
- #scroll_offset ⇒ Object
- #scroll_offset=(val) ⇒ Object
- #split_horizontal ⇒ Object
-
#split_vertical ⇒ Object
— Pane operations —.
- #submit_line(line) ⇒ Object
- #write_input(bytes) ⇒ Object
Constructor Details
#initialize(command:, rows:, cols:, cwd: nil, embedded: false, editor_file: nil) ⇒ Tab
Returns a new instance of Tab.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/echoes/tab.rb', line 8 def initialize(command:, rows:, cols:, cwd: nil, embedded: false, editor_file: nil) @command = command @rows = rows @cols = cols @embedded = pane = Pane.new(command: command, rows: rows, cols: cols, cwd: cwd, embedded: , editor_file: editor_file) @pane_tree = PaneTree.new(pane) @title = pane.title end |
Instance Attribute Details
#pane_tree ⇒ Object (readonly)
Returns the value of attribute pane_tree.
5 6 7 |
# File 'lib/echoes/tab.rb', line 5 def pane_tree @pane_tree end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/echoes/tab.rb', line 6 def title @title end |
Instance Method Details
#active_pane ⇒ Object
— Active pane delegation (backward compatibility) —
21 22 23 |
# File 'lib/echoes/tab.rb', line 21 def active_pane @pane_tree.active_pane end |
#alive? ⇒ Boolean
— Lifecycle —
125 126 127 |
# File 'lib/echoes/tab.rb', line 125 def alive? panes.any?(&:alive?) end |
#close ⇒ Object
135 136 137 |
# File 'lib/echoes/tab.rb', line 135 def close panes.each(&:close) end |
#close_active_pane ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/echoes/tab.rb', line 101 def close_active_pane return false if @pane_tree.single_pane? pane = active_pane @pane_tree.remove(pane) pane.close resize_panes true end |
#next_pane ⇒ Object
111 112 113 |
# File 'lib/echoes/tab.rb', line 111 def next_pane @pane_tree.active_pane = @pane_tree.next_pane(active_pane) end |
#panes ⇒ Object
119 120 121 |
# File 'lib/echoes/tab.rb', line 119 def panes @pane_tree.panes end |
#parser ⇒ Object
29 30 31 |
# File 'lib/echoes/tab.rb', line 29 def parser active_pane.parser end |
#prev_pane ⇒ Object
115 116 117 |
# File 'lib/echoes/tab.rb', line 115 def prev_pane @pane_tree.active_pane = @pane_tree.prev_pane(active_pane) end |
#pty_pid ⇒ Object
41 42 43 |
# File 'lib/echoes/tab.rb', line 41 def pty_pid active_pane.pty_pid end |
#pty_read ⇒ Object
33 34 35 |
# File 'lib/echoes/tab.rb', line 33 def pty_read active_pane.pty_read end |
#pty_write ⇒ Object
37 38 39 |
# File 'lib/echoes/tab.rb', line 37 def pty_write active_pane.pty_write end |
#read_available_output(max = 16384) ⇒ Object
53 54 55 |
# File 'lib/echoes/tab.rb', line 53 def read_available_output(max = 16384) active_pane.read_available_output(max) end |
#resize(rows, cols) ⇒ Object
129 130 131 132 133 |
# File 'lib/echoes/tab.rb', line 129 def resize(rows, cols) @rows = rows @cols = cols resize_panes end |
#screen ⇒ Object
25 26 27 |
# File 'lib/echoes/tab.rb', line 25 def screen active_pane.screen end |
#scroll_accum ⇒ Object
65 66 67 |
# File 'lib/echoes/tab.rb', line 65 def scroll_accum active_pane.scroll_accum end |
#scroll_accum=(val) ⇒ Object
69 70 71 |
# File 'lib/echoes/tab.rb', line 69 def scroll_accum=(val) active_pane.scroll_accum = val end |
#scroll_offset ⇒ Object
57 58 59 |
# File 'lib/echoes/tab.rb', line 57 def scroll_offset active_pane.scroll_offset end |
#scroll_offset=(val) ⇒ Object
61 62 63 |
# File 'lib/echoes/tab.rb', line 61 def scroll_offset=(val) active_pane.scroll_offset = val end |
#split_horizontal ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/echoes/tab.rb', line 88 def split_horizontal new_pane = create_pane layout = @pane_tree.layout(0, 0, @cols, @rows) current_rect = layout.find { |r| r[:pane] == active_pane } if current_rect half_rows = current_rect[:h] / 2 active_pane.resize(half_rows, current_rect[:w]) new_pane.resize(current_rect[:h] - half_rows, current_rect[:w]) end @pane_tree.split(active_pane, :horizontal, new_pane) new_pane end |
#split_vertical ⇒ Object
— Pane operations —
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/echoes/tab.rb', line 75 def split_vertical new_pane = create_pane layout = @pane_tree.layout(0, 0, @cols, @rows) current_rect = layout.find { |r| r[:pane] == active_pane } if current_rect half_cols = current_rect[:w] / 2 active_pane.resize(current_rect[:h], half_cols) new_pane.resize(current_rect[:h], current_rect[:w] - half_cols) end @pane_tree.split(active_pane, :vertical, new_pane) new_pane end |
#submit_line(line) ⇒ Object
49 50 51 |
# File 'lib/echoes/tab.rb', line 49 def submit_line(line) active_pane.submit_line(line) end |
#write_input(bytes) ⇒ Object
45 46 47 |
# File 'lib/echoes/tab.rb', line 45 def write_input(bytes) active_pane.write_input(bytes) end |