Module: Thaum::App

Instance Attribute Summary collapse

Attributes included from Concerns::Layout

#child_layouts, #leaf_sigils, #rect, #subtree_children, #subtree_leaves

Instance Method Summary collapse

Methods included from Concerns::TabNavigation

#handle_tab_cycle

Methods included from Concerns::Modal

#hide_modal, #modal_active?, #recompute_modal_rect, #show_modal

Methods included from Concerns::ContextUpdate

#update_context

Methods included from Concerns::Focus

#focus, #focus_next, #focus_prev, #focused_sigil, #initial_focus

Methods included from Concerns::Layout

#collect_octagrams, #effective_focus_order, #first_focusable_leaf, #focus_order, #focus_scope_units, #focusable_descendant?, #inset_for_partition, #last_focusable_leaf, #layout_subtree_in_order, #partition, #repartition, #run_partition, #validate_focus_order_tree, #wire_handler_parents

Instance Attribute Details

#in_on_updateObject (readonly)

Returns the value of attribute in_on_update.



11
12
13
# File 'lib/thaum/app.rb', line 11

def in_on_update
  @in_on_update
end

Returns the value of attribute modal_rect.



11
12
13
# File 'lib/thaum/app.rb', line 11

def modal_rect
  @modal_rect
end

Returns the value of attribute modal_sigil.



11
12
13
# File 'lib/thaum/app.rb', line 11

def modal_sigil
  @modal_sigil
end

Instance Method Details

#clear_dirtyObject



22
# File 'lib/thaum/app.rb', line 22

def clear_dirty = (@dirty = false)

#dirty?Boolean

Returns:

  • (Boolean)


21
# File 'lib/thaum/app.rb', line 21

def dirty? = @dirty

#dispatch_from_child(event) ⇒ Object Also known as: dispatch_from_sigil

A child here is either the focused Sigil (when it emits) or the outermost Octagram (which propagates from its own children). Tab cycling is intercepted before App#on_key so handlers see :tab with focus already updated.



44
45
46
47
48
49
50
51
52
53
# File 'lib/thaum/app.rb', line 44

def dispatch_from_child(event)
  # When a modal is active, bubbled Tab/Shift-Tab is eaten. Other
  # bubbled events still reach App handlers — emit from the modal Sigil
  # can therefore reach App#on_event so apps can react to modal events.
  return if @modal_sigil && event.is_a?(KeyEvent) && event.key == :tab

  handle_tab_cycle(event) if event.is_a?(KeyEvent) && event.key == :tab

  Dispatch.invoke_handler(target: self, event:, label: "App##{handler_name_for(event)}")
end

#on_event(event) ⇒ Object



70
71
72
# File 'lib/thaum/app.rb', line 70

def on_event(event)
  warn "[Thaum] unhandled event: #{event.class} #{event.inspect}"
end

#on_key(event) ⇒ Object

— Default App handlers (no-ops — App is top of dispatch chain) —



62
# File 'lib/thaum/app.rb', line 62

def on_key(event);      end

#on_mountObject



67
# File 'lib/thaum/app.rb', line 67

def on_mount;           end

#on_mouse(event) ⇒ Object



63
# File 'lib/thaum/app.rb', line 63

def on_mouse(event);    end

#on_paste(event) ⇒ Object



64
# File 'lib/thaum/app.rb', line 64

def on_paste(event);    end

#on_resize(event) ⇒ Object



65
# File 'lib/thaum/app.rb', line 65

def on_resize(event);   end

#on_tick(event) ⇒ Object



66
# File 'lib/thaum/app.rb', line 66

def on_tick(event);     end

#on_unmountObject



68
# File 'lib/thaum/app.rb', line 68

def on_unmount;         end

#quitObject

— Quit —



15
# File 'lib/thaum/app.rb', line 15

def quit = (@quit_requested = true)

#quit?Boolean

Returns:

  • (Boolean)


16
# File 'lib/thaum/app.rb', line 16

def quit? = @quit_requested

#request_renderObject

— Render dirty flag —



20
# File 'lib/thaum/app.rb', line 20

def request_render = (@dirty = true)

#set_initial_focus(sigil) ⇒ Object

Used by the run loop to seed the initially-focused Sigil before entering the main loop. Bypasses Focus#focus’s mount check because the mount pass has already run.



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

def set_initial_focus(sigil) = (@focused_sigil = sigil)

#thaum_app_refObject



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

def thaum_app_ref = self

#themeObject

— Theme (override to choose a non-default theme for this app) —



58
# File 'lib/thaum/app.rb', line 58

def theme = Themes::DEFAULT

#wire_sigilsObject

— Mount wiring —



26
27
28
29
# File 'lib/thaum/app.rb', line 26

def wire_sigils
  (@leaf_sigils || []).each { |s| s.thaum_app = self }
  wire_handler_parents(handler_parent: self, app: self)
end