Skip to content

Commit ef3215a

Browse files
committed
Merge branch 'upstream_master' into dev
# Conflicts: # .github/PULL_REQUEST_TEMPLATE.md # tox.ini
2 parents 701d058 + 9c96038 commit ef3215a

File tree

114 files changed

+4827
-2621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+4827
-2621
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Thanks you for contributing to this project! Make sure you've read: https://codebyzach.github.io/sublime_color_helper/contributing/. Please follow the guidelines below.
1+
Thanks you for contributing to this project! Make sure you've read: https://codebyzach.github.io/sublime_color_helper/contributing/. Please follow the guidelines below.
22

33
- Please describe the change in as much detail as possible so I can understand what is being added or modified.
44

55
- If you are solving a bug that does not already have an issue, please describe the bug in detail and provide info on how to reproduce if applicable (this is good for me and others to reference later when verifying the issue has been resolved).
66

77
- Please reference and link related open bugs or feature requests in this pull if applicable.
88

9-
- Make sure you've documented or updated the existing documentation if introducing a new feature or modifying the behavior of an existing feature that a user needs to be aware of. I will not accept new features if you have not provided documentation describing the feature.
9+
- Make sure you've documented or updated the existing documentation if introducing a new feature or modifying the behavior of an existing feature that a user needs to be aware of. I will not accept new features if you have not provided documentation describing the feature.

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
python-version: 3.9
2727
- name: Install dependencies
2828
run: |
29-
python -m pip install --upgrade pip setuptools tox
29+
python -m pip install --upgrade pip setuptools tox build
3030
- name: Tests
3131
run: |
3232
python -m tox
@@ -46,7 +46,7 @@ jobs:
4646
python-version: 3.9
4747
- name: Install dependencies
4848
run: |
49-
python -m pip install --upgrade pip setuptools tox
49+
python -m pip install --upgrade pip setuptools tox build
5050
- name: Lint
5151
run: |
5252
python -m tox
@@ -66,7 +66,7 @@ jobs:
6666
python-version: 3.9
6767
- name: Install dependencies
6868
run: |
69-
python -m pip install --upgrade pip setuptools tox
69+
python -m pip install --upgrade pip setuptools tox build
7070
- name: Install Aspell
7171
run: |
7272
sudo apt-get install aspell aspell-en

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
python-version: 3.9
2222
- name: Install dependencies
2323
run: |
24-
python -m pip install --upgrade pip setuptools
24+
python -m pip install --upgrade pip setuptools build
2525
python -m pip install -r docs/src/requirements.txt
2626
- name: Deploy documents
2727
run: |

CHANGES.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
# ColorHelper
22

3+
## 5.0.0
4+
5+
> **BREAKING CHANGE**: Newest `coloraide` was updated. It is approaching
6+
> a 1.0 release. In the path to a 1.0 release some refactoring and
7+
> reworking caused custom color classes to break. All internal color
8+
> classes should be fine, but any users that created custom local
9+
> color classes will need to update the color classes and color spaces
10+
> to work with the latest version.
11+
12+
- **NEW**: Upgrade to latest `coloraide`.
13+
- **NEW**: Many new color spaces have been added and can optionally
14+
be included via the new `add_to_default_spaces` option. Some that
15+
were available previously are no longer registered by default.
16+
See `add_to_default_spaces` in the settings file to enable more
17+
spaces. A restart of Sublime Text is required when changing this
18+
setting.
19+
- **NEW**: Add new `add_to_default_spaces` which allows a user to add
20+
NEW color spaces to the default color space so that the new spaces
21+
can be saved and recognized in palettes and other areas of ColorHelper.
22+
Modifying this setting requires a restart of Sublime Text. Custom
23+
color classes should only be used to modifying previously added
24+
color spaces to add to recognized input and output formats.
25+
326
## 4.3.1
427

5-
- **NEW**: Upgrade underlying `coloraide` library to fix a color parsing
28+
- **NEW**: Upgrade underlying `coloraide` library to fix a color parsing
629
bug.
730

