ruco 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE.txt +20 -0
  3. data/bin/ruco +24 -30
  4. data/lib/ruco.rb +1 -3
  5. data/lib/ruco/command_bar.rb +1 -1
  6. data/lib/ruco/core_ext/range.rb +1 -1
  7. data/lib/ruco/core_ext/string.rb +2 -15
  8. data/lib/ruco/editor/colors.rb +2 -2
  9. data/lib/ruco/status_bar.rb +1 -1
  10. data/lib/ruco/syntax_parser.rb +1 -1
  11. data/lib/ruco/version.rb +1 -1
  12. data/lib/ruco/window.rb +1 -1
  13. metadata +34 -64
  14. data/.gitignore +0 -2
  15. data/.travis.yml +0 -7
  16. data/Gemfile +0 -8
  17. data/Gemfile.lock +0 -39
  18. data/Rakefile +0 -32
  19. data/Readme.md +0 -164
  20. data/lib/ruco/keyboard.rb +0 -206
  21. data/lib/ruco/screen.rb +0 -148
  22. data/lib/ruco/style_map.rb +0 -108
  23. data/playground/benchmark_syntax_parser.rb +0 -23
  24. data/ruco.gemspec +0 -22
  25. data/spec/fixtures/slow.js +0 -4
  26. data/spec/fixtures/test.tmTheme +0 -186
  27. data/spec/ruco/application_spec.rb +0 -433
  28. data/spec/ruco/array_processor_spec.rb +0 -46
  29. data/spec/ruco/command_bar_spec.rb +0 -127
  30. data/spec/ruco/core_ext/array_spec.rb +0 -31
  31. data/spec/ruco/core_ext/range_spec.rb +0 -37
  32. data/spec/ruco/core_ext/string_spec.rb +0 -36
  33. data/spec/ruco/editor_spec.rb +0 -1261
  34. data/spec/ruco/file_store_spec.rb +0 -102
  35. data/spec/ruco/form_spec.rb +0 -83
  36. data/spec/ruco/history_spec.rb +0 -143
  37. data/spec/ruco/keyboard_spec.rb +0 -136
  38. data/spec/ruco/option_accessor_spec.rb +0 -26
  39. data/spec/ruco/screen_spec.rb +0 -52
  40. data/spec/ruco/status_bar_spec.rb +0 -49
  41. data/spec/ruco/style_map_spec.rb +0 -124
  42. data/spec/ruco/syntax_parser_spec.rb +0 -78
  43. data/spec/ruco/text_area_spec.rb +0 -183
  44. data/spec/ruco/tm_theme_spec.rb +0 -14
  45. data/spec/ruco/window_spec.rb +0 -170
  46. data/spec/ruco_spec.rb +0 -7
  47. data/spec/spec_helper.rb +0 -36
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4b7d7e0b73027d1ef874c0f3494581976e973a5
4
+ data.tar.gz: 247ba8d64c6c7eab0592790dce749d6a79813a77
5
+ SHA512:
6
+ metadata.gz: 7f096d447626e9462030116c3b0604a8360f2b9c9e75c45a4c22148517c0c3fe82609809cfa6908216d98371a45d85bb83a528493e0bbc586bb5e7dc2f3829e8
7
+ data.tar.gz: 94746342db307fda720f6c7a726d84f98b452fdacada82186b984708e7bab32fa69e6c8967c657cf402b0a2f76b58d43caf00e31c247528873f14915ccff92c8
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2013 Michael Grosser <michael@grosser.it>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/ruco CHANGED
@@ -48,41 +48,40 @@ def log(stuff)
48
48
  File.open('ruco.log','ab'){|f| f.puts stuff }
49
49
  end
50
50
 
51
- # do not use colors if the terminal does not support colors
52
- # so far the only terminal that supports it:
53
- # - xterm-256color on osx
54
- # - xterm and xterm-256color on ubuntu 10.04+
55
- # (setting ENV['TERM'] will sometimes crash un-rescue-able -> test if it works)
56
- def activate_256_colors
57
- require 'ruco/file_store'
58
- (
59
- # not windows
60
- RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ and
61
-
62
- # possible to open xterm-256color
63
- ['xterm', 'xterm-256color'].include?(ENV['TERM']) and
64
- Ruco::FileStore.new('~/.ruco/cache').cache('color_possible'){
65
- system(%{TERM=xterm-256color ruby -r curses -e 'Curses.noecho' > /dev/null 2>&1})
66
- }
67
-
68
- # finally switch terminal, so curses knows we want colors
69
- ) and ENV['TERM'] = 'xterm-256color'
70
- end
71
-
72
51
  options = parse_options
