Module: Tuile

Defined in:
lib/tuile.rb,
lib/tuile/ansi.rb,
lib/tuile/keys.rb,
lib/tuile/rect.rb,
lib/tuile/size.rb,
lib/tuile/color.rb,
lib/tuile/event.rb,
lib/tuile/final.rb,
lib/tuile/mouse.rb,
lib/tuile/point.rb,
lib/tuile/theme.rb,
lib/tuile/buffer.rb,
lib/tuile/canvas.rb,
lib/tuile/locale.rb,
lib/tuile/screen.rb,
lib/tuile/testing.rb,
lib/tuile/version.rb,
lib/tuile/fraction.rb,
lib/tuile/component.rb,
lib/tuile/listeners.rb,
lib/tuile/theme_def.rb,
lib/tuile/color_depth.rb,
lib/tuile/event_queue.rb,
lib/tuile/fake_screen.rb,
lib/tuile/layout_pass.rb,
lib/tuile/screen_pane.rb,
lib/tuile/mouse/router.rb,
lib/tuile/strict_layout.rb,
lib/tuile/styled_string.rb,
lib/tuile/canvas/backend.rb,
lib/tuile/component/fill.rb,
lib/tuile/component/list.rb,
lib/tuile/component/slot.rb,
lib/tuile/component/tabs.rb,
lib/tuile/component_util.rb,
lib/tuile/component/label.rb,
lib/tuile/component/popup.rb,
lib/tuile/component/button.rb,
lib/tuile/component/layout.rb,
lib/tuile/component/select.rb,
lib/tuile/component/window.rb,
lib/tuile/fake_event_queue.rb,
lib/tuile/testing/gestures.rb,
lib/tuile/component/overlay.rb,
lib/tuile/component/checkbox.rb,
lib/tuile/component/menu_bar.rb,
lib/tuile/component/scroller.rb,
lib/tuile/component/combo_box.rb,
lib/tuile/component/form_item.rb,
lib/tuile/component/has_value.rb,
lib/tuile/component/tab_sheet.rb,
lib/tuile/component/text_area.rb,
lib/tuile/component/text_view.rb,
lib/tuile/terminal_background.rb,
lib/tuile/component/date_field.rb,
lib/tuile/component/layout/box.rb,
lib/tuile/component/log_window.rb,
lib/tuile/component/text_field.rb,
lib/tuile/component/time_field.rb,
lib/tuile/component_background.rb,
lib/tuile/component/float_field.rb,
lib/tuile/component/form_layout.rb,
lib/tuile/component/has_caption.rb,
lib/tuile/component/has_content.rb,
lib/tuile/component/info_window.rb,
lib/tuile/component/radio_group.rb,
lib/tuile/component/notification.rb,
lib/tuile/component/progress_bar.rb,
lib/tuile/component/has_bad_input.rb,
lib/tuile/component/integer_field.rb,
lib/tuile/component/list_dropdown.rb,
lib/tuile/component/log_text_view.rb,
lib/tuile/component/picker_window.rb,
lib/tuile/component/checkbox_group.rb,
lib/tuile/component/confirm_window.rb,
lib/tuile/component/has_validation.rb,
lib/tuile/component/password_field.rb,
lib/tuile/component/date_time_field.rb,
lib/tuile/component/has_placeholder.rb,
lib/tuile/component/layout/absolute.rb,
lib/tuile/component/layout/vertical.rb,
lib/tuile/component/menu_bar/cascade.rb,
lib/tuile/component/big_decimal_field.rb,
lib/tuile/component/layout/horizontal.rb,
lib/tuile/component/vertical_scroll_bar.rb,
lib/tuile/component/abstract_string_field.rb,
lib/tuile/component/text_area/wrapped_text.rb,
lib/tuile/component/abstract_wrapping_field.rb,
sig/tuile.rbs

Overview

Tuile is a small component-oriented terminal UI framework, built on top of the TTY toolkit. The name is French for a roof tile — a small piece that composes into a larger whole, which mirrors how Tuile UIs are built from Components nested under a single Screen.

Defined Under Namespace

Modules: Ansi, ColorDepth, ComponentUtil, Event, Final, Keys, LayoutPass, Mouse, StrictLayout, TerminalBackground, Testing Classes: Buffer, Canvas, Color, Component, ComponentBackground, Error, EventQueue, FakeEventQueue, FakeScreen, Fraction, Listeners, Locale, Point, Rect, Screen, ScreenPane, Size, StyledString, Theme, ThemeDef

Constant Summary collapse

VERSION =

Returns:

  • (String)
"0.17.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.logger ⇒ Logger

Returns:

  • (Logger)


30
31
32
# File 'lib/tuile.rb', line 30

def logger
  @logger ||= Logger.new(IO::NULL)
end

Class Method Details

.strict_layout ⇒ Symbol, bool

How a pre-settle Tuile::Component#rect read is reported: false, :warn to #logger, or :raise. Unset — which is how a process starts — answers the default: :raise under a FakeScreen, where a spec suite is the audience, and false anywhere else. See StrictLayout.

Returns:

  • (Symbol, bool)


39
40
41
42
43
# File 'lib/tuile.rb', line 39

def strict_layout
  return @strict_layout unless @strict_layout.nil?

  Screen.instance? && Screen.instance.is_a?(FakeScreen) ? :raise : false
end

.strict_layout=(mode) ⇒ void

This method returns an undefined value.

Chooses for the whole process, overriding that default either way — true means :raise, and nil hands the choice back:

Tuile.strict_layout = :warn     # a running app, being watched
Tuile.strict_layout = false     # a spec suite that wants none of it

A mode that isn't false prepends StrictLayout into Component, which is permanent for the process; false afterwards makes the check inert rather than removing it.

@param mode — :warn, :raise, false, or nil for the default.

Parameters:

  • mode (Symbol, bool, nil)


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

def strict_layout=(mode)
  mode = :raise if mode == true
  unless [nil, false, :warn, :raise].include?(mode)
    raise ArgumentError, "expected :warn, :raise, false or nil, got #{mode.inspect}"
  end

  StrictLayout.install if mode
  @strict_layout = mode
end

.without_strict_layout ⇒ Object

Runs the block with the diagnostic off, for a spec's read taken pre-settle on purpose — asserting that a rect survived a round trip is a question only the unsettled value answers:

Tuile.without_strict_layout { assert_equal rect, second.rect }

A test tool, not app code: the diagnostic is on only under a FakeScreen or after strict_layout=, so an app's stale read wants settling, not silencing. Restores whatever was in force, default included, and silences every read in the block, on this thread and any other.

@return — the block's value.

Returns:

  • (Object)


79
80
81
82
83
84
85
# File 'lib/tuile.rb', line 79

def without_strict_layout
  previous = @strict_layout
  @strict_layout = false
  yield
ensure
  @strict_layout = previous
end