ruco 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +1 -0
- data/VERSION +1 -1
- data/lib/ruco/application.rb +12 -1
- data/lib/ruco/editor.rb +9 -1
- data/ruco.gemspec +2 -2
- data/spec/ruco/application_spec.rb +52 -0
- metadata +4 -4
data/Readme.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.8
|
data/lib/ruco/application.rb
CHANGED
@@ -176,7 +176,18 @@ module Ruco
|
|
176
176
|
end
|
177
177
|
|
178
178
|
action :find do
|
179
|
-
ask("Find: ", :cache => true)
|
179
|
+
ask("Find: ", :cache => true) do |result|
|
180
|
+
next if editor.find(result)
|
181
|
+
|
182
|
+
if editor.content.include?(result)
|
183
|
+
ask("No matches found -- Enter=First match ESC=Stop") do
|
184
|
+
editor.move(:to, 0,0)
|
185
|
+
editor.find(result)
|
186
|
+
end
|
187
|
+
else
|
188
|
+
ask("No matches found in entire file", :auto_enter => true){}
|
189
|
+
end
|
190
|
+
end
|
180
191
|
end
|
181
192
|
|
182
193
|
action :find_and_replace do
|
data/lib/ruco/editor.rb
CHANGED
@@ -37,10 +37,14 @@ module Ruco
|
|
37
37
|
|
38
38
|
def find(text)
|
39
39
|
move(:relative, 0,0) # reset selection
|
40
|
-
|
40
|
+
start = text_area.content.index(text, text_area.index_for_position+1)
|
41
|
+
return unless start
|
42
|
+
|
43
|
+
# select the found word
|
41
44
|
finish = start + text.size
|
42
45
|
move(:to_index, finish)
|
43
46
|
selecting{ move(:to_index, start) }
|
47
|
+
|
44
48
|
true
|
45
49
|
end
|
46
50
|
|
@@ -66,6 +70,10 @@ module Ruco
|
|
66
70
|
session_store.set(@file, text_area.state.slice(:position, :screen_position))
|
67
71
|
end
|
68
72
|
|
73
|
+
def content
|
74
|
+
text_area.content.freeze # no modifications allowed
|
75
|
+
end
|
76
|
+
|
69
77
|
private
|
70
78
|
|
71
79
|
def restore_session
|
data/ruco.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruco}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-11-
|
12
|
+
s.date = %q{2011-11-03}
|
13
13
|
s.default_executable = %q{ruco}
|
14
14
|
s.email = %q{michael@grosser.it}
|
15
15
|
s.executables = ["ruco"]
|
@@ -356,6 +356,58 @@ describe Ruco::Application do
|
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
|
+
describe 'find' do
|
360
|
+
def command_bar
|
361
|
+
app.view.split("\n").last
|
362
|
+
end
|
363
|
+
|
364
|
+
it "finds" do
|
365
|
+
write('text foo')
|
366
|
+
type :'Ctrl+f', 'foo', :enter
|
367
|
+
app.cursor.should == [1, 5]
|
368
|
+
end
|
369
|
+
|
370
|
+
it "marks the found word" do
|
371
|
+
write('text foo')
|
372
|
+
type :'Ctrl+f', 'foo', :enter, 'a'
|
373
|
+
editor_part(app.view).should == "text a\n\n"
|
374
|
+
end
|
375
|
+
|
376
|
+
it "shows a menu when nothing was found and there were previous matches" do
|
377
|
+
write('text bar bar foo')
|
378
|
+
type :'Ctrl+f', 'bar', :enter
|
379
|
+
type :'Ctrl+f', 'bar', :enter
|
380
|
+
type :'Ctrl+f', 'bar', :enter
|
381
|
+
command_bar.should include("No matches found")
|
382
|
+
end
|
383
|
+
|
384
|
+
it "returns to first match if user confirms after no more match is found" do
|
385
|
+
write('text foo foo')
|
386
|
+
type :'Ctrl+f', 'foo', :enter
|
387
|
+
app.cursor.should == [1, 5]
|
388
|
+
type :'Ctrl+f', 'foo', :enter
|
389
|
+
app.cursor.should == [1, 9]
|
390
|
+
type :'Ctrl+f', 'foo', :enter, :enter
|
391
|
+
app.cursor.should == [1, 5]
|
392
|
+
end
|
393
|
+
|
394
|
+
it "notifies the user when no matches are found in the entire file" do
|
395
|
+
write('text foo')
|
396
|
+
type :'Ctrl+f', 'bar', :enter
|
397
|
+
command_bar.should include("No matches found in entire file")
|
398
|
+
type :enter
|
399
|
+
command_bar.should_not include("No matches found in entire file")
|
400
|
+
end
|
401
|
+
|
402
|
+
it "dismisses the nothing found warning on a single key-press" do
|
403
|
+
write('text foo')
|
404
|
+
type :'Ctrl+f', 'bar', :enter
|
405
|
+
command_bar.should include("No matches found in entire file")
|
406
|
+
type 'a'
|
407
|
+
command_bar.should_not include("No matches found in entire file")
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
359
411
|
describe :save do
|
360
412
|
it "just saves" do
|
361
413
|
write('')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 8
|
10
|
+
version: 0.2.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-03 00:00:00 -07:00
|
19
19
|
default_executable: ruco
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|