ruco 0.0.48 → 0.0.49

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 CHANGED
@@ -4,6 +4,7 @@ Features:
4
4
 
5
5
  - **Intuitive interface**
6
6
  - selecting via Shift+left/right/up/down (only on Linux) and Ctrl+a(all)
7
+ - move line up/down (Alt+Ctrl+up/down)
7
8
  - Tab -> indent / Shift+Tab -> unindent
8
9
  - keeps indentation (+ paste-detection e.g. via Cmd+v)
9
10
  - change (*) + writable (!) indicators
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.48
1
+ 0.0.49
@@ -209,6 +209,8 @@ module Ruco
209
209
 
210
210
  action(:undo){ @editor.undo if @focused == @editor }
211
211
  action(:redo){ @editor.redo if @focused == @editor }
212
+ action(:move_line_up){ @editor.move_line(-1) if @focused == @editor }
213
+ action(:move_line_down){ @editor.move_line(1) if @focused == @editor }
212
214
  end
213
215
 
214
216
  def setup_keys
@@ -226,6 +228,8 @@ module Ruco
226
228
  bind :"Ctrl+v", :paste
227
229
  bind :"Ctrl+z", :undo
228
230
  bind :"Ctrl+y", :redo
231
+ bind :"Alt+Ctrl+down", :move_line_down
232
+ bind :"Alt+Ctrl+up", :move_line_up
229
233
  end
230
234
 
231
235
  def load_user_config
@@ -269,4 +273,4 @@ module Ruco
269
273
  [file, go_to_line]
270
274
  end
271
275
  end
272
- end
276
+ end
@@ -20,6 +20,10 @@ class String
20
20
  match(/^\s*/)[0]
21
21
  end
22
22
 
23
+ def leading_whitespace=(whitespace)
24
+ sub!(/^\s*/, whitespace)
25
+ end
26
+
23
27
  # stub for 1.8
24
28
  unless method_defined?(:force_encoding)
25
29
  def force_encoding(encoding)
@@ -44,4 +48,4 @@ class String
44
48
  end
45
49
  found
46
50
  end
47
- end
51
+ end
data/lib/ruco/editor.rb CHANGED
@@ -7,7 +7,7 @@ module Ruco
7
7
  :insert, :indent, :unindent, :delete, :delete_line,
8
8
  :redo, :undo,
9
9
  :selecting, :selection, :text_in_selection, :reset,
10
- :move, :resize,
10
+ :move, :resize, :move_line,
11
11
  :to => :text_area
12
12
 
13
13
  def initialize(file, options)
@@ -27,6 +27,16 @@ module Ruco
27
27
  sanitize_position
28
28
  end
29
29
 
30
+ def move_line(direction)
31
+ old = line
32
+ new = line + direction
33
+ return if new < 0
34
+ return if new >= lines.size
35
+ lines[old].leading_whitespace = lines[new].leading_whitespace
36
+ lines[old], lines[new] = lines[new], lines[old]
37
+ @line += direction
38
+ end
39
+
30
40
  def indent
31
41
  selected_lines.each do |line|
32
42
  lines[line].insert(0, ' ' * Ruco::TAB_SIZE)
@@ -88,4 +98,4 @@ module Ruco
88
98
  selection.first.line.upto(selection.last.line)
89
99
  end
90
100
  end
91
- end
101
+ end
data/lib/ruco/keyboard.rb CHANGED
@@ -38,16 +38,37 @@ class Keyboard
38
38
  when Curses::Key::DOWN then :down
39
39
  when Curses::Key::RIGHT then :right
40
40
  when Curses::Key::LEFT then :left
41
+
42
+ when 337, '^[1;2A' then :"Shift+up"
43
+ when 336, '^[1;2B' then :"Shift+down"
41
44
  when 402, '^[1;2C' then :"Shift+right"
42
- when 554, '^[1;5C' then :"Ctrl+right"
43
- when 555, '^[1;6C' then :"Ctrl+Shift+right"
44
45
  when 393, '^[1;2D' then :"Shift+left"
45
- when 539, '^[1;5D' then :"Ctrl+left"
46
- when 540, '^[1;6D' then :"Ctrl+Shift+left"
47
- when 337, '^[1;2A' then :"Shift+up"
46
+
47
+ when 558, '^[1;3A' then :"Alt+up"
48
+ when 517, '^[1;3B' then :"Alt+down"
49
+ when 552, '^[1;3C' then :"Alt+right"
50
+ when 537, '^[1;3D' then :"Alt+left"
51
+
48
52
  when 560, '^[1;5A' then :"Ctrl+up"
49
- when 336, '^[1;2B' then :"Shift+down"
50
53
  when 519, '^[1;5B' then :"Ctrl+down"
