Skip to content

Commit

Permalink
Merge branch 'upstream_master' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/PULL_REQUEST_TEMPLATE.md
#	tox.ini
  • Loading branch information
CodeByZach committed Jul 15, 2022
2 parents 701d058 + 9c96038 commit ef3215a
Show file tree
Hide file tree
Showing 114 changed files with 4,827 additions and 2,621 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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.
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.

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

- 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).

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

- 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.
- 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.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
python -m pip install --upgrade pip setuptools tox build
- name: Tests
run: |
python -m tox
Expand All @@ -46,7 +46,7 @@ jobs:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
python -m pip install --upgrade pip setuptools tox build
- name: Lint
run: |
python -m tox
Expand All @@ -66,7 +66,7 @@ jobs:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox
python -m pip install --upgrade pip setuptools tox build
- name: Install Aspell
run: |
sudo apt-get install aspell aspell-en
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade pip setuptools build
python -m pip install -r docs/src/requirements.txt
- name: Deploy documents
run: |
Expand Down
25 changes: 24 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
# ColorHelper

## 5.0.0

> **BREAKING CHANGE**: Newest `coloraide` was updated. It is approaching
> a 1.0 release. In the path to a 1.0 release some refactoring and
> reworking caused custom color classes to break. All internal color
> classes should be fine, but any users that created custom local
> color classes will need to update the color classes and color spaces
> to work with the latest version.
- **NEW**: Upgrade to latest `coloraide`.
- **NEW**: Many new color spaces have been added and can optionally
be included via the new `add_to_default_spaces` option. Some that
were available previously are no longer registered by default.
See `add_to_default_spaces` in the settings file to enable more
spaces. A restart of Sublime Text is required when changing this
setting.
- **NEW**: Add new `add_to_default_spaces` which allows a user to add
NEW color spaces to the default color space so that the new spaces
can be saved and recognized in palettes and other areas of ColorHelper.
Modifying this setting requires a restart of Sublime Text. Custom
color classes should only be used to modifying previously added
color spaces to add to recognized input and output formats.

## 4.3.1

- **NEW**: Upgrade underlying `coloraide` library to fix a color parsing
- **NEW**: Upgrade underlying `coloraide` library to fix a color parsing
bug.

## 4.3.0
Expand Down
51 changes: 41 additions & 10 deletions ColorHelper.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"auto_color_picker_mode": true,

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

// This option requires a restart of Sublime Text.
// This allows a user to add NEW previously unincluded color spaces.
// This ensures that the new color space will work in palettes etc.
// Then, custom color classes can override the space for special, file
// specific formatting via the `class` attribute under `user_color_classes`.
"add_to_default_spaces": [
// "ColorHelper.lib.coloraide.spaces.cmy.CMY",
// "ColorHelper.lib.coloraide.spaces.cmyk.CMYK",
// "ColorHelper.lib.coloraide.spaces.din99o.Din99o",
// "ColorHelper.lib.coloraide.spaces.hsi.HSI",
// "ColorHelper.lib.coloraide.spaces.hunter_lab.HunterLab",
// "ColorHelper.lib.coloraide.spaces.ictcp.ICtCp",
// "ColorHelper.lib.coloraide.spaces.igtgpg.IgTgPg",
// "ColorHelper.lib.coloraide.spaces.itp.ITP",
// "ColorHelper.lib.coloraide.spaces.jzazbz.Jzazbz",
// "ColorHelper.lib.coloraide.spaces.jzczhz.JzCzhz",
// "ColorHelper.lib.coloraide.spaces.lch99o.lch99o",
// "ColorHelper.lib.coloraide.spaces.orgb.ORGB",
// "ColorHelper.lib.coloraide.spaces.prismatic.Prismatic",
// "ColorHelper.lib.coloraide.spaces.rec2100pq.Rec2100PQ",
// "ColorHelper.lib.coloraide.spaces.rlab.RLAB",
// "ColorHelper.lib.coloraide.spaces.ucs.UCS",
// "ColorHelper.lib.coloraide.spaces.uvw.UVW",
// "ColorHelper.lib.coloraide.spaces.xyy.XyY",
"ColorHelper.lib.coloraide.spaces.hsluv.HSLuv",
"ColorHelper.lib.coloraide.spaces.lchuv.Lchuv",
"ColorHelper.lib.coloraide.spaces.luv.Luv",
"ColorHelper.lib.coloraide.spaces.okhsl.Okhsl",
"ColorHelper.lib.coloraide.spaces.okhsv.Okhsv"
],

