-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_edit_command.py
More file actions
39 lines (28 loc) · 1.17 KB
/
run_edit_command.py
File metadata and controls
39 lines (28 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sublime
import sublime_plugin
class RunEditCommandCommand(sublime_plugin.TextCommand):
def run(self, edit, command, arguments=[], **kwargs):
"""
Allows you to run:
replace()
erase()
insert()
without worrying about the edit object.
By math2001
"""
# return getattr(self.view, command)(edit, *arguments, **kwargs)
class EditReplaceCommand(sublime_plugin.TextCommand):
def run(self, edit, region, text):
return self.view.replace(edit, sublime.Region(region[0], region[1]), text)
class EditEraseCommand(sublime_plugin.TextCommand):
def run(self, edit, region):
return self.view.erase(edit, sublime.Region(region[0], region[1]))
class EditInsertCommand(sublime_plugin.TextCommand):
def run(self, edit, point, text):
return self.view.insert(edit, point, text)
class MessageDialogCommand(sublime_plugin.WindowCommand):
def run(self, **kwargs):
msg = kwargs.get('msg', None) or kwargs.get('text', None)
if msg is None:
return sublime.message_dialog("[no 'msg' or 'text']")
return sublime.message_dialog(msg)