Debian Codegraph @

res/unite/script-doc

raw
1 
2 FQTerm支持javascript和Python脚本
3
4 javascript运行方式是在脚本菜单中选择运行脚本
5
6 而Python则需要选择运行Python脚本
7
8 如果你的菜单中没有"运行Python脚本",说明编译时未将Python支持编译进FQTerm,请与作者或者打包者联系
9
10 *编译fqterm时,若要支持Python,请在环境变量中包含python2*.lib的路径
11
12 现在fqterm对脚本回调的支持仍然处于试验阶段,所以没有记载在这里。
13
14
15 以下是js的api列表,你基本可以在js中像调用普通的javascript function一样调用这些函数
16
17 QString类型的返回值将被转变为字符串,而QList类型则会被转变为一个列表
18
19 如果需要sleep,则需要fqterm.import(utils.js)。sleep是忙等,参数为ms。
20
21 调用方式:在js脚本中,fqterm.function()即可
22
23 //import另一个脚本,如果是相对路径,则先在脚本当前路径搜索
24 //然后在script目录下搜索
25 bool import(const QString& filename);
26
27 //timer
28 int setInterval(int ms, const QScriptValue& func);
29 void clearInterval(int id);
30
31 //ui functions.
32 void msgBox(const QString& msg);
33
34 //bbs ui functions
35 int caretX();
36 int caretY();
37
38 QString getText(int row);
39 QString getTextAt(int row, int column, int len);
40 //当column是一个字的后半部分时,用full的这个版本可以得到这个字
41 QString getFullTextAt(int row, int column, int len);
42 QString getAttrText(int row);
43 QString getAttrTextAt(int row, int column, int len);
44 QString getFullAttrTextAt(int row, int column, int len);
45
46 void sendString(const QString& str);
47 void sendParsedString(const QString& str);
48
49 int columns();
50 int rows();
51
52 bool isConnected();
53 void disconnect();
54 void reconnect();
55
56 QString getBBSCodec();
57 QString getAddress();
58 int getPort();
59 int getProtocol();
60
61 QString getReplyKey();
62
63 QString getURL();
64 QString getIP();
65 void previewImage(const QString& url);
66 QString copyArticle();
67 void openUrl(const QString & url);
68 QString getSelect(bool color_copy);
69 QList<int> mapToChar(int screenX, int screenY);
70 //next 2 functions are map screen to char for x, y.
71 int charX(int screenX);
72 int charY(int screenY);
73 //mouse position is given in screen coordinate.
74 int mouseX();
75 int mouseY();
76
77 //auxiliary functions.
78 //should be move to some other class.
79 //qt script provides so poor extensions to js.
80 void writeFile(const QString& filename, const QString& str);
81 void appendFile(const QString& filename, const QString& str);
82 QString readFile(const QString& filename);
83 QStringList readFolder(const QString& path);
84 QString platform();
85 bool makePath(const QString& path);
86 QString newLine();
87
88
89 以下是Python的API列表,具体用法还请参考script目录下的脚本示例
90
91 需要注意的是
92
93 1.需要import fqterm,才能使用fqterm的API
94 2.long(sys.argv[0])是当前窗口的标记
95
96 sessionID=long(sys.argv[0])
97
98 formatError(sessionID)
99 get the traceback info
100 return string
101
102 getArticle(sessionID, interval)
103 copy current article
104 return (string, success)
105
106
107 copyArticle(sessionID)
108 copy current article (obsolete)
109 return string
110
111 getText(sessionID, line)
112 get text at line
113 return string
114
115
116 getAttrText(sessionID, line)
117 get attr text at line
118 return string
119
120 sendString(sessionID, str)
121 send string to server
122 return number of bytes written
123
124
125 sendParsedString(sessionID, str)
126 send string with escape
127 return number of bytes written
128
129 caretX(sessionID)
130 caret x
131 return int
132
133 caretY(sessionID)
134 caret y
135 return int
136
137
138 columns(sessionID)
139 screen width
140 return int
141
142
143 rows(sessionID)
144 screen height
145 return int
146
147
148 isConnected(sessionID)
149 connected to server or not
150 return int
151
152 disconnect(sessionID)
153 disconnect from server
154
155
156 reconnect(sessionID)
157 reconnect
158
159
160 getBBSCodec(sessionID)
161 get the bbs encoding, GBK or Big5
162 return string
163
164 getAddress(sessionID)
165 get the bbs address
166 return string
167
168 getPort(sessionID)
169 get the bbs port number
170 return int
171
172 getProtocol(sessionID)
173 get the bbs protocol, 0/1/2 TELNET/SSH1/SSH2
174 return int
175
176 getReplyKey(sessionID)
177 get the key to reply messages
178 return string (wtf...?)
179
180
181 getURL(sessionID)
182 get the url string under mouse (not sure if works)
183 return string
184
185
186 previewImage(sessionID, url)
187 preview the image link
188
189
190 fromUTF8(str, codec)
191 decode from utf8 to string in specified codec
192 return string
193
194
195 toUTF8(str, codec)
196 decode from string in specified codec to utf8
197 return string
198
199