Module: Thaum

Defined in:
lib/thaum/events.rb,
lib/thaum.rb,
lib/thaum/app.rb,
lib/thaum/seq.rb,
lib/thaum/keys.rb,
lib/thaum/rect.rb,
lib/thaum/tree.rb,
lib/thaum/color.rb,
lib/thaum/event.rb,
lib/thaum/sigil.rb,
lib/thaum/action.rb,
lib/thaum/themes.rb,
lib/thaum/painter.rb,
lib/thaum/version.rb,
lib/thaum/dispatch.rb,
lib/thaum/hit_test.rb,
lib/thaum/minitest.rb,
lib/thaum/octagram.rb,
lib/thaum/run_loop.rb,
lib/thaum/terminal.rb,
lib/thaum/key_event.rb,
lib/thaum/sigils/tabs.rb,
lib/thaum/sigils/text.rb,
lib/thaum/input_reader.rb,
lib/thaum/sigils/table.rb,
lib/thaum/escape_parser.rb,
lib/thaum/sigils/button.rb,
lib/thaum/sigils/select.rb,
lib/thaum/concerns/focus.rb,
lib/thaum/concerns/modal.rb,
lib/thaum/rendering/cell.rb,
lib/thaum/sigils/spinner.rb,
lib/thaum/concerns/layout.rb,
lib/thaum/rendering/style.rb,
lib/thaum/sigils/checkbox.rb,
lib/thaum/rendering/buffer.rb,
lib/thaum/rendering/canvas.rb,
lib/thaum/sigils/status_bar.rb,
lib/thaum/sigils/text_input.rb,
lib/thaum/rendering/renderer.rb,
lib/thaum/sigils/scroll_view.rb,
lib/thaum/sigils/progress_bar.rb,
lib/thaum/rendering/box_drawing.rb,
lib/thaum/concerns/context_update.rb,
lib/thaum/concerns/tab_navigation.rb

Overview

Framework-internal event types pushed onto the main queue by the input reader, signal traps, and the tick timer. KeyEvent has its own file because it carries modifier predicates.

Defined Under Namespace

Modules: Action, App, Color, Concerns, Dispatch, Event, HitTest, Keys, Octagram, Painter, Rendering, RunLoop, Seq, Sigil, Snapshot, SnapshotMatcher, Suspender, Themes, Tree Classes: Button, Checkbox, EmitFromUpdateError, Error, EscapeParser, FocusOrderError, InputReader, LayoutError, ProgressBar, Rect, ScrollView, Select, Spinner, StatusBar, Table, Tabs, Terminal, Text, TextInput, Theme

Constant Summary collapse

PasteEvent =
Event.define(:text)
ResizeEvent =
Event.define(:width, :height)
TickEvent =
Event.define(:time, :delta)
MouseEvent =

SGR mouse event. Actions: :press / :release / :drag / :scroll. Scroll direction is folded into ‘button` (:wheel_up / :wheel_down). Modifier booleans (shift/alt/ctrl) come from the SGR Cb bits.

‘x`/`y` are canvas-relative to the receiving Sigil and are set by the dispatcher right before invoking on_mouse. `abs_x`/`abs_y` are the terminal-absolute coordinates and are always populated.

Event.define(:button, :action, :x, :y, :abs_x, :abs_y, :shift, :alt, :ctrl) do
  def initialize(button:, action:, abs_x:, abs_y:, x: abs_x, y: abs_y,
                 shift: false, alt: false, ctrl: false)
    super
  end

  def shift? = shift
  def alt?   = alt
  def ctrl?  = ctrl
end
VERSION =
"0.2.0"
KeyEvent =
Event.define(:key, :ctrl, :alt, :shift) do
  def initialize(key:, ctrl: false, alt: false, shift: false)
    super
  end

  def ctrl?  = ctrl
  def alt?   = alt
  def shift? = shift
end

Class Method Summary collapse

Class Method Details

.run(app, tick: 0.1, threads: 4) ⇒ Object

Startup entry point. Blocks until app.quit is called. Returns nil.



68
69
70
# File 'lib/thaum.rb', line 68

def self.run(app, tick: 0.1, threads: 4)
  RunLoop.run(app:, tick:, threads:)
end

.safe_invoke(label) ⇒ Object

Invoke a handler, rescuing any exception so a bug in user code can’t leave the terminal in raw mode + alt screen. Logs class, message, and backtrace to stderr.



59
60
61
62
63
64
65
# File 'lib/thaum.rb', line 59

def self.safe_invoke(label)
  yield
rescue StandardError => e
  warn "[Thaum] unhandled exception in #{label}: #{e.class}: #{e.message}"
  warn e.backtrace.join("\n") if e.backtrace
  nil
end