ruco 0.2.0.beta8 → 0.2.0.beta9

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/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
3
  gem 'clipboard', '>=0.9.8'
4
- gem 'ultraviolet1x'
4
+ gem 'textpow1x', '>=1'
5
5
  gem 'language_sniffer'
6
6
 
7
7
  group :dev do # not development <-> would add unneeded development dependencies in gemspec
data/Gemfile.lock CHANGED
@@ -20,10 +20,8 @@ GEM
20
20
  rspec-expectations (2.6.0)
21
21
  diff-lcs (~> 1.1.2)
22
22
  rspec-mocks (2.6.0)
23
- textpow1x (0.11.0)
23
+ textpow1x (1.0.0)
24
24
  plist (>= 3.0.1)
25
- ultraviolet1x (0.12.1)
26
- textpow1x (>= 0.11.0)
27
25
 
28
26
  PLATFORMS
29
27
  ruby
@@ -36,4 +34,4 @@ DEPENDENCIES
36
34
  oniguruma
37
35
  rake
38
36
  rspec (~> 2)
39
- ultraviolet1x
37
+ textpow1x (>= 1)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta8
1
+ 0.2.0.beta9
data/bin/ruco CHANGED
@@ -48,8 +48,8 @@ end
48
48
 
49
49
  # do not use colors if the terminal does not support colors
50
50
  # so far the only terminal that supports it:
51
- # - xterm-256color on osx (not ssh)
52
- # - xterm on ubuntu (not ssh)
51
+ # - xterm-256color on osx
52
+ # - xterm and xterm-256color on ubuntu 10.04+
53
53
  # (setting ENV['TERM'] will sometimes crash un-rescue-able -> test if it works)
54
54
  def activate_256_colors
55
55
  require 'ruco/file_store'
@@ -7,8 +7,8 @@ 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
11
  map = super
11
- return map if @colors_took_too_long
12
12
 
13
13
  # disable colors if syntax-parsing takes too long
14
14
  begin
@@ -22,39 +22,37 @@ module Ruco
22
22
  return map
23
23
  end
24
24
 
25
- add_syntax_highlighting_to_style_map(map, syntax)
25
+ $ruco_foreground = theme.foreground
26
+ $ruco_background = theme.background
27
+
28
+ if syntax
29
+ add_syntax_highlighting_to_style_map(map, syntax)
26
30
 
27
- if @selection
28
31
  # add selection a second time so it stays on top
29
- @window.add_selection_styles(map, @selection)
32
+ @window.add_selection_styles(map, @selection) if @selection
30
33
  end
34
+
31
35
  map
32
36
  end
33
37
 
34
38
  private
35
39
 
36
40
  def syntax_info
37
- if language = @options[:language]
38
- @syntax_info ||= {}
39
- language = [language.name.downcase, language.lexer]
40
- lines.map do |line|
41
- @syntax_info[line] ||= SyntaxParser.syntax_for_lines([line], language).first
42
- end
43
- else
44
- []
41
+ language = @options[:language]
42
+ possible_languages = [language.name.downcase, language.lexer]
43
+
44
+ @syntax_info ||= {}
45
+ lines.map do |line|
46
+ @syntax_info[line] ||= SyntaxParser.syntax_for_lines([line], possible_languages).first
45
47
  end
46
48
  end
47
49
 
48
50
  def add_syntax_highlighting_to_style_map(map, syntax_info)
49
- return unless syntax_info
50
-
51
- $ruco_foreground = theme.foreground
52
- $ruco_background = theme.background
53
-
54
51
  syntax_info.each_with_index do |syntax_positions, line|
55
52
  next unless syntax_positions
56
53
  syntax_positions.each do |syntax_element, columns|
57
54
  columns = columns.move(-@window.left)
55
+ columns = 0...columns.last if columns.first < 0 and columns.last > 0
58
56
  style = style_for_syntax_element(syntax_element)
59
57
  if style and columns.first >= 0
60
58
  map.add(style, line, columns)
@@ -60,7 +60,7 @@ module Ruco
60
60
  end
61
61
 
62
62
  def deserialize(value)
63
- Marshal.load(value)
63
+ @options[:string] ? value : Marshal.load(value)
64
64
  end
