Class: Mxup::StatusView
- Inherits:
-
Object
- Object
- Mxup::StatusView
- Defined in:
- lib/mxup/status_view.rb
Overview
Renders ‘mxup status` output.
Constant Summary collapse
- INDENT =
' '
Instance Method Summary collapse
-
#initialize(config, resolver:, out: nil) ⇒ StatusView
constructor
A new instance of StatusView.
- #out ⇒ Object
- #render(lines:) ⇒ Object
Constructor Details
#initialize(config, resolver:, out: nil) ⇒ StatusView
Returns a new instance of StatusView.
10 11 12 13 14 15 |
# File 'lib/mxup/status_view.rb', line 10 def initialize(config, resolver:, out: nil) @config = config @session = config.session @resolver = resolver @out_override = out end |
Instance Method Details
#out ⇒ Object
17 18 19 |
# File 'lib/mxup/status_view.rb', line 17 def out @out_override || $stdout end |
#render(lines:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mxup/status_view.rb', line 21 def render(lines:) unless Tmux.has_session?(@session) out.puts "SESSION: #{@session} — NOT RUNNING" out.puts "Start with: mxup up #{@session}" return end active = @resolver.active_layout created = Tmux.session_created(@session) created_at = Time.at(created.to_i).strftime('%Y-%m-%d %H:%M:%S') stored_prof = Tmux.show_environment(@session, 'MXUP_PROFILE') bits = [] bits << "profile: #{stored_prof}" if stored_prof bits << "layout: #{active}" if active suffix = bits.empty? ? '' : " (#{bits.join(', ')})" out.puts "SESSION: #{@session} — up since #{created_at}#{suffix}" out.puts panes = Tmux.list_panes(@session) declared_names = @config.windows.map(&:name) printed = Set.new order = @config.effective_window_order(active) order.each do |entry| if entry[:type] == :group render_group(entry[:group], panes, lines, printed) else render_standalone(entry[:name], panes, lines, declared_names, printed) end end render_extras(panes, lines, printed) end |