73
52
 
74
- $ruco_colors = if options[:no_colors]
53
+ options[:colors] = if options[:no_colors]
75
54
  false
76
55
  elsif options[:colors]
77
56
  true
78
57
  else
79
- activate_256_colors
58
+ # so far the only terminal that supports it:
59
+ # - xterm-256color on osx
60
+ # - xterm on ubuntu 10.04+
61
+ if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
62
+ if ENV["TERM"] == 'xterm-256color'
63
+ true
64
+ else
65
+ require 'ruco/file_store'
66
+ if ENV['TERM'] == 'xterm'
67
+ # switch terminal, so curses knows we want colors
68
+ # setting ENV['TERM'] will sometimes crash un-rescue-able -> test if it works
69
+ possible = Ruco::FileStore.new('~/.ruco/cache').cache('color_possible') do
70
+ system(%{TERM=xterm-256color ruby -r curses -e 'Curses.noecho' > /dev/null 2>&1})
71
+ end
72
+ ENV['TERM'] = 'xterm-256color' if possible
73
+ end
74
+ end
75
+ end
80
76
  end
77
+ $ruco_colors = options[:colors]
81
78
 
82
79
  require 'ruco'
83
80
 
84
81
  # draw app and redraw after each keystroke (or paste)
85
- Ruco::Screen.open(options) do |screen|
82
+ Dispel::Screen.open(options) do |screen|
83
+ $ruco_screen = screen
84
+
86
85
  app = Ruco::Application.new(ARGV[0],
87
86
  :convert_tabs => options[:convert_tabs],
88
87
  :undo_stack_size => options[:undo_stack_size],
@@ -91,15 +90,10 @@ Ruco::Screen.open(options) do |screen|
91
90
 
92
91
  screen.draw *app.display_info
93
92
 
94
- Keyboard.input do
95
- Curses.getch
96
- end
97
-
98
- Keyboard.output do |key|
93
+ Dispel::Keyboard.output do |key|
99
94
  screen.debug_key(key) if options[:debug_keys]
100
95
  if key == :resize
101
96
  app.resize(screen.lines, screen.columns)
102
- screen.clear_cache
103
97
  else
104
98
  result = app.key key
105
99
  break if result == :quit
@@ -1,3 +1,4 @@
1
+ require 'dispel'
1
2
  require 'language_sniffer'
2
3
 
3
4
  require 'ruco/version'
@@ -9,14 +10,11 @@ require 'ruco/core_ext/hash'
9
10
  require 'ruco/core_ext/range'
10
11
  require 'ruco/core_ext/file'
11
12
 
12
- require 'ruco/keyboard'
13
13
  require 'ruco/position'
14
14
  require 'ruco/history'
15
15
  require 'ruco/option_accessor'
16
16
  require 'ruco/file_store'
17
17
  require 'ruco/window'
18
- require 'ruco/screen'
19
- require 'ruco/style_map'
20
18
  require 'ruco/syntax_parser'
21
19
 
22
20
  require 'ruco/editor'
@@ -34,7 +34,7 @@ module Ruco
34
34
  map.prepend(:reverse, 0, 0..@options[:columns])
35
35
  map
36
36
  else
37
- StyleMap.single_line_reversed(@options[:columns])
37
+ Dispel::StyleMap.single_line_reversed(@options[:columns])
38
38
  end
39
39
  end
40
40
 
@@ -7,7 +7,7 @@ class Range
7
7
  # (1..2).last_element == 2
8
8
  # (1...3).last_element == 2
9
9
  def last_element
10
- exclude_end? ? last.pred : last
10
+ Dispel::Tools.last_element(self)
11
11
  end unless defined? last_element
12
12
 
13
13
  # (1..2).move(2) == (3..4)
@@ -1,13 +1,6 @@
1
1
  class String
2
- # http://grosser.it/2011/08/28/ruby-string-naive-split-because-split-is-to-clever/
3
- # " ".split(' ') == []
4
- # " ".naive_split(' ') == ['','','','']
5
- # "".split(' ') == []
6
- # "".naive_split(' ') == ['']
7
2
  def naive_split(pattern)
8
- pattern = /#{Regexp.escape(pattern)}/ unless pattern.is_a?(Regexp)
9
- result = split(pattern, -1)
10
- result.empty? ? [''] : result
3
+ Dispel::Tools.naive_split(self, pattern)
11
4
  end
12
5
 
13
6
  def tabs_to_spaces!
@@ -53,14 +46,8 @@ class String
53
46
  end unless defined? ellipsize
54
47
  end
55
48
 
56
- # http://grosser.it/2010/12/31/ruby-string-indexes-indices-find-all-indexes-in-a-string
57
49
  class String
58
50
  def indexes(needle)
59
- found = []
60
- current_index = -1
61
- while current_index = index(needle, current_index+1)
62
- found << current_index
63
- end
64
- found
51
+ Dispel::Tools.indexes(self, needle)
65
52
  end
66
53
  end
@@ -7,8 +7,8 @@ module Ruco
7
7
  STYLING_TIMEOUT = 4
8
8
 
9
9
  def style_map
10
- $ruco_foreground = theme.foreground
11
- $ruco_background = theme.background
10
+ $ruco_screen && $ruco_screen.options[:foreground] = theme.foreground
11
+ $ruco_screen && $ruco_screen.options[:background] = theme.background
12
12
  map = super
13
13
 
14
14
  return map if @colors_took_too_long or not @options[:language]
@@ -23,7 +23,7 @@ module Ruco
23
23
  end
24
24
 
25
25
  def style_map
26
- StyleMap.single_line_reversed(@options[:columns])
26
+ Dispel::StyleMap.single_line_reversed(@options[:columns])
27
27
  end
28
28
 
29
29
  def change_indicator
@@ -16,7 +16,7 @@ module Ruco
16
16
  begin
17
17
  processor = syntax.parse(lines.join("\n"), Ruco::ArrayProcessor.new)
18
18
  processor.lines
19
- rescue RegexpError
19
+ rescue RegexpError, ArgumentError
20
20
  $stderr.puts $!
21
21
  []
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Ruco
2
- VERSION = Version = "0.2.18"
2
+ VERSION = Version = "0.2.19"
3
3
  end
@@ -50,7 +50,7 @@ module Ruco
50
50
  end
51
51
 
52
52
  def style_map(selection)
53
- map = StyleMap.new(lines)
53
+ map = Dispel::StyleMap.new(lines)
54
54
  if selection
55
55
  add_selection_styles(map, selection)
56
56
  else
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
5
- prerelease:
4
+ version: 0.2.19
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Grosser
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: clipboard
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.9.8
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.9.8
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: textpow
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.3.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.3.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: language_sniffer
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dispel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description:
@@ -66,12 +73,7 @@ executables:
66
73
  extensions: []
67
74
  extra_rdoc_files: []
68
75
  files:
69
- - .gitignore
70
- - .travis.yml
71
- - Gemfile
72
- - Gemfile.lock
73
- - Rakefile
74
- - Readme.md
76
+ - MIT-LICENSE.txt
75
77
  - bin/ruco
76
78
  - lib/ruco.rb
77
79
  - lib/ruco/application.rb
@@ -91,74 +93,42 @@ files:
91
93
  - lib/ruco/file_store.rb
92
94
  - lib/ruco/form.rb
93
95
  - lib/ruco/history.rb
94
- - lib/ruco/keyboard.rb
95
96
  - lib/ruco/option_accessor.rb
96
97
  - lib/ruco/position.rb
97
- - lib/ruco/screen.rb
98
98
  - lib/ruco/status_bar.rb
99
- - lib/ruco/style_map.rb
100
99
  - lib/ruco/syntax_parser.rb
101
100
  - lib/ruco/text_area.rb
102
101
  - lib/ruco/text_field.rb
103
102
  - lib/ruco/tm_theme.rb
104
103
  - lib/ruco/version.rb
105
104
  - lib/ruco/window.rb
106
- - playground/benchmark_syntax_parser.rb
107
- - ruco.gemspec
108
105
  - spec/fixtures/railscasts.tmTheme
109
- - spec/fixtures/slow.js
110
- - spec/fixtures/test.tmTheme
111
- - spec/ruco/application_spec.rb
112
- - spec/ruco/array_processor_spec.rb
113
- - spec/ruco/command_bar_spec.rb
114
- - spec/ruco/core_ext/array_spec.rb
115
- - spec/ruco/core_ext/range_spec.rb
116
- - spec/ruco/core_ext/string_spec.rb
117
- - spec/ruco/editor_spec.rb
118
- - spec/ruco/file_store_spec.rb
119
- - spec/ruco/form_spec.rb
120
- - spec/ruco/history_spec.rb
121
- - spec/ruco/keyboard_spec.rb
122
- - spec/ruco/option_accessor_spec.rb
123
- - spec/ruco/screen_spec.rb
124
- - spec/ruco/status_bar_spec.rb
125
- - spec/ruco/style_map_spec.rb
126
- - spec/ruco/syntax_parser_spec.rb
127
- - spec/ruco/text_area_spec.rb
128
- - spec/ruco/tm_theme_spec.rb
129
- - spec/ruco/window_spec.rb
130
- - spec/ruco_spec.rb
131
- - spec/spec_helper.rb
132
- homepage: http://github.com/grosser/ruco
106
+ homepage: https://github.com/grosser/ruco
133
107
  licenses:
134
108
  - MIT
135
- post_install_message: ! "\n Mac: shift/ctrl + arrow-keys only work in iterm (not
136
- Terminal.app)\n Ubuntu: sudo apt-get install xclip # to use the clipboard\n\n"
109
+ metadata: {}
110
+ post_install_message: |2+
111
+
112
+ Mac: shift/ctrl + arrow-keys only work in iterm (not Terminal.app)
113
+ Ubuntu: sudo apt-get install xclip # to use the clipboard
114
+
137
115
  rdoc_options: []
