ruco 0.0.53 → 0.0.54

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
@@ -81,9 +81,9 @@ TIPS
81
81
 
82
82
  TODO
83
83
  =====
84
- - check writeable status every x seconds (e.g. in background) -> faster while typing
84
+ - check writable status every x seconds (e.g. in background) -> faster while typing
85
85
  - search help e.g. 'Nothing found' '#4 of 6 hits' 'no more hits, start from beginning ?'
86
- - hightlight current work when reopening search (so typing replaces it)
86
+ - highlight current work when reopening search (so typing replaces it)
87
87
  - align soft-tabs
88
88
  - highlight tabs (e.g. strange character or reverse/underline/color)
89
89
  - big warning when editing a not-writable file
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.53
1
+ 0.0.54
@@ -65,7 +65,11 @@ module Ruco
65
65
  def cached_form_if(cache, question)
66
66
  if cache
67
67
  new_form = yield
68
- new_form.insert(@forms_cache[question].value) if @forms_cache[question]
68
+ if @forms_cache[question]
69
+ new_form.insert(@forms_cache[question].value)
70
+ new_form.move(:to, 0,0)
71
+ new_form.selecting{ move(:to_eol) }
72
+ end
69
73
  @forms_cache[question] = new_form
70
74
  else
71
75
  yield
@@ -3,7 +3,7 @@ module Ruco
3
3
  attr_reader :file
4
4
  attr_reader :text_area
5
5
  private :text_area
6
- delegate :view, :style_map, :cursor,
6
+ delegate :view, :style_map, :cursor, :position,
7
7
  :insert, :indent, :unindent, :delete, :delete_line,
8
8
  :redo, :undo,
9
9
  :selecting, :selection, :text_in_selection, :reset,
@@ -6,11 +6,8 @@ module Ruco
6
6
  end
7
7
 
8
8
  def view
9
- "Ruco #{Ruco::VERSION} -- #{@editor.file}#{change_indicator}#{writable_indicator}"
10
- end
11
-
12
- def format
13
- Curses::A_REVERSE
9
+ position = @editor.position
10
+ spread "Ruco #{Ruco::VERSION} -- #{@editor.file}#{change_indicator}#{writable_indicator}", "#{position.line + 1}:#{position.column + 1}"
14
11
  end
15
12
 
16
13
  def change_indicator
@@ -18,10 +15,17 @@ module Ruco
18
15
  end
19
16
 
20
17
  def writable_indicator
21
- @writeable ||= begin
18
+ @writable ||= begin
22
19
  writable = (not File.exist?(@editor.file) or system("test -w #{@editor.file}"))
23
20
  writable ? ' ' : '!'
24
21
  end
25
22
  end
23
+
24
+ private
25
+
26
+ def spread(left, right)
27
+ empty = [@options[:columns] - left.size - right.size, 0].max
28
+ "#{left}#{' ' * empty}#{right}"
29
+ end
26
30
  end
27
- end
31
+ end
@@ -123,12 +123,12 @@ module Ruco
123
123
  @window.columns = columns
124
124
  end
125
125
 
126
- protected
127
-
128
126
  def position
129
127
  Position.new(line, column)
130
128
  end
131
129
 
130
+ protected
131
+
132
132
  def position_for_index(index)
133
133
  jump = content.slice(0, index).to_s.naive_split("\n")
134
134
  [jump.size - 1, jump.last.size]
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.0.53"
8
+ s.version = "0.0.54"
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-05-06}
12
+ s.date = %q{2011-05-08}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -30,9 +30,12 @@ describe Ruco::Application do
30
30
  keys.each{|k| app.key k }
31
31
  end
32
32
 
33
+ def status(line=1)
34
+ "Ruco #{Ruco::VERSION} -- spec/temp.txt #{line}:1\n"
35
+ end
36
+
33
37
  let(:rucorc){ 'spec/.ruco.rb' }
34
38
  let(:app){ Ruco::Application.new(@file, :lines => 5, :columns => 10, :rc => rucorc) }
35
- let(:status){ "Ruco #{Ruco::VERSION} -- spec/temp.txt \n" }
36
39
  let(:command){ "^W Exit" }
37
40
 
38
41
  it "renders status + editor + command" do
@@ -46,7 +49,7 @@ describe Ruco::Application do
46
49
  app.key(:enter)
47
50
  app.key('2')
48
51
  app.key(:enter)
49
- app.view.should == "#{status.sub('.txt ','.txt*')}2\n\n\n#{command}"
52
+ app.view.should == "#{status(3).sub('.txt ','.txt*')}2\n\n\n#{command}"
50
53
  end
51
54
 
52
55
  it "does not enter key-codes" do
@@ -59,7 +62,7 @@ describe Ruco::Application do
59
62
  app.key(:"Ctrl+g") # go to line
60
63
  app.key('2') # 2
61
64
  app.key(:enter)
62
- app.view.should == "#{status}123\n456\n789\n#{command}"
65
+ app.view.should == "#{status(2)}123\n456\n789\n#{command}"
63
66
  app.cursor.should == [2,0] # 0 offset + 1 for statusbar
64
67
  end
65
68
 
@@ -75,6 +75,15 @@ describe Ruco::CommandBar do
75
75
  bar.view.should == "Find: abc"
76
76
  end
77
77
 
78
+ it "selects last value on cache-hit so I can type for new value" do
79
+ bar.ask('Find: ', :cache => true){}
80
+ bar.insert('abc')
81
+ bar.insert("\n")
82
+ bar.ask('Find: ', :cache => true){}
83
+ bar.cursor.column.should == 9
84
+ bar.text_in_selection.should == 'abc'
85
+ end
86
+
78
87
  it "gets reset when starting a new question" do
79
88
  bar.ask('Find: '){}
80
89
  bar.insert('123')
@@ -32,4 +32,8 @@ describe Ruco::StatusBar do
32
32
  editor.stub!(:file).and_return '/etc/sudoers'
33
33
  bar.view.should include('!')
34
34
  end
35
- end
35
+
36
+ it "shows line and column and right side" do
37
+ bar.view.should =~ /1:1$/
38
+ end
39
+ end
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: 117
4
+ hash: 115
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 53
10
- version: 0.0.53
9
+ - 54
10
+ version: 0.0.54
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-06 00:00:00 +02:00
18
+ date: 2011-05-08 00:00:00 +02:00
19
19
  default_executable: ruco
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency