Skip to content

Instantly share code, notes, and snippets.

@evanemolo
Forked from kellishaver/SublimeBlockCursor.py
Created October 27, 2012 22:49
Show Gist options
  • Save evanemolo/3966741 to your computer and use it in GitHub Desktop.
Save evanemolo/3966741 to your computer and use it in GitHub Desktop.
Sublime Text 2 Block Cursor - outside of Vintage Mode
# Add this file to a directory called SublimeBlockCursor in the Packages directory.
import sublime
import sublime_plugin
class SublimeBlockCursor(sublime_plugin.EventListener):
def view_is_widget(view):
settings = view.settings()
return bool(settings.get('is_widget'))
def show_block_cursor(self, view):
validRegions = []
for s in view.sel():
if s.a != s.b:
continue
validRegions.append(sublime.Region(s.a, s.a + 1))
if validRegions.__len__:
view.add_regions('SublimeBlockCursorListener', validRegions, 'block_cursor')
else:
view.erase_regions('SublimeBlockCursorListener')
def on_selection_modified(self, view):
if view.settings().get('is_widget'):
view.erase_regions('SublimeBlockCursorListener')
return
self.show_block_cursor(view)
def on_deactivated(self, view):
view.erase_regions('SublimeBlockCursorListener')
def on_activated(self, view):
self.show_block_cursor(view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment