vic 0.0.5 → 0.0.6
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/lib/vic/color.rb +3 -2
- data/lib/vic/color_error.rb +2 -2
- data/lib/vic/colorscheme/highlight.rb +22 -15
- data/lib/vic/colorscheme/highlight_set.rb +1 -1
- data/lib/vic/colorscheme.rb +10 -21
- data/lib/vic.rb +1 -1
- metadata +2 -2
data/lib/vic/color.rb
CHANGED
@@ -79,8 +79,9 @@ module Vic
|
|
79
79
|
#
|
80
80
|
# @param [String] subject the string in question
|
81
81
|
# @return [Match
|
82
|
-
def
|
83
|
-
subject.
|
82
|
+
def is_hexadecimal?(subject)
|
83
|
+
return false unless subject.respond_to? :match
|
84
|
+
subject.match(/#?[\da-f]{6}/i) ? true : false
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
data/lib/vic/color_error.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Vic
|
2
2
|
class Colorscheme::Highlight
|
3
|
-
include Vic::Color
|
4
3
|
|
5
4
|
attr_accessor :group
|
6
5
|
|
@@ -11,7 +10,8 @@ module Vic
|
|
11
10
|
# @param [Hash] args the arguments to set
|
12
11
|
# @return [Vic::Colorscheme::Highlight] the new highlight
|
13
12
|
def initialize(group, args={})
|
14
|
-
|
13
|
+
# Convert to group name to symbol to ensure consistency
|
14
|
+
@group = group.to_sym
|
15
15
|
update_arguments!(args)
|
16
16
|
end
|
17
17
|
|
@@ -34,9 +34,6 @@ module Vic
|
|
34
34
|
arg = Argument.new(m, val)
|
35
35
|
argument_set.add arg
|
36
36
|
end
|
37
|
-
|
38
|
-
# Return self for chaining
|
39
|
-
self
|
40
37
|
end
|
41
38
|
end
|
42
39
|
end
|
@@ -45,22 +42,32 @@ module Vic
|
|
45
42
|
# the 256 color code for ctermfg.
|
46
43
|
#
|
47
44
|
# @param [String] hex a hexidecimal color
|
48
|
-
def fg=(
|
49
|
-
|
50
|
-
|
45
|
+
def fg=(color)
|
46
|
+
if color == 'NONE'
|
47
|
+
self.ctermfg = color
|
48
|
+
elsif Color.is_hexadecimal?(color)
|
49
|
+
self.ctermfg = Color.hex_to_256(color)
|
50
|
+
else
|
51
|
+
raise ColorError.new "invalid hexadecimal color #{color}"
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
self
|
54
|
+
self.guifg = color
|
54
55
|
end
|
55
56
|
|
56
57
|
# Sets guibg and ctermbg simultaneously. `hex` is automatically converted to
|
57
58
|
# the 256 color code for ctermbg.
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
#
|
60
|
+
# @param [String] hex a hexidecimal color
|
61
|
+
def bg=(color)
|
62
|
+
if color == 'NONE'
|
63
|
+
self.ctermbg = color
|
64
|
+
elsif Color.is_hexadecimal?(color)
|
65
|
+
self.ctermbg = Color.hex_to_256(color)
|
66
|
+
else
|
67
|
+
raise ColorError.new "invalid hexadecimal color #{color}"
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
self
|
70
|
+
self.guibg = color
|
64
71
|
end
|
65
72
|
|
66
73
|
# Updates/sets the current highlight's arguments.
|
data/lib/vic/colorscheme.rb
CHANGED
@@ -61,7 +61,7 @@ module Vic
|
|
61
61
|
end
|
62
62
|
alias_method :highlights, :highlight_set
|
63
63
|
|
64
|
-
# Creates a new highlight
|
64
|
+
# Creates a new highlight
|
65
65
|
#
|
66
66
|
# If inside of a language block the langauge name is automatcially prepended
|
67
67
|
# to the group name of the new highlight.
|
@@ -69,32 +69,21 @@ module Vic
|
|
69
69
|
# @see Vic::Highlight
|
70
70
|
# @return [Vic::Highlight] the new highlight
|
71
71
|
def highlight(group, args={})
|
72
|
-
|
73
|
-
no_args = args.empty?
|
72
|
+
return if args.empty?
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
# may need to create or update a highlight using this syntax:
|
78
|
-
#
|
79
|
-
# `hi('Normal').gui('bold')
|
80
|
-
#
|
81
|
-
# Note: If a highlight has no arguments it isn't rendered.
|
82
|
-
if not hilight and no_args
|
83
|
-
hilight = Highlight.new("#{language}#{group}")
|
84
|
-
highlight_set.add(hilight)
|
85
|
-
elsif hilight and no_args
|
86
|
-
return hilight
|
87
|
-
elsif hilight
|
88
|
-
hilight.update_arguments!(args)
|
74
|
+
if h = find_highlight(group)
|
75
|
+
h.update_arguments! args
|
89
76
|
else
|
90
|
-
|
91
|
-
highlight_set.add
|
77
|
+
h = Highlight.new "#{language}#{group}", args
|
78
|
+
highlight_set.add h
|
92
79
|
end
|
93
|
-
|
94
|
-
hilight
|
95
80
|
end
|
96
81
|
alias_method :hi, :highlight
|
97
82
|
|
83
|
+
def find_highlight(group)
|
84
|
+
highlight_set.find_by_group(group)
|
85
|
+
end
|
86
|
+
|
98
87
|
# Sets the current language to name. Any new highlights created will have
|
99
88
|
# the language name automatically prepended.
|
100
89
|
#
|
data/lib/vic.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-02-22 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create Vim colorschemes with Ruby
|
15
15
|
email: cjholdbrooks@gmail.com
|