ruco 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruco/application.rb +9 -16
- data/lib/ruco/text_area.rb +31 -24
- data/ruco.gemspec +2 -2
- data/spec/ruco/editor_spec.rb +56 -0
- metadata +8 -25
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/ruco/application.rb
CHANGED
@@ -52,24 +52,17 @@ module Ruco
|
|
52
52
|
when :home then move_with_select_mode :to_bol
|
53
53
|
when :page_up then move_with_select_mode :page_up
|
54
54
|
when :page_down then move_with_select_mode :page_down
|
55
|
+
when :"Ctrl+right" then move_with_select_mode :jump, :right
|
56
|
+
when :"Ctrl+left" then move_with_select_mode :jump, :left
|
55
57
|
|
56
58
|
# select
|
57
|
-
when :"Shift+down" then
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
when :"Shift+
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
when :"Shift+up"
|
66
|
-
@focused.selecting do
|
67
|
-
move(:relative, -1, 0)
|
68
|
-
end
|
69
|
-
when :"Shift+left" then
|
70
|
-
@focused.selecting do
|
71
|
-
move(:relative, 0, -1)
|
72
|
-
end
|
59
|
+
when :"Shift+down" then @focused.selecting { move(:relative, 1, 0) }
|
60
|
+
when :"Shift+right" then @focused.selecting { move(:relative, 0, 1) }
|
61
|
+
when :"Shift+up" then @focused.selecting { move(:relative, -1, 0) }
|
62
|
+
when :"Shift+left" then @focused.selecting { move(:relative, 0, -1) }
|
63
|
+
when :"Ctrl+Shift+left" then @focused.selecting{ move(:jump, :left) }
|
64
|
+
when :"Ctrl+Shift+right" then @focused.selecting{ move(:jump, :right) }
|
65
|
+
|
73
66
|
|
74
67
|
# modify
|
75
68
|
when :tab then
|
data/lib/ruco/text_area.rb
CHANGED
@@ -29,37 +29,22 @@ module Ruco
|
|
29
29
|
def move(where, *args)
|
30
30
|
case where
|
31
31
|
when :relative
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
# user moves right on end of line -> next line
|
36
|
-
if line_change == 0 and line != lines.size - 1 and new_column > current_line.size
|
37
|
-
self.column = 0
|
38
|
-
self.line += 1
|
39
|
-
|
40
|
-
# user moves left on start of line -> prev line
|
41
|
-
elsif line_change == 0 and line != 0 and new_column <= 0
|
42
|
-
self.line -= 1
|
43
|
-
self.column = current_line.size
|
44
|
-
|
45
|
-
# normal movement
|
46
|
-
else
|
47
|
-
self.line += line_change
|
48
|
-
self.column += column_change
|
49
|
-
end
|
50
|
-
when :to then
|
32
|
+
move_relative(*args)
|
33
|
+
when :to
|
51
34
|
self.line, self.column = args
|
52
35
|
when :to_bol then move_to_bol(*args)
|
53
36
|
when :to_eol then move_to_eol(*args)
|
54
37
|
when :to_line then self.line = args.first
|
55
38
|
when :to_column then self.column = args.first
|
56
39
|
when :to_index then move(:to, *position_for_index(*args))
|
57
|
-
when :page_down
|
40
|
+
when :page_down
|
58
41
|
self.line += @window.lines
|
59
42
|
@window.set_top(@window.top + @window.lines, @lines.size)
|
60
|
-
when :page_up
|
43
|
+
when :page_up
|
61
44
|
self.line -= @window.lines
|
62
45
|
@window.set_top(@window.top - @window.lines, @lines.size)
|
46
|
+
when :jump
|
47
|
+
move_jump(args.first)
|
63
48
|
else
|
64
49
|
raise "Unknown move type #{where} with #{args.inspect}"
|
65
50
|
end
|
@@ -125,9 +110,7 @@ module Ruco
|
|
125
110
|
end
|
126
111
|
|
127
112
|
def index_for_position(position=self.position)
|
128
|
-
|
129
|
-
index += 1 if position.line > 0 # account for missing newline
|
130
|
-
index
|
113
|
+
lines[0...position.line].sum{|l| l.size + 1} + position.column
|
131
114
|
end
|
132
115
|
|
133
116
|
def content
|
@@ -180,6 +163,30 @@ module Ruco
|
|
180
163
|
move :to_column, column
|
181
164
|
end
|
182
165
|
|
166
|
+
def move_relative(line_change, column_change)
|
167
|
+
if line_change == 0
|
168
|
+
# let user wrap around start/end of line
|
169
|
+
move :to_index, index_for_position + column_change
|
170
|
+
else
|
171
|
+
# normal movement
|
172
|
+
self.line += line_change
|
173
|
+
self.column += column_change
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def move_jump(direction)
|
178
|
+
regex = /\b/m
|
179
|
+
text = content
|
180
|
+
|
181
|
+
next_index = if direction == :right
|
182
|
+
text.index(regex, index_for_position + 1) || text.size
|
183
|
+
else
|
184
|
+
text.rindex(regex,[index_for_position - 1, 0].max) || 0
|
185
|
+
end
|
186
|
+
|
187
|
+
move :to_index, next_index
|
188
|
+
end
|
189
|
+
|
183
190
|
def backspace(count)
|
184
191
|
if @column >= count
|
185
192
|
new_colum = @column - count
|
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.1.
|
8
|
+
s.version = "0.1.3"
|
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-05-
|
12
|
+
s.date = %q{2011-05-30}
|
13
13
|
s.default_executable = %q{ruco}
|
14
14
|
s.email = %q{michael@grosser.it}
|
15
15
|
s.executables = ["ruco"]
|
data/spec/ruco/editor_spec.rb
CHANGED
@@ -349,6 +349,62 @@ describe Ruco::Editor do
|
|
349
349
|
editor.cursor.should == [1,2]
|
350
350
|
end
|
351
351
|
end
|
352
|
+
|
353
|
+
describe 'jumping' do
|
354
|
+
it "can jump right" do
|
355
|
+
write("abc def")
|
356
|
+
editor.move(:jump, :right)
|
357
|
+
editor.cursor.should == [0,3]
|
358
|
+
end
|
359
|
+
|
360
|
+
it "does not jump over braces" do
|
361
|
+
write("abc(def")
|
362
|
+
editor.move(:jump, :right)
|
363
|
+
editor.cursor.should == [0,3]
|
364
|
+
end
|
365
|
+
|
366
|
+
it "can jump over whitespace and newlines" do
|
367
|
+
write("abc\n 123")
|
368
|
+
editor.move(:jump, :right)
|
369
|
+
editor.cursor.should == [0,3]
|
370
|
+
editor.move(:jump, :right)
|
371
|
+
editor.cursor.should == [1,1]
|
372
|
+
end
|
373
|
+
|
374
|
+
it "can jump left" do
|
375
|
+
write("abc def")
|
376
|
+
editor.move(:relative, 0,3)
|
377
|
+
editor.move(:jump, :left)
|
378
|
+
editor.cursor.should == [0,0]
|
379
|
+
end
|
380
|
+
|
381
|
+
it "can jump to start" do
|
382
|
+
write("abc\ndef")
|
383
|
+
editor.move(:relative, 0,2)
|
384
|
+
editor.move(:jump, :left)
|
385
|
+
editor.cursor.should == [0,0]
|
386
|
+
end
|
387
|
+
|
388
|
+
it "stays at start" do
|
389
|
+
write("abc\ndef")
|
390
|
+
editor.move(:jump, :left)
|
391
|
+
editor.cursor.should == [0,0]
|
392
|
+
end
|
393
|
+
|
394
|
+
it "can jump to end" do
|
395
|
+
write("abc\ndef")
|
396
|
+
editor.move(:relative, 1,1)
|
397
|
+
editor.move(:jump, :right)
|
398
|
+
editor.cursor.should == [1,3]
|
399
|
+
end
|
400
|
+
|
401
|
+
it "stays at end" do
|
402
|
+
write("abc\ndef")
|
403
|
+
editor.move(:to, 1,3)
|
404
|
+
editor.move(:jump, :right)
|
405
|
+
editor.cursor.should == [1,3]
|
406
|
+
end
|
407
|
+
end
|
352
408
|
end
|
353
409
|
|
354
410
|
describe :move_line do
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 31
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 2
|
10
|
-
version: 0.1.2
|
5
|
+
version: 0.1.3
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Michael Grosser
|
@@ -15,25 +10,20 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-30 00:00:00 +02:00
|
19
14
|
default_executable: ruco
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
17
|
+
name: clipboard
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
19
|
none: false
|
24
20
|
requirements:
|
25
21
|
- - ">="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 43
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 9
|
31
|
-
- 8
|
32
23
|
version: 0.9.8
|
33
|
-
requirement: *id001
|
34
|
-
prerelease: false
|
35
24
|
type: :runtime
|
36
|
-
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
37
27
|
description:
|
38
28
|
email: michael@grosser.it
|
39
29
|
executables:
|
@@ -95,11 +85,7 @@ has_rdoc: true
|
|
95
85
|
homepage: http://github.com/grosser/ruco
|
96
86
|
licenses: []
|
97
87
|
|
98
|
-
post_install_message:
|
99
|
-
|
100
|
-
Mac: shift/ctrl + arrow-keys only work in iterm (not Terminal.app)
|
101
|
-
Ubuntu: sudo apt-get install xclip # to use the clipboard
|
102
|
-
|
88
|
+
post_install_message: "\n Mac: shift/ctrl + arrow-keys only work in iterm (not Terminal.app)\n Ubuntu: sudo apt-get install xclip # to use the clipboard\n\n"
|
103
89
|
rdoc_options: []
|
104
90
|
|
105
91
|
require_paths:
|
@@ -109,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
95
|
requirements:
|
110
96
|
- - ">="
|
111
97
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
98
|
+
hash: 472274319
|
113
99
|
segments:
|
114
100
|
- 0
|
115
101
|
version: "0"
|
@@ -118,9 +104,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
104
|
requirements:
|
119
105
|
- - ">="
|
120
106
|
- !ruby/object:Gem::Version
|
121
|
-
hash: 3
|
122
|
-
segments:
|
123
|
-
- 0
|
124
107
|
version: "0"
|
125
108
|
requirements: []
|
126
109
|
|