-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview_commands.py
48 lines (30 loc) · 1.09 KB
/
view_commands.py
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
40
41
42
43
44
45
46
47
48
import sublime
import sublime_plugin
class SetViewNewNameCommand(sublime_plugin.TextCommand):
def run(self, edit, new_name):
if self.view.name() == 'Find Results':
self.view.set_syntax_file( 'Packages/Text/Plain text.tmLanguage' )
self.view.set_name( new_name )
self.view.settings().set( 'last_input', new_name )
def input(self, args):
if "new_name" not in args:
return SetViewNewNameInputHandler( self.view )
class SetViewNewNameInputHandler(sublime_plugin.TextInputHandler):
def __init__(self, view):
self.view = view
def name(self):
return "new_name"
def placeholder(self):
return "New View Name"
def cancel(self):
pass
def initial_text(self):
return "%s %s" % ( self.view.settings().get( 'last_input', 'New Name' ), self.view.name() )
def preview(self, text):
pass
def confirm(self, text):
pass
def validate(self, text):
return len( text ) > 0
def next_input(self, args):
pass