ruco 0.0.44 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -12,6 +12,7 @@ Features:
12
12
  - cut, copy and paste -> Ctrl+x/c/v
13
13
  - undo / redo
14
14
  - stays at last position when reopening a file
15
+ - (optional) remove trailing whitespace on save
15
16
 
16
17
  Install
17
18
  =======
@@ -29,6 +30,7 @@ Customize
29
30
  # set options
30
31
  options.window_line_scroll_offset = 5 # default 1
31
32
  options.history_entries = 10 # default 100
33
+ options.editor_remove_trailing_whitespace_on_save = true # default false
32
34
  ...
33
35
 
34
36
  # bind a key
@@ -63,7 +65,7 @@ Customize
63
65
  TIPS
64
66
  ====
65
67
  - [Tabs] Ruco does not like tabs. Existing tabs are displayed as ' ' and pressing tab inserts 2*' '
66
- - [RVM] `alias r="rvm ree exec ruco"` and you only have to install ruco once
68
+ - [RVM] `alias r="rvm ree exec ruco"` and you only have to install ruco once
67
69
  - [Ruby1.9] Unicode support -> install libncursesw5-dev before installing ruby (does not work for 1.8)
68
70
  - [ssh vs clipboard] access your desktops clipboard by installing `xauth` on the server and then using `ssh -X`
69
71
  - [Alt key] if Alt does not work try your Meta/Win/Cmd key
@@ -71,7 +73,6 @@ TIPS
71
73
  TODO
72
74
  =====
73
75
  - align soft-tabs
74
- - strip whitespace after content / whitespace only lines, without removing intentional whitespace e.g. from markdown
75
76
  - handle \\r and \\r\\n nicely <-> breaks curses output
76
77
  - highlight tabs (e.g. strange character or reverse/underline/color)
77
78
  - big warning when editing a not-writable file
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.44
1
+ 0.0.45
data/lib/ruco/editor.rb CHANGED
@@ -12,6 +12,7 @@ module Ruco
12
12
 
13
13
  def initialize(file, options)
14
14
  @file = file
15
+ @options = options
15
16
 
16
17
  # check for size (10000 lines * 100 chars should be enough for everybody !?)
17
18
  if File.exist?(@file) and File.size(@file) > (1024 * 1024)
@@ -19,16 +20,16 @@ module Ruco
19
20
  end
20
21
 
21
22
  content = (File.exist?(@file) ? File.read(@file) : '')
22
- content.tabs_to_spaces! if options[:convert_tabs]
23
+ content.tabs_to_spaces! if @options[:convert_tabs]
23
24
 
24
- if options[:convert_return]
25
+ if @options[:convert_return]
25
26
  content.gsub!(/\r\n?/,"\n")
26
27
  else
27
28
  raise "Ruco does not support \\r characters, start with --convert-return to remove them" if content.include?("\r")
28
29
  end
29
30
 
30
31
  @saved_content = content
31
- @text_area = EditorArea.new(content, options)
32
+ @text_area = EditorArea.new(content, @options)
32
33
  restore_session
33
34
  end
34
35
 
@@ -46,9 +47,13 @@ module Ruco
46
47
  end
47
48
 
48
49
  def save
49
- content = text_area.content
50
+ lines = text_area.send(:lines)
51
+ lines.each(&:rstrip!) if @options[:remove_trailing_whitespace_on_save]
52
+ content = lines * "\n"
53
+
50
54
  File.open(@file,'w'){|f| f.write(content) }
51
55
  @saved_content = content
56
+
52
57
  true
53
58
  rescue Object => e
54
59
  e.message
@@ -243,6 +243,7 @@ module Ruco
243
243
  end
244
244
 
245
245
  def adjust_window
246
+ sanitize_position
246
247
  @window.set_position(position, :max_lines => @lines.size)
247
248
  end
248
249
  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.44"
8
+ s.version = "0.0.45"
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-09}
12
+ s.date = %q{2011-02-10}
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.3.7}
66
+ s.rubygems_version = %q{1.4.2}
67
67
  s.summary = %q{Commandline editor written in ruby}
68
68
  s.test_files = [
69
69
  "spec/ruco/application_spec.rb",
@@ -85,7 +85,6 @@ 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
89
88
  s.specification_version = 3
90
89
 
91
90
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -691,6 +691,33 @@ describe Ruco::Editor do
691
691
  `chmod +w #{@file}`
692
692
  end
693
693
  end
694
+
695
+ describe 'remove trailing whitespace' do
696
+ it "can remove trailing whitespace" do
697
+ write("a \n \nb\n\n")
698
+ editor.move(:to, 0,2)
699
+ editor.instance_eval{@options[:remove_trailing_whitespace_on_save] = true}
700
+ editor.save
701
+ editor.view.should == "a\n\nb\n"
702
+ editor.cursor.should == [0,1]
703
+ end
704
+
705
+ it "does not affect trailing newlines" do
706
+ write("\n\n\n")
707
+ editor.move(:to, 2,0)
708
+ editor.instance_eval{@options[:remove_trailing_whitespace_on_save] = true}
709
+ editor.save
710
+ editor.view.should == "\n\n\n"
711
+ editor.cursor.should == [2,0]
712
+ end
713
+
714
+ it "does not remove trailing whitespace by default" do
715
+ write("a \n \nb\n\n")
716
+ editor.save
717
+ editor.view.should == "a \n \nb\n"
718
+ editor.cursor.should == [0,0]
719
+ end
720
+ end
694
721
  end
695
722
 
696
723
  describe :delete do
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: 69
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 44
9
- version: 0.0.44
9
+ - 45
10
+ version: 0.0.45
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Grosser
@@ -14,24 +15,25 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-02-09 00:00:00 +01:00
18
+ date: 2011-02-10 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:
@@ -101,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
103
  requirements:
102
104
  - - ">="
103
105
  - !ruby/object:Gem::Version
104
- hash: -55157123
106
+ hash: 3
105
107
  segments:
106
108
  - 0
107
109
  version: "0"
@@ -110,13 +112,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
112
  requirements:
111
113
  - - ">="
112
114
  - !ruby/object:Gem::Version
115
+ hash: 3
113
116
  segments:
114
117
  - 0
115
118
  version: "0"
116
119
  requirements: []
117
120
 
118
121
  rubyforge_project:
119
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.4.2
120
123
  signing_key:
121
124
  specification_version: 3
122
125
  summary: Commandline editor written in ruby