added option to disable spaces or tabs

This commit is contained in:
Peter Conerly 2013-07-11 15:05:57 -07:00 committed by Kemal Hadimli
parent 04b88f15bd
commit 87141119fa
2 changed files with 27 additions and 15 deletions

View File

@ -11,7 +11,9 @@ Config summary (see README.md for details):
"highlight_whitespaces_space_highlight_scope_name": "invalid", "highlight_whitespaces_space_highlight_scope_name": "invalid",
"highlight_whitespaces_tab_highlight_scope_name": "invalid", "highlight_whitespaces_tab_highlight_scope_name": "invalid",
"highlight_whitespaces_file_max_size": 1048576, "highlight_whitespaces_file_max_size": 1048576,
"highlight_whitespaces_enabled": true "highlight_whitespaces_enabled": true,
"highlight_whitespaces_check_spaces": true,
"highlight_whitespaces_check_tabs": true
} }
Forked from https://github.com/SublimeText/TrailingSpaces/ by Jean-Denis Vauguet <jd@vauguet.fr>, Oktay Acikalin <ok@ryotic.de> Forked from https://github.com/SublimeText/TrailingSpaces/ by Jean-Denis Vauguet <jd@vauguet.fr>, Oktay Acikalin <ok@ryotic.de>
@ -27,6 +29,8 @@ import sublime_plugin
DEFAULT_MAX_FILE_SIZE = 1048576 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_TABS = True
#Set whether the plugin is on or off #Set whether the plugin is on or off
hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings') hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings')
@ -54,10 +58,12 @@ def highlight_whitespaces(view):
tab_scope_name = hws_settings.get('highlight_whitespaces_tab_highlight_scope_name', tab_scope_name = hws_settings.get('highlight_whitespaces_tab_highlight_scope_name',
DEFAULT_COLOR_SCOPE_NAME) DEFAULT_COLOR_SCOPE_NAME)
if view.size() <= max_size and not is_find_results(view): if view.size() <= max_size and not is_find_results(view):
if hws_settings.get('highlight_whitespaces_check_spaces', DEFAULT_CHECK_SPACES):
space_regions = find_whitespaces_spaces(view) space_regions = find_whitespaces_spaces(view)
view.add_regions('WhitespacesHighlightListener', view.add_regions('WhitespacesHighlightListener',
space_regions, space_scope_name, '', space_regions, space_scope_name, '',
sublime.DRAW_EMPTY) sublime.DRAW_EMPTY)
if hws_settings.get('highlight_whitespaces_check_tabs', DEFAULT_CHECK_TABS):
tab_regions = find_whitespaces_tabs(view) tab_regions = find_whitespaces_tabs(view)
view.add_regions('WhitespacesHighlightListener2', view.add_regions('WhitespacesHighlightListener2',
tab_regions, tab_scope_name, '', tab_regions, tab_scope_name, '',

View File

@ -1,13 +1,19 @@
{ {
// Spaces color is determined by scope (default, "invalid") // Spaces color is determined by scope (default, "invalid")
// "highlight_whitespaces_space_highlight_scope_name": "Whitespaces.space.highlight", // "highlight_whitespaces_space_highlight_scope_name": "Whitespaces.space.highlight",
// Tabs color is determined by scope (default, "invalid") // Tabs color is determined by scope (default, "invalid")
// "highlight_whitespaces_tab_highlight_scope_name": "Whitespaces.tab.highlight", // "highlight_whitespaces_tab_highlight_scope_name": "Whitespaces.tab.highlight",
// Max file size to search // Max file size to search
"highlight_whitespaces_file_max_size": 1048576, "highlight_whitespaces_file_max_size": 1048576,
// By default plugin is enabled or disabled (true|false) // By default plugin is enabled or disabled (true|false)
"highlight_whitespaces_enabled": true "highlight_whitespaces_enabled": true,
// Whether to check for spaces
"highlight_whitespaces_check_spaces": true,
// Whether to check for tabs
"highlight_whitespaces_check_tabs": true
} }