-ran pep8 and fixed suggestions except for a long line issue
This commit is contained in:
parent
40dcc62448
commit
710a69fd87
|
@ -17,7 +17,8 @@ Config summary (see README.md for details):
|
||||||
@since: 2011-02-25
|
@since: 2011-02-25
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sublime, sublime_plugin
|
import sublime
|
||||||
|
import sublime_plugin
|
||||||
|
|
||||||
DEFAULT_MAX_FILE_SIZE = 1048576
|
DEFAULT_MAX_FILE_SIZE = 1048576
|
||||||
DEFAULT_COLOR_SCOPE_NAME = "invalid"
|
DEFAULT_COLOR_SCOPE_NAME = "invalid"
|
||||||
|
@ -26,10 +27,12 @@ DEFAULT_IS_ENABLED = True
|
||||||
#Set whether the plugin is on or off
|
#Set whether the plugin is on or off
|
||||||
TrailingSpacesEnabled = DEFAULT_IS_ENABLED
|
TrailingSpacesEnabled = DEFAULT_IS_ENABLED
|
||||||
|
|
||||||
|
|
||||||
# Return an array of regions matching trailing spaces.
|
# Return an array of regions matching trailing spaces.
|
||||||
def find_trailing_spaces(view):
|
def find_trailing_spaces(view):
|
||||||
return view.find_all('[ \t]+$')
|
return view.find_all('[ \t]+$')
|
||||||
|
|
||||||
|
|
||||||
# Highlight trailing spaces
|
# Highlight trailing spaces
|
||||||
def highlight_trailing_spaces(view):
|
def highlight_trailing_spaces(view):
|
||||||
max_size = view.settings().get('trailing_spaces_file_max_size',
|
max_size = view.settings().get('trailing_spaces_file_max_size',
|
||||||
|
@ -42,37 +45,42 @@ def highlight_trailing_spaces(view):
|
||||||
regions, color_scope_name,
|
regions, color_scope_name,
|
||||||
sublime.DRAW_EMPTY)
|
sublime.DRAW_EMPTY)
|
||||||
|
|
||||||
|
|
||||||
# Clear all trailing spaces
|
# Clear all trailing spaces
|
||||||
def clear_trailing_spaces_highlight(window):
|
def clear_trailing_spaces_highlight(window):
|
||||||
for view in window.views():
|
for view in window.views():
|
||||||
view.erase_regions('TrailingSpacesHighlightListener')
|
view.erase_regions('TrailingSpacesHighlightListener')
|
||||||
|
|
||||||
|
|
||||||
# Toggle the event listner on or off
|
# Toggle the event listner on or off
|
||||||
class ToggleTrailingSpacesCommand(sublime_plugin.WindowCommand):
|
class ToggleTrailingSpacesCommand(sublime_plugin.WindowCommand):
|
||||||
def run(self):
|
def run(self):
|
||||||
global TrailingSpacesEnabled
|
global TrailingSpacesEnabled
|
||||||
TrailingSpacesEnabled = False if(TrailingSpacesEnabled) else True
|
TrailingSpacesEnabled = False if TrailingSpacesEnabled else True
|
||||||
|
|
||||||
# If toggling on go ahead and perform a pass, if not clear the highlighting in all views
|
# If toggling on go ahead and perform a pass,
|
||||||
if(TrailingSpacesEnabled):
|
# if not clear the highlighting in all views
|
||||||
|
if TrailingSpacesEnabled:
|
||||||
highlight_trailing_spaces(self.window.active_view())
|
highlight_trailing_spaces(self.window.active_view())
|
||||||
else:
|
else:
|
||||||
clear_trailing_spaces_highlight(self.window)
|
clear_trailing_spaces_highlight(self.window)
|
||||||
|
|
||||||
|
|
||||||
# Highlight matching regions.
|
# Highlight matching regions.
|
||||||
class TrailingSpacesHighlightListener(sublime_plugin.EventListener):
|
class TrailingSpacesHighlightListener(sublime_plugin.EventListener):
|
||||||
def on_modified(self, view):
|
def on_modified(self, view):
|
||||||
if(TrailingSpacesEnabled):
|
if TrailingSpacesEnabled:
|
||||||
highlight_trailing_spaces(view)
|
highlight_trailing_spaces(view)
|
||||||
|
|
||||||
def on_activated(self,view):
|
def on_activated(self, view):
|
||||||
if(TrailingSpacesEnabled):
|
if TrailingSpacesEnabled:
|
||||||
highlight_trailing_spaces(view)
|
highlight_trailing_spaces(view)
|
||||||
|
|
||||||
def on_load(self,view):
|
def on_load(self, view):
|
||||||
if(TrailingSpacesEnabled):
|
if TrailingSpacesEnabled:
|
||||||
highlight_trailing_spaces(view)
|
highlight_trailing_spaces(view)
|
||||||
|
|
||||||
|
|
||||||
# Allows to erase matching regions.
|
# Allows to erase matching regions.
|
||||||
class DeleteTrailingSpacesCommand(sublime_plugin.TextCommand):
|
class DeleteTrailingSpacesCommand(sublime_plugin.TextCommand):
|
||||||
def run(self, edit):
|
def run(self, edit):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user