ruco 0.2.0.beta12 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ before_script:
2
+ - sudo apt-get install -y libonig-dev && bundle install
3
+ script: "bundle exec rake"
4
+ rvm:
5
+ - ree
6
+ - 1.9.2
7
+ - 1.9.3
data/Readme.md CHANGED
@@ -1,8 +1,8 @@
1
1
  Simple, extendable, test-driven commandline editor written in ruby, for Linux/Mac/Windows.
2
2
 
3
- Features:
3
+ ### Features
4
4
 
5
- - **Intuitive interface**
5
+ - **Desktop-like / intuitive interface**
6
6
  - TextMate Syntax and Theme support
7
7
  - selecting via Shift + arrow-keys (only Linux or iTerm) or 'select mode' Ctrl+b + arrow-keys
8
8
  - move line up/down (Alt+Ctrl+up/down)
@@ -10,12 +10,12 @@ Features:
10
10
  - keeps indentation (+ paste-detection e.g. via Cmd+v)
11
11
  - change (*) + writable (!) indicators
12
12
  - find / go to line / delete line / search & replace
13
- - configuration via `~/.ruco.rb`
14
- - cut, copy and paste -> Ctrl+x/c/v
15
- - undo / redo
13
+ - configuration via `~/.ruco.rb` in Ruby
14
+ - Full clipboard support -> Ctrl+x/c/v
15
+ - undo / redo -> Ctrl+z/y
16
16
  - stays at last position when reopening a file
