Class: Muxr::Drawer

Inherits:
Object
  • Object
show all
Defined in:
lib/muxr/drawer.rb

Overview

A Drawer is a single persistent overlay pane, rendered on top of the tiled layout. Toggling visibility never tears down the underlying PTY — the drawer’s shell process and scrollback survive across hide/show.

The actual Pane is injected (rather than constructed here) so tests can exercise the visibility/state machine without spawning real shells.

‘command` records what kind of shell the drawer is hosting: nil for the default user shell (Ctrl-a ~), or the literal command string used to spawn it (e.g. “claude” for the Ctrl-a C drawer). The Application uses this to decide whether a Ctrl-a ~ / Ctrl-a C press should toggle visibility or tear down and replace the drawer with a different kind.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pane: nil, origin_cwd: nil, command: nil) ⇒ Drawer

Returns a new instance of Drawer.



18
19
20
21
22
23
# File 'lib/muxr/drawer.rb', line 18

def initialize(pane: nil, origin_cwd: nil, command: nil)
  @pane = pane
  @visible = false
  @origin_cwd = origin_cwd
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



16
17
18
# File 'lib/muxr/drawer.rb', line 16

def command
  @command
end

#origin_cwdObject (readonly)

Returns the value of attribute origin_cwd.



16
17
18
# File 'lib/muxr/drawer.rb', line 16

def origin_cwd
  @origin_cwd
end

#paneObject

Returns the value of attribute pane.



15
16
17
# File 'lib/muxr/drawer.rb', line 15

def pane
  @pane
end

#visibleObject

Returns the value of attribute visible.



15
16
17
# File 'lib/muxr/drawer.rb', line 15

def visible
  @visible
end

Instance Method Details

#closeObject



45
46
47
48
49
# File 'lib/muxr/drawer.rb', line 45

def close
  @pane&.close
  @pane = nil
  @visible = false
end

#cwdObject



41
42
43
# File 'lib/muxr/drawer.rb', line 41

def cwd
  pane&.cwd || @origin_cwd
end

#hide!Object



33
34
35
# File 'lib/muxr/drawer.rb', line 33

def hide!
  @visible = false
end

#show!Object



29
30
31
# File 'lib/muxr/drawer.rb', line 29

def show!
  @visible = true
end

#toggle!Object



37
38
39
# File 'lib/muxr/drawer.rb', line 37

def toggle!
  @visible = !@visible
end

#visible?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/muxr/drawer.rb', line 25

def visible?
  @visible
end