vedeu 0.4.19 → 0.4.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dab76c44fae79844ccc5b6321392ee99a09c23d0
4
- data.tar.gz: 43162ef0fdcf20ba49b09957d32316379e3e0583
3
+ metadata.gz: 7c7cd26a499c374db75b879fd68895f3556128d7
4
+ data.tar.gz: eb83922ae30bc67dd8dd4c85f5187b677db16168
5
5
  SHA512:
6
- metadata.gz: a9774a3562701e47aaacc997d01dd157ce021c46b688adda4f56b4cdffb323c918189bc1038b0af46031aa858825449b865eb77b37b41d482aa106e6120f406e
7
- data.tar.gz: 222d43c099bf843b27b616536b10b0cc316c6c0cb9bb09e06606ffd00362aa2ee02eb79f84cd09c4ac437d94270df33ec88a1fd4e328d0a6d22e8f9259b104a2
6
+ metadata.gz: f0e7347e6b8b32abd258f387ffb16dfedba70a02969bd441d66c0075429b53da21337e990159daf02763dbf77342a42a1ea6b95bf0ee6f427858fa2717a124e3
7
+ data.tar.gz: 14583143e3615ad64da7c574403882ec6a40dea16445990c0f892322a9839cd670caa91e107be0171c8d34ecb65656285fb92ee2114a60de8516f342732707de
@@ -36,6 +36,10 @@ module Vedeu
36
36
 
37
37
  module_function
38
38
 
39
+ # @!method background_colours
40
+ # @see Vedeu::BackgroundColours.background_colours
41
+ def_delegators Vedeu::BackgroundColours, :background_colours
42
+
39
43
  # @!method borders
40
44
  # @see Vedeu::Borders.borders
41
45
  def_delegators Vedeu::Borders, :borders
@@ -48,66 +52,18 @@ module Vedeu
48
52
  # @see Vedeu::Canvas.canvas
49
53
  def_delegators Vedeu::Canvas, :canvas
50
54
 
51
- # @!method background_colours
52
- # @see Vedeu::BackgroundColours.background_colours
53
- def_delegators Vedeu::BackgroundColours, :background_colours
54
-
55
- # @!method foreground_colours
56
- # @see Vedeu::ForegroundColours.foreground_colours
57
- def_delegators Vedeu::ForegroundColours, :foreground_colours
58
-
59
- # @!method cursors
60
- # @see Vedeu::Cursors.cursors
61
- def_delegators Vedeu::Cursors, :cursors
62
-
63
- # @!method cursor
64
- # @see Vedeu::Cursors.cursor
65
- def_delegators Vedeu::Cursors, :cursor
66
-
67
- # @!method events
68
- # @see Vedeu::EventsRepository.events
69
- def_delegators Vedeu::EventsRepository, :events
70
-
71
- # @!method geometries
72
- # @see Vedeu::Geometries.geometries
73
- def_delegators Vedeu::Geometries, :geometries
74
-
75
- # @!method groups
76
- # @see Vedeu::Groups.groups
77
- def_delegators Vedeu::Groups, :groups
78
-
79
- # @!method interfaces
80
- # @see Vedeu::InterfacesRepository.interfaces
81
- def_delegators Vedeu::InterfacesRepository, :interfaces
82
-
83
- # @!method keymaps
84
- # @see Vedeu::Keymaps.keymaps
85
- def_delegators Vedeu::Keymaps, :keymaps
86
-
87
- # @!method keypress
88
- # @see Vedeu::Mapper.keypress
89
- def_delegators Vedeu::Mapper, :keypress
90
-
91
- # @!method menus
92
- # @see Vedeu::Menus.menus
93
- def_delegators Vedeu::Menus, :menus
94
-
95
- # @!method bind
96
- # @see Vedeu::Event.bind
97
- # @!method unbind
98
- # @see Vedeu::Event.unbind
99
- def_delegators Vedeu::Event, :bind, :unbind
100
-
101
- # @!method trigger
102
- # @see Vedeu::Trigger.trigger
103
- def_delegators Vedeu::Trigger, :trigger
104
-
105
55
  # @!method configure
106
56
  # @see Vedeu::Configuration.configure
107
57
  # @!method configuration
108
58
  # @see Vedeu::Configuration.configuration
109
59
  def_delegators Vedeu::Configuration, :configure, :configuration
110
60
 