17
- - opens file at line with `ruco foo/bar.rb:32` syntax
18
- - keeps whatever newline format you use (\r \n \r\n)
17
+ - opens file at line e.g. `ruco foo/bar.rb:32`
18
+ - supports all newline formats
19
19
  - surrounds selection with quotes/braces (select abc + " --> "abc")
20
20
  - shortens long file names in the middle
21
21
  - (optional) remove trailing whitespace on save
@@ -25,14 +25,17 @@ Features:
25
25
  ![ruco with railscasts theme](http://dl.dropbox.com/u/2670385/Web/ruco-with-railscasts-theme.png)<br/>
26
26
  [Colors in Ruby 1.8](#colors)
27
27
 
28
+
28
29
  Install
29
30
  =======
30
31
  sudo gem install ruco
31
32
 
33
+
32
34
  Usage
33
35
  =====
34
36
  ruco file.rb
35
37
 
38
+
36
39
  Customize
37
40
  =========
38
41
 
@@ -80,12 +83,13 @@ Customize
80
83
  bind :"Ctrl+u", :first_line
81
84
  end
82
85
 
86
+
83
87
  TIPS
84
88
  ====
85
89
  - [Mac] arow-keys + Shift/Alt does not work in default terminal (use iTerm)
86
- - [Tabs] Ruco does not like tabs. Existing tabs are displayed as ' ' and pressing tab inserts 2*space
90
+ - [Tabs] Ruco does not like tabs. Existing tabs are displayed as single space and pressing tab inserts 2*space
87
91
  - [RVM] `alias r="rvm 1.9.2 exec ruco"` and you only have to install ruco once
88
- - [Ruby1.9] Unicode support -> install libncursesw5-dev before installing ruby (does not work for 1.8)
92
+ - [Ruby1.9] Unicode support -> install libncursesw5-dev before installing ruby
89
93
  - [ssh vs clipboard] access your desktops clipboard by installing `xauth` on the server and then using `ssh -X`
90
94
  - [Alt key] if Alt does not work try your Meta/Win/Cmd key
91
95
 
@@ -102,6 +106,24 @@ TIPS
102
106
  gem install oniguruma
103
107
 
104
108
 
109
+ Architecture
110
+ ============
111
+ Ruco is basically a lot of String manipulation separated in HTML style elements.
112
+ The only component dealing with the commandline interface are Screen and Keyboard. Therefore
113
+ everything is very simple to build and test since it returns a string or a e.g. cursor position.
114
+
115
+ Writing/reading is done in a TextArea or a TextField (a TextArea with 1 line)
116
+ which are placed in Form`s.
117
+
118
+ The Application consists of a StatusBar, Editor, CommandBar and delegates actions to the currently active element.
119
+
120
+ To build the commandline output Editor/CommandBar return:
121
+
122
+ - view -- text that should be displayed on the screen (complete content cropped via Window)
123
+ - style_map -- a big Array with style infos, e.g. 'on line 1 chars 5 to 7 are red'
124
+ - cursor -- where to draw the cursor
125
+
126
+
105
127
  TODO
106
128
  =====
107
129
  - only do syntax parsing for changed lines + selected lines <-> will not be redrawn anyhow
@@ -125,6 +147,7 @@ TODO
125
147
  - 1.8: unicode support <-> already finished but unusable due to Curses (see encoding branch)
126
148
  - add double quotes/braces when typing one + skip over quote/brace when its already typed at current position
127
149
 
150
+
128
151
  Authors
129
152
  =======
130
153
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta12
1
+ 0.2.0
@@ -7,9 +7,12 @@ module Ruco
7
7
  STYLING_TIMEOUT = 4
8
8
 
9
9
  def style_map
10
- return super if @colors_took_too_long or not @options[:language]
10
+ $ruco_foreground = theme.foreground
11
+ $ruco_background = theme.background
11
12
  map = super
12
13
 
14
+ return map if @colors_took_too_long or not @options[:language]
15
+
13
16
  # disable colors if syntax-parsing takes too long
14
17
  begin
15
18
  syntax = Timeout.timeout(STYLING_TIMEOUT) do
@@ -22,9 +25,6 @@ module Ruco
22
25
  return map
23
26
  end
24
27
 
25
- $ruco_foreground = theme.foreground
26
- $ruco_background = theme.background
27
-
28
28
  if syntax
29
29
  add_syntax_highlighting_to_style_map(map, syntax)
30
30
 
data/lib/ruco/screen.rb CHANGED
@@ -74,7 +74,7 @@ module Ruco
74
74
  # position at start of line and draw
75
75
  Curses.setpos(line_number,0)
76
76
  Ruco::StyleMap.styled(line, styles).each do |style, part|
77
- Curses.attrset self.class.curses_style(style)
77
+ Curses.attrset self.class.curses_style(style, $ruco_colors)
78
78
  Curses.addstr part
79
79
  end
80
80
 
@@ -91,8 +91,8 @@ module Ruco
91
91
  yield # render the line
92
92
  end
93
93
 
94
- def self.curses_style(style)
95
- if $ruco_colors
94
+ def self.curses_style(style, colors)
95
+ if colors
96
96
  foreground = $ruco_foreground || '#ffffff'
97
97
  background = $ruco_background || '#000000'
98
98
 
@@ -3,7 +3,8 @@ module Ruco
3
3
  # textpow only offers certain syntax
4
4
  TEXTPOW_CONVERT = {
5
5
  'scss' => 'sass',
6
- 'html+erb' => 'html_rails',
6
+ 'html+erb' => 'html',
7
+ 'rhtml' => 'html',
7
8
  }
8
9
 
9
10
  def self.syntax_for_line(line, languages)
data/ruco.gemspec CHANGED
@@ -5,15 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.2.0.beta12"
8
+ s.version = "0.2.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
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-10-04}
12
+ s.date = %q{2011-10-06}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
16
16
  s.files = [
17
+ ".travis.yml",
17
18
  "Gemfile",
18
19
  "Gemfile.lock",
19
20
  "Rakefile",
@@ -86,6 +87,29 @@ Gem::Specification.new do |s|
86
87
  s.require_paths = ["lib"]
87
88
  s.rubygems_version = %q{1.6.2}
88
89
  s.summary = %q{Commandline editor written in ruby}
90
+ s.test_files = [
91
+ "spec/ruco/application_spec.rb",
92
+ "spec/ruco/array_processor_spec.rb",
93
+ "spec/ruco/command_bar_spec.rb",
94
+ "spec/ruco/core_ext/array_spec.rb",
95
+ "spec/ruco/core_ext/range_spec.rb",
96
+ "spec/ruco/core_ext/string_spec.rb",
97
+ "spec/ruco/editor_spec.rb",
98
+ "spec/ruco/file_store_spec.rb",
99
+ "spec/ruco/form_spec.rb",
100
+ "spec/ruco/history_spec.rb",
101
+ "spec/ruco/keyboard_spec.rb",
102
+ "spec/ruco/option_accessor_spec.rb",
103
+ "spec/ruco/screen_spec.rb",
104
+ "spec/ruco/status_bar_spec.rb",
105
+ "spec/ruco/style_map_spec.rb",
106
+ "spec/ruco/syntax_parser_spec.rb",
107
+ "spec/ruco/text_area_spec.rb",
108
+ "spec/ruco/tm_theme_spec.rb",
109
+ "spec/ruco/window_spec.rb",
110
+ "spec/ruco_spec.rb",
111
+ "spec/spec_helper.rb"
112
+ ]
89
113
 
90
114
  if s.respond_to? :specification_version then
91
115
  s.specification_version = 3
@@ -722,15 +722,10 @@ describe Ruco::Editor do
722
722
  end
723
723
 
724
724
  it "times out when styling takes too long" do
725
- begin
726
- STDERR.should_receive(:puts)
727
- old = Ruco::Editor::Colors::STYLING_TIMEOUT
728
- silence_warnings{ Ruco::Editor::Colors::STYLING_TIMEOUT = 0.001 }
729
- write(File.read('lib/ruco.rb'))
730
- editor.style_map.flatten.should == [nil,nil,nil]
731
- ensure
732
- silence_warnings{ Ruco::Editor::Colors::STYLING_TIMEOUT = old }
733
- end
725
+ STDERR.should_receive(:puts)
726
+ Timeout.should_receive(:timeout).and_raise Timeout::Error
727
+ write(File.read('lib/ruco.rb'))
728
+ editor.style_map.flatten.should == [nil,nil,nil]
734
729
  end
735
730
 
736
731
  describe 'with theme' do
@@ -3,44 +3,35 @@ require File.expand_path('spec/spec_helper')
3
3
  describe Ruco::Screen do
4
4
  describe :curses_style do
5
5
  it "is 'normal' for nothing" do
6
- Ruco::Screen.curses_style(:normal).should == 256
6
+ Ruco::Screen.curses_style(:normal, true).should == 256
7
7
  end
8
8
 
9
9
  it "is red for red" do
10
10
  pending
11
- Ruco::Screen.curses_style(:red).should == Curses::color_pair( Curses::COLOR_RED )
11
+ Ruco::Screen.curses_style(:red, true).should == Curses::color_pair( Curses::COLOR_RED )
12
12
  end
13
13
 
14
14
  it "is reverse for reverse" do
15
- Ruco::Screen.curses_style(:reverse).should == 512
15
+ Ruco::Screen.curses_style(:reverse, true).should == 512
16
16
  end
17
17
 
18
18
  it "raises on unknown style" do
19
19
  lambda{
20
- Ruco::Screen.curses_style(:foo)
20
+ Ruco::Screen.curses_style(:foo, true)
21
21
  }.should raise_error
22
22
  end
23
23
 
24
24
  describe 'without colors' do
25
- before do
26
- Ruco::Screen.class_eval '@@styles = {}' # clear cache
27
- $ruco_colors = false
28
- end
29
-
30
- after do
31
- $ruco_colors = true
32
- end
33
-
34
25
  it "is 'normal' for normal" do
35
- Ruco::Screen.curses_style(:normal).should == Curses::A_NORMAL
26
+ Ruco::Screen.curses_style(:normal, false).should == Curses::A_NORMAL
36
27
  end
37
28
 
38
29
  it "is reverse for reverse" do
39
- Ruco::Screen.curses_style(:reverse).should == Curses::A_REVERSE
30
+ Ruco::Screen.curses_style(:reverse, false).should == Curses::A_REVERSE
40
31
  end
41
32
 
42
33
  it "is normal for unknown style" do
43
- Ruco::Screen.curses_style(:foo).should == Curses::A_NORMAL
34
+ Ruco::Screen.curses_style(:foo, false).should == Curses::A_NORMAL
44
35
  end
45
36
  end
46
37
  end
metadata CHANGED
@@ -1,15 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196379
5
- prerelease: 6
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
- - beta
11
- - 12
12
- version: 0.2.0.beta12
10
+ version: 0.2.0
13
11
  platform: ruby
14
12
  authors:
15
13
  - Michael Grosser
@@ -17,11 +15,11 @@ autorequire:
17
15
  bindir: bin
18
16
  cert_chain: []
19
17
 
20
- date: 2011-10-04 00:00:00 +02:00
18
+ date: 2011-10-06 00:00:00 +02:00
21
19
  default_executable: ruco
22
20
  dependencies:
23
21
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
27
25
  - - ">="
@@ -32,12 +30,12 @@ dependencies:
32
30
  - 9
33
31
  - 8
34
32
  version: 0.9.8
35
- requirement: *id001
36
33
  type: :runtime
37
34
  name: clipboard
35
+ version_requirements: *id001
38
36
  prerelease: false
39
37
  - !ruby/object:Gem::Dependency
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ">="
@@ -46,12 +44,12 @@ dependencies:
46
44
  segments:
47
45
  - 1
48
46
  version: "1"
49
- requirement: *id002
50
47
  type: :runtime
51
48
  name: textpow1x
49
+ version_requirements: *id002
52
50
  prerelease: false
53
51
  - !ruby/object:Gem::Dependency
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
55
53
  none: false
56
54
  requirements:
57
55
  - - ">="
@@ -60,9 +58,9 @@ dependencies:
60
58
  segments:
61
59
  - 0
62
60
  version: "0"
63
- requirement: *id003
64
61
  type: :runtime
65
62
  name: language_sniffer
63
+ version_requirements: *id003
66
64
  prerelease: false
67
65
  description:
68
66
  email: michael@grosser.it
@@ -73,6 +71,7 @@ extensions: []
73
71
  extra_rdoc_files: []
74
72
 
75
73
  files:
74
+ - .travis.yml
76
75
  - Gemfile
77
76
  - Gemfile.lock
78
77
  - Rakefile
@@ -160,14 +159,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
159
  required_rubygems_version: !ruby/object:Gem::Requirement
161
160
  none: false
162
161
  requirements:
163
- - - ">"
162
+ - - ">="
164
163
  - !ruby/object:Gem::Version
165
- hash: 25
164
+ hash: 3
166
165
  segments:
167
- - 1
168
- - 3
169
- - 1
170
- version: 1.3.1
166
+ - 0
167
+ version: "0"
171
168
  requirements: []
172
169
 
173
170
  rubyforge_project:
@@ -175,5 +172,25 @@ rubygems_version: 1.6.2
175
172
  signing_key:
176
173
  specification_version: 3
177
174
  summary: Commandline editor written in ruby
178
- test_files: []
179
-
175
+ test_files:
176
+ - spec/ruco/application_spec.rb
177
+ - spec/ruco/array_processor_spec.rb
178
+ - spec/ruco/command_bar_spec.rb
179
+ - spec/ruco/core_ext/array_spec.rb
180
+ - spec/ruco/core_ext/range_spec.rb
181
+ - spec/ruco/core_ext/string_spec.rb
182
+ - spec/ruco/editor_spec.rb
183
+ - spec/ruco/file_store_spec.rb
184
+ - spec/ruco/form_spec.rb
185
+ - spec/ruco/history_spec.rb
186
+ - spec/ruco/keyboard_spec.rb
187
+ - spec/ruco/option_accessor_spec.rb
188
+ - spec/ruco/screen_spec.rb
189
+ - spec/ruco/status_bar_spec.rb
190
+ - spec/ruco/style_map_spec.rb
191
+ - spec/ruco/syntax_parser_spec.rb
192
+ - spec/ruco/text_area_spec.rb
193
+ - spec/ruco/tm_theme_spec.rb
194
+ - spec/ruco/window_spec.rb
195
+ - spec/ruco_spec.rb
196
+ - spec/spec_helper.rb