// If a there is no rule for the current file, commands will assume
// the options specified here. This allows translate custom input color
// formats to our defaults and back out again. Here you can also filter
Expand Down Expand Up @@ -263,7 +294,7 @@
// - `color_class`: A string defining the name of a color class to use for the associated views. Color class
// name should be defined in `color_classes`.
//
// If needed, you can define multiple color classes with a list of dicitionaries. Each
// If needed, you can define multiple color classes with a list of dictionaries. Each
// dictionary in the list should contain a `class` and `scopes`:
//
// - `scopes`: A string that defines a base scope that the color class applies to.
Expand Down Expand Up @@ -312,10 +343,10 @@
//
// All of this "could" lead to false positives. We do our best to limit scoping as
// much as reasonable. HSV support is currently limited due to the fact the syntax
// is very non-spefic (floats separated by commas or spaces) and is likely to cause
// is very non-specific (floats separated by commas or spaces) and is likely to cause
// the most false positives. If the GraphViz syntax were to scope colors with a
// special scope, or at least properties that are likely to contain colors, we
// could greatly reduce/elliminate false positives and add HSV support with more
// could greatly reduce/eliminate false positives and add HSV support with more
// confidence.
"name": "Graphviz",
"base_scopes": [
Expand Down Expand Up @@ -344,7 +375,7 @@
]
},
{
//Sass (based on: https://packagecontrol.io/packages/Sass)
// Sass (based on: https://packagecontrol.io/packages/Sass)
"name": "Sass",
"syntax_files": ["Sass/Syntaxes/Sass", "Sass/Syntaxes/SCSS"],
"base_scopes": [
Expand Down Expand Up @@ -387,7 +418,7 @@
]
},
{
// Sass (based on https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20PostCSS)
// Sass (based on: https://packagecontrol.io/packages/Syntax%20Highlighting%20for%20PostCSS)
"name": "PostCSS",
"syntax_files": ["Syntax Highlighting for PostCSS/Syntaxes/PostCSS"],
"base_scopes": [
Expand Down Expand Up @@ -417,11 +448,11 @@
]
},
{
// Stylus (based on: https://github.com/billymoon/Stylus/blob/master/Stylus.tmLanguage)
"name": "Stylus",
"base_scopes": ["source.stylus"],
"color_class": "css-level-4",
"scanning": [
// Based on https://github.com/billymoon/Stylus/blob/master/Stylus.tmLanguage
"constant.other.color.rgb-value.stylus",
"constant.color.w3c-standard-color-name.stylus",
"meta.property-value.stylus"
Expand All @@ -438,7 +469,7 @@
]
},
{
// ASS ( based on: https://packagecontrol.io/packages/Advanced%20Substation%20Alpha%20(ASS) )
// ASS (based on: https://packagecontrol.io/packages/Advanced%20Substation%20Alpha%20(ASS))
"name": "ASS",
"base_scopes": ["text.ass"],
"scanning": ["constant.other.color"],
Expand All @@ -449,11 +480,11 @@

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

// User color classes. These will be added to the normal `color_classes` unless they
// share the same name with an existing entry. In that case, a shallow merge will be performed allowing
// the values of top level keys to be overriden and new keys to be added.
// the values of top level keys to be overridden and new keys to be added.
"user_color_classes": {}
}
18 changes: 9 additions & 9 deletions ch_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ def setup_image_border(self):
border_color = ch_settings.get('image_border_color')
if border_color is not None:
try:
border_color = Color(border_color)
border_color.fit(self.gamut_space, in_place=True)
border_color = self.base(border_color)
border_color.fit(self.gamut_space)
except Exception:
border_color = None

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

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

# Check if the first point within the color matches our scope rules
# and load up the appropriate color class
color_class = Color
color_class = self.base
filters = []
output = []
edit_mode = "default"
Expand All @@ -88,7 +88,7 @@ def get_color_options(self, pt, rule):
edit_mode = 'default'
break
except Exception:
color_class = Color
color_class = self.base
filters = []
output = []
edit_mode = 'default'
Expand All @@ -109,7 +109,7 @@ def setup_color_class(self):
self.custom_color_class = color_class
self.filters = filters
self.output_options = output
self.color_class = Color
self.color_class = self.base
try:
self.color_trigger = rule.get("color_trigger", util.RE_COLOR_START)
except Exception:
Expand Down
14 changes: 7 additions & 7 deletions ch_native_picker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""OS specific color pickers."""
import sublime
import subprocess
from .lib.coloraide import Color
import time

MAC_CHOOSE_COLOR = '''\
Expand Down Expand Up @@ -40,6 +39,7 @@ class _ColorPicker:
def __init__(self, color):
"""Initialize the color."""

self.base = type(color)
self.color = color

def pick(self):
Expand All @@ -55,7 +55,7 @@ def pick(self):
"""Pick the color."""

color = self.color.convert('srgb')
coords = [x * UINT for x in color.fit(in_place=True).coords()]
coords = [x * UINT for x in color.clone().fit()[:-1]]
try:
p = subprocess.Popen(
['osascript', '-e', MAC_CHOOSE_COLOR.format(*coords)],
Expand All @@ -67,7 +67,7 @@ def pick(self):
if returncode:
color = None
else:
color = Color("srgb", [int(x) / UINT for x in out[0].split(b', ')])
color = self.base("srgb", [int(x) / UINT for x in out[0].split(b', ')])
self.color = color
except Exception:
color = None
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_win_pick_colors(self):
colors.extend(['color(srgb 1 1 1)'] * delta)
for index, color in enumerate(colors, 0):
try:
hx = Color(color).to_string(hex=True, alpha=False)[1:]
hx = self.base(color).to_string(hex=True, alpha=False)[1:]
colors[index] = int(hx[4:6] + hx[2:4] + hx[0:2], 16)
except Exception:
colors[index] = 0xffffff
Expand All @@ -108,7 +108,7 @@ def set_win_pick_colors(self, colors):
for index in range(16):
hx = '{:06x}'.format(colors[index])
pcolors.append(
Color('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16))).to_string(
self.base('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16))).to_string(
color=True, fit=False, precision=-1
)
)
Expand All @@ -132,7 +132,7 @@ def pick(self):
time.sleep(1)
if ChooseColorW(ctypes.pointer(picker)):
hx = '{:06x}'.format(picker.rgbResult)
color = Color('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16)))
color = self.base('rgb({} {} {})'.format(int(hx[4:6], 16), int(hx[2:4], 16), int(hx[0:2], 16)))
self.color = color
else:
color = None
Expand Down Expand Up @@ -163,7 +163,7 @@ def pick(self):
if returncode:
color = None
else:
color = Color(out[0].decode('utf-8').strip())
color = self.base(out[0].decode('utf-8').strip())
self.color = color
except Exception:
color = None
Expand Down
Loading

0 comments on commit ef3215a

Please sign in to comment.