ruco 0.2.0.beta11 → 0.2.0.beta12
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/VERSION +1 -1
- data/lib/ruco/core_ext/object.rb +7 -0
- data/lib/ruco/editor/colors.rb +1 -2
- data/lib/ruco/screen.rb +29 -32
- data/lib/ruco/syntax_parser.rb +13 -10
- data/ruco.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.0.
|
1
|
+
0.2.0.beta12
|
data/lib/ruco/core_ext/object.rb
CHANGED
data/lib/ruco/editor/colors.rb
CHANGED
@@ -41,9 +41,8 @@ module Ruco
|
|
41
41
|
language = @options[:language]
|
42
42
|
possible_languages = [language.name.downcase, language.lexer]
|
43
43
|
|
44
|
-
@syntax_info ||= {}
|
45
44
|
lines.map do |line|
|
46
|
-
|
45
|
+
SyntaxParser.syntax_for_line(line, possible_languages)
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
data/lib/ruco/screen.rb
CHANGED
@@ -92,48 +92,45 @@ module Ruco
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def self.curses_style(style)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
foreground, background
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
95
|
+
if $ruco_colors
|
96
|
+
foreground = $ruco_foreground || '#ffffff'
|
97
|
+
background = $ruco_background || '#000000'
|
98
|
+
|
99
|
+
foreground, background = if style == :normal
|
100
|
+
[foreground, background]
|
101
|
+
elsif style == :reverse
|
102
|
+
['#000000', '#ffffff']
|
103
|
+
else
|
104
|
+
# :red or [:red, :blue]
|
105
|
+
f,b = style
|
106
|
+
[f || foreground, b || background]
|
107
|
+
end
|
109
108
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
109
|
+
foreground = html_to_terminal_color(foreground)
|
110
|
+
background = html_to_terminal_color(background)
|
111
|
+
color_id(foreground, background)
|
112
|
+
else # no colors
|
113
|
+
if style == :reverse
|
114
|
+
Curses::A_REVERSE
|
115
|
+
else
|
116
|
+
Curses::A_NORMAL
|
119
117
|
end
|
120
118
|
end
|
121
119
|
end
|
120
|
+
cmemoize :curses_style
|
122
121
|
|
123
122
|
# create a new color from foreground+background or reuse old
|
124
123
|
# and return color-id
|
125
124
|
def self.color_id(foreground, background)
|
126
|
-
|
127
|
-
@@
|
128
|
-
|
129
|
-
|
130
|
-
id
|
131
|
-
unless defined? RSpec # stops normal text-output, do not use in tests
|
132
|
-
Curses::init_pair(id, foreground, background)
|
133
|
-
end
|
134
|
-
Curses.color_pair(id)
|
125
|
+
# make a new pair with a unique id
|
126
|
+
@@max_color_id ||= 0
|
127
|
+
id = (@@max_color_id += 1)
|
128
|
+
unless defined? RSpec # stops normal text-output, do not use in tests
|
129
|
+
Curses::init_pair(id, foreground, background)
|
135
130
|
end
|
131
|
+
Curses.color_pair(id)
|
136
132
|
end
|
133
|
+
cmemoize :color_id
|
137
134
|
|
138
135
|
COLOR_SOURCE_VALUES = 256
|
139
136
|
COLOR_TARGET_VALUES = 5
|
data/lib/ruco/syntax_parser.rb
CHANGED
@@ -6,6 +6,11 @@ module Ruco
|
|
6
6
|
'html+erb' => 'html_rails',
|
7
7
|
}
|
8
8
|
|
9
|
+
def self.syntax_for_line(line, languages)
|
10
|
+
syntax_for_lines([line], languages).first
|
11
|
+
end
|
12
|
+
cmemoize :syntax_for_line
|
13
|
+
|
9
14
|
def self.syntax_for_lines(lines, languages)
|
10
15
|
if syntax = syntax_node(languages)
|
11
16
|
processor = syntax.parse(lines.join("\n"), Ruco::ArrayProcessor.new)
|
@@ -16,18 +21,16 @@ module Ruco
|
|
16
21
|
end
|
17
22
|
|
18
23
|
def self.syntax_node(languages)
|
19
|
-
|
20
|
-
|
21
|
-
found = nil
|
22
|
-
fallbacks = languages.map{|l| TEXTPOW_CONVERT[l] }.compact
|
24
|
+
found = nil
|
25
|
+
fallbacks = languages.map{|l| TEXTPOW_CONVERT[l] }.compact
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
found
|
27
|
+
(languages + fallbacks).detect do |language|
|
28
|
+
syntax = File.join(Textpow.syntax_path, "#{language}.syntax")
|
29
|
+
found = Textpow::SyntaxNode.load(syntax) if File.exist?(syntax)
|
30
30
|
end
|
31
|
+
|
32
|
+
found
|
31
33
|
end
|
34
|
+
cmemoize :syntax_node
|
32
35
|
end
|
33
36
|
end
|
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.
|
8
|
+
s.version = "0.2.0.beta12"
|
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-10-
|
12
|
+
s.date = %q{2011-10-04}
|
13
13
|
s.default_executable = %q{ruco}
|
14
14
|
s.email = %q{michael@grosser.it}
|
15
15
|
s.executables = ["ruco"]
|
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:
|
4
|
+
hash: 62196379
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 0.2.0.
|
11
|
+
- 12
|
12
|
+
version: 0.2.0.beta12
|
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-10-
|
20
|
+
date: 2011-10-04 00:00:00 +02:00
|
21
21
|
default_executable: ruco
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|