ruco 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Readme.md +9 -14
- data/VERSION +1 -1
- data/lib/ruco/application.rb +1 -1
- data/lib/ruco/command_bar.rb +2 -2
- data/lib/ruco/form.rb +1 -1
- data/lib/ruco/keyboard.rb +6 -2
- data/lib/ruco/{cursor.rb → position.rb} +9 -1
- data/lib/ruco/text_area.rb +12 -12
- data/lib/ruco.rb +1 -1
- data/ruco.gemspec +3 -4
- data/spec/ruco/keyboard_spec.rb +5 -0
- metadata +11 -8
data/Readme.md
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
|
1
|
+
Simple, extendable, test-driven commandline editor written in ruby.
|
2
2
|
|
3
|
-
|
3
|
+
Features:
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
- viewing / scrolling / editing / saving / creating
|
5
|
+
- **Intuitive interface**
|
8
6
|
- selecting via Shift+left/right/up/down and Ctrl+a(all)
|
9
|
-
- Home/End + Page up/down
|
10
7
|
- Tab -> indent / Shift+Tab -> unindent (tab == 2 space)
|
11
|
-
-
|
12
|
-
- writable
|
13
|
-
-
|
14
|
-
- find / go to line
|
15
|
-
- delete line
|
8
|
+
- keeps indentation (+ paste-detection e.g. via Cmd+v)
|
9
|
+
- change (*) + writable (!) indicators
|
10
|
+
- find / go to line / delete line
|
16
11
|
- configuration via `~/.ruco.rb`
|
17
|
-
-
|
18
|
-
- cut, copy and paste (defaults: Ctrl+x/c/v)
|
19
|
-
- paste-detection (e.g. cmd+v) -> clean indentation
|
12
|
+
- cut, copy and paste -> Ctrl+x/c/v
|
20
13
|
|
21
14
|
Install
|
22
15
|
=======
|
@@ -69,8 +62,10 @@ TODO
|
|
69
62
|
- warnings / messages
|
70
63
|
- syntax highlighting
|
71
64
|
- raise when binding to a unsupported key
|
65
|
+
- search options regex + case-sensitive
|
72
66
|
- search & replace
|
73
67
|
- 1.8: unicode support <-> already finished but unusable due to Curses (see encoding branch)
|
68
|
+
- support Alt+Fx keys
|
74
69
|
|
75
70
|
Author
|
76
71
|
======
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.29
|
data/lib/ruco/application.rb
CHANGED
data/lib/ruco/command_bar.rb
CHANGED
data/lib/ruco/form.rb
CHANGED
data/lib/ruco/keyboard.rb
CHANGED
@@ -140,7 +140,7 @@ class Keyboard
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def self.escape_sequence?(sequence)
|
143
|
-
sequence[0
|
143
|
+
sequence[0] == 27 # Esc
|
144
144
|
end
|
145
145
|
|
146
146
|
def self.escape_sequence_to_key(sequence)
|
@@ -148,7 +148,11 @@ class Keyboard
|
|
148
148
|
when [27, 91, 49, 59, 50, 65] then :"Shift+up"
|
149
149
|
when [27, 91, 49, 59, 50, 66] then :"Shift+down"
|
150
150
|
else
|
151
|
-
|
151
|
+
if sequence.size == 2
|
152
|
+
:"Alt+#{sequence[1].chr}"
|
153
|
+
else
|
154
|
+
bytes_to_string(sequence)
|
155
|
+
end
|
152
156
|
end
|
153
157
|
end
|
154
158
|
end
|
@@ -1,9 +1,17 @@
|
|
1
1
|
module Ruco
|
2
|
-
class
|
2
|
+
class Position < Array
|
3
3
|
def initialize(line, column)
|
4
4
|
super([line, column])
|
5
5
|
end
|
6
6
|
|
7
|
+
def line=(x)
|
8
|
+
self[0] = x
|
9
|
+
end
|
10
|
+
|
11
|
+
def column=(x)
|
12
|
+
self[1] = x
|
13
|
+
end
|
14
|
+
|
7
15
|
alias_method :line, :first
|
8
16
|
alias_method :column, :last
|
9
17
|
end
|
data/lib/ruco/text_area.rb
CHANGED
@@ -83,8 +83,8 @@ module Ruco
|
|
83
83
|
|
84
84
|
def text_in_selection
|
85
85
|
return '' unless @selection
|
86
|
-
start = index_for_position(
|
87
|
-
finish = index_for_position(
|
86
|
+
start = index_for_position(@selection.first)
|
87
|
+
finish = index_for_position(@selection.last)
|
88
88
|
content.slice(start, finish-start)
|
89
89
|
end
|
90
90
|
|
@@ -149,12 +149,12 @@ module Ruco
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def cursor
|
152
|
-
|
152
|
+
Position.new @cursor_line, @cursor_column
|
153
153
|
end
|
154
154
|
|
155
|
-
def index_for_position(
|
156
|
-
index = lines[0...line].join("\n").size + column
|
157
|
-
index += 1 if line > 0 # account for missing newline
|
155
|
+
def index_for_position(position=self.position)
|
156
|
+
index = lines[0...position.line].join("\n").size + position.column
|
157
|
+
index += 1 if position.line > 0 # account for missing newline
|
158
158
|
index
|
159
159
|
end
|
160
160
|
|
@@ -170,7 +170,7 @@ module Ruco
|
|
170
170
|
protected
|
171
171
|
|
172
172
|
def position
|
173
|
-
|
173
|
+
Position.new(@line, @column)
|
174
174
|
end
|
175
175
|
|
176
176
|
def position_for_index(index)
|
@@ -302,8 +302,8 @@ module Ruco
|
|
302
302
|
|
303
303
|
def delete_content_in_selection
|
304
304
|
with_lines_as_string do |content|
|
305
|
-
start = index_for_position(
|
306
|
-
finish = index_for_position(
|
305
|
+
start = index_for_position(@selection.first)
|
306
|
+
finish = index_for_position(@selection.last)
|
307
307
|
content.slice!(start, finish-start)
|
308
308
|
move(:to, *@selection.first)
|
309
309
|
end
|
@@ -322,8 +322,8 @@ module Ruco
|
|
322
322
|
last ||= first
|
323
323
|
if selection
|
324
324
|
adjust_cursor = selection.first == position ? first : last
|
325
|
-
selection.first
|
326
|
-
selection.last
|
325
|
+
selection.first.column = [selection.first.column + first, 0].max
|
326
|
+
selection.last.column = [selection.last.column + last, 0].max
|
327
327
|
@column += adjust_cursor
|
328
328
|
else
|
329
329
|
@column += first
|
@@ -331,7 +331,7 @@ module Ruco
|
|
331
331
|
end
|
332
332
|
|
333
333
|
def selected_lines
|
334
|
-
selection.first
|
334
|
+
selection.first.line.upto(selection.last.line)
|
335
335
|
end
|
336
336
|
end
|
337
337
|
end
|
data/lib/ruco.rb
CHANGED
data/ruco.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruco}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.29"
|
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"]
|
@@ -28,10 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/ruco/core_ext/object.rb",
|
29
29
|
"lib/ruco/core_ext/range.rb",
|
30
30
|
"lib/ruco/core_ext/string.rb",
|
31
|
-
"lib/ruco/cursor.rb",
|
32
31
|
"lib/ruco/editor.rb",
|
33
32
|
"lib/ruco/form.rb",
|
34
33
|
"lib/ruco/keyboard.rb",
|
34
|
+
"lib/ruco/position.rb",
|
35
35
|
"lib/ruco/status_bar.rb",
|
36
36
|
"lib/ruco/text_area.rb",
|
37
37
|
"lib/ruco/text_field.rb",
|
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
]
|
52
52
|
s.homepage = %q{http://github.com/grosser/ruco}
|
53
53
|
s.require_paths = ["lib"]
|
54
|
-
s.rubygems_version = %q{1.
|
54
|
+
s.rubygems_version = %q{1.4.2}
|
55
55
|
s.summary = %q{Commandline editor written in ruby}
|
56
56
|
s.test_files = [
|
57
57
|
"spec/ruco/application_spec.rb",
|
@@ -68,7 +68,6 @@ Gem::Specification.new do |s|
|
|
68
68
|
]
|
69
69
|
|
70
70
|
if s.respond_to? :specification_version then
|
71
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
72
71
|
s.specification_version = 3
|
73
72
|
|
74
73
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/spec/ruco/keyboard_spec.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 37
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 29
|
10
|
+
version: 0.0.29
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Michael Grosser
|
@@ -18,20 +19,21 @@ date: 2011-01-26 00:00:00 +01:00
|
|
18
19
|
default_executable: ruco
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name: clipboard
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
+
hash: 51
|
27
28
|
segments:
|
28
29
|
- 0
|
29
30
|
- 9
|
30
31
|
- 4
|
31
32
|
version: 0.9.4
|
32
|
-
type: :runtime
|
33
33
|
prerelease: false
|
34
34
|
version_requirements: *id001
|
35
|
+
type: :runtime
|
36
|
+
name: clipboard
|
35
37
|
description:
|
36
38
|
email: michael@grosser.it
|
37
39
|
executables:
|
@@ -55,10 +57,10 @@ files:
|
|
55
57
|
- lib/ruco/core_ext/object.rb
|
56
58
|
- lib/ruco/core_ext/range.rb
|
57
59
|
- lib/ruco/core_ext/string.rb
|
58
|
-
- lib/ruco/cursor.rb
|
59
60
|
- lib/ruco/editor.rb
|
60
61
|
- lib/ruco/form.rb
|
61
62
|
- lib/ruco/keyboard.rb
|
63
|
+
- lib/ruco/position.rb
|
62
64
|
- lib/ruco/status_bar.rb
|
63
65
|
- lib/ruco/text_area.rb
|
64
66
|
- lib/ruco/text_field.rb
|
@@ -89,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
91
|
requirements:
|
90
92
|
- - ">="
|
91
93
|
- !ruby/object:Gem::Version
|
92
|
-
hash:
|
94
|
+
hash: 3
|
93
95
|
segments:
|
94
96
|
- 0
|
95
97
|
version: "0"
|
@@ -98,13 +100,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
100
|
requirements:
|
99
101
|
- - ">="
|
100
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
101
104
|
segments:
|
102
105
|
- 0
|
103
106
|
version: "0"
|
104
107
|
requirements: []
|
105
108
|
|
106
109
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.
|
110
|
+
rubygems_version: 1.4.2
|
108
111
|
signing_key:
|
109
112
|
specification_version: 3
|
110
113
|
summary: Commandline editor written in ruby
|