forked from aardio/ImTip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.aardio
141 lines (118 loc) · 3.72 KB
/
main.aardio
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import win.ui;
import win.ui.atom;
import win.dlg.message;
import fonts.imtip;
/*DSG{{*/
mainForm = win.form(text="ImTip - 通用输入法提示工具";right=759;bottom=469)
mainForm.add()
/*}}*/
for(k,v in _ARGV){
if(string.endWith(v,".aardio",true)){
if(io.exist(v)){
__argvImTipConfig = v;
}
}
}
var atom,hwnd = mainForm.atom("E474890D-1DFA-4575-B456-7B46C15665DC.imtip");
if(!atom){
if(__argvImTipConfig) win.sendCopyData(hwnd,__argvImTipConfig);
else win.sendCopyData(hwnd,"start");
win.quitMessage();
return;
}
mainForm.enableDpiScaling("init");
//显示输入状态栏
import key.ime.stateBar;
imeBar = key.ime.stateBar(mainForm);
import config;
imeBar.interval = config.setting.interval;
imeBar.timeout = config.setting.timeout;
imeBar.editorClasses = config.setting.editorClasses;
imeBar.quirksMode = config.setting.quirksMode;
//下面创建托盘图标
import win.util.tray;
mainForm.tray = win.util.tray(mainForm)
mainForm.tray.tip = "ImTip:通用输入法状态跟踪提示工具" //设置鼠标提示
//响应托盘消息
mainForm.onTrayMessage = {
[0x205/*_WM_RBUTTONUP*/] = function(wParam){
import ui.appTrayMenu;
var menu = ui.appTrayMenu(mainForm); //延迟创建,避免系统启动时 DPI 缩放前创建菜单
win.setForeground(mainForm.hwnd); //避免不点击菜单不会消失,父窗口隐藏也要这样做
menu.popup();
};
[0x201/*_WM_LBUTTONDOWN*/] = function(wParam){
if(mainHotkeyForm) mainHotkeyForm.hitMin();
if(!mainSettingForm) mainSettingForm = mainForm.loadForm("\dlg\frmSetting.aardio");
mainSettingForm.show();
win.setForeground(mainSettingForm.hwnd);
};
}
import fsys.update.simpleMain;
if( fsys.update.simpleMain(
"ImTip ( 通用输入法状态跟踪提示工具 )",
"http://imtip.aardio.com/update/",
io.appData("/aardio/std/ImTip/app/update"),
function(version,description,status){})){
return 0;
}
import config;
import app.util;
mainForm.importImTipStyle = function(path){
var buf = string.loadBuffer(path);
if(!#buf) return mainForm.msgboxErr("此文件不包含有效的 ImTip 外观配置方案!");
var data = string.match(buf,"\/\*ImTipConfig\{\{\*\/(.+)\/\*\}\}\*\/");
if(!#data) return mainForm.msgboxErr("此文件不包含有效的 ImTip 外观配置方案!");
try{
var cfg = eval(data);
app.util.updateFontAwesome(cfg);
imeBar.imeSkin(cfg);
config.style.embeddingFontData = null;
config.style.embeddingFontName = null;
config.style.openStyle = null;
config.style.border = null;
config.style.embeddingFontData = null;
config.style.embeddingFontName = null;
config.style.openStyle = null;
config.style.border = null;
config.style.background = null;
config.style.foreground = null;
config.style.linearGradient = null;
config.style.paddingLeft = null;
config.style.paddingRight = null;
config.style.paddingTop = null;
config.style.paddingBottom = null;
table.assign(config.style,cfg);
config.style.save();
}
catch(e){
mainForm.msgboxErr(e);
}
}
mainForm.onCopyData = function(data,dataType){
if(data=="start"){
if(mainSettingForm){
return win.setForeground(mainSettingForm.hwnd);
}
var frmChild = mainForm.loadForm("\dlg\frmSetting.aardio");
frmChild.show();
}
elseif(string.endWith(data,".aardio",true) && io.exist(data) ){
if(mainSettingForm) {
win.setForeground(mainSettingForm.hwnd);
return mainSettingForm.importStyleFromFile(data);
}
mainForm.importImTipStyle(data);
}
}
if(config.style.width){
app.util.updateFontAwesome(config.style);
imeBar.imeSkin(config.style)
}
if(__argvImTipConfig){
win.sendCopyData(mainForm.hwnd,__argvImTipConfig);
}
if(config.hotkey.chkEnableHotkey){
mainHotkeyForm = ..mainForm.loadForm("\dlg\frmHotkey.aardio");
}
win.loopMessage();