Class: RSpecTelemetry::Trace::Viewer::TimelinePane

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_telemetry/trace/viewer/timeline_pane.rb

Constant Summary collapse

EXPANDED =
"- "
COLLAPSED =
"+ "
NO_CHILDREN =
"  "
EVENT_INDENT =
"    "

Instance Method Summary collapse

Constructor Details

#initialize(entries, list:, focus:, collapsed: nil, childful: nil, durations: nil) ⇒ TimelinePane

Returns a new instance of TimelinePane.



16
17
18
19
20
21
22
23
# File 'lib/rspec_telemetry/trace/viewer/timeline_pane.rb', line 16

def initialize(entries, list:, focus:, collapsed: nil, childful: nil, durations: nil)
  @entries = entries
  @list = list
  @focus = focus
  @collapsed = collapsed || []
  @childful = childful || []
  @durations = durations || {}
end

Instance Method Details

#draw(canvas, rect) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/rspec_telemetry/trace/viewer/timeline_pane.rb', line 25

def draw(canvas, rect)
  highlight = @focus ? Theme::SELECT : Theme::SELECT_BLUR
  TuiTui::List.new(@list).draw(canvas, rect, highlight: highlight, scrollbar: Theme.base) do |index, selected|
    entry = @entries[index]
    text = prefix(entry) + Label.plain(entry) + duration_suffix(entry)
    style = selected ? highlight : Theme.style(Label.category(entry))
    TuiTui::Line[TuiTui::Span[text, style]]
  end
end