Created
January 5, 2012 22:35
-
-
Save ryukzak/1567715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
class ClearMarkCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
self.view.run_command("clear_bookmarks", {"name": "mark"}) | |
self.view.settings().set('with_marker', False) | |
class DoAfterMarkCommand(sublime_plugin.TextCommand): | |
def run(self, edit, command, args = {}): | |
self.view.run_command("clear_mark") | |
self.view.run_command(command) | |
class SetMarkCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
if not self.view.get_regions("mark"): | |
mark = [s for s in self.view.sel()] | |
self.view.add_regions("mark", mark, "mark", "dot", | |
sublime.HIDDEN | sublime.PERSISTENT) | |
self.view.settings().set('with_marker', True) | |
else: | |
self.view.run_command("clear_mark") | |
class MarkDetector(sublime_plugin.EventListener): | |
def on_selection_modified(self, view): | |
mark = view.get_regions("mark") | |
if mark: | |
view.run_command("select_to_mark") | |
def on_modified(self, view): | |
mark = view.get_regions("mark") | |
if mark: | |
view.run_command("clear_mark") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment