ruco 0.1.9 → 0.1.10

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
@@ -16,6 +16,7 @@ Features:
16
16
  - opens file at line with `ruco foo/bar.rb:32` syntax
17
17
  - keeps whatever newline format you use (\r \n \r\n)
18
18
  - surrounds selection with quotes/braces (select abc + " --> "abc")
19
+ - shortens long file names in the middle
19
20
  - (optional) remove trailing whitespace on save
20
21
  - (optional) blank line before eof on save
21
22
  - (optional) line numbers
@@ -98,7 +99,6 @@ TODO
98
99
  - search options regex + case-sensitive
99
100
  - add auto-confirm to 'replace?' dialog -> type s == skip, no enter needed
100
101
  - 1.8: unicode support <-> already finished but unusable due to Curses (see encoding branch)
101
- - shorten long file names in the middle/start, not at the end
102
102
  - add double quotes/braces when typing one + skip over quote/brace when its already typed at current position
103
103
 
104
104
  Authors
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -42,6 +42,17 @@ class String
42
42
  last = words.last
43
43
  slice(0,first.size) == first and slice(-last.size,last.size) == last
44
44
  end
45
+
46
+ # https://gist.github.com/20844
47
+ # remove middle from strings exceeding max length.
48
+ def ellipsize(options={})
49
+ max = options[:max] || 40
50
+ delimiter = options[:delimiter] || "..."
51
+ return self if self.size <= max
52
+ remainder = max - delimiter.size
53
+ offset = remainder / 2
54
+ (self[0,offset + (remainder.odd? ? 1 : 0)].to_s + delimiter + self[-offset,offset].to_s)[0,max].to_s
55
+ end unless defined? ellipsize
45
56
  end
46
57
 
47
58
  # http://grosser.it/2010/12/31/ruby-string-indexes-indices-find-all-indexes-in-a-string
@@ -6,8 +6,20 @@ module Ruco
6
6
  end
7
7
 
8
8
  def view
9
- position = @editor.position
10
- spread "Ruco #{Ruco::VERSION} -- #{@editor.file}#{change_indicator}#{writable_indicator}", "#{position.line + 1}:#{position.column + 1}"
9
+ columns = @options[:columns]
10
+
11
+ version = "Ruco #{Ruco::VERSION} -- "
12
+ position = " #{@editor.position.line + 1}:#{@editor.position.column + 1}"
13
+ indicators = "#{change_indicator}#{writable_indicator}"
14
+ essential = version + position + indicators
15
+ space_left = [columns - essential.size, 0].max
16
+
17
+ # fit file name into remaining space
18
+ file = @editor.file
19
+ file = file.ellipsize(:max => space_left)
20
+ space_left -= file.size
21
+
22
+ "#{version}#{file}#{indicators}#{' ' * space_left}#{position}"[0, columns]
11
23
  end
12
24
 
13
25
  def change_indicator
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.1.9"
8
+ s.version = "0.1.10"
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"]
@@ -69,7 +69,7 @@ describe Ruco::Application do
69
69
  it "can resize" do
70
70
  write("01234567\n1\n2\n3\n4\n5678910111213\n6\n7\n8")
71
71
  app.resize(8, 7)
72
- app.view.should == "Ruc 1:1\n0123456\n1\n2\n3\n4\n5678910\n^W Exit"
72
+ app.view.should == "Ruco 0.\n0123456\n1\n2\n3\n4\n5678910\n^W Exit"
73
73
  end
74
74
 
75
75
  describe 'opening with line' do
@@ -138,7 +138,7 @@ describe Ruco::Application do
138
138
  editor_part(reopened.view).should == "x\n\n"
139
139
  end
140
140
  end
141
-
141
+
142
142
  it "can select all" do
143
143
  write("1\n2\n3\n4\n5\n")
144
144
  app.key(:down)
@@ -14,10 +14,10 @@ describe Ruco::StatusBar do
14
14
  end
15
15
 
16
16
  it "can show to long files" do
17
- editor = Ruco::Editor.new('a'*20+'b', :lines => 5, :columns => 20)
18
- bar = Ruco::StatusBar.new(editor, :columns => 20)
19
- bar.view.should == "Ruco #{Ruco::VERSION} -- aa 1:1"
20
- bar.view.size.should == 20
17
+ editor = Ruco::Editor.new('123456789abcdefghijklmnop', :lines => 5, :columns => 20)
18
+ bar = Ruco::StatusBar.new(editor, :columns => 30)
19
+ bar.view.should == "Ruco #{Ruco::VERSION} -- 1234...nop 1:1"
20
+ bar.view.size.should == 30
21
21
  end
22
22
 
23
23
  it "indicates modified" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 9
10
- version: 0.1.9
9
+ - 10
10
+ version: 0.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser