Module: Thaum::App
- Includes:
- Concerns::ContextUpdate, Concerns::Focus, Concerns::Layout, Concerns::Modal, Concerns::TabNavigation
- Defined in:
- lib/thaum/app.rb
Instance Attribute Summary collapse
-
#in_on_update ⇒ Object
readonly
Returns the value of attribute in_on_update.
-
#modal_rect ⇒ Object
readonly
Returns the value of attribute modal_rect.
-
#modal_sigil ⇒ Object
readonly
Returns the value of attribute modal_sigil.
Attributes included from Concerns::Layout
#child_layouts, #leaf_sigils, #rect, #subtree_children, #subtree_leaves
Instance Method Summary collapse
- #clear_dirty ⇒ Object
- #dirty? ⇒ Boolean
-
#dispatch_from_child(event) ⇒ Object
(also: #dispatch_from_sigil)
A child here is either the focused Sigil (when it emits) or the outermost Octagram (which propagates from its own children).
- #on_event(event) ⇒ Object
-
#on_key(event) ⇒ Object
— Default App handlers (no-ops — App is top of dispatch chain) —.
- #on_mount ⇒ Object
- #on_mouse(event) ⇒ Object
- #on_paste(event) ⇒ Object
- #on_resize(event) ⇒ Object
- #on_tick(event) ⇒ Object
- #on_unmount ⇒ Object
-
#quit ⇒ Object
— Quit —.
- #quit? ⇒ Boolean
-
#request_render ⇒ Object
— Render dirty flag —.
-
#set_initial_focus(sigil) ⇒ Object
Used by the run loop to seed the initially-focused Sigil before entering the main loop.
- #thaum_app_ref ⇒ Object
-
#theme ⇒ Object
— Theme (override to choose a non-default theme for this app) —.
-
#wire_sigils ⇒ Object
— Mount wiring —.
Methods included from Concerns::TabNavigation
Methods included from Concerns::Modal
#hide_modal, #modal_active?, #recompute_modal_rect, #show_modal
Methods included from Concerns::ContextUpdate
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_update ⇒ Object (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 |
#modal_rect ⇒ Object (readonly)
Returns the value of attribute modal_rect.
11 12 13 |
# File 'lib/thaum/app.rb', line 11 def modal_rect @modal_rect end |
#modal_sigil ⇒ Object (readonly)
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_dirty ⇒ Object
22 |
# File 'lib/thaum/app.rb', line 22 def clear_dirty = (@dirty = false) |
#dirty? ⇒ 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_mount ⇒ Object
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_unmount ⇒ Object
68 |
# File 'lib/thaum/app.rb', line 68 def on_unmount; end |
#quit ⇒ Object
— Quit —
15 |
# File 'lib/thaum/app.rb', line 15 def quit = (@quit_requested = true) |
#quit? ⇒ Boolean
16 |
# File 'lib/thaum/app.rb', line 16 def quit? = @quit_requested |
#request_render ⇒ Object
— 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_ref ⇒ Object
31 |
# File 'lib/thaum/app.rb', line 31 def thaum_app_ref = self |
#theme ⇒ Object
— Theme (override to choose a non-default theme for this app) —
58 |
# File 'lib/thaum/app.rb', line 58 def theme = Themes::DEFAULT |
#wire_sigils ⇒ Object
— 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 |