61
+ # @!method cursor
62
+ # @see Vedeu::Cursors.cursor
63
+ # @!method cursors
64
+ # @see Vedeu::Cursors.cursors
65
+ def_delegators Vedeu::Cursors, :cursor, :cursors
66
+
111
67
  # @!method border
112
68
  # @see Vedeu::DSL::Border.border
113
69
  def_delegators Vedeu::DSL::Border, :border
@@ -116,14 +72,14 @@ module Vedeu
116
72
  # @see Vedeu::DSL::Geometry.geometry
117
73
  def_delegators Vedeu::DSL::Geometry, :geometry
118
74
 
119
- # @!method keymap
120
- # @see Vedeu::DSL::Keymap.keymap
121
- def_delegators Vedeu::DSL::Keymap, :keymap
122
-
123
75
  # @!method group
124
76
  # @see Vedeu::DSL::Group.group
125
77
  def_delegators Vedeu::DSL::Group, :group
126
78
 
79
+ # @!method keymap
80
+ # @see Vedeu::DSL::Keymap.keymap
81
+ def_delegators Vedeu::DSL::Keymap, :keymap
82
+
127
83
  # @!method interface
128
84
  # @see Vedeu::DSL::View.interface
129
85
  # @!method renders
@@ -132,6 +88,16 @@ module Vedeu
132
88
  # @see Vedeu::DSL::View.views
133
89
  def_delegators Vedeu::DSL::View, :interface, :renders, :views
134
90
 
91
+ # @!method bind
92
+ # @see Vedeu::Event.bind
93
+ # @!method unbind
94
+ # @see Vedeu::Event.unbind
95
+ def_delegators Vedeu::Event, :bind, :unbind
96
+
97
+ # @!method events
98
+ # @see Vedeu::EventsRepository.events
99
+ def_delegators Vedeu::EventsRepository, :events
100
+
135
101
  # @!method focus
136
102
  # @see Vedeu::Focus#focus
137
103
  # @!method focus_by_name
@@ -145,14 +111,48 @@ module Vedeu
145
111
  def_delegators Vedeu::Focus, :focus, :focus_by_name, :focussed?,
146
112
  :focus_next, :focus_previous
147
113
 
114
+ # @!method foreground_colours
115
+ # @see Vedeu::ForegroundColours.foreground_colours
116
+ def_delegators Vedeu::ForegroundColours, :foreground_colours
117
+
118
+ # @!method geometries
119
+ # @see Vedeu::Geometries.geometries
120
+ def_delegators Vedeu::Geometries, :geometries
121
+
122
+ # @!method groups
123
+ # @see Vedeu::Groups.groups
124
+ def_delegators Vedeu::Groups, :groups
125
+
126
+ # @!method interfaces
127
+ # @see Vedeu::InterfacesRepository.interfaces
128
+ def_delegators Vedeu::InterfacesRepository, :interfaces
129
+
130
+ # @!method keymaps
131
+ # @see Vedeu::Keymaps.keymaps
132
+ def_delegators Vedeu::Keymaps, :keymaps
133
+
148
134
  # @!method log
149
135
  # @see Vedeu::Log.log
150
136
  def_delegators Vedeu::Log, :log
151
137
 
138
+ # @!method keypress
139
+ # @see Vedeu::Mapper.keypress
140
+ def_delegators Vedeu::Mapper, :keypress
141
+
152
142
  # @!method menu
153
143
  # @see Vedeu::Menu.menu
154
144
  def_delegators Vedeu::Menu, :menu
155
145
 
146
+ # @!method menus
147
+ # @see Vedeu::Menus.menus
148
+ def_delegators Vedeu::Menus, :menus
149
+
150
+ # @!method renderer
151
+ # @see Vedeu::Renderers#renderer
152
+ # @!method renderers
153
+ # @see Vedeu::Renderers#renderers
154
+ def_delegators Vedeu::Renderers, :renderer, :renderers
155
+
156
156
  # @!method height
157
157
  # @see Vedeu::Terminal#height
158
158
  # @!method width
@@ -161,11 +161,9 @@ module Vedeu
161
161
  # @see Vedeu::Terminal#resize
162
162
  def_delegators Vedeu::Terminal, :height, :width, :resize
163
163
 
