summaryrefslogtreecommitdiff
path: root/res/unite/script-doc
blob: b23f26feb2f81e5b3f918d6675d00b68d87936b9 (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199

FQTerm支持javascript和Python脚本

javascript运行方式是在脚本菜单中选择运行脚本

而Python则需要选择运行Python脚本

如果你的菜单中没有"运行Python脚本",说明编译时未将Python支持编译进FQTerm,请与作者或者打包者联系

*编译fqterm时,若要支持Python,请在环境变量中包含python2*.lib的路径

现在fqterm对脚本回调的支持仍然处于试验阶段,所以没有记载在这里。


以下是js的api列表,你基本可以在js中像调用普通的javascript function一样调用这些函数

QString类型的返回值将被转变为字符串,而QList类型则会被转变为一个列表

如果需要sleep,则需要fqterm.import(utils.js)。sleep是忙等,参数为ms。

调用方式:在js脚本中,fqterm.function()即可

  //import另一个脚本,如果是相对路径,则先在脚本当前路径搜索
  //然后在script目录下搜索
  bool import(const QString& filename);

  //timer
  int setInterval(int ms, const QScriptValue& func);
  void clearInterval(int id);

  //ui functions.
  void msgBox(const QString& msg);

  //bbs ui functions
  int caretX();
  int caretY();

  QString getText(int row);
  QString getTextAt(int row, int column, int len);
  //当column是一个字的后半部分时,用full的这个版本可以得到这个字
  QString getFullTextAt(int row, int column, int len);
  QString getAttrText(int row);
  QString getAttrTextAt(int row, int column, int len);
  QString getFullAttrTextAt(int row, int column, int len);

  void sendString(const QString& str);
  void sendParsedString(const QString& str);

  int columns();
  int rows();

  bool isConnected();
  void disconnect();
  void reconnect();

  QString getBBSCodec();
  QString getAddress();
  int getPort();
  int getProtocol();

  QString getReplyKey();

  QString getURL();
  QString getIP();
  void previewImage(const QString& url);
  QString copyArticle();
  void openUrl(const QString & url);
  QString getSelect(bool color_copy);
  QList<int> mapToChar(int screenX, int screenY);
  //next 2 functions are map screen to char for x, y.
  int charX(int screenX);
  int charY(int screenY);
  //mouse position is given in screen coordinate.
  int mouseX();
  int mouseY();

  //auxiliary functions.
  //should be move to some other class.
  //qt script provides so poor extensions to js.
  void writeFile(const QString& filename, const QString& str);
  void appendFile(const QString& filename, const QString& str);
  QString readFile(const QString& filename);
  QStringList readFolder(const QString& path);
  QString platform();
  bool makePath(const QString& path);
  QString newLine();


以下是Python的API列表,具体用法还请参考script目录下的脚本示例

需要注意的是

1.需要import fqterm,才能使用fqterm的API
2.long(sys.argv[0])是当前窗口的标记

sessionID=long(sys.argv[0])

formatError(sessionID) 
get the traceback info
return string

getArticle(sessionID, interval)
copy current article
return (string, success)


copyArticle(sessionID)
copy current article (obsolete)
return string

getText(sessionID, line)
get text at line
return string


getAttrText(sessionID, line)
get attr text at line
return string

sendString(sessionID, str)
send string to server
return number of bytes written


sendParsedString(sessionID, str)
send string with escape
return number of bytes written

caretX(sessionID)
caret x
return int

caretY(sessionID)
caret y
return int


columns(sessionID)
screen width
return int


rows(sessionID)
screen height
return int


isConnected(sessionID)
connected to server or not
return int

disconnect(sessionID)
disconnect from server


reconnect(sessionID)
reconnect


getBBSCodec(sessionID)
get the bbs encoding, GBK or Big5
return string

getAddress(sessionID)
get the bbs address
return string

getPort(sessionID)
get the bbs port number
return int

getProtocol(sessionID)
get the bbs protocol, 0/1/2 TELNET/SSH1/SSH2
return int

getReplyKey(sessionID)
get the key to reply messages
return string (wtf...?)


getURL(sessionID)
get the url string under mouse (not sure if works)
return string


previewImage(sessionID, url)
preview the image link


fromUTF8(str, codec)
decode from utf8 to string in specified codec
return string


toUTF8(str, codec)
decode from string in specified codec to utf8
return string