-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathencoding.py
61 lines (41 loc) · 1.48 KB
/
encoding.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
49
50
51
52
53
54
55
56
57
58
59
60
61
import sublime
import sublime_plugin
class EncodingInputHandler(sublime_plugin.ListInputHandler):
def name(self):
return "encoding"
def placeholder(self):
return "text encoding"
def list_items(self):
return [
item["args"]["encoding"]
for item in sublime.decode_value(sublime.load_resource(
"Packages/Default/Encoding.sublime-menu"))[0]["children"]
if "args" in item
]
class ReopenEncodingCommand(sublime_plugin.WindowCommand):
def input_description(self):
return "Reopen with"
def input(self, args):
if "encoding" not in args:
return EncodingInputHandler()
return None
def run(self, encoding):
self.window.run_command("reopen", {"encoding": encoding})
class SaveEncodingCommand(sublime_plugin.WindowCommand):
def input_description(self):
return "Save with"
def input(self, args):
if "encoding" not in args:
return EncodingInputHandler()
return None
def run(self, encoding):
self.window.run_command("save", {"async": True, "encoding": encoding})
class SetEncodingCommand(sublime_plugin.WindowCommand):
def input_description(self):
return "Set Encoding"
def input(self, args):
if "encoding" not in args:
return EncodingInputHandler()
return None
def run(self, encoding):
self.window.run_command("set_encoding", {"encoding": encoding})