@@ -7,6 +7,7 @@ var g_timerConnect; // 重连定时器
77var g_timerApply ; // 延迟应用样式
88var g_autoApply = true ; // 是否启用自动应用样式
99var g_valid = true ;
10+ var g_host = "localhost" ;
1011var g_port = 61052 ;
1112var g_zh = false ;
1213
@@ -22,6 +23,14 @@ function initKeywords(context) {
2223 keywords . register ( context ) ;
2324} ;
2425
26+ /**
27+ * 初始化服务端地址和端口
28+ */
29+ function initAddress ( ) {
30+ g_host = vscode . workspace . getConfiguration ( ) . get ( 'qsseditor.serverHost' , '127.0.0.1' ) ;
31+ g_port = Number ( vscode . workspace . getConfiguration ( ) . get ( 'qsseditor.serverPort' , '61052' ) ) ;
32+ } ;
33+
2534/**
2635 * 启动客户端
2736 */
@@ -32,7 +41,9 @@ function startClient() {
3241 g_timerConnect = undefined ;
3342 }
3443 if ( ! g_valid ) return ;
35- g_client = new RpcWebSocket ( 'ws://localhost:' + g_port , {
44+
45+ initAddress ( ) ;
46+ g_client = new RpcWebSocket ( 'ws://' + g_host + ':' + g_port , {
3647 reconnect : false
3748 } ) ;
3849 g_client . on ( 'open' , function ( ) {
@@ -61,6 +72,14 @@ function stopClient() {
6172 if ( g_client != undefined ) g_client . close ( ) ;
6273} ;
6374
75+ /**
76+ * 选中控件
77+ */
78+ function selectWidget ( word ) {
79+ if ( g_client == undefined ) return ;
80+ g_client . notify ( 'selectWidget' , [ word ] ) ;
81+ } ;
82+
6483/**
6584 * 应用样式
6685 */
@@ -93,13 +112,6 @@ function applyStyle(doc) {
93112 g_client . notify ( 'setStyleSheet' , styleSheets ) ;
94113} ;
95114
96- /**
97- * 初始化端口
98- */
99- function initPort ( port ) {
100- g_port = port ;
101- } ;
102-
103115/**
104116 * 设置端口
105117 */
@@ -168,8 +180,8 @@ module.exports = {
168180 initKeywords,
169181 startClient,
170182 stopClient,
183+ selectWidget,
171184 applyStyle,
172- initPort,
173185 setPort,
174186 onDidChangeTextDocument,
175187 onDidSaveTextDocument,
0 commit comments