vedeu 0.6.38 → 0.6.39

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: a3b9204a33456f344d0f99492f9b00b544036b23
4
- data.tar.gz: 80f15efc5738f5fcaacd6065e53235f61e5e5b0e
3
+ metadata.gz: ba1c61c6e18c58f67aa29538d0f7c7765199fad5
4
+ data.tar.gz: 82dc0fd7e7f3c65bff2fa207d6103cf8784ada1f
5
5
  SHA512:
6
- metadata.gz: bd3541b906d8894c766f680ce02d5e49f9ad323302a8476ac2105a75aac5413c8956de137acb26a725be1a6e9bfee7b4493d16cc6398ec5bb280308c4d79881f
7
- data.tar.gz: 11373347106344fd1617785d3367920f18d5ef6cd404e9f778833b812180fa1945013efa9ef557688e2cb399e89244885883c4f0e41447d10408a3ecf6d095d2
6
+ metadata.gz: b53f28b9940e7f4cb175adec72115203635cceaab007d13f134fca09d39b426fd06fe95ee2526c8a4f6bac591672b40f4217c1fcedfc409e5506c7aad67ff52b
7
+ data.tar.gz: e05e316be1c418cde5c71c4b2d1bfe5b58ac5a119ceeb5bad4b2227c0e83857c9a4586b1fb1b5e6fde1c440f82c081707bfa798b317eef3808e44e5c3e10c9e1
data/docs/cursors.md CHANGED
@@ -57,6 +57,8 @@ specified. If 'name' is unknown, using 'Vedeu.focus' will use the
57
57
  interface currently in focus.
58
58
 
59
59
  ### `:\_cursor_left\_`
60
+ Moves the cursor one character left, unless the left-most position
61
+ for the view or terminal is reached.
60
62
 
61
63
  Vedeu.trigger(:_cursor_left_, name)
62
64
  Vedeu.trigger(:_cursor_left_, Vedeu.focus)
@@ -67,6 +69,8 @@ interface currently in focus.
67
69
  Vedeu.trigger(:_cursor_down_, Vedeu.focus)
68
70
 
69
71
  ### `:\_cursor_up\_`
72
+ Moves the cursor one line up, unless the top-most position for the
73
+ view or terminal is reached.
70
74
 
71
75
  Vedeu.trigger(:_cursor_up_, name)
72
76
  Vedeu.trigger(:_cursor_up_, Vedeu.focus)
@@ -76,3 +80,18 @@ interface currently in focus.
76
80
  Vedeu.trigger(:_cursor_right_, name)
77
81
  Vedeu.trigger(:_cursor_right_, Vedeu.focus)
78
82
 
83
+ ### `:\_cursor_top\_`
84
+ Moves the cursor to the top-most position for the view or terminal.
85
+ If the view contains content, then this event will effectively scroll
86
+ to the first line of the content.
87
+
88
+ Vedeu.trigger(:_cursor_top_, name)
89
+ Vedeu.trigger(:_cursor_top_, Vedeu.focus)
90
+
91
+ ### `:\_cursor_bottom\_`
92
+ Moves the cursor to the bottom-most position for the view or terminal.
93
+ If the view contains content, then this event will effectively scroll
94
+ to the last line of the content.
95
+
96
+ Vedeu.trigger(:_cursor_bottom_, name)
97
+ Vedeu.trigger(:_cursor_bottom_, Vedeu.focus)
@@ -8,8 +8,8 @@ class AlignmentApp
8
8
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
9
9
 
10
10
  Vedeu.configure do
11
- log './tmp/alignment.log'
12
- renderers Vedeu::Renderers::File.new(filename: './tmp/alignment.out')
11
+ log '/tmp/alignment.log'
12
+ renderers Vedeu::Renderers::File.new(filename: '/tmp/alignment.out')
13
13
  end
14
14
 
15
15
  Vedeu.interface :top_left_view do
@@ -8,8 +8,8 @@ class EditorApp
8
8
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
9
9
 
10
10
  Vedeu.configure do
11
- log './tmp/editor.log'
12
- renderers Vedeu::Renderers::File.new(filename: './tmp/editor.out')
11
+ log '/tmp/editor.log'
12
+ renderers Vedeu::Renderers::File.new(filename: '/tmp/editor.out')
13
13
  fake!
14
14
  end
15
15
 
@@ -21,7 +21,7 @@ class HelloWorldsApp
21
21
  # Add specific configuration for the client application.
22
22
  #
23
23
  # Vedeu.configure do
24
- # log './tmp/hello_worlds.log'
24
+ # log '/tmp/hello_worlds.log'
25
25
  # end
26
26
 
27
27
  Vedeu.interface :hello do
