Class: Vedeu::DSL::Interface
- Inherits:
-
Object
- Object
- Vedeu::DSL::Interface
- Defined in:
- lib/vedeu/dsl/interface.rb
Overview
DSL for creating interfaces.
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
- #model ⇒ Interface readonly private
Instance Method Summary collapse
- #attributes ⇒ Hash private
-
#border(&block) ⇒ Vedeu::Border
Allows the setting of a border for the interface.
-
#border! ⇒ Vedeu::Border
Applies the default border to the interface.
-
#cursor(value = true) ⇒ Cursor
Set the cursor visibility on an interface.
-
#cursor! ⇒ Vedeu::Cursor
Set the cursor to visible for the interface.
-
#delay(value) ⇒ Fixnum|Float
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
-
#focus! ⇒ String
Specify this interface as being in focus when the application starts.
-
#geometry(&block) ⇒ Geometry
Define the geometry for an interface.
-
#group(name) ⇒ String
Specify a group for an interface.
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Interface
constructor
Returns an instance of Vedeu::DSL::Interface.
- #keymap(name = model.name, &block) ⇒ Object (also: #keys)
-
#lines(&block) ⇒ Line
(also: #line)
Specify multiple lines in a view.
-
#name(value) ⇒ String
The name of the interface.
Methods included from Use
Methods included from Text
#stream_attributes, #stream_builder, #text
Methods included from Style
Methods included from Colour
#background, #colour, #foreground
Methods included from Vedeu::DSL
Methods included from Common
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Interface
Returns an instance of Vedeu::DSL::Interface.
29 30 31 32 |
# File 'lib/vedeu/dsl/interface.rb', line 29 def initialize(model, client = nil) @model = model @client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Attribute Details
#client ⇒ Object (readonly, private)
213 214 215 |
# File 'lib/vedeu/dsl/interface.rb', line 213 def client @client end |
#model ⇒ Interface (readonly, private)
216 217 218 |
# File 'lib/vedeu/dsl/interface.rb', line 216 def model @model end |
Instance Method Details
#attributes ⇒ Hash (private)
219 220 221 222 223 224 |
# File 'lib/vedeu/dsl/interface.rb', line 219 def attributes { client: client, parent: model, } end |
#border(&block) ⇒ Vedeu::Border
Allows the setting of a border for the interface.
39 40 41 42 43 44 45 46 |
# File 'lib/vedeu/dsl/interface.rb', line 39 def border(&block) fail InvalidSyntax, 'block not given' unless block_given? border_attrs = attributes.merge!({ enabled: true, name: model.name }) Vedeu::Border.build(border_attrs, &block).store end |
#border! ⇒ Vedeu::Border
Applies the default border to the interface.
51 52 53 54 55 |
# File 'lib/vedeu/dsl/interface.rb', line 51 def border! border do # adds default border end end |
#cursor(value = true) ⇒ Cursor
Set the cursor visibility on an interface.
79 80 81 |
# File 'lib/vedeu/dsl/interface.rb', line 79 def cursor(value = true) Vedeu::Cursor.new({ name: model.name, state: value }).store end |
#cursor! ⇒ Vedeu::Cursor
Set the cursor to visible for the interface.
86 87 88 |
# File 'lib/vedeu/dsl/interface.rb', line 86 def cursor! cursor(true) end |
#delay(value) ⇒ Fixnum|Float
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
102 103 104 |
# File 'lib/vedeu/dsl/interface.rb', line 102 def delay(value) model.delay = value end |
#focus! ⇒ String
If multiple interfaces are defined, and this is included in each, then the last defined will be the interface in focus.
Specify this interface as being in focus when the application starts.
112 113 114 |
# File 'lib/vedeu/dsl/interface.rb', line 112 def focus! Vedeu::Focus.add(model.name, true) if defined_value?(model.name) end |
#geometry(&block) ⇒ Geometry
Define the geometry for an interface.
128 129 130 131 132 |
# File 'lib/vedeu/dsl/interface.rb', line 128 def geometry(&block) fail InvalidSyntax, 'block not given' unless block_given? Vedeu::Geometry.build({ name: model.name }, &block).store end |
#group(name) ⇒ String
Specify a group for an interface. Interfaces of the same group can be targetted together; for example you may want to refresh multiple interfaces at once.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/vedeu/dsl/interface.rb', line 146 def group(name) return false unless defined_value?(name) if defined_value?(model.name) if Vedeu.groups.registered?(name) Vedeu.groups.find(name).add(model.name) else new_group = Vedeu::Group.new({ name: name }) new_group.add(model.name) end end model.group = name end |
#keymap(name = model.name, &block) ⇒ Object Also known as: keys
164 165 166 |
# File 'lib/vedeu/dsl/interface.rb', line 164 def keymap(name = model.name, &block) Vedeu.keymap(name, &block) end |
#lines(&block) ⇒ Line Also known as: line
Specify multiple lines in a view.
188 189 190 191 192 |
# File 'lib/vedeu/dsl/interface.rb', line 188 def lines(&block) fail InvalidSyntax, 'block not given' unless block_given? model.add(model.member.build(attributes, &block)) end |
#name(value) ⇒ String
The name of the interface. Used to reference the interface throughout your application’s execution lifetime.
206 207 208 |
# File 'lib/vedeu/dsl/interface.rb', line 206 def name(value) model.name = value end |