164
- # @!method renderer
165
- # @see Vedeu::Renderers#renderer
166
- # @!method renderers
167
- # @see Vedeu::Renderers#renderers
168
- def_delegators Vedeu::Renderers, :renderer, :renderers
164
+ # @!method trigger
165
+ # @see Vedeu::Trigger.trigger
166
+ def_delegators Vedeu::Trigger, :trigger
169
167
 
170
168
  end # API
171
169
 
@@ -2,6 +2,14 @@ module Vedeu
2
2
 
3
3
  # The Buffer object represents the states of display for an interface. The
4
4
  # states are 'front', 'back' and 'previous'.
5
+ #
6
+ # [Back] -> [Front] -> [Previous]
7
+ #
8
+ # The content on the screen, or last output will always be the 'Front' buffer.
9
+ # Content due to be displayed on next refresh will come from the 'Back' buffer
10
+ # if available, otherwise from the current 'Front' buffer. When new content
11
+ # is copied to the 'Front' buffer, the current 'Front' buffer is also copied
12
+ # to the 'Previous' buffer.
5
13
  class Buffer
6
14
 
7
15
  include Vedeu::Model
@@ -36,17 +44,15 @@ module Vedeu
36
44
  #
37
45
  # @option attributes name [String] The name of the interface for which the
38
46
  # buffer belongs.
39
- # @option attributes back [Interface]
40
- # @option attributes front [Interface]
41
- # @option attributes previous [Interface]
47
+ # @option attributes back [Vedeu::Interface]
48
+ # @option attributes front [Vedeu::Interface]
49
+ # @option attributes previous [Vedeu::Interface]
42
50
  # @option attributes repository [Vedeu::Buffers]
43
51
  # @return [Vedeu::Buffer]
44
52
  def initialize(attributes = {})
45
53
  @attributes = defaults.merge!(attributes)
46
54
 
47
- @attributes.each do |key, value|
48
- instance_variable_set("@#{key}", value)
49
- end
55
+ @attributes.each { |key, value| instance_variable_set("@#{key}", value) }
50
56
  end
51
57
 
52
58
  # Add the content to the back buffer, then update the repository.
@@ -71,6 +77,8 @@ module Vedeu
71
77
  clear_buffer
72
78
  end
73
79
 
80
+ # Hide this buffer.
81
+ #
74
82
  # @return [void]
75
83
  def hide
76
84
  return nil unless visible?
@@ -98,6 +106,8 @@ module Vedeu
98
106
  end
99
107
  alias_method :content, :render
100
108
 
109
+ # Show this buffer.
110
+ #
101
111
  # @return [void]
102
112
  def show
103
113
  return nil if visible?
@@ -108,6 +118,8 @@ module Vedeu
108
118
 
109
119
  private
110
120
 
121
+ # Retrieve the latest content from the buffer.
122
+ #
111
123
  # @return [Array<Array<Array<Vedeu::Char>>>]
112
124
  def buffer
113
125
  swap if content_for?(:back)
@@ -124,6 +136,8 @@ module Vedeu
124
136
  end
125
137
  end
126
138
 
139
+ # Clear the buffer.
140
+ #
127
141
  # @return [void]
128
142
  def clear_buffer
129
143
  @clear_buffer ||= Vedeu::Clear.new(view).clear
@@ -166,6 +180,8 @@ module Vedeu
166
180
  true
167
181
  end
168
182
 
183
+ # Retrieve the interface by name.
184
+ #
169
185
  # @return [Vedeu::Interface]
170
186
  def interface
171
187
  @interface ||= Vedeu.interfaces.by_name(name)
@@ -23,7 +23,7 @@ module Vedeu
23
23
  # refresh event is triggered for the interface.
24
24
  #
25
25
  # @raise [InvalidSyntax] The name is not defined.
26
- # @return [Interface]
26
+ # @return [Vedeu::Interface]
27
27
  def store_deferred
28
28
  unless defined_value?(name)
29
29
  fail InvalidSyntax, 'Cannot store an interface without a name.'
@@ -40,7 +40,7 @@ module Vedeu
40
40
  # and also adds interface's name to list of focussable interfaces.
41
41
  #
42
42
  # @see Vedeu::Buffer
43
- # @return [Interface]
43
+ # @return [Vedeu::Interface]
44
44
  def store_new_buffer
45
45
  if Vedeu.buffers.registered?(name)
46
46
  Vedeu.buffers.find(name).add(self)
