Skip to content

Commit 940276c

Browse files
committed
fix #3 default to rgba hex; new setting for argb
1 parent 08743a8 commit 940276c

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

ColorHints.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def get_cursor_color(view, region):
2626
color = None
2727
alpha = None
2828
alpha_dec = None
29+
settings = sublime.load_settings('ColorHints.sublime-settings')
30+
argb = settings.get('argb_hex', False)
2931
point = region.begin()
3032
visible = view.visible_region()
3133
start = point - 50
@@ -38,7 +40,7 @@ def get_cursor_color(view, region):
3840
ref = point - start
3941
for m in util.COLOR_RE.finditer(bfr):
4042
if ref >= m.start(0) and ref < m.end(0):
41-
color, alpha, alpha_dec = util.translate_color(m, True)
43+
color, alpha, alpha_dec = util.translate_color(m, argb)
4244
break
4345
return color, alpha, alpha_dec
4446

ColorHints.sublime-settings

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
// - always
44
// - never
55
// - in scope selector, eg 'source.css, source.scss, source.sass, source.less, text.html'
6-
"live_hints": "always"
6+
"live_hints": "always",
7+
8+
// Interpret hex values with an alpha channel as argb (not rgba)
9+
"argb_hex": false
710
}

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ Call up an inline color box displaying the color at the cursor(s). Live hints ca
77

88
ColorHints currently understands:
99

10-
- hex(a)
10+
- hex(a)<sup>*</sup>
1111
- rgb(a)
1212
- hsl(a)
1313
- hwb(a)
1414
- css color names (e.g. "aliceblue" or "rebeccapurple")
1515
- Pantone color codes (e.g. "16-1546 TCX" or "Yellow 012 C")
1616
- RAL classic color codes (e.g. "RAL 6034")
1717

18+
<sup>*</sup>) Set the "argb_hex" preference to `true` for (a)hex, ie. argb in hex values.
19+
1820
## Notes
1921

2022
The alpha (opacity) value is not represented in the hint. In these small samples it's impossible to properly judge the opacity anyway, and it's usually more interesting to know the base color.

0 commit comments

Comments
 (0)