forked from bizoo/OracleSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoracle_commands.py
More file actions
40 lines (33 loc) · 1.5 KB
/
oracle_commands.py
File metadata and controls
40 lines (33 loc) · 1.5 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
40
import sublime
import sublime_plugin
from . import oracle_lib
import subprocess
import os
class OracleGotoBodyCommand(sublime_plugin.TextCommand):
def run(self, edit):
def _on_change(result):
try:
ln = int(result) - 1
if ln >= 0:
row, col = self.view.rowcol(pkgbody.begin())
pos = self.view.text_point(row + ln, 0)
reg = sublime.Region(pos, pos)
self.view.sel().clear()
self.view.sel().add(reg)
self.view.show(reg)
except:
ln = None
pkgbody = oracle_lib.find_body(self.view)
if pkgbody:
self.view.window().show_input_panel('Package body line number:', '', _on_change, _on_change, None)
else:
sublime.error_message('Error: Package body not found !')
class OracleFormat(sublime_plugin.TextCommand):
def run(self, edit):
#def _on_change(result):
if os.name == "nt":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
self.view.run_command("save")
process = subprocess.Popen(([os.path.join(sublime.packages_path(), 'Oracle', 'format_sql.bat'), '"' + self.view.file_name() + '"'])) #stdin=subprocess.PIPE, stdout=subprocess.PIPE, startupinfo=startupinfo
print('Source Formated: ' + self.view.file_name())