@@ -55,7 +55,7 @@ module Vedeu
55
55
 
56
56
  # Registers interface name in focus list unless already registered.
57
57
  #
58
- # @return [Interface]
58
+ # @return [Vedeu::Interface]
59
59
  def store_focusable
60
60
  Vedeu.focusable.add(name) unless Vedeu.focusable.registered?(name)
61
61
 
@@ -64,20 +64,18 @@ module Vedeu
64
64
 
65
65
  # Registers a new cursor for the interface unless already registered.
66
66
  #
67
- # @return [Interface]
67
+ # @return [Vedeu::Interface]
68
68
  def store_cursor
69
- Vedeu::Cursor.new(name: name).store unless Vedeu.cursors.registered?(name)
69
+ Vedeu.cursors.by_name(name)
70
70
 
71
71
  self
72
72
  end
73
73
 
74
74
  # Registers a new group for the interface unless already registered.
75
75
  #
76
- # @return [Interface]
76
+ # @return [Vedeu::Interface]
77
77
  def store_group
78
- unless group.nil? || group.empty? || Vedeu.groups.registered?(group)
79
- Vedeu::Group.new(members: name, name: group).store
80
- end
78
+ Vedeu.groups.by_name(group).add(name) if group?
81
79
 
82
80
  self
83
81
  end
@@ -46,6 +46,8 @@ module Vedeu
46
46
 
47
47
  private
48
48
 
49
+ # Setup Vedeu using CLI configuration options for the client application.
50
+ #
49
51
  # @return [void]
50
52
  def setup!
51
53
  ([:banner] + allowed_options).each { |opt| send(opt) }
@@ -100,6 +100,8 @@ module Vedeu
100
100
 
101
101
  private
102
102
 
103
+ # Return the position of this cursor.
104
+ #
103
105
  # @return [Vedeu::Position]
104
106
  def position
105
107
  @position ||= Vedeu::Position.new(y, x)
@@ -133,11 +133,15 @@ module Vedeu
133
133
 
134
134
  private
135
135
 
136
+ # Retrieve the attributes of the cursor.
137
+ #
136
138
  # @return [Hash<Symbol => Fixnum, String>]
137
139
  def attributes
138
140
  cursor.attributes
139
141
  end
140
142
 
143
+ # Provide the new attributes for the cursor.
144
+ #
141
145
  # @return [Hash<Symbol => Fixnum>]
142
146
  def new_attributes
143
147
  {
@@ -148,6 +152,8 @@ module Vedeu
148
152
  }
149
153
  end
150
154
 
155
+ # Validates the new position of the cursor.
156
+ #
151
157
  # @return [PositionValidator]
152
158
  def validator
153
159
  @validator ||= Vedeu::PositionValidator.validate(name,
@@ -155,16 +161,23 @@ module Vedeu
155
161
  y_position)
156
162
  end
157
163
 
164
+ # Returns the cursors x position based on its current offset.
165
+ #
158
166
  # @return [Fixnum]
159
167
  def x_position
160
168
  coordinate.x_position(ox)
161
169
  end
162
170
 
171
+ # Returns the cursors y position based on its current offset.
172
+ #
163
173
  # @return [Fixnum]
164
174
  def y_position
165
175
  coordinate.y_position(oy)
166
176
  end
167
177
 
178
+ # Retrieve the border for the named view: this will provide the geometry for
179
+ # the cursor, ensuring it displays within the interface boundaries.
180
+ #
168
181
  # @return (see Vedeu::Borders#by_name)
169
182
  def border
170
183
  @border ||= Vedeu.borders.by_name(name)
@@ -44,6 +44,10 @@ module Vedeu
44
44
 
45
45
  private
46
46
 
47
+ # Returns true when the view should be refreshed. This is determined by
48
+ # checking that the offsets for x and y are outside the width and height
49
+ # of the named interface.
50
+ #
47
51
  # @return [Boolean]
48
52
  def refresh_view?
49
53
  new_cursor.ox >= width || new_cursor.oy >= height
@@ -96,6 +96,8 @@ module Vedeu
96
96
  attributes.merge!(existing_attributes(name))
97
97
  end
98
98
 
99
+ # Retrieve the attributes of the interface by name.
100
+ #
99
101
  # @param name [String] The name of the interface.
100
102
  # @return [Hash]
101
103
  def existing_attributes(name)
@@ -4,9 +4,10 @@ class Fixnum
4
4
 
