Class: Thaum::Text

Inherits:
Object
  • Object
show all
Includes:
Sigil
Defined in:
lib/thaum/sigils/text.rb

Instance Attribute Summary collapse

Attributes included from Sigil

#handler_parent, #rect, #thaum_app

Instance Method Summary collapse

Methods included from Sigil

#emit, #focused?, #on_blur, #on_focus, #on_key, #on_mount, #on_mouse, #on_paste, #on_tick, #on_unmount, #on_update, #request_render

Constructor Details

#initialize(content:, align: :left, wrap: :none) ⇒ Text

Returns a new instance of Text.



9
10
11
12
13
# File 'lib/thaum/sigils/text.rb', line 9

def initialize(content:, align: :left, wrap: :none)
  @content = content
  @align   = align
  @wrap    = wrap
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/thaum/sigils/text.rb', line 7

def content
  @content
end

Instance Method Details

#focusable?Boolean

Returns:

  • (Boolean)


15
# File 'lib/thaum/sigils/text.rb', line 15

def focusable? = false

#render(canvas:, theme:) ⇒ Object



17
18
19
20
# File 'lib/thaum/sigils/text.rb', line 17

def render(canvas:, theme:)
  resolved = content.respond_to?(:call) ? content.call : content
  canvas.text(content: resolved.to_s, fg: theme.fg, align: @align, wrap: @wrap)
end