831
## 4.3.0

ColorHelper.sublime-settings

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"auto_color_picker_mode": true,
7575

7676
// If "auto" mode is disabled, or the "auto" mode could not determine a suitable picker,
77-
// the preferrreed color picker space will be used. If the preferred is invalid, the
77+
// the preferred color picker space will be used. If the preferred is invalid, the
7878
// first picker from `enabled_color_picker_modes` will be used, and if that is not valid,
7979
// `srgb` will be used.
8080
"preferred_color_picker_mode": "hsl",
@@ -112,6 +112,37 @@
112112
// Color Rules
113113
//////////////////
114114

115+
// This option requires a restart of Sublime Text.
116+
// This allows a user to add NEW previously unincluded color spaces.
117+
// This ensures that the new color space will work in palettes etc.
118+
// Then, custom color classes can override the space for special, file
119+
// specific formatting via the `class` attribute under `user_color_classes`.
120+
"add_to_default_spaces": [
121+
// "ColorHelper.lib.coloraide.spaces.cmy.CMY",
122+
// "ColorHelper.lib.coloraide.spaces.cmyk.CMYK",
123+
// "ColorHelper.lib.coloraide.spaces.din99o.Din99o",
124+
// "ColorHelper.lib.coloraide.spaces.hsi.HSI",
125+
// "ColorHelper.lib.coloraide.spaces.hunter_lab.HunterLab",
126+
// "ColorHelper.lib.coloraide.spaces.ictcp.ICtCp",
127+
// "ColorHelper.lib.coloraide.spaces.igtgpg.IgTgPg",
128+
// "ColorHelper.lib.coloraide.spaces.itp.ITP",
129+
// "ColorHelper.lib.coloraide.spaces.jzazbz.Jzazbz",
130+
// "ColorHelper.lib.coloraide.spaces.jzczhz.JzCzhz",
131+
// "ColorHelper.lib.coloraide.spaces.lch99o.lch99o",
132+
// "ColorHelper.lib.coloraide.spaces.orgb.ORGB",
133+
// "ColorHelper.lib.coloraide.spaces.prismatic.Prismatic",
134+
// "ColorHelper.lib.coloraide.spaces.rec2100pq.Rec2100PQ",
135+
// "ColorHelper.lib.coloraide.spaces.rlab.RLAB",
136+
// "ColorHelper.lib.coloraide.spaces.ucs.UCS",
137+
// "ColorHelper.lib.coloraide.spaces.uvw.UVW",
138+
// "ColorHelper.lib.coloraide.spaces.xyy.XyY",
139+
"ColorHelper.lib.coloraide.spaces.hsluv.HSLuv",
140+
"ColorHelper.lib.coloraide.spaces.lchuv.Lchuv",
141+
"ColorHelper.lib.coloraide.spaces.luv.Luv",
142+
"ColorHelper.lib.coloraide.spaces.okhsl.Okhsl",
143+
"ColorHelper.lib.coloraide.spaces.okhsv.Okhsv"
144+
],
145+
115146
// If a there is no rule for the current file, commands will assume
116147
// the options specified here. This allows translate custom input color
117148
// formats to our defaults and back out again. Here you can also filter
@@ -263,7 +294,7 @@
263294
// - `color_class`: A string defining the name of a color class to use for the associated views. Color class
264295
// name should be defined in `color_classes`.
265296
//
266-
// If needed, you can define multiple color classes with a list of dicitionaries. Each
297+
// If needed, you can define multiple color classes with a list of dictionaries. Each
267298
// dictionary in the list should contain a `class` and `scopes`:
268299
//
269300
// - `scopes`: A string that defines a base scope that the color class applies to.
@@ -312,10 +343,10 @@
312343
//
313344
// All of this "could" lead to false positives. We do our best to limit scoping as
314345
// much as reasonable. HSV support is currently limited due to the fact the syntax
315-
// is very non-spefic (floats separated by commas or spaces) and is likely to cause
346+
// is very non-specific (floats separated by commas or spaces) and is likely to cause
316347
// the most false positives. If the GraphViz syntax were to scope colors with a
317348
// special scope, or at least properties that are likely to contain colors, we
318-
// could greatly reduce/elliminate false positives and add HSV support with more
349+
// could greatly reduce/eliminate false positives and add HSV support with more
319350
// confidence.
320351
"name": "Graphviz",
321352
"base_scopes": [
@@ -344,7 +375,7 @@
344375
]
345376
},
346377
{
347-
//Sass (based on: https://packagecontrol.io/packages/Sass)
378+
// Sass (based on: https://packagecontrol.io/packages/Sass)
348379
"name": "Sass",
349380
"syntax_files": ["Sass/Syntaxes/Sass", "Sass/Syntaxes/SCSS"],
350381
"base_scopes": [
@@ -387,7 +418,7 @@
387418
]
388419
},
389420
{
390-
// Sass (based on https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20PostCSS)
421+
// Sass (based on: https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20PostCSS)
391422
"name": "PostCSS",
392423
"syntax_files": ["Syntax Highlighting for PostCSS/Syntaxes/PostCSS"],
393424
"base_scopes": [
@@ -417,11 +448,11 @@
417448
]
418449
},
419450
{
451+
// Stylus (based on: https://github.com/billymoon/Stylus/blob/master/Stylus.tmLanguage)
420452
"name": "Stylus",
421453
"base_scopes": ["source.stylus"],
422454
"color_class": "css-level-4",
423455
"scanning": [
424-
// Based on https://github.com/billymoon/Stylus/blob/master/Stylus.tmLanguage
425456
"constant.other.color.rgb-value.stylus",
426457
"constant.color.w3c-standard-color-name.stylus",
427458
"meta.property-value.stylus"
@@ -438,7 +469,7 @@
438469
]
439470
},
440471
{
441-
// ASS ( based on: https://packagecontrol.io/packages/Advanced%20Substation%20Alpha%20(ASS) )
472+
// ASS (based on: https://packagecontrol.io/packages/Advanced%20Substation%20Alpha%20(ASS))
442473
"name": "ASS",
443474
"base_scopes": ["text.ass"],
444475
"scanning": ["constant.other.color"],
@@ -449,11 +480,11 @@
449480

450481
// User rules. These will be appended to the normal `color_rules` unless they
451482
// share the same name. In that case, a shallow merge will be performed allowing
452-
// the values of top level keys to be overriden and new keys to be added.
483+
// the values of top level keys to be overridden and new keys to be added.
453484
"user_color_rules": [],
454485

455486
// User color classes. These will be added to the normal `color_classes` unless they
456487
// share the same name with an existing entry. In that case, a shallow merge will be performed allowing
457-
// the values of top level keys to be overriden and new keys to be added.
488+
// the values of top level keys to be overridden and new keys to be added.
458489
"user_color_classes": {}
459490
}