@@ -64,8 +64,8 @@ class HorizontalAlignmentApp
64
64
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
65
65
 
66
66
  Vedeu.configure do
67
- log './tmp/horizontal_alignment.log'
68
- renderers Vedeu::Renderers::File.new(filename: './tmp/horizontal_alignment.out')
67
+ log '/tmp/horizontal_alignment.log'
68
+ renderers Vedeu::Renderers::File.new(filename: '/tmp/horizontal_alignment.out')
69
69
  end
70
70
 
71
71
  Vedeu.interface :left_interface do
@@ -64,8 +64,8 @@ class VerticalAlignmentApp
64
64
  Vedeu.bind(:_initialize_) { Vedeu.trigger(:_refresh_) }
65
65
 
66
66
  Vedeu.configure do
67
- log './tmp/vertical_alignment.log'
68
- renderers Vedeu::Renderers::File.new(filename: './tmp/vertical_alignment.out')
67
+ log '/tmp/vertical_alignment.log'
68
+ renderers Vedeu::Renderers::File.new(filename: '/tmp/vertical_alignment.out')
69
69
  end
70
70
 
71
71
  Vedeu.interface :top_interface do
@@ -123,6 +123,26 @@ module Vedeu
123
123
  end
124
124
  end
125
125
 
126
+ # Returns the number of lines of content for the buffer or 0 if
127
+ # the buffer is empty.
128
+ #
129
+ # @return [Fixnum]
130
+ def size
131
+ if back?
132
+ back.lines.size
133
+
134
+ elsif front?
135
+ front.lines.size
136
+
137
+ elsif previous?
138
+ previous.lines.size
139
+
140
+ else
141
+ 0
142
+
143
+ end
144
+ end
145
+
126
146
  private
127
147
 
128
148
  # Returns the default options/attributes for this class.
@@ -212,12 +212,12 @@ module Vedeu
212
212
 
213
213
  # @return [Fixnum]
214
214
  def ox
215
- @ox < 0 ? 0 : @ox
215
+ @ox = @ox < 0 ? 0 : @ox
216
216
  end
217
217
 
218
218
  # @return [Fixnum]
219
219
  def oy
220
- @oy < 0 ? 0 : @oy
220
+ @oy = @oy < 0 ? 0 : @oy
221
221
  end
222
222
 
223
223
  # Return the position of this cursor.
@@ -382,6 +382,18 @@ module Vedeu
382
382
  Vedeu.trigger(:_refresh_cursor_, name)
383
383
  end
384
384
 
385
+ # See {file:docs/cursors.md}
386
+ Vedeu.bind(:_cursor_top_) do |name|
387
+ Vedeu.trigger(:_cursor_reposition_, name, 0, 0)
388
+ end
389
+
390
+ # See {file:docs/cursors.md}
391
+ Vedeu.bind(:_cursor_bottom_) do |name|
392
+ count = Vedeu.buffers.by_name(name).size
393
+
394
+ Vedeu.trigger(:_cursor_reposition_, name, count, 0)
395
+ end
396
+
385
397
  # :nocov:
386
398
 
387
399
  end # Vedeu
@@ -108,6 +108,7 @@ module Vedeu
108
108
  "\e[3~" => :delete,
109
109
  "\u232B" => :delete,
110
110
  "\e[F" => :end,
111
+ "\eOF" => :end,
111
112
  "\r" => :enter,
112
113
  "\n" => :enter,
113
114
  "\e" => :escape,
@@ -103,11 +103,11 @@ module Vedeu
103
103
 
104
104
  # @return [void]
105
105
  def toggle_cursor
106
- Vedeu.hide_cursor(Vedeu.focus)
106
+ Vedeu.trigger(:_hide_cursor_)
107
107
 
108
108
  yield
109
109
 
110
- Vedeu.show_cursor(Vedeu.focus)
110
+ Vedeu.trigger(:_show_cursor_)
111
111
  end
112
112
 
113
113
  end # Renderers
@@ -166,6 +166,7 @@ module Vedeu
166
166
 
167
167
  private
168
168
 
169
+ # @param model [void] A model instance.
169
170
  # @return [String]
170
171
  def log_store(model)
171
172
  type = registered?(model.name) ? :update : :create
data/lib/vedeu/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Vedeu
2
2
 
3
3
  # The current version of Vedeu.
4
- VERSION = '0.6.38'.freeze
4
+ VERSION = '0.6.39'.freeze
5
5
 
6
6
  end
@@ -149,6 +149,38 @@ module Vedeu
149
149
  end
150
150
  end
151
151
 