65
65
  end
66
66
  end
data/lib/ruco/screen.rb CHANGED
@@ -104,8 +104,7 @@ module Ruco
104
104
  else
105
105
  # :red or [:red, :blue]
106
106
  f,b = style
107
- b ||= background
108
- [f,b]
107
+ [f || foreground, b || background]
109
108
  end
110
109
 
111
110
  foreground = html_to_terminal_color(foreground)
@@ -1,7 +1,7 @@
1
1
  module Ruco
2
2
  module SyntaxParser
3
- # uv only offers certain syntax
4
- UV_CONVERT = {
3
+ # textpow only offers certain syntax
4
+ TEXTPOW_CONVERT = {
5
5
  'scss' => 'sass',
6
6
  'html+erb' => 'html_rails',
7
7
  }
@@ -19,10 +19,10 @@ module Ruco
19
19
  @@syntax_node ||= {}
20
20
  @@syntax_node[languages] ||= begin
21
21
  found = nil
22
- fallbacks = languages.map{|l| UV_CONVERT[l] }.compact
22
+ fallbacks = languages.map{|l| TEXTPOW_CONVERT[l] }.compact
23
23
 
24
24
  (languages + fallbacks).detect do |language|
25
- syntax = File.join(Uv.syntax_path, "#{language}.syntax")
25
+ syntax = File.join(Textpow.syntax_path, "#{language}.syntax")
26
26
  found = Textpow::SyntaxNode.load(syntax) if File.exist?(syntax)
27
27
  end
28
28
 
data/lib/ruco.rb CHANGED
@@ -36,8 +36,6 @@ if $ruco_colors
36
36
  require 'plist'
37
37
  gem 'textpow1x'
38
38
  require 'textpow'
39
- gem 'ultraviolet1x'
40
- require 'uv'
41
39
 
42
40
  # we do not need there if any other color li failed
43
41
  require 'ruco/array_processor'
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.2.0.beta8"
8
+ s.version = "0.2.0.beta9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-09-28}
12
+ s.date = %q{2011-10-02}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -92,16 +92,16 @@ Gem::Specification.new do |s|
92
92
 
93
93
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
94
94
  s.add_runtime_dependency(%q<clipboard>, [">= 0.9.8"])
95
- s.add_runtime_dependency(%q<ultraviolet1x>, [">= 0"])
95
+ s.add_runtime_dependency(%q<textpow1x>, [">= 1"])
96
96
  s.add_runtime_dependency(%q<language_sniffer>, [">= 0"])
97
97
  else
98
98
  s.add_dependency(%q<clipboard>, [">= 0.9.8"])
99
- s.add_dependency(%q<ultraviolet1x>, [">= 0"])
99
+ s.add_dependency(%q<textpow1x>, [">= 1"])
100
100
  s.add_dependency(%q<language_sniffer>, [">= 0"])
101
101
  end
102
102
  else
103
103
  s.add_dependency(%q<clipboard>, [">= 0.9.8"])
104
- s.add_dependency(%q<ultraviolet1x>, [">= 0"])
104
+ s.add_dependency(%q<textpow1x>, [">= 1"])
105
105
  s.add_dependency(%q<language_sniffer>, [">= 0"])
106
106
  end
107
107
  end
@@ -31,7 +31,7 @@ describe Ruco::Application do
31
31
  end
32
32
 
33
33
  def status(line=1)
34
- "Ruco #{Ruco::VERSION} -- spec/temp.txt #{line}:1\n"
34
+ "Ruco #{Ruco::VERSION} -- spec/temp.txt #{line}:1\n"
35
35
  end
36
36
 
37
37
  let(:rucorc){ 'spec/.ruco.rb' }
@@ -631,14 +631,14 @@ describe Ruco::Editor do
631
631
  end
632
632
 
633
633
  it "shows multi-line selection in scrolled space" do
634
- write("\n\n\n\n\n0123456789\n0123456789\n0123456789\n\n")
634
+ write("\n\n\n\n\nacdefghijk\nacdefghijk\nacdefghijk\n\n")
635
635
  ta = editor.send(:text_area)
636
636
  ta.send(:position=, [5,8])
637
637
  ta.send(:screen_position=, [5,7])
638
638
  editor.selecting do
639
639
  move(:relative, 2, 1)
640
640
  end
641
- editor.view.should == "789\n789\n789"
641
+ editor.view.should == "ijk\nijk\nijk"
642
642
  editor.cursor.should == [2,2]
643
643
  editor.style_map.flatten.should == [
644
644
  [nil, :reverse, nil, nil, nil, :normal], # start to end of screen
@@ -668,6 +668,18 @@ describe Ruco::Editor do
668
668
  ]
669
669
  end
670
670
 
671
+ it "shows mid-keywords for moved window" do
672
+ write("\n\n\n\n\nclass ")
673
+ editor.move(:to, 5, 6)
674
+ editor.cursor.should == [1,3]
675
+ editor.view.should == "\nss \n"
676
+ editor.style_map.flatten.should == [
677
+ nil,
678
+ [color(:keyword), nil, :normal],
679
+ nil
680
+ ]
681
+ end
682
+
671
683
  it "shows multiple syntax elements" do
672
684
  write("if @x")
673
685
  editor.style_map.flatten.should == [
@@ -91,6 +91,7 @@ describe Ruco::FileStore do
91
91
  store = Ruco::FileStore.new(@folder, :keep => 3, :string => true)
92
92
  store.set('xxx','yyy')
93
93
  File.read(store.file('xxx')).should == 'yyy'
94
+ store.get('xxx').should == 'yyy'
94
95
  end
95
96
 
96
97
  it "works without colors" do
@@ -16,7 +16,7 @@ describe Ruco::StatusBar do
16
16
  it "can show to long files" do
17
17
  editor = Ruco::Editor.new('123456789abcdefghijklmnop', :lines => 5, :columns => 20)
18
18
  bar = Ruco::StatusBar.new(editor, :columns => 30)
19
- bar.view.should == "Ruco #{Ruco::VERSION} -- 123...nop 1:1"
19
+ bar.view.should == "Ruco #{Ruco::VERSION} -- 1234...nop 1:1"
20
20
  bar.view.size.should == 30
21
21
  end
22
22
 
data/spec/ruco_spec.rb CHANGED
@@ -2,6 +2,6 @@ require File.expand_path('spec/spec_helper')
2
2
 
3
3
  describe Ruco do
4
4
  it "has a VERSION" do
5
- Ruco::VERSION.should =~ /^\d+\.\d+\.\d+$/
5
+ Ruco::OLD_VERSION.should =~ /^\d+\.\d+\.\d+(\.[a-z\d]+)?$/
6
6
  end
7
- end
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,11 @@ require 'ruco'
5
5
  require 'timeout'
6
6
  require 'tempfile'
7
7
 
8
- silence_warnings{ Ruco::Editor::Colors::DEFAULT_THEME = 'spec/fixtures/test.tmTheme' }
8
+ silence_warnings do
9
+ Ruco::Editor::Colors::DEFAULT_THEME = 'spec/fixtures/test.tmTheme'
10
+ Ruco::OLD_VERSION = Ruco::VERSION
11
+ Ruco::VERSION = '0.0.0' # so tests dont fail if version gets longer
12
+ end
9
13
 
10
14
  class Tempfile
11
15
  def self.string_as_file(data)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196371
4
+ hash: 62196369
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
10
  - beta
11
- - 8
12
- version: 0.2.0.beta8
11
+ - 9
12
+ version: 0.2.0.beta9
13
13
  platform: ruby
14
14
  authors:
15
15
  - Michael Grosser
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-09-28 00:00:00 +02:00
20
+ date: 2011-10-02 00:00:00 +02:00
21
21
  default_executable: ruco
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -42,13 +42,13 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 1
46
46
  segments:
47
- - 0
48
- version: "0"
47
+ - 1
48
+ version: "1"
49
49
  requirement: *id002
50
50
  type: :runtime
51
- name: ultraviolet1x
51
+ name: textpow1x
52
52
  prerelease: false
53
53
  - !ruby/object:Gem::Dependency
54
54
  version_requirements: &id003 !ruby/object:Gem::Requirement