ch_mixin.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ def setup_image_border(self):
3333
border_color = ch_settings.get('image_border_color')
3434
if border_color is not None:
3535
try:
36-
border_color = Color(border_color)
37-
border_color.fit(self.gamut_space, in_place=True)
36+
border_color = self.base(border_color)
37+
border_color.fit(self.gamut_space)
3838
except Exception:
3939
border_color = None
4040

4141
if border_color is None:
4242
# Calculate border color for images
43-
border_color = Color(
43+
border_color = self.base(
4444
self.view.style()['background'],
4545
filters=util.CSS_SRGB_SPACES
4646
).convert("hsl")
47-
border_color.lightness = border_color.lightness + (0.3 if border_color.luminance() < 0.5 else -0.3)
47+
border_color['lightness'] = border_color['lightness'] + (0.3 if border_color.luminance() < 0.5 else -0.3)
4848

4949
self.default_border = border_color.convert(self.gamut_space, in_place=True)
50-
self.out_of_gamut = Color("transparent").convert(self.gamut_space, in_place=True)
51-
self.out_of_gamut_border = Color(
50+
self.out_of_gamut = self.base("transparent").convert(self.gamut_space, in_place=True)
51+
self.out_of_gamut_border = self.base(
5252
self.view.style().get('redish', "red"),
5353
filters=util.CSS_SRGB_SPACES
5454
).convert(self.gamut_space, in_place=True)
@@ -61,7 +61,7 @@ def get_color_options(self, pt, rule):
6161

6262
# Check if the first point within the color matches our scope rules
6363
# and load up the appropriate color class
64-
color_class = Color
64+
color_class = self.base
6565
filters = []
6666
output = []
6767
edit_mode = "default"
@@ -88,7 +88,7 @@ def get_color_options(self, pt, rule):
8888
edit_mode = 'default'
8989
break
9090
except Exception:
91-
color_class = Color
91+
color_class = self.base
9292
filters = []
9393
output = []
9494
edit_mode = 'default'
@@ -109,7 +109,7 @@ def setup_color_class(self):
109109
self.custom_color_class = color_class
110110
self.filters = filters
111111
self.output_options = output
112-
self.color_class = Color
112+
self.color_class = self.base
113113
try:
114114
self.color_trigger = rule.get("color_trigger", util.RE_COLOR_START)
115115
except Exception:

ch_native_picker.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""OS specific color pickers."""
22
import sublime
33
import subprocess
4-
from .lib.coloraide import Color
54
import time
65

76
MAC_CHOOSE_COLOR = '''\
@@ -40,6 +39,7 @@ class _ColorPicker:
4039
def __init__(self, color):
4140
"""Initialize the color."""
4241

42+
self.base = type(color)
4343
self.color = color
4444

4545
def pick(self):
@@ -55,7 +55,7 @@ def pick(self):
5555
"""Pick the color."""
5656

5757
color = self.color.convert('srgb')
58-
coords = [x * UINT for x in color.fit(in_place=True).coords()]
58+
coords = [x * UINT for x in color.clone().fit()[:-1]]
5959
try:
6060
p = subprocess.Popen(
6161
['osascript', '-e', MAC_CHOOSE_COLOR.format(*coords)],
@@ -67,7 +67,7 @@ def pick(self):
6767
if returncode:
6868
color = None
6969
else:
70-
color = Color("srgb", [int(x) / UINT for x in out[0].split(b', ')])
70+
color = self.base("srgb", [int(x) / UINT for x in out[0].split(b', ')])
7171
self.color = color
7272
except Exception:
7373
color = None
@@ -95,7 +95,7 @@ def get_win_pick_colors(self):
9595
colors.extend(['color(srgb 1 1 1)'] * delta)
9696
for index, color in enumerate(colors, 0):
9797
try:
98-
hx = Color(color).to_string(hex=True, alpha=False)[1:]
98+
hx = self.base(color).to_string(hex=True, alpha=False)[1:]
9999
colors[index] = int(hx[4:6] + hx[2:4] + hx[0:2], 16)
100100
except Exception:
101101
colors[index] = 0xffffff
@@ -108,7 +108,7 @@ def set_win_pick_colors(self, colors):
108108
for index in range(16):
109109
hx = '{:06x}'.format(colors[index])
110110
pcolors.append(
111-
Color('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16))).to_string(
111+
self.base('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16))).to_string(
112112
color=True, fit=False, precision=-1
113113
)
114114
)
@@ -132,7 +132,7 @@ def pick(self):
132132
time.sleep(1)
133133
if ChooseColorW(ctypes.pointer(picker)):
134134
hx = '{:06x}'.format(picker.rgbResult)
135-
color = Color('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16)))
135+
color = self.base('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16)))
136136
self.color = color
137137
else:
138138
color = None
@@ -163,7 +163,7 @@ def pick(self):
163163
if returncode:
164164
color = None
165165
else:
166-
color = Color(out[0].decode('utf-8').strip())
166+
color = self.base(out[0].decode('utf-8').strip())
167167
self.color = color
168168
except Exception:
169169
color = None

0 commit comments

Comments
 (0)