-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathinputhelper.py
30 lines (24 loc) · 914 Bytes
/
inputhelper.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
import sublime
import sublime_plugin
import subprocess
import os
class InputHelperCommand(sublime_plugin.TextCommand):
def run(self, edit):
sel = self.view.sel()
selected = None
text_output = None
args = []
if len(sel) > 0:
selected = sel
if sublime.platform() == 'linux':
location = os.path.join(sublime.packages_path(), 'InputHelper', 'lib', 'linux_text_input_gui.py')
args = [location]
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
text_returned = proc.communicate()[0].strip()
text_output = text_returned.decode('utf-8')
if text_output:
for region in sel:
if region.size() == 0:
self.view.insert(edit, region.end(), text_output)
else:
self.view.replace(edit, region, text_output)