Module: NattyUI
- Extended by:
- Features
- Defined in:
- lib/natty-ui.rb,
lib/natty-ui/task.rb,
lib/natty-ui/table.rb,
lib/natty-ui/theme.rb,
lib/natty-ui/utils.rb,
lib/natty-ui/choice.rb,
lib/natty-ui/framed.rb,
lib/natty-ui/element.rb,
lib/natty-ui/options.rb,
lib/natty-ui/section.rb,
lib/natty-ui/version.rb,
lib/natty-ui/features.rb,
lib/natty-ui/progress.rb,
lib/natty-ui/temporary.rb,
lib/natty-ui/attributes.rb,
lib/natty-ui/dumb_choice.rb,
lib/natty-ui/ls_renderer.rb,
lib/natty-ui/dumb_options.rb,
lib/natty-ui/width_finder.rb,
lib/natty-ui/hbars_renderer.rb,
lib/natty-ui/table_renderer.rb,
lib/natty-ui/vbars_renderer.rb
Overview
Defined Under Namespace
Modules: Attributes, Features, ProgressHelper, WithStatus Classes: Element, Section, Table, Task, Temporary, Theme
Constant Summary collapse
- Ansi =
Uses the ANSI tools of the Terminal.rb gem
Terminal::Ansi
- Text =
Uses the Text tools of the Terminal.rb gem
Terminal::Text
- VERSION =
The version number of the gem.
'0.30.0'
Class Attribute Summary collapse
- .element ⇒ Features readonly
-
.input_mode ⇒ :default, ...
readonly
Supported input mode.
-
.title ⇒ String?
Terminal title.
User Interaction collapse
-
.await(yes: 'Enter', no: 'Esc') ⇒ Object
extended
from Features
Wait for user input.
-
.choice(*choices, abortable: false, selected: nil, **kwchoices, &block) ⇒ Object
extended
from Features
Allows the user to select an option from a selection.
-
.options(abortable: false, selected: nil, **choices) {|temp| ... } ⇒ {#to_s => [true,false]}?
extended
from Features
Allows the user to select from several options.
-
.select(*choices, abortable: false, selected: nil) {|temp| ... } ⇒ Array<#to_s>?
extended
from Features
Allows the user to select from several options.
Printing Methods collapse
-
.cols(*columns, **attributes) {|row| ... } ⇒ Features
extended
from Features
Print text in columns.
-
.div(*text, **attributes) ⇒ Features
extended
from Features
Print a text division with attributes.
-
.h1(*text) ⇒ Features
extended
from Features
Print given text as a H1 Features#heading.
-
.h2(*text) ⇒ Features
extended
from Features
Print given text as a H2 Features#heading.
-
.h3(*text) ⇒ Features
extended
from Features
Print given text as a H3 Features#heading.
-
.h4(*text) ⇒ Features
extended
from Features
Print given text as a H4 Features#heading.
-
.h5(*text) ⇒ Features
extended
from Features
Print given text as a H5 Features#heading.
-
.h6(*text) ⇒ Features
extended
from Features
Print given text as a H6 Features#heading.
-
.hbars(values, with_values: true, normalize: false, width: :auto, style: nil, text_style: nil) ⇒ Features
extended
from Features
Dump given values as horizontal bars.
-
.heading(level, *text) ⇒ Features
extended
from Features
Print given text as a heading.
-
.hr(type = :default) ⇒ Features
extended
from Features
Print a horizontal rule.
-
.ls(*items, compact: true, glyph: nil) ⇒ Features
extended
from Features
Print given items as list (like 'ls' command).
-
.mark(*text, mark: :default, **options) ⇒ Features
extended
from Features
Print given text with a decoration mark.
-
.pin(*text, mark: nil, **options) ⇒ Features
extended
from Features
Print given text as lines like Features#puts.
-
.progress(title, max: nil, pin: false, &block) ⇒ Object
extended
from Features
Dynamically display a task progress.
-
.puts(*text, **options) ⇒ Features
extended
from Features
Print given text as lines.
-
.quote(*text) ⇒ Features
extended
from Features
Print given text as a quotation.
-
.space(count = 1) ⇒ Features
extended
from Features
Print one or more space lines.
-
.table(**attributes) {|table| ... } ⇒ Features
extended
from Features
Generate and print a table.
-
.vbars(values, normalize: false, height: 10, bar_width: :auto, style: nil) ⇒ Features
extended
from Features
Dump given values as vertical bars.
Sub-Elements collapse
-
.error(title, *text) {|section| ... } ⇒ Object
(also: #err)
extended
from Features
Create a visually separated section marked as an error with a title for the output of text elements.
-
.failed(title, *text) {|section| ... } ⇒ Object
extended
from Features
Create a visually separated section marked as a failure with a title for the output of text elements.
-
.framed(*text, align: :left, border: :default, border_style: nil) {|frame| ... } ⇒ Object
extended
from Features
Create a framed section.
-
.information(title, *text) {|section| ... } ⇒ Object
(also: #info)
extended
from Features
Create a visually separated section marked as informational with a title for the output of text elements.
-
.message(title, *text) {|section| ... } ⇒ Object
(also: #msg)
extended
from Features
Create a visually separated section with a title for the output of text elements.
-
.section(*text) {|section| ... } ⇒ Object
extended
from Features
Create a visually separated section for the output of text elements.
-
.task(title, *text, pin: false) {|task| ... } ⇒ Object
extended
from Features
Generate a task section.
-
.warning(title, *text) {|section| ... } ⇒ Object
(also: #warn)
extended
from Features
Create a visually separated section marked as a warning with a title for the output of text elements.
Utilities collapse
-
.temporary {|temp| ... } ⇒ Object
extended
from Features
Display some temporary content.
Class Attribute Details
.element ⇒ Features (readonly)
26 27 28 |
# File 'lib/natty-ui.rb', line 26 def element @element end |
.input_mode ⇒ :default, ... (readonly)
Supported input mode.
37 38 39 40 41 42 43 44 |
# File 'lib/natty-ui.rb', line 37 def input_mode case Terminal.input_mode when :csi_u, :legacy :default when :dumb :dumb end end |
.title ⇒ String?
Terminal title.
53 |
# File 'lib/natty-ui.rb', line 53 def title = @title_stack.last |
Class Method Details
#await(yes: 'Enter', no: 'Esc') ⇒ true, false #await(yes: 'Enter', no: 'Esc') {|temp| ... } ⇒ true, false Originally defined in module Features
Wait for user input.
#choice(*choices, abortable: false) ⇒ Integer? #choice(*choices, abortable: false) {|temp| ... } ⇒ Integer? #choice(**choices, abortable: false) ⇒ Object? #choice(**choices, abortable: false) {|temp| ... } ⇒ Object? Originally defined in module Features
Allows the user to select an option from a selection. The selected option is returned.
.cols(*columns, **attributes) {|row| ... } ⇒ Features Originally defined in module Features
Print text in columns. This is a shorthand to define a Table with a single row.
.div(*text, **attributes) ⇒ Features Originally defined in module Features
Print a text division with attributes. This is a shorthand to define a Table with a single cell.
.error(title, *text) {|section| ... } ⇒ Object Also known as: err Originally defined in module Features
Create a visually separated section marked as an error with a title for the output of text elements.
.failed(title, *text) {|section| ... } ⇒ Object Originally defined in module Features
Create a visually separated section marked as a failure with a title for the output of text elements.
.framed(*text, align: :left, border: :default, border_style: nil) {|frame| ... } ⇒ Object Originally defined in module Features
Create a framed section.
.hbars(values, with_values: true, normalize: false, width: :auto, style: nil, text_style: nil) ⇒ Features Originally defined in module Features
Dump given values as horizontal bars.
.information(title, *text) {|section| ... } ⇒ Object Also known as: info Originally defined in module Features
Create a visually separated section marked as informational with a title for the output of text elements.
.ls(*items, compact: true, glyph: nil) ⇒ Features Originally defined in module Features
Print given items as list (like 'ls' command).
Each list item will optionally be decorated with the given glyph as:
Integer
as the start value for a numbered listSymbol
as the start symbol:hex
to create a hexadecimal numbered list- any text as prefix
.mark(*text, mark: :default, **options) ⇒ Features Originally defined in module Features
Print given text with a decoration mark.
.message(title, *text) {|section| ... } ⇒ Object Also known as: msg Originally defined in module Features
Create a visually separated section with a title for the output of text elements.
.options(abortable: false, selected: nil, **choices) {|temp| ... } ⇒ {#to_s => [true,false]}? Originally defined in module Features
Allows the user to select from several options. All options are returned with their selection status.
#progress(title, max: nil, pin: false) ⇒ ProgressHelper #progress(title, max: nil, pin: false) {|progress| ... } ⇒ Object Originally defined in module Features
Dynamically display a task progress.
When a max
parameter is given the progress will be displayed as a
progress bar below the title
. Otherwise the progress is displayed just
by accumulating dots.
.section(*text) {|section| ... } ⇒ Object Originally defined in module Features
Create a visually separated section for the output of text elements. Like any other Element sections support all NattyUI::Features.
.select(*choices, abortable: false, selected: nil) {|temp| ... } ⇒ Array<#to_s>? Originally defined in module Features
Allows the user to select from several options. The selected options are returned.
.table(**attributes) {|table| ... } ⇒ Features Originally defined in module Features
Generate and print a table. See Table for much more details about table generation.
.task(title, *text, pin: false) {|task| ... } ⇒ Object Originally defined in module Features
Generate a task section.
.temporary {|temp| ... } ⇒ Object Originally defined in module Features
Display some temporary content. The content displayed in the block will be erased after the block ends.
.vbars(values, normalize: false, height: 10, bar_width: :auto, style: nil) ⇒ Features Originally defined in module Features
Dump given values as vertical bars.
.warning(title, *text) {|section| ... } ⇒ Object Also known as: warn Originally defined in module Features
Create a visually separated section marked as a warning with a title for the output of text elements.