-
-
Save rcherny/4afdaa0183761d2f1a07e8c9c558c569 to your computer and use it in GitHub Desktop.
Revisions
-
skuroda revised this gist
Mar 21, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,11 @@ def run(self, edit, action="add"): for cursor in cursors: self.saved_cursors_map[view_id].add(cursor.begin()) elif action == "show" and len(self.saved_cursors_map[view_id]) > 0: for cursor in cursors: self.saved_cursors_map[view_id].add(cursor.begin()) cursors.clear() for cursor in self.saved_cursors_map[view_id]: cursors.add(cursor) self.saved_cursors_map[view_id].clear() -
skuroda revised this gist
Mar 21, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def run(self, edit, action="add"): if action == "add": for cursor in cursors: self.saved_cursors_map[view_id].add(cursor.begin()) elif action == "show" and len(self.saved_cursors_map[view_id]) > 0: cursors.clear() for cursor in self.saved_cursors_map[view_id]: cursors.add(cursor) -
skuroda revised this gist
Mar 20, 2013 . 1 changed file with 18 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,30 +3,38 @@ class CursorCommand(sublime_plugin.TextCommand): saved_cursors_map = {} def run(self, edit, action="add"): view = self.view cursors = view.sel() view_id = view.id() if view_id not in self.saved_cursors_map: self.saved_cursors_map[view_id] = set() if action == "add": for cursor in cursors: self.saved_cursors_map[view_id].add(cursor.begin()) elif action == "show": cursors.clear() for cursor in self.saved_cursors_map[view_id]: cursors.add(cursor) self.saved_cursors_map[view_id].clear() elif action == "clear": self.saved_cursors_map[view_id].clear() elif action == "remove": for cursor in cursors: try: self.saved_cursors_map[view_id].remove(cursor.begin()) except KeyError: pass self.highlight_regions() def highlight_regions(self): view_id = self.view.id() regions = [sublime.Region(x, x) for x in self.saved_cursors_map[view_id]] self.view.add_regions("saved_cursor_region", regions, "keyword", "", sublime.DRAW_EMPTY) class EventListener(sublime_plugin.EventListener): def on_modified(self, view): view.run_command("cursor", {"action": "noop"}) -
skuroda revised this gist
Mar 20, 2013 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,13 +6,14 @@ class CursorCommand(sublime_plugin.TextCommand): saved_cursors = set() def run(self, edit, action="add"): view = self.view cursors = view.sel() if action == "add": for cursor in cursors: self.saved_cursors.add(cursor.begin()) elif action == "show": cursors.clear() for cursor in self.saved_cursors: cursors.add(cursor) self.saved_cursors.clear() elif action == "clear": self.saved_cursors.clear() -
skuroda renamed this gist
Mar 20, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
skuroda created this gist
Mar 20, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ [ { "keys": ["f12"], "command": "cursor", "args": {"action": "add"}}, { "keys": ["f11"], "command": "cursor", "args": {"action": "show"}}, { "keys": ["f10"], "command": "cursor", "args": {"action": "clear"}}, { "keys": ["f9"], "command": "cursor", "args": {"action": "remove"}} ] This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ import sublime import sublime_plugin class CursorCommand(sublime_plugin.TextCommand): saved_cursors = set() def run(self, edit, action="add"): view = self.view cursors = view.sel(); if action == "add": for cursor in cursors: self.saved_cursors.add(cursor.begin()) elif action == "show": cursors.clear() cursors.add_all(self.saved_cursors) self.saved_cursors.clear() elif action == "clear": self.saved_cursors.clear() elif action == "remove": for cursor in cursors: try: self.saved_cursors.remove(cursor.begin()) except KeyError: pass self.highlight_regions() def highlight_regions(self): regions = [sublime.Region(x, x) for x in self.saved_cursors] self.view.add_regions("saved_cursor_region", regions, "keyword", "", sublime.DRAW_EMPTY)