vedeu 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/borders_app.rb +60 -56
- data/lib/vedeu/buffers/all.rb +1 -0
- data/lib/vedeu/configuration/configuration.rb +2 -4
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +4 -3
- data/lib/vedeu/cursor/move_cursor.rb +7 -4
- data/lib/vedeu/cursor/toggle_cursor.rb +0 -1
- data/lib/vedeu/dsl/components/border.rb +99 -0
- data/lib/vedeu/dsl/components/geometry.rb +1 -0
- data/lib/vedeu/dsl/components/keymap.rb +1 -1
- data/lib/vedeu/dsl/composition.rb +7 -12
- data/lib/vedeu/dsl/interface.rb +7 -8
- data/lib/vedeu/dsl/line.rb +1 -10
- data/lib/vedeu/dsl/stream.rb +0 -2
- data/lib/vedeu/input/key.rb +10 -6
- data/lib/vedeu/input/keymap.rb +10 -8
- data/lib/vedeu/models/menu.rb +0 -2
- data/lib/vedeu/models/model.rb +20 -0
- data/lib/vedeu/models/view/composition.rb +4 -17
- data/lib/vedeu/models/view/interface.rb +9 -21
- data/lib/vedeu/models/view/line.rb +4 -17
- data/lib/vedeu/models/view/stream.rb +4 -17
- data/lib/vedeu/output/all.rb +1 -0
- data/lib/vedeu/output/border.rb +2 -2
- data/lib/vedeu/output/compositor.rb +0 -4
- data/lib/vedeu/output/wordwrap.rb +146 -0
- data/lib/vedeu/repositories/repository.rb +3 -2
- data/lib/vedeu/support/console.rb +29 -6
- data/lib/vedeu/support/content_geometry.rb +2 -0
- data/lib/vedeu/support/coordinate.rb +9 -4
- data/lib/vedeu/support/position_validator.rb +28 -7
- data/lib/vedeu/support/sentence.rb +21 -1
- data/lib/vedeu/support/terminal.rb +0 -2
- data/lib/vedeu/support/trace.rb +48 -2
- data/lib/vedeu/support/visible.rb +2 -0
- data/test/lib/vedeu/cursor/all_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +7 -29
- data/test/lib/vedeu/input/key_test.rb +3 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +266 -0
- data/test/lib/vedeu/presentation/colour_test.rb +68 -33
- data/test/lib/vedeu/support/common_test.rb +10 -0
- data/test/lib/vedeu/support/console_test.rb +82 -0
- data/test/lib/vedeu/support/position_validator_test.rb +13 -0
- data/test/support/helpers/all.rb +0 -1
- data/vedeu.gemspec +8 -8
- metadata +19 -18
- data/test/support/helpers/misc.rb +0 -15
data/lib/vedeu/dsl/line.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'vedeu/dsl/shared/all'
|
2
|
-
require 'vedeu/support/common'
|
3
2
|
|
4
3
|
module Vedeu
|
5
4
|
|
@@ -37,7 +36,6 @@ module Vedeu
|
|
37
36
|
# @api public
|
38
37
|
class Line
|
39
38
|
|
40
|
-
include Vedeu::Common
|
41
39
|
include Vedeu::DSL
|
42
40
|
include Vedeu::DSL::Colour
|
43
41
|
include Vedeu::DSL::Style
|
@@ -105,7 +103,7 @@ module Vedeu
|
|
105
103
|
def streams(&block)
|
106
104
|
fail InvalidSyntax, 'block not given' unless block_given?
|
107
105
|
|
108
|
-
model.add(
|
106
|
+
model.add(model.member.build(attributes, &block))
|
109
107
|
end
|
110
108
|
alias_method :stream, :streams
|
111
109
|
|
@@ -121,13 +119,6 @@ module Vedeu
|
|
121
119
|
}
|
122
120
|
end
|
123
121
|
|
124
|
-
# Return the class name for the children on this model.
|
125
|
-
#
|
126
|
-
# @return [Class]
|
127
|
-
def child
|
128
|
-
Vedeu::Stream
|
129
|
-
end
|
130
|
-
|
131
122
|
end # Line
|
132
123
|
|
133
124
|
end # DSL
|
data/lib/vedeu/dsl/stream.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'vedeu/dsl/shared/all'
|
2
|
-
require 'vedeu/support/common'
|
3
2
|
|
4
3
|
module Vedeu
|
5
4
|
|
@@ -10,7 +9,6 @@ module Vedeu
|
|
10
9
|
# @api public
|
11
10
|
class Stream
|
12
11
|
|
13
|
-
include Vedeu::Common
|
14
12
|
include Vedeu::DSL
|
15
13
|
include Vedeu::DSL::Colour
|
16
14
|
include Vedeu::DSL::Style
|
data/lib/vedeu/input/key.rb
CHANGED
@@ -5,13 +5,17 @@ module Vedeu
|
|
5
5
|
#
|
6
6
|
class Key
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# Creates a new instance of Key.
|
11
|
+
#
|
12
|
+
# @see Vedeu::Key#initialize
|
13
|
+
def build(input = nil, &block)
|
14
|
+
fail InvalidSyntax, 'block not given' unless block_given?
|
15
|
+
|
16
|
+
new(input, &block)
|
17
|
+
end
|
13
18
|
|
14
|
-
new(input, &block)
|
15
19
|
end
|
16
20
|
|
17
21
|
# Returns a new instance of Key.
|
data/lib/vedeu/input/keymap.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'vedeu/exceptions'
|
2
|
-
require 'vedeu/support/common'
|
3
2
|
require 'vedeu/models/model'
|
4
3
|
require 'vedeu/dsl/components/keymap'
|
5
4
|
|
@@ -7,15 +6,16 @@ module Vedeu
|
|
7
6
|
|
8
7
|
class Keymap
|
9
8
|
|
10
|
-
include Vedeu::Common
|
11
9
|
include Vedeu::Model
|
12
10
|
|
11
|
+
collection Vedeu::Keys
|
12
|
+
member Vedeu::Key
|
13
|
+
|
13
14
|
attr_accessor :name
|
14
|
-
attr_reader :
|
15
|
+
attr_reader :repository
|
15
16
|
|
16
17
|
class << self
|
17
18
|
|
18
|
-
|
19
19
|
# @option attributes client []
|
20
20
|
# @option attributes keys []
|
21
21
|
# @option attributes name []
|
@@ -81,7 +81,7 @@ module Vedeu
|
|
81
81
|
# @return [Vedeu::Keymap]
|
82
82
|
def initialize(name = '', keys = [], repository = nil)
|
83
83
|
@name = name
|
84
|
-
@keys =
|
84
|
+
@keys = keys
|
85
85
|
@repository = repository || Vedeu.keymaps
|
86
86
|
end
|
87
87
|
|
@@ -89,10 +89,12 @@ module Vedeu
|
|
89
89
|
def add(key)
|
90
90
|
return false unless valid?(key)
|
91
91
|
|
92
|
-
@keys
|
92
|
+
@keys = keys.add(key)
|
93
|
+
end
|
93
94
|
|
94
|
-
|
95
|
-
|
95
|
+
# @return [Vedeu::Keys]
|
96
|
+
def keys
|
97
|
+
collection.coerce(@keys, self)
|
96
98
|
end
|
97
99
|
|
98
100
|
# @param input [String|Symbol]
|
data/lib/vedeu/models/menu.rb
CHANGED
data/lib/vedeu/models/model.rb
CHANGED
@@ -8,6 +8,25 @@ module Vedeu
|
|
8
8
|
|
9
9
|
attr_reader :repository
|
10
10
|
|
11
|
+
module ClassMethods
|
12
|
+
|
13
|
+
# Provide a convenient way to define the child or children of a model.
|
14
|
+
#
|
15
|
+
# @param klass [Class] The member (singular) or collection (multiple)
|
16
|
+
# class name for the respective model.
|
17
|
+
# @return []
|
18
|
+
def child(klass)
|
19
|
+
send(:define_method, __callee__) { klass }
|
20
|
+
end
|
21
|
+
alias_method :member, :child
|
22
|
+
alias_method :collection, :child
|
23
|
+
|
24
|
+
end # ClassMethods
|
25
|
+
|
26
|
+
def self.included(klass)
|
27
|
+
klass.send :extend, ClassMethods
|
28
|
+
end
|
29
|
+
|
11
30
|
# Returns a DSL instance responsible for defining the DSL methods of this
|
12
31
|
# model.
|
13
32
|
#
|
@@ -20,6 +39,7 @@ module Vedeu
|
|
20
39
|
Object.const_get(dsl_class).new(self, client)
|
21
40
|
end
|
22
41
|
|
42
|
+
# @todo Perhaps some validation could be added here?
|
23
43
|
# @return [void] The model instance stored in the repository.
|
24
44
|
def store
|
25
45
|
repository.store(self) # if valid?
|
@@ -16,6 +16,9 @@ module Vedeu
|
|
16
16
|
include Vedeu::Presentation
|
17
17
|
include Vedeu::Model
|
18
18
|
|
19
|
+
collection Vedeu::Interfaces
|
20
|
+
member Vedeu::Interface
|
21
|
+
|
19
22
|
attr_reader :interfaces
|
20
23
|
alias_method :value, :interfaces
|
21
24
|
|
@@ -77,23 +80,7 @@ module Vedeu
|
|
77
80
|
|
78
81
|
# @return [Vedeu::Interfaces]
|
79
82
|
def interfaces
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
# Return the class name for the children on this model.
|
86
|
-
#
|
87
|
-
# @return [Class]
|
88
|
-
def child
|
89
|
-
Vedeu::Interface
|
90
|
-
end
|
91
|
-
|
92
|
-
# Return the class name for the children on this model.
|
93
|
-
#
|
94
|
-
# @return [Class]
|
95
|
-
def children
|
96
|
-
Vedeu::Interfaces
|
83
|
+
collection.coerce(@interfaces, self)
|
97
84
|
end
|
98
85
|
|
99
86
|
end # Composition
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'vedeu/support/common'
|
2
1
|
require 'vedeu/support/content_geometry'
|
3
2
|
require 'vedeu/models/model'
|
4
3
|
require 'vedeu/presentation/presentation'
|
@@ -6,6 +5,7 @@ require 'vedeu/buffers/display_buffer'
|
|
6
5
|
require 'vedeu/buffers/buffer'
|
7
6
|
|
8
7
|
require 'vedeu/models/view/lines'
|
8
|
+
require 'vedeu/models/view/line'
|
9
9
|
|
10
10
|
module Vedeu
|
11
11
|
|
@@ -18,11 +18,13 @@ module Vedeu
|
|
18
18
|
|
19
19
|
extend Forwardable
|
20
20
|
|
21
|
-
include Vedeu::Common
|
22
21
|
include Vedeu::Model
|
23
22
|
include Vedeu::Presentation
|
24
23
|
include Vedeu::DisplayBuffer
|
25
24
|
|
25
|
+
collection Vedeu::Lines
|
26
|
+
member Vedeu::Line
|
27
|
+
|
26
28
|
attr_accessor :border,
|
27
29
|
:colour,
|
28
30
|
:delay,
|
@@ -155,7 +157,7 @@ module Vedeu
|
|
155
157
|
|
156
158
|
# @return [Vedeu::Lines]
|
157
159
|
def lines
|
158
|
-
|
160
|
+
collection.coerce(@lines, self)
|
159
161
|
end
|
160
162
|
alias_method :content, :lines
|
161
163
|
alias_method :value, :lines
|
@@ -167,9 +169,11 @@ module Vedeu
|
|
167
169
|
lines.any?
|
168
170
|
end
|
169
171
|
|
170
|
-
#
|
172
|
+
# Renders the interface with a border if one is defined.
|
173
|
+
#
|
174
|
+
# @return [Array]
|
171
175
|
def render
|
172
|
-
if border
|
176
|
+
if border?
|
173
177
|
border.render
|
174
178
|
|
175
179
|
else
|
@@ -194,22 +198,6 @@ module Vedeu
|
|
194
198
|
Vedeu::Viewport.show(self)
|
195
199
|
end
|
196
200
|
|
197
|
-
private
|
198
|
-
|
199
|
-
# Return the class name for the children on this model.
|
200
|
-
#
|
201
|
-
# @return [Class]
|
202
|
-
def child
|
203
|
-
Vedeu::Line
|
204
|
-
end
|
205
|
-
|
206
|
-
# Return the class name for the children on this model.
|
207
|
-
#
|
208
|
-
# @return [Class]
|
209
|
-
def children
|
210
|
-
Vedeu::Lines
|
211
|
-
end
|
212
|
-
|
213
201
|
end # Interface
|
214
202
|
|
215
203
|
end # Vedeu
|
@@ -15,6 +15,9 @@ module Vedeu
|
|
15
15
|
include Vedeu::Model
|
16
16
|
include Vedeu::Presentation
|
17
17
|
|
18
|
+
collection Vedeu::Streams
|
19
|
+
member Vedeu::Stream
|
20
|
+
|
18
21
|
attr_accessor :parent,
|
19
22
|
:streams
|
20
23
|
|
@@ -103,7 +106,7 @@ module Vedeu
|
|
103
106
|
|
104
107
|
# @return [Vedeu::Streams]
|
105
108
|
def streams
|
106
|
-
|
109
|
+
collection.coerce(@streams, self)
|
107
110
|
end
|
108
111
|
|
109
112
|
# Delegate to Vedeu::Interface#width if available.
|
@@ -113,22 +116,6 @@ module Vedeu
|
|
113
116
|
parent.width if parent
|
114
117
|
end
|
115
118
|
|
116
|
-
private
|
117
|
-
|
118
|
-
# Return the class name for the children on this model.
|
119
|
-
#
|
120
|
-
# @return [Class]
|
121
|
-
def child
|
122
|
-
Vedeu::Stream
|
123
|
-
end
|
124
|
-
|
125
|
-
# Return the class name for the children on this model.
|
126
|
-
#
|
127
|
-
# @return [Class]
|
128
|
-
def children
|
129
|
-
Vedeu::Streams
|
130
|
-
end
|
131
|
-
|
132
119
|
end # Line
|
133
120
|
|
134
121
|
end # Vedeu
|
@@ -13,6 +13,9 @@ module Vedeu
|
|
13
13
|
include Vedeu::Model
|
14
14
|
include Vedeu::Presentation
|
15
15
|
|
16
|
+
collection Vedeu::Chars
|
17
|
+
member Vedeu::Char
|
18
|
+
|
16
19
|
attr_accessor :parent,
|
17
20
|
:value
|
18
21
|
|
@@ -85,7 +88,7 @@ module Vedeu
|
|
85
88
|
return [] if value.empty?
|
86
89
|
|
87
90
|
value.chars.map do |char|
|
88
|
-
|
91
|
+
member.new(char, parent, colour, style, nil).to_s
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
@@ -123,22 +126,6 @@ module Vedeu
|
|
123
126
|
parent.width if parent
|
124
127
|
end
|
125
128
|
|
126
|
-
private
|
127
|
-
|
128
|
-
# Return the class name for the children on this model.
|
129
|
-
#
|
130
|
-
# @return [Class]
|
131
|
-
def child
|
132
|
-
Vedeu::Char
|
133
|
-
end
|
134
|
-
|
135
|
-
# Return the class name for the collection of children on this model.
|
136
|
-
#
|
137
|
-
# @return [Class]
|
138
|
-
def children
|
139
|
-
Vedeu::Chars
|
140
|
-
end
|
141
|
-
|
142
129
|
end # Stream
|
143
130
|
|
144
131
|
end # Vedeu
|
data/lib/vedeu/output/all.rb
CHANGED
data/lib/vedeu/output/border.rb
CHANGED
@@ -124,14 +124,14 @@ module Vedeu
|
|
124
124
|
|
125
125
|
# Set the border colour.
|
126
126
|
#
|
127
|
-
# @return []
|
127
|
+
# @return [Vedeu::Colour]
|
128
128
|
def colour=(value)
|
129
129
|
@colour = Colour.coerce(value)
|
130
130
|
end
|
131
131
|
|
132
132
|
# Set the border style.
|
133
133
|
#
|
134
|
-
# @return []
|
134
|
+
# @return [Vedeu::Style]
|
135
135
|
def style=(value)
|
136
136
|
@style = Style.coerce(value)
|
137
137
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'vedeu/support/common'
|
2
|
-
|
3
1
|
module Vedeu
|
4
2
|
|
5
3
|
# Before the content of the buffer can be output to the terminal, if there are
|
@@ -14,8 +12,6 @@ module Vedeu
|
|
14
12
|
# @api private
|
15
13
|
class Compositor
|
16
14
|
|
17
|
-
include Vedeu::Common
|
18
|
-
|
19
15
|
# Convenience method to initialize a new Compositor and call its {#compose}
|
20
16
|
# method.
|
21
17
|
#
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Vedeu
|
2
|
+
|
3
|
+
class Wordwrap
|
4
|
+
|
5
|
+
# @param text [String]
|
6
|
+
# @param options [Hash]
|
7
|
+
# @option options ellipsis [String]
|
8
|
+
# @option options width [Fixnum]
|
9
|
+
# @return [Vedeu::Wordwrap]
|
10
|
+
def initialize(text, options = {})
|
11
|
+
@text = text
|
12
|
+
@options = defaults.merge(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Array<String>|String]
|
16
|
+
def prune
|
17
|
+
return text if text.size <= pruned_width
|
18
|
+
|
19
|
+
processed = []
|
20
|
+
|
21
|
+
if split_lines.size > 1
|
22
|
+
processed = split_lines.reduce([]) do |acc, line|
|
23
|
+
acc << ellipsis_string(line)
|
24
|
+
end
|
25
|
+
|
26
|
+
else
|
27
|
+
processed = ellipsis_string(text)
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
processed
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [String]
|
35
|
+
def wrap
|
36
|
+
processed = []
|
37
|
+
text.split(/\n/).map do |unprocessed|
|
38
|
+
line_length = 0
|
39
|
+
reformatted = []
|
40
|
+
|
41
|
+
unprocessed.split(/\s/).map do |word|
|
42
|
+
word_length = word.length + 1
|
43
|
+
|
44
|
+
if (line_length += word_length) >= width
|
45
|
+
line_length = word_length
|
46
|
+
processed << reformatted
|
47
|
+
reformatted = []
|
48
|
+
end
|
49
|
+
|
50
|
+
reformatted << word
|
51
|
+
end
|
52
|
+
|
53
|
+
processed << reformatted
|
54
|
+
end
|
55
|
+
|
56
|
+
processed.reduce([]) do |output, line|
|
57
|
+
output << line.join(' ')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def as_lines
|
62
|
+
if __callee__ == :prune_as_lines
|
63
|
+
to_line_objects(prune)
|
64
|
+
|
65
|
+
elsif __callee__ == :wrap_as_lines
|
66
|
+
to_line_objects(wrap)
|
67
|
+
|
68
|
+
else
|
69
|
+
to_line_objects(split_lines)
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
alias_method :prune_as_lines, :as_lines
|
74
|
+
alias_method :wrap_as_lines, :as_lines
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
attr_reader :text, :options
|
79
|
+
|
80
|
+
# @param text_as_lines [Array<String>]
|
81
|
+
# @return [Vedeu::Lines]
|
82
|
+
def to_line_objects(text_as_lines)
|
83
|
+
line_objects = Array(text_as_lines).map do |text_line|
|
84
|
+
stream = Vedeu::Stream.new(text_line)
|
85
|
+
line = Vedeu::Line.new
|
86
|
+
stream.parent = line
|
87
|
+
line.add(stream)
|
88
|
+
line
|
89
|
+
end
|
90
|
+
Vedeu::Lines.new(line_objects)
|
91
|
+
end
|
92
|
+
|
93
|
+
# @return [Array<String>]
|
94
|
+
def split_lines
|
95
|
+
text.split(/\n/)
|
96
|
+
end
|
97
|
+
|
98
|
+
# @return [String]
|
99
|
+
def output
|
100
|
+
processed.reduce([]) do |output, line|
|
101
|
+
output << line.join(' ')
|
102
|
+
end.join("\n")
|
103
|
+
end
|
104
|
+
|
105
|
+
# @return [String]
|
106
|
+
def ellipsis_string(string)
|
107
|
+
if string.size < ellipsis.size
|
108
|
+
prune_string(string)
|
109
|
+
|
110
|
+
else
|
111
|
+
[prune_string(string), ellipsis].join
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# @return [String]
|
117
|
+
def prune_string(string)
|
118
|
+
string.chomp.slice(0..pruned_width)
|
119
|
+
end
|
120
|
+
|
121
|
+
# @return [Fixnum]
|
122
|
+
def pruned_width
|
123
|
+
width - ellipsis.size
|
124
|
+
end
|
125
|
+
|
126
|
+
# @return [String]
|
127
|
+
def ellipsis
|
128
|
+
options.fetch(:ellipsis)
|
129
|
+
end
|
130
|
+
|
131
|
+
# @return [Fixnum]
|
132
|
+
def width
|
133
|
+
options.fetch(:width)
|
134
|
+
end
|
135
|
+
|
136
|
+
# @return [Hash]
|
137
|
+
def defaults
|
138
|
+
{
|
139
|
+
ellipsis: '...',
|
140
|
+
width: 70,
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
end # Wordwrap
|
145
|
+
|
146
|
+
end # Vedeu
|
@@ -123,8 +123,9 @@ module Vedeu
|
|
123
123
|
|
124
124
|
end
|
125
125
|
end
|
126
|
-
alias_method :destroy,
|
127
|
-
alias_method :delete,
|
126
|
+
alias_method :destroy, :remove
|
127
|
+
alias_method :delete, :remove
|
128
|
+
alias_method :deregister, :remove
|
128
129
|
|
129
130
|
# Reset the repository.
|
130
131
|
#
|
@@ -5,12 +5,6 @@ module Vedeu
|
|
5
5
|
|
6
6
|
class Console
|
7
7
|
|
8
|
-
attr_reader :height,
|
9
|
-
:width
|
10
|
-
|
11
|
-
alias_method :yn, :height
|
12
|
-
alias_method :xn, :width
|
13
|
-
|
14
8
|
# @param height [Fixnum]
|
15
9
|
# @param width [Fixnum]
|
16
10
|
def initialize(height = 25, width = 80)
|
@@ -56,17 +50,46 @@ module Vedeu
|
|
56
50
|
centre.last
|
57
51
|
end
|
58
52
|
|
53
|
+
# @param block [Proc]
|
54
|
+
# @return [Proc]
|
55
|
+
def cooked(&block)
|
56
|
+
yield
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Fixnum]
|
60
|
+
def height
|
61
|
+
@height
|
62
|
+
end
|
63
|
+
alias_method :tyn, :height
|
64
|
+
alias_method :yn, :height
|
65
|
+
|
59
66
|
# @return [Fixnum]
|
60
67
|
def origin
|
61
68
|
1
|
62
69
|
end
|
63
70
|
alias_method :x, :origin
|
64
71
|
alias_method :y, :origin
|
72
|
+
alias_method :tx, :origin
|
73
|
+
alias_method :ty, :origin
|
74
|
+
|
75
|
+
# @param block [Proc]
|
76
|
+
# @return [Proc]
|
77
|
+
def raw(&block)
|
78
|
+
yield
|
79
|
+
end
|
65
80
|
|
66
81
|
# @return [Array]
|
67
82
|
def size
|
68
83
|
[height, width]
|
69
84
|
end
|
85
|
+
alias_method :winsize, :size
|
86
|
+
|
87
|
+
# @return [Fixnum]
|
88
|
+
def width
|
89
|
+
@width
|
90
|
+
end
|
91
|
+
alias_method :txn, :width
|
92
|
+
alias_method :xn, :width
|
70
93
|
|
71
94
|
end # Console
|
72
95
|
|
@@ -4,10 +4,15 @@ module Vedeu
|
|
4
4
|
class Coordinate
|
5
5
|
|
6
6
|
attr_reader :height,
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
:width,
|
8
|
+
:x,
|
9
|
+
:y
|
10
|
+
|
11
|
+
# @param height [Fixnum]
|
12
|
+
# @param width [Fixnum]
|
13
|
+
# @param x [Fixnum]
|
14
|
+
# @param y [Fixnum]
|
15
|
+
# @return [Vedeu::Coordinate]
|
11
16
|
def initialize(height, width, x, y)
|
12
17
|
@height = height
|
13
18
|
@width = width
|