5
5
  # Augment Fixnum to calculate column width in a grid-based layout.
6
6
  #
7
- # The grid system splits the terminal width into 12 equal parts, by dividing
8
- # the available width by 12. If the terminal width is not a multiple of 12,
9
- # then Grid chooses the maximum value which will fit.
7
+ # The grid system splits the terminal height and width into 12 equal parts, by
8
+ # dividing the available height and width by 12. If the terminal height or
9
+ # width is not a multiple of 12, then Grid chooses the maximum value which
10
+ # will fit.
10
11
  #
11
12
  # Used primarily at interface creation time:
12
13
  #
@@ -17,19 +18,45 @@ class Fixnum
17
18
  Vedeu::Grid.columns(self)
18
19
  end
19
20
 
21
+ def rows
22
+ Vedeu::Grid.rows(self)
23
+ end
24
+
20
25
  end # Fixnum
21
26
 
22
27
  module Vedeu
23
28
 
24
- # Divides horizontal terminal space into 12 equal columns, discarding
25
- # the remainder.
29
+ # Augment Fixnum to calculate column width or row height in a grid-based
30
+ # layout.
31
+ #
32
+ # The grid system splits the terminal height and width into 12 equal parts, by
33
+ # dividing the available height and width by 12. If the terminal height or
34
+ # width is not a multiple of 12, then Grid chooses the maximum value which
35
+ # will fit.
36
+ #
37
+ # Used primarily whilst defining geometry:
38
+ #
39
+ # width: 9.columns # (Terminal width / 12) * 9 characters wide; e.g.
40
+ # # Terminal is 92 characters wide, maximum value is
41
+ # # therefore 84, meaning a column is 7 characters wide.
42
+ #
43
+ # height: 3.columns # (Terminal height / 12) * 3 rows high; e.g.
44
+ # # Terminal is 38 characters wide, maximum value is
45
+ # # therefore 36, meaning a row is 3 characters tall.
26
46
  class Grid
27
47
 
28
- # @see (#initialize)
48
+ # @see #initialize
49
+ # @see #columns
29
50
  def self.columns(value)
30
51
  new(value).columns
31
52
  end
32
53
 
54
+ # @see #initialize
55
+ # @see #rows
56
+ def self.rows(value)
57
+ new(value).rows
58
+ end
59
+
33
60
  # Returns a new instance of Vedeu::Grid.
34
61
  #
35
62
  # @param value [Fixnum]
@@ -38,6 +65,8 @@ module Vedeu
38
65
  @value = value
39
66
  end
40
67
 
68
+ # Returns the width in characters for the number of columns specified.
69
+ #
41
70
  # @raise [OutOfRange] When the value parameter is not between 1 and 12
42
71
  # inclusive.
43
72
  # @return [Fixnum|OutOfRange]
@@ -48,6 +77,34 @@ module Vedeu
48
77
  column * value
49
78
  end
50
79
 
80
+ # Returns the height of a single row in characters.
81
+ #
82
+ # @return [Fixnum]
83
+ def height
84
+ actual_height / 12
85
+ end
86
+ alias_method :row, :height
87
+
88
+ # Returns the height in characters for the number of rows specified.
89
+ #
90
+ # @raise [OutOfRange] When the value parameter is not between 1 and 12
91
+ # inclusive.
92
+ # @return [Fixnum|OutOfRange]
93
+ def rows
94
+ fail OutOfRange,
95
+ 'Valid value between 1 and 12 inclusive.' if out_of_range?
96
+
97
+ row * value
98
+ end
99
+
100
+ # Returns the width of a single column in characters.
101
+ #
102
+ # @return [Fixnum]
103
+ def width
104
+ actual_width / 12
105
+ end
106
+ alias_method :column, :width
107
+
51
108
  protected
52
109
 
53
110
  # @!attribute [r] value
@@ -56,15 +113,13 @@ module Vedeu
56
113
 
57
114
  private
58
115
 
59
- # Returns the width of a single column in characters.
60
- #
61
116
  # @return [Fixnum]
62
- def column
63
- actual / 12
117
+ def actual_height
118
+ Vedeu::Terminal.height
64
119
  end
65
120
 
66
121
  # @return [Fixnum]
67
- def actual
122
+ def actual_width
68
123
  Vedeu::Terminal.width
69
124
  end
70
125