152
+ describe '#size' do
153
+ subject { instance.size }
154
+
155
+ context 'when there is new content on the back buffer' do
156
+ let(:back) {
157
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
158
+ }
159
+
160
+ it { subject.must_equal(1) }
161
+ end
162
+
163
+ context 'when there is existing content on the front buffer' do
164
+ let(:front) {
165
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
166
+ }
167
+
168
+ it { subject.must_equal(1) }
169
+ end
170
+
171
+ context 'when there is content on the previous buffer' do
172
+ let(:previous) {
173
+ Vedeu::Views::View.new(value: [Vedeu::Views::Line.new])
174
+ }
175
+
176
+ it { subject.must_equal(1) }
177
+ end
178
+
179
+ context 'when there is no content on any buffer' do
180
+ it { subject.must_equal(0) }
181
+ end
182
+ end
183
+
152
184
  end # Buffer
153
185
 
154
186
  end # Buffers
@@ -11,6 +11,8 @@ module Vedeu
11
11
  # it { Vedeu.bound?(:_cursor_reset_).must_equal(true) }
12
12
  it { Vedeu.bound?(:_cursor_right_).must_equal(true) }
13
13
  it { Vedeu.bound?(:_cursor_up_).must_equal(true) }
14
+ it { Vedeu.bound?(:_cursor_top_).must_equal(true) }
15
+ it { Vedeu.bound?(:_cursor_bottom_).must_equal(true) }
14
16
  end
15
17
 
16
18
  module Cursors
@@ -64,8 +64,8 @@ module Vedeu
64
64
  Vedeu.stubs(:focus).returns(:vedeu_renderers_render)
65
65
  Vedeu::Renderers.reset
66
66
  Vedeu::Renderers.renderer(DummyRenderer)
67
- Vedeu.stubs(:hide_cursor)
68
- Vedeu.stubs(:show_cursor)
67
+ Vedeu.stubs(:trigger).with(:_hide_cursor_)
68
+ Vedeu.stubs(:trigger).with(:_show_cursor_)
69
69
  end
70
70
 
71
71
  subject { described.render(output) }
@@ -82,6 +82,17 @@ module Vedeu
82
82
  .new(value: Vedeu::EscapeSequences::Esc.hide_cursor)
83
83
  }
84
84
 
85
+ it 'hides the cursor before rendering the content to avoid cursor ' \
86
+ 'flicker' do
87
+ Vedeu.expects(:trigger).with(:_hide_cursor_)
88
+ subject
89
+ end
90
+
91
+ it 'shows the cursor after rendering the content' do
92
+ Vedeu.expects(:trigger).with(:_show_cursor_)
93
+ subject
94
+ end
95
+
85
96
  it { subject.must_be_instance_of(Vedeu::Models::Escape) }
86
97
  end
87
98
 
@@ -89,12 +100,6 @@ module Vedeu
89
100
  it { subject.must_be_instance_of(NilClass) }
90
101
  end
91
102
  end
92
-
93
- context 'when no interfaces/view have been defined' do
94
- before { Vedeu.stubs(:focus).raises(Vedeu::Error::Fatal) }
95
-
96
- it { proc { subject }.must_raise(Vedeu::Error::Fatal) }
97
- end
98
103
  end
99
104
 
100
105
  describe '.renderer' do
@@ -97,7 +97,7 @@ class VedeuMaterialColoursApp
97
97
  x(3)
98
98
  xn(64)
99
99
  y(15)
100
- yn(32)
100
+ yn(34)
101
101
  end
102
102
  zindex(1)
103
103
  end
@@ -107,6 +107,8 @@ class VedeuMaterialColoursApp
107
107
  key(:right) { Vedeu.trigger(:_cursor_right_) }
108
108
  key(:down) { Vedeu.trigger(:_cursor_down_) }
109
109
  key(:left) { Vedeu.trigger(:_cursor_left_) }
110
+ key(:home) { Vedeu.trigger(:_cursor_top_) }
111
+ key(:end) { Vedeu.trigger(:_cursor_bottom_) }
110
112
 
111
113
  key('q') { Vedeu.trigger(:_exit_) }
112
114
  key(:escape) { Vedeu.trigger(:_mode_switch_) }
@@ -202,6 +204,20 @@ class VedeuMaterialColoursApp
202
204
  }
203
205
  stream { left "Move cursor" }
204
206
  }
207
+ line {
208
+ stream {
209
+ left "home",
210
+ foreground: '#ffff00', width: 20
211
+ }
212
+ stream { left "Move cursor to first line of content." }
213
+ }
214
+ line {
215
+ stream {
216
+ left "end",
217
+ foreground: '#ffff00', width: 20
218
+ }
219
+ stream { left "Move cursor to last line of content." }
220
+ }
205
221
  line {}
206
222
  line {
207
223
  stream {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.38
4
+ version: 0.6.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-25 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard