This repository has been archived by the owner on Oct 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ax_text.py
58 lines (55 loc) · 2.34 KB
/
ax_text.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
# -*- coding: utf-8 -*-
import sublime, sublime_plugin, sys
import os, subprocess, string, json, threading, re, time
import base64
ST3 = int(sublime.version()) > 3000
if ST3:
from .chigi_args import ChigiArgs
else:
from chigi_args import ChigiArgs
class AxTextCommand(sublime_plugin.TextCommand):
def __init__(self,view):
self.view = view;
ChigiArgs.GetInstance().cmdManager[id(self)] = self;
def __del__(self):
print(u"结束");
ChigiArgs.GetInstance().cmdManager[id(self)] = None;
pass;
def run(self, edit, call, cmd_args):
# 1. 加载配置信息
self.setting = sublime.load_settings("phpConnector.sublime-settings");
ChigiArgs.GetInstance().viewManager[self.view.id()] = self.view;
ChigiArgs.GetInstance().currentView = self.view;
command_to_run = {
'id':id(self),
'call':"\\Chigi\\Sublime\\Commands\\UpdateCurrentView",
'args' : {
'id' : self.view.id(),
'file_name' : self.view.file_name(),
'file_scope' : self.view.scope_name(0),
'sel_pos' : [self.view.sel()[0].begin(),self.view.sel()[0].end()],
'sel_scope' : self.view.scope_name(self.view.sel()[0].begin())
}
};
cmd_str = base64.b64encode(json.dumps(command_to_run, sort_keys=True).encode('utf-8')).decode('utf-8');
if ChigiArgs.GetInstance().phpMain is None:
CheckEnvironmentCommandThread.GetInstance().start();
while True:
time.sleep(1);
if ChigiArgs.GetInstance().phpMain is not None:
break;
ChigiArgs.GetInstance().phpMain.stdin.write(cmd_str.encode("UTF-8"));
ChigiArgs.GetInstance().phpMain.stdin.write("\n".encode("UTF-8"));
ChigiArgs.GetInstance().phpMain.stdin.flush();
command_to_run = {
'id':id(self),
'call':call,
'args' : cmd_args
};
cmd_str = base64.b64encode(json.dumps(command_to_run, sort_keys=True).encode('utf-8')).decode('utf-8');
ChigiArgs.GetInstance().phpMain.stdin.write(cmd_str.encode("UTF-8"));
ChigiArgs.GetInstance().phpMain.stdin.write("\n".encode("UTF-8"));
ChigiArgs.GetInstance().phpMain.stdin.flush();
pass;
def is_visible(self):
return True;