Compare commits

..

7 Commits

Author SHA1 Message Date
Will Bradley
f030fe86ee Add /Packages
The repository seemingly needs to be cloned into the Packages folder in order to work.
2015-02-17 13:02:06 -07:00
Kemal
42b9b62842 Merge pull request #10 from jackmaney/master
Added `highlight_whitespaces_enabled` summary to README
2014-06-06 14:06:12 +03:00
Jack Maney
e363121abb Added highlight_whitespaces_enabled summary to README
Documented feature in Issue #8 of the parent repository.
2014-01-17 19:37:38 -06:00
Kemal
0060617485 Merge pull request #9 from jethar/st3
Fix #7, add option to allow highlight on single space
2013-10-22 08:10:38 -07:00
Harjeet Singh
1df06d1ada Restored option to allow highlight on single space, but set as false by default 2013-10-21 19:14:30 +05:30
Harjeet Singh
1067d50461 Enabling by default again 2013-10-21 17:30:44 +05:30
Harjeet Singh
7c8152b0d6 Fixes for ST3 and disabling plugin by default 2013-10-21 17:20:29 +05:30
2 changed files with 21 additions and 4 deletions

View File

@ -12,7 +12,7 @@ Go to your `Packages` subdirectory under ST2's data directory:
* Windows: `%APPDATA%\Sublime Text 2` * Windows: `%APPDATA%\Sublime Text 2`
* OS X: `~/Library/Application Support/Sublime Text 2/Packages` * OS X: `~/Library/Application Support/Sublime Text 2/Packages`
* Linux: `~/.config/sublime-text-2` * Linux: `~/.config/sublime-text-2/Packages`
* Portable Installation: `Sublime Text 2/Data` * Portable Installation: `Sublime Text 2/Data`
Then clone this repository: Then clone this repository:
@ -33,6 +33,10 @@ menu.
The default toggle highlight shortcut is ```ctrl+alt+w``` (```cmd+alt+w``` for OS X) The default toggle highlight shortcut is ```ctrl+alt+w``` (```cmd+alt+w``` for OS X)
### Disable highlighting when Sublime Text starts up
Change `highlight_whitespaces_enabled` from the default of `true` to `false`.
### Change the highlighting color ### Change the highlighting color
One may also change the highlighting color, providing a scope name such One may also change the highlighting color, providing a scope name such

View File

@ -14,6 +14,7 @@ Config summary (see README.md for details):
"highlight_whitespaces_enabled": true, "highlight_whitespaces_enabled": true,
"highlight_whitespaces_check_spaces": true, "highlight_whitespaces_check_spaces": true,
"highlight_whitespaces_check_tabs": true, "highlight_whitespaces_check_tabs": true,
"highlight_whitespaces_single_space": false,
"highlight_last_whitespace": true "highlight_last_whitespace": true
} }
@ -31,6 +32,7 @@ DEFAULT_MAX_FILE_SIZE = 1048576
DEFAULT_COLOR_SCOPE_NAME = "invalid" DEFAULT_COLOR_SCOPE_NAME = "invalid"
DEFAULT_IS_ENABLED = True DEFAULT_IS_ENABLED = True
DEFAULT_CHECK_SPACES = True DEFAULT_CHECK_SPACES = True
DEFAULT_SINGLE_SPACE = False
DEFAULT_CHECK_TABS = True DEFAULT_CHECK_TABS = True
DEFAULT_LAST_WHITESPACE = False DEFAULT_LAST_WHITESPACE = False
@ -39,16 +41,25 @@ hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings')
hws_enabled = bool(hws_settings.get('highlight_whitespaces_enabled', hws_enabled = bool(hws_settings.get('highlight_whitespaces_enabled',
DEFAULT_IS_ENABLED)) DEFAULT_IS_ENABLED))
def get_settings():
s = sublime.load_settings('highlight_whitespaces.sublime-settings')
return s
# Determine if the view is a find results view # Determine if the view is a find results view
def is_find_results(view): def is_find_results(view):
return view.settings().get('syntax') and "Find Results" in view.settings().get('syntax') return view.settings().get('syntax') and "Find Results" in view.settings().get('syntax')
# Return an array of regions matching whitespaces. # Return an array of regions matching whitespaces.
def find_whitespaces_spaces(view): def find_whitespaces_spaces(view):
hws_settings = get_settings()
last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE)) last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE))
regex = ' {2,}|\t | \t' single_space = bool(hws_settings.get('highlight_whitespaces_single_space',DEFAULT_SINGLE_SPACE))
if last_whitespace: if single_space:
regex += '| {1,}$' regex = ' +'
else:
regex = ' {2,}|\t | \t'
if last_whitespace:
regex += '| {1,}$'
return view.find_all(regex) return view.find_all(regex)
@ -58,6 +69,8 @@ def find_whitespaces_tabs(view):
# Highlight whitespaces # Highlight whitespaces
def highlight_whitespaces(view): def highlight_whitespaces(view):
hws_settings = get_settings()
max_size = hws_settings.get('highlight_whitespaces_file_max_size', max_size = hws_settings.get('highlight_whitespaces_file_max_size',
DEFAULT_MAX_FILE_SIZE) DEFAULT_MAX_FILE_SIZE)
space_scope_name = hws_settings.get('highlight_whitespaces_space_highlight_scope_name', space_scope_name = hws_settings.get('highlight_whitespaces_space_highlight_scope_name',