Skip to content

Commit

Permalink
Implement dark/light Visual bell configuration
Browse files Browse the repository at this point in the history
Closes #502
  • Loading branch information
gerardroche committed May 7, 2019
1 parent 917a5f7 commit 082fc34
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 51 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Expand Up @@ -12,8 +12,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* Added [#512](https://github.com/NeoVintageous/NeoVintageous/issues/512): Visual block mode to Visual mode (`v`)
* Added [#511](https://github.com/NeoVintageous/NeoVintageous/issues/511): Visual block mode to Visual line mode (`V`)
* Added [#510](https://github.com/NeoVintageous/NeoVintageous/issues/510): Visual block mode
* Added [#502](https://github.com/NeoVintageous/NeoVintageous/issues/502): Visual bell styles
* Added [#502](https://github.com/NeoVintageous/NeoVintageous/issues/502): Visual bell styles
* Added [#502](https://github.com/NeoVintageous/NeoVintageous/issues/502): Visual bell styles including configurable dark and light color schemes
* Added [#500](https://github.com/NeoVintageous/NeoVintageous/issues/500): `-` in Visual line mode
* Added [#492](https://github.com/NeoVintageous/NeoVintageous/issues/492): `(` and `)` in Visual line mode
* Added [#499](https://github.com/NeoVintageous/NeoVintageous/issues/499): `<CR>` in Visual line mode
Expand Down
9 changes: 8 additions & 1 deletion Preferences.sublime-settings
Expand Up @@ -112,5 +112,12 @@
// Visual bell type.
// Valid values are: blink, view, or views.
// {not in Vim}
"vintageous_bell": "blink"
"vintageous_bell": "blink",

// Visual bell color scheme.
// Two color schemes are provided: "dark" and "light"
// You can also specify a path to custom one, for example:
// "Packages/NeoVintageous/res/Bell-dark.hidden-color-scheme"
// {not in Vim}
"vintageous_bell_color_scheme": "dark"
}
12 changes: 8 additions & 4 deletions nv/ui.py
Expand Up @@ -43,14 +43,18 @@ def ui_bell(msg=None):
if settings.get('vintageous_belloff') == 'all':
return

style = settings.get('vintageous_bell')
theme = 'Packages/NeoVintageous/res/Bell.tmTheme'
color_scheme = settings.get('vintageous_bell_color_scheme', 'dark')
if color_scheme in ('dark', 'light'):
color_scheme = 'Packages/NeoVintageous/res/Bell-%s.hidden-color-scheme' % color_scheme

duration = int(0.3 * 1000)
times = 4
delay = 55

style = settings.get('vintageous_bell')

if style == 'view':
settings.set('color_scheme', theme)
settings.set('color_scheme', color_scheme)

def remove_bell():
settings.erase('color_scheme')
Expand All @@ -61,7 +65,7 @@ def remove_bell():
for group in range(window.num_groups()):
view = window.active_view_in_group(group)
if view:
view.settings().set('color_scheme', theme)
view.settings().set('color_scheme', color_scheme)
views.append(view)

def remove_bell():
Expand Down
22 changes: 22 additions & 0 deletions res/Bell-dark.hidden-color-scheme
@@ -0,0 +1,22 @@
{
"name": "NeoVintageous Dark Bell",
"variables":
{
"dim-bg": "#1b1d1e",
"dim-fg": "#3e3d32"
},
"globals": {
"background": "var(dim-bg)",
"foreground": "var(dim-fg)",
"line_highlight": "var(dim-bg)",
"caret": "var(dim-fg)",
"selection": "var(dim-fg)",
"selection_foreground": "var(dim-bg)"
},
"rules": [
{
"scope": "markup,region,source,string,sublimelinter,text",
"background": "var(dim-bg)"
}
]
}
22 changes: 22 additions & 0 deletions res/Bell-light.hidden-color-scheme
@@ -0,0 +1,22 @@
{
"name": "NeoVintageous Light Bell",
"variables":
{
"dim-bg": "#ebedee",
"dim-fg": "#cecdc2"
},
"globals": {
"background": "var(dim-bg)",
"foreground": "var(dim-fg)",
"line_highlight": "var(dim-bg)",
"caret": "var(dim-fg)",
"selection": "var(dim-fg)",
"selection_foreground": "var(dim-bg)"
},
"rules": [
{
"scope": "markup,region,source,string,sublimelinter,text",
"background": "var(dim-bg)"
}
]
}
44 changes: 0 additions & 44 deletions res/Bell.tmTheme

This file was deleted.

8 changes: 8 additions & 0 deletions res/doc/neovintageous.txt
Expand Up @@ -431,6 +431,14 @@ List of available options:
Style of visual bell. The available styles are: blink (default), view,
or views.

*'vintageous_bell_color_scheme'*
'vintageous_bell_color_scheme'
string (default "dark")
Color scheme to use for visual bells. Two color schemes are provided,
a dark and light variant, but you can specify a custom one too:
- Packages/NeoVintageous/res/Bell-dark.hidden-color-scheme
- Packages/NeoVintageous/res/Bell-light.hidden-color-scheme

*'vintageous_belloff'*
'vintageous_belloff' string (default "")
Specifies for which events the bell (visual blink) will not be rung. It
Expand Down

0 comments on commit 082fc34

Please sign in to comment.