Class: Muxr::Pane
- Inherits:
-
Object
- Object
- Muxr::Pane
- Defined in:
- lib/muxr/pane.rb
Overview
A Pane bundles a Terminal emulator buffer with the PTYProcess running the shell that feeds it. The Window keeps a list of panes; the Renderer asks each pane for its current grid contents and cursor position.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
-
#rect ⇒ Object
Returns the value of attribute rect.
-
#terminal ⇒ Object
readonly
Returns the value of attribute terminal.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #close ⇒ Object
- #cwd ⇒ Object
-
#initialize(id:, rows: 24, cols: 80, cwd: nil, command: nil, process: nil) ⇒ Pane
constructor
A new instance of Pane.
- #io ⇒ Object
- #read_from_pty ⇒ Object
- #resize(rows, cols) ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(id:, rows: 24, cols: 80, cwd: nil, command: nil, process: nil) ⇒ Pane
Returns a new instance of Pane.
9 10 11 12 13 14 15 16 17 |
# File 'lib/muxr/pane.rb', line 9 def initialize(id:, rows: 24, cols: 80, cwd: nil, command: nil, process: nil) @id = id @rows = rows @cols = cols @terminal = Terminal.new(rows: rows, cols: cols) @process = process || PTYProcess.new(rows: rows, cols: cols, cwd: cwd, command: command) @rect = nil @initial_cwd = cwd || @process.cwd end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/muxr/pane.rb', line 6 def id @id end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
6 7 8 |
# File 'lib/muxr/pane.rb', line 6 def process @process end |
#rect ⇒ Object
Returns the value of attribute rect.
7 8 9 |
# File 'lib/muxr/pane.rb', line 7 def rect @rect end |
#terminal ⇒ Object (readonly)
Returns the value of attribute terminal.
6 7 8 |
# File 'lib/muxr/pane.rb', line 6 def terminal @terminal end |
Instance Method Details
#alive? ⇒ Boolean
40 41 42 |
# File 'lib/muxr/pane.rb', line 40 def alive? @process.alive? end |
#close ⇒ Object
48 49 50 |
# File 'lib/muxr/pane.rb', line 48 def close @process.close end |
#cwd ⇒ Object
44 45 46 |
# File 'lib/muxr/pane.rb', line 44 def cwd @process.cwd || @initial_cwd end |
#io ⇒ Object
19 20 21 |
# File 'lib/muxr/pane.rb', line 19 def io @process.io end |
#read_from_pty ⇒ Object
27 28 29 30 31 32 |
# File 'lib/muxr/pane.rb', line 27 def read_from_pty data = @process.read_nonblock return nil unless data @terminal.feed(data) data end |
#resize(rows, cols) ⇒ Object
34 35 36 37 38 |
# File 'lib/muxr/pane.rb', line 34 def resize(rows, cols) return if rows == @terminal.rows && cols == @terminal.cols @terminal.resize(rows, cols) @process.resize(rows, cols) end |
#write(data) ⇒ Object
23 24 25 |
# File 'lib/muxr/pane.rb', line 23 def write(data) @process.write(data) end |