138
116
  require_paths:
139
117
  - lib
140
118
  required_ruby_version: !ruby/object:Gem::Requirement
141
- none: false
142
119
  requirements:
143
- - - ! '>='
120
+ - - '>='
144
121
  - !ruby/object:Gem::Version
145
122
  version: '0'
146
- segments:
147
- - 0
148
- hash: 169951991926027466
149
123
  required_rubygems_version: !ruby/object:Gem::Requirement
150
- none: false
151
124
  requirements:
152
- - - ! '>='
125
+ - - '>='
153
126
  - !ruby/object:Gem::Version
154
127
  version: '0'
155
- segments:
156
- - 0
157
- hash: 169951991926027466
158
128
  requirements: []
159
129
  rubyforge_project:
160
- rubygems_version: 1.8.24
130
+ rubygems_version: 2.0.14
161
131
  signing_key:
162
- specification_version: 3
132
+ specification_version: 4
163
133
  summary: Commandline editor written in ruby
164
134
  test_files: []
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- spec/temp.txt
2
- ruco.log
@@ -1,7 +0,0 @@
1
- before_install:
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/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- source :rubygems
2
- gemspec
3
-
4
- gem 'bump'
5
- gem 'oniguruma', :platform => :ruby_18
6
- gem 'ffi', :platform => [:mingw]
7
- gem 'rake'
8
- gem 'rspec', '~>2'
@@ -1,39 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ruco (0.2.18)
5
- clipboard (>= 0.9.8)
6
- language_sniffer
7
- textpow (>= 1.3.0)
8
-
9
- GEM
10
- remote: http://rubygems.org/
11
- specs:
12
- bump (0.3.9)
13
- clipboard (1.0.1)
14
- diff-lcs (1.1.3)
15
- language_sniffer (1.0.2)
16
- oniguruma (1.1.0)
17
- plist (3.1.0)
18
- rake (0.9.2.2)
19
- rspec (2.12.0)
20
- rspec-core (~> 2.12.0)
21
- rspec-expectations (~> 2.12.0)
22
- rspec-mocks (~> 2.12.0)
23
- rspec-core (2.12.2)
24
- rspec-expectations (2.12.1)
25
- diff-lcs (~> 1.1.3)
26
- rspec-mocks (2.12.2)
27
- textpow (1.3.1)
28
- plist (>= 3.0.1)
29
-
30
- PLATFORMS
31
- ruby
32
-
33
- DEPENDENCIES
34
- bump
35
- ffi
36
- oniguruma
37
- rake
38
- rspec (~> 2)
39
- ruco!