54
+ when 554, '^[1;5C' then :"Ctrl+right"
55
+ when 539, '^[1;5D' then :"Ctrl+left"
56
+
57
+ when 561, '^[1;6A' then :"Ctrl+Shift+up"
58
+ when 520, '^[1;6B' then :"Ctrl+Shift+down"
59
+ when 555, '^[1;6C' then :"Ctrl+Shift+right"
60
+ when 540, '^[1;6D' then :"Ctrl+Shift+left"
61
+
62
+ when 562, '^[1;7A' then :"Alt+Ctrl+up"
63
+ when 521, '^[1;7B' then :"Alt+Ctrl+down"
64
+ when 556, '^[1;7C' then :"Alt+Ctrl+right"
65
+ when 541, '^[1;7D' then :"Alt+Ctrl+left"
66
+
67
+ when '^[1;8A' then :"Alt+Ctrl+Shift+up"
68
+ when '^[1;8B' then :"Alt+Ctrl+Shift+down"
69
+ when '^[1;8C' then :"Alt+Ctrl+Shift+right"
70
+ when '^[1;8D' then :"Alt+Ctrl+Shift+left"
71
+
51
72
  when Curses::KEY_END then :end
52
73
  when Curses::KEY_HOME then :home
53
74
  when Curses::KEY_NPAGE then :page_down
@@ -154,4 +175,4 @@ class Keyboard
154
175
  def self.is_alt_key_code?(key)
155
176
  key.slice(0,1) == "^" and key.size == 2
156
177
  end
157
- end
178
+ end
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.0.48"
8
+ s.version = "0.0.49"
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-02-19}
12
+ s.date = %q{2011-02-20}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
63
63
  ]
64
64
  s.homepage = %q{http://github.com/grosser/ruco}
65
65
  s.require_paths = ["lib"]
66
- s.rubygems_version = %q{1.4.2}
66
+ s.rubygems_version = %q{1.3.7}
67
67
  s.summary = %q{Commandline editor written in ruby}
68
68
  s.test_files = [
69
69
  "spec/ruco/application_spec.rb",
@@ -85,6 +85,7 @@ Gem::Specification.new do |s|
85
85
  ]
86
86
 
87
87
  if s.respond_to? :specification_version then
88
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
88
89
  s.specification_version = 3
89
90
 
90
91
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -347,4 +347,4 @@ describe Ruco::Application do
347
347
  end
348
348
  end
349
349
  end
350
- end
350
+ end
@@ -323,6 +323,48 @@ describe Ruco::Editor do
323
323
  end
324
324
  end
325
325
 
326
+ describe :move_line do
327
+ before do
328
+ write("0\n1\n2\n")
329
+ end
330
+
331
+ it "moves the line" do
332
+ editor.move_line(1)
333
+ editor.view.should == "1\n0\n2\n"
334
+ end
335
+
336
+ it "keeps the cursor at the moved line" do
337
+ editor.move_line(1)
338
+ editor.cursor.should == [1,0]
339
+ end
340
+
341
+ it "keeps the cursor at current column" do
342
+ editor.move(:to, 0,1)
343
+ editor.move_line(1)
344
+ editor.cursor.should == [1,1]
345
+ end
346
+
347
+ it "uses indentation of moved-to-line" do
348
+ write(" 0\n 1\n 2\n")
349
+ editor.move_line(1)
350
+ editor.view.should == " 1\n 0\n 2\n"
351
+ end
352
+
353
+ it "cannot move past start of file" do
354
+ editor.move_line(-1)
355
+ editor.view.should == "0\n1\n2\n"
356
+ end
357
+
358
+ it "cannot move past end of file" do
359
+ write("0\n1\n")
360
+ editor.move_line(1)
361
+ editor.move_line(1)
362
+ editor.move_line(1)
363
+ editor.move_line(1)
364
+ editor.view.should == "1\n\n0\n"
365
+ end
366
+ end
367
+
326
368
  describe :selecting do
327
369
  before do
328
370
  write('012345678')
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 127
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 48
10
- version: 0.0.48
8
+ - 49
9
+ version: 0.0.49
11
10
  platform: ruby
12
11
  authors:
13
12
  - Michael Grosser
@@ -15,25 +14,24 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-02-19 00:00:00 +01:00
17
+ date: 2011-02-20 00:00:00 +01:00
19
18
  default_executable: ruco
20
19
  dependencies:
21
20
  - !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
28
27
  segments:
29
28
  - 0
30
29
  - 9
31
30
  - 4
32
31
  version: 0.9.4
32
+ type: :runtime
33
33
  prerelease: false
34
34
  version_requirements: *id001
35
- type: :runtime
36
- name: clipboard
37
35
  description:
38
36
  email: michael@grosser.it
39
37
  executables:
@@ -103,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
101
  requirements:
104
102
  - - ">="
105
103
  - !ruby/object:Gem::Version
106
- hash: 3
104
+ hash: -100213919
107
105
  segments:
108
106
  - 0
109
107
  version: "0"
@@ -112,14 +110,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
110
  requirements:
113
111
  - - ">="
114
112
  - !ruby/object:Gem::Version
115
- hash: 3
116
113
  segments:
117
114
  - 0
118
115
  version: "0"
119
116
  requirements: []
120
117
 
121
118
  rubyforge_project:
122
- rubygems_version: 1.4.2
119
+ rubygems_version: 1.3.7
123
120
  signing_key:
124
121
  specification_version: 3
125
122
  summary: Commandline editor written in ruby