57
57
* Es muss 'weechat_init' definiert und darin die Funktion 'register' ausgeführt werden
58
58
* Funktionen werden im Format `Weechat.xxx(arg1, arg2, ...)` ausgeführt
59
* Aufgrund einer Limitierung, seitens Ruby (maximal 15 Argumente pro Funktion), empfängt
60
die Funktion `Weechat.config_new_option` den Callback in einem Array von 6 Strings
61
(3 Callbacks + 3 Data Strings), somit sieht ein Aufruf der Funktion folgendermaßen aus:
64
----------------------------------------
65
Weechat.config_new_option(config, section, "name", "string", "description of option", "", 0, 0,
66
"value", "value", 0, ["check_cb", "", "change_cb", "", "delete_cb", ""])
67
----------------------------------------
163
172
Laden von Skripten
164
173
~~~~~~~~~~~~~~~~~~
166
Der Befehl zum Laden von Skripten ist davon abhängig welche Skriptsprache
175
Es wird empfohlen die "script" Erweiterung zum Laden von Skripten zu
176
nutzen, zum Beispiel:
178
----------------------------------------
179
/script load script.py
180
/script load script.pl
181
/script load script.rb
182
/script load script.lua
183
/script load script.tcl
184
/script load script.scm
185
----------------------------------------
187
Es besteht natürlich weiterhin die Möglichkeit, individuell für jede
188
Skriptsprache, den entsprechenden Befehl zu nutzen:
169
190
----------------------------------------
170
191
/python load python/skript.py
175
196
/guile load guile/skript.scm
176
197
----------------------------------------
178
Um Skripten automatisch beim Start von WeeChat zu laden kann man einen Link
179
in das Verzeichnis 'Skriptsprache/autoload' setzen.
199
Um Skripten automatisch beim Start von WeeChat zu laden sollte man einen Link
200
anlegen, der in das Verzeichnis 'Skriptsprache/autoload' zeigt.
181
202
Ein Beispiel für ein Python-Skript:
202
227
wie folgt abgearbeitet:
204
229
........................................
207
test.py -------> python Erweiterung (python.so) -------> WeeChat core
230
┌──────────────────────┐ ╔══════════════════╗
231
│ python Erweiterung │ ║ WeeChat "core" ║
232
├────────────┬─────────┤ ╟─────────┐ ║
233
test.py ─────► │ Skript API │ C API │ ─────► ║ C API │ ║
234
└────────────┴─────────┘ ╚═════════╧════════╝
208
235
........................................
210
237
Gibt WeeChat einen Rückgabewert an Ihr Skript 'test.py' zurück wird der
211
238
Aufruf in umgekehrter Reihenfolge abgearbeitet:
213
240
........................................
216
WeeChat core -------> python Erweiterung (python.so) -------> test.py
241
╔══════════════════╗ ┌──────────────────────┐
242
║ WeeChat "core" ║ │ python Erweiterung │
243
║ ┌─────────╢ ├─────────┬────────────┤
244
║ │ C API ║ ─────► │ C API │ Skript API │ ─────► test.py
245
╚════════╧═════════╝ └─────────┴────────────┘
217
246
........................................
257
286
Skript API ist "Data" ein String der jeden Wert haben darf (es handelt sich
258
287
nicht um einen Pointer).
289
callback Beispiele, für jede Skriptsprache:
263
294
----------------------------------------
264
weechat.hook_timer(1000, 0, 1, "mein_timer_cb", "mein data")
266
def mein_timer_cb(data, verbleibende_aufrufe):
267
# es wird "mein data" angezeigt
268
weechat.prnt("", data)
269
return weechat.WEECHAT_RC_OK
295
def timer_cb(data, remaining_calls):
296
weechat.prnt("", "timer! data=%s" % data)
297
return weechat.WEECHAT_RC_OK
299
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
300
----------------------------------------
305
----------------------------------------
307
my ($data, $remaining_calls) = @_;
308
weechat::print("", "timer! data=$data");
309
return weechat::WEECHAT_RC_OK;
312
weechat::hook_timer(1000, 0, 1, "timer_cb", "test");
313
----------------------------------------
318
----------------------------------------
319
def timer_cb(data, remaining_calls)
320
Weechat.print("", "timer! data=#{data}");
321
return Weechat::WEECHAT_RC_OK
324
Weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
325
----------------------------------------
330
----------------------------------------
331
function timer_cb(data, remaining_calls)
332
weechat.print("", "timer! data="..data)
333
return weechat.WEECHAT_RC_OK
336
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
337
----------------------------------------
342
----------------------------------------
343
proc timer_cb { data remaining_calls } {
344
weechat::print {} "timer! data=$data"
345
return $::weechat::WEECHAT_RC_OK
348
weechat::hook_timer 1000 0 1 timer_cb test
349
----------------------------------------
354
----------------------------------------
355
(define (timer_cb data remaining_calls)
356
(weechat:print "" (string-append "timer! data=" data))
357
weechat:WEECHAT_RC_OK
360
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
270
361
----------------------------------------
293
384
charset_set, iconv_to_internal, iconv_from_internal, gettext, ngettext, +
294
385
string_match, string_has_highlight, string_has_highlight_regex,
295
386
string_mask_to_regex, string_remove_color, string_is_command_char,
296
string_input_for_buffer
387
string_input_for_buffer, string_eval_expression
297
388
| Verzeichnisse |
298
389
mkdir_home, mkdir, mkdir_parents
299
390
| sortierte Listen |
354
445
infolist_time, infolist_free
356
447
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
448
hdata_get_var_array_size, hdata_get_var_array_size_string,
357
449
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
358
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
359
hdata_time, hdata_hashtable, hdata_get_string
450
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
451
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
361
453
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
362
454
|========================================
650
742
----------------------------------------
651
# Zeigt die Versionen der Linux-Kerne.
743
# Zeigt die aktuelle stabile Version von WeeChat an.
654
def kernel_process_cb(data, command, rc, out, err):
746
def weechat_process_cb(data, command, rc, out, err):
747
global weechat_version
749
weechat_version += out
659
weechat.prnt("", kernel_txt)
751
weechat.prnt("", "aktuelle stabile WeeChat-Version: %s" % weechat_version)
660
752
return weechat.WEECHAT_RC_OK
662
weechat.hook_process("url:http://www.kernel.org/kdist/finger_banner",
663
30 * 1000, "kernel_process_cb", "")
754
weechat.hook_process("url:http://weechat.org/info/stable/",
755
30 * 1000, "weechat_process_cb", "")
664
756
----------------------------------------
759
Alle Informationen die WeeChat betreffen findet man auf: http://weechat.org/info
666
761
Beispiel eines URL Transfers, mit zusätzliche Optionen: Es wird das neuste
667
762
WeeChat Entwicklerpaket in die Datei '/tmp/weechat-devel.tar.gz' gesichert: