Module: Thaum::Sigil

Included in:
Button, Checkbox, ProgressBar, ScrollView, Select, Spinner, StatusBar, Table, Tabs, Text, TextInput
Defined in:
lib/thaum/sigil.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handler_parentObject

Returns the value of attribute handler_parent.



5
6
7
# File 'lib/thaum/sigil.rb', line 5

def handler_parent
  @handler_parent
end

#rectObject

Returns the value of attribute rect.



5
6
7
# File 'lib/thaum/sigil.rb', line 5

def rect
  @rect
end

#thaum_appObject

Returns the value of attribute thaum_app.



5
6
7
# File 'lib/thaum/sigil.rb', line 5

def thaum_app
  @thaum_app
end

Instance Method Details

#emit(event) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/thaum/sigil.rb', line 12

def emit(event)
  app = @thaum_app or return
  raise Thaum::EmitFromUpdateError, "emit called from on_update" if app.in_on_update

  if event.is_a?(Thaum::TickEvent) || event.is_a?(Thaum::ResizeEvent)
    warn "[Thaum] dropping #{event.class} from #{self.class}: " \
         "framework-internal events cannot be emitted from Sigils or Actions"
    return
  end

  (@handler_parent || app).dispatch_from_child(event)
end

#focusable?Boolean

Returns:

  • (Boolean)


9
# File 'lib/thaum/sigil.rb', line 9

def focusable?  = true

#focused?Boolean

The safe-nav ‘&.` makes `focused_sigil` nil when no app is set; nil.equal?(self) is false.

Returns:

  • (Boolean)


8
# File 'lib/thaum/sigil.rb', line 8

def focused?    = @thaum_app&.focused_sigil.equal?(self)

#on_blurObject



37
# File 'lib/thaum/sigil.rb', line 37

def on_blur;              end

#on_focusObject



36
# File 'lib/thaum/sigil.rb', line 36

def on_focus;             end

#on_key(event) ⇒ Object

Terminal event handlers — defaults propagate via emit



29
# File 'lib/thaum/sigil.rb', line 29

def on_key(event)   = emit(event)

#on_mountObject

Lifecycle — override for side effects



34
# File 'lib/thaum/sigil.rb', line 34

def on_mount;             end

#on_mouse(event) ⇒ Object



30
# File 'lib/thaum/sigil.rb', line 30

def on_mouse(event) = emit(event)

#on_paste(event) ⇒ Object



31
# File 'lib/thaum/sigil.rb', line 31

def on_paste(event) = emit(event)

#on_tick(event) ⇒ Object



39
# File 'lib/thaum/sigil.rb', line 39

def on_tick(event);       end

#on_unmountObject



35
# File 'lib/thaum/sigil.rb', line 35

def on_unmount;           end

#on_update(context) ⇒ Object



38
# File 'lib/thaum/sigil.rb', line 38

def on_update(context);   end

#render(canvas:, theme:) ⇒ Object

Rendering — override in subclass



26
# File 'lib/thaum/sigil.rb', line 26

def render(canvas:, theme:); end

#request_renderObject



10
# File 'lib/thaum/sigil.rb', line 10

def request_render = @thaum_app&.request_render