Class: Vedeu::Interfaces::DSL Private
- Inherits:
-
Object
- Object
- Vedeu::Interfaces::DSL
- Extended by:
- Common
- Includes:
- Common, DSL, DSL::Border, DSL::Cursors, DSL::Geometry, DSL::Presentation, DSL::Use
- Defined in:
- lib/vedeu/interfaces/dsl.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
DSL for creating interfaces.
Instance Attribute Summary
Attributes included from DSL
Class Method Summary collapse
-
.add_buffers!(name) ⇒ Vedeu::Buffers::Buffer
private
private
Registers a set of buffers for the interface unless already registered, and also adds interface’s name to list of focussable interfaces.
-
.add_cursor!(name) ⇒ Vedeu::Cursors::Cursor
private
private
Registers a new cursor for the interface unless already registered.
-
.add_editor!(name) ⇒ Object
private
private
Registers a new document with the interface.
-
.add_focusable!(name) ⇒ Array<String|Symbol>
private
private
Registers interface name in focus list unless already registered.
-
.add_keymap!(name) ⇒ NilClass|Vedeu::Input::Keymap
private
private
Registers a new keymap for the interface unless already registered.
-
.client(&block) ⇒ Object
private
private
Returns the client object which called the DSL method.
-
.interface(name, &block) ⇒ Vedeu::Interfaces::Interface
private
Register an interface by name which will display output from an event or a command.
- .keymap?(name) ⇒ Boolean private private
Instance Method Summary collapse
-
#delay(value) ⇒ Fixnum|Float
private
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
-
#editable(value = true) ⇒ Boolean
private
Set whether the interface is editable.
-
#editable! ⇒ Boolean
private
Set the interface to be editable.
-
#focus! ⇒ Array<String>
private
Specify this interface as being in focus when the application starts.
-
#group(name) ⇒ Vedeu::Groups::Group
private
Specify a group for an interface.
-
#hide! ⇒ Boolean
private
Set the interface to invisible.
- #keymap(name = model.name, &block) ⇒ Object (also: #keys) private
-
#show! ⇒ Boolean
(also: #visible!)
private
Set the interface to visible.
-
#use(name) ⇒ Vedeu::Interfaces::Interface
private
Use a value from another model.
-
#visible(value = true) ⇒ Boolean
private
Set the visibility of the interface.
-
#zindex(value) ⇒ Fixnum
(also: #z_index, #z)
private
Set the zindex of the interface.
Methods included from Common
absent?, array?, boolean, boolean?, empty_value?, escape?, falsy?, hash?, line_model?, numeric?, positionable?, present?, snake_case, stream_model?, string?, symbol?, truthy?, view_model?
Methods included from DSL::Presentation
#background, #colour, #colour_attributes, #foreground, #no_wordwrap!, #style, #wordwrap
Methods included from DSL::Geometry
Methods included from DSL::Border
Methods included from DSL::Cursors
#cursor, #cursor!, #no_cursor!
Methods included from DSL
#attributes, #initialize, #method_missing, #name
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Class Method Details
.add_buffers!(name) ⇒ Vedeu::Buffers::Buffer (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers a set of buffers for the interface unless already registered, and also adds interface’s name to list of focussable interfaces.
68 69 70 |
# File 'lib/vedeu/interfaces/dsl.rb', line 68 def add_buffers!(name) Vedeu::Buffers::Buffer.new(name: name).store end |
.add_cursor!(name) ⇒ Vedeu::Cursors::Cursor (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers a new cursor for the interface unless already registered.
77 78 79 |
# File 'lib/vedeu/interfaces/dsl.rb', line 77 def add_cursor!(name) Vedeu::Cursors::Cursor.store(name: name) end |
.add_editor!(name) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers a new document with the interface.
84 85 86 |
# File 'lib/vedeu/interfaces/dsl.rb', line 84 def add_editor!(name) Vedeu::Editor::Document.store(name: name) end |
.add_focusable!(name) ⇒ Array<String|Symbol> (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers interface name in focus list unless already registered.
93 94 95 |
# File 'lib/vedeu/interfaces/dsl.rb', line 93 def add_focusable!(name) Vedeu::Models::Focus.add(name) end |
.add_keymap!(name) ⇒ NilClass|Vedeu::Input::Keymap (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Registers a new keymap for the interface unless already registered.
102 103 104 |
# File 'lib/vedeu/interfaces/dsl.rb', line 102 def add_keymap!(name) Vedeu::Input::Keymap.store(name: name) unless keymap?(name) end |
.client(&block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the client object which called the DSL method.
110 111 112 |
# File 'lib/vedeu/interfaces/dsl.rb', line 110 def client(&block) eval('self', block.binding) if block_given? end |
.interface(name, &block) ⇒ Vedeu::Interfaces::Interface
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
More documentation required.
Register an interface by name which will display output from an event or a command. This provides the means for you to define your the views of your application without their content.
Vedeu.interface :my_interface do
# ... some code
end
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vedeu/interfaces/dsl.rb', line 40 def interface(name, &block) raise Vedeu::Error::MissingRequired unless name raise Vedeu::Error::RequiresBlock unless block_given? attributes = { client: client(&block), name: name } interface = Vedeu::Interfaces::Interface .build(attributes, &block) .store add_buffers!(name) add_cursor!(name) add_editor!(name) if interface.editable? add_focusable!(name) add_keymap!(name) interface end |
.keymap?(name) ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 |
# File 'lib/vedeu/interfaces/dsl.rb', line 116 def keymap?(name) Vedeu.keymaps.registered?(name) end |
Instance Method Details
#delay(value) ⇒ Fixnum|Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
To maintain performance interfaces can be delayed from refreshing too often, the reduces artefacts particularly when resizing the terminal screen.
136 137 138 |
# File 'lib/vedeu/interfaces/dsl.rb', line 136 def delay(value) model.delay = value end |
#editable(value = true) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
When an interface is made editable, then the cursor visibility will be set to visible.
Set whether the interface is editable.
170 171 172 173 174 |
# File 'lib/vedeu/interfaces/dsl.rb', line 170 def editable(value = true) cursor(true) if Vedeu::Boolean.coerce(value) model.editable = Vedeu::Boolean.coerce(value) end |
#editable! ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the interface to be editable.
179 180 181 |
# File 'lib/vedeu/interfaces/dsl.rb', line 179 def editable! editable(true) end |
#focus! ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
If multiple interfaces are defined, and this is included in each, then the last defined will be the interface in focus. However, this behaviour can be overridden:
“‘ruby Vedeu.focus_by_name :some_interface “`
When the above is specified (outside of a ‘Vedeu.interface` declaration), the named interface will be focussed instead.
Specify this interface as being in focus when the application starts.
198 199 200 |
# File 'lib/vedeu/interfaces/dsl.rb', line 198 def focus! Vedeu::Models::Focus.add(model.name, true) if present?(model.name) end |
#group(name) ⇒ Vedeu::Groups::Group
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
214 215 216 217 218 219 220 |
# File 'lib/vedeu/interfaces/dsl.rb', line 214 def group(name) return false unless present?(name) model.group = name Vedeu.groups.by_name(name).add(model.name) end |
#hide! ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the interface to invisible.
252 253 254 |
# File 'lib/vedeu/interfaces/dsl.rb', line 252 def hide! visible(false) end |
#keymap(name = model.name, &block) ⇒ Object Also known as: keys
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
224 225 226 |
# File 'lib/vedeu/interfaces/dsl.rb', line 224 def keymap(name = model.name, &block) Vedeu.keymap(name, &block) end |
#show! ⇒ Boolean Also known as: visible!
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the interface to visible.
239 240 241 |
# File 'lib/vedeu/interfaces/dsl.rb', line 239 def show! visible(true) end |
#use(name) ⇒ Vedeu::Interfaces::Interface
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use a value from another model.
260 261 262 |
# File 'lib/vedeu/interfaces/dsl.rb', line 260 def use(name) model.repository.by_name(name) end |
#visible(value = true) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the visibility of the interface.
290 291 292 |
# File 'lib/vedeu/interfaces/dsl.rb', line 290 def visible(value = true) model.visible = Vedeu::Boolean.coerce(value) end |
#zindex(value) ⇒ Fixnum Also known as: z_index, z
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the zindex of the interface. This controls the render order of interfaces. Interfaces with a lower zindex will render before those with a higher zindex.
311 312 313 |
# File 'lib/vedeu/interfaces/dsl.rb', line 311 def zindex(value) model.zindex = value end |