ruco 0.0.28 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -1,22 +1,15 @@
1
- Commandline editor written in ruby
1
+ Simple, extendable, test-driven commandline editor written in ruby.
2
2
 
3
- Alpha, lets see if this works...
3
+ Features:
4
4
 
5
- Finished:
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
- - change-indicator (*)
12
- - writable indicator (!)
13
- - backspace / delete
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
- - keeps indentation
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.28
1
+ 0.0.29
@@ -20,7 +20,7 @@ module Ruco
20
20
  end
21
21
 
22
22
  def cursor
23
- Cursor.new(@focused.cursor.line + @status_lines, @focused.cursor.column)
23
+ Position.new(@focused.cursor.line + @status_lines, @focused.cursor.column)
24
24
  end
25
25
 
26
26
  def key(key)
@@ -41,9 +41,9 @@ module Ruco
41
41
 
42
42
  def cursor
43
43
  if @form
44
- Cursor.new cursor_line, @form.cursor.column
44
+ Position.new cursor_line, @form.cursor.column
45
45
  else
46
- Cursor.new cursor_line, 0
46
+ Position.new cursor_line, 0
47
47
  end
48
48
  end
49
49
 
data/lib/ruco/form.rb CHANGED
@@ -19,7 +19,7 @@ module Ruco
19
19
  end
20
20
 
21
21
  def cursor
22
- Cursor.new 0, @label.size + @text_field.cursor.column
22
+ Position.new 0, @label.size + @text_field.cursor.column
23
23
  end
24
24
 
25
25
  def reset
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..1] == [27, 91] # Esc [
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
- bytes_to_string(sequence)
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 Cursor < Array
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
@@ -83,8 +83,8 @@ module Ruco
83
83
 
84
84
  def text_in_selection
85
85
  return '' unless @selection
86
- start = index_for_position(*@selection.first)
87
- finish = index_for_position(*@selection.last)
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
- Cursor.new @cursor_line, @cursor_column
152
+ Position.new @cursor_line, @cursor_column
153
153
  end
154
154
 
155
- def index_for_position(line=@line, column=@column)
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
- Cursor.new(@line, @column)
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(*@selection.first)
306
- finish = index_for_position(*@selection.last)
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[1] = [selection.first[1] + first, 0].max
326
- selection.last[1] = [selection.last[1] + last, 0].max
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[0].upto(selection.last[0])
334
+ selection.first.line.upto(selection.last.line)
335
335
  end
336
336
  end
337
337
  end
data/lib/ruco.rb CHANGED
@@ -7,7 +7,7 @@ require 'ruco/core_ext/hash'
7
7
  require 'ruco/core_ext/range'
8
8
 
9
9
  require 'ruco/keyboard'
10
- require 'ruco/cursor'
10
+ require 'ruco/position'
11
11
 
12
12
  require 'ruco/editor'
13
13
  require 'ruco/status_bar'
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.28"
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.3.7}
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
@@ -100,4 +100,9 @@ describe Keyboard do
100
100
  type ['a']
101
101
  output.should == ["a"]
102
102
  end
103
+
104
+ it "can handle Alt+x codes" do
105
+ type [27,103]
106
+ output.should == [:"Alt+g"]
107
+ end
103
108
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 37
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 28
9
- version: 0.0.28
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: 712420077
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.3.7
110
+ rubygems_version: 1.4.2
108
111
  signing_key:
109
112
  specification_version: 3
110
113
  summary: Commandline editor written in ruby