~alivema4ever/ubuntu/trusty/weechat/lp-1299347-fix

« back to all changes in this revision

Viewing changes to doc/de/weechat_scripting.de.txt

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2013-05-21 19:44:31 UTC
  • mfrom: (1.1.24)
  • Revision ID: package-import@ubuntu.com-20130521194431-o1n165ouj17uk0q1
Tags: 0.4.1-1
* New upstream release
* Move guile build dependency from to guile-2.0-dev (previous versions are
  no longer supported).
* Add supported protocols in long description. Thanks to Jonas Smedegaard
  for the suggestion (Closes: #705216)

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
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:
 
62
 
 
63
[source,ruby]
 
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
----------------------------------------
59
68
 
60
69
Lua
61
70
^^^
163
172
Laden von Skripten
164
173
~~~~~~~~~~~~~~~~~~
165
174
 
166
 
Der Befehl zum Laden von Skripten ist davon abhängig welche Skriptsprache
167
 
genutzt werden soll:
 
175
Es wird empfohlen die "script" Erweiterung zum Laden von Skripten zu
 
176
nutzen, zum Beispiel:
 
177
 
 
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
----------------------------------------
 
186
 
 
187
Es besteht natürlich weiterhin die Möglichkeit, individuell für jede
 
188
Skriptsprache, den entsprechenden Befehl zu nutzen:
168
189
 
169
190
----------------------------------------
170
191
/python load python/skript.py
175
196
/guile load guile/skript.scm
176
197
----------------------------------------
177
198
 
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.
180
201
 
181
202
Ein Beispiel für ein Python-Skript:
182
203
 
185
206
$ ln -s ../script.py
186
207
----------------------------------------
187
208
 
 
209
[NOTE]
 
210
Installiert man mittels `/script install` ein Skript, dann wird automatisch
 
211
ein Link in das entsprechende 'autoload' Verzeichnis erzeugt.
 
212
 
188
213
[[differences_with_c_api]]
189
214
Unterschiede zur C API
190
215
----------------------
202
227
wie folgt abgearbeitet:
203
228
 
204
229
........................................
205
 
       (Skript API)                                (C API)
206
 
            \/                                        \/
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
........................................
209
236
 
210
237
Gibt WeeChat einen Rückgabewert an Ihr Skript 'test.py' zurück wird der
211
238
Aufruf in umgekehrter Reihenfolge abgearbeitet:
212
239
 
213
240
........................................
214
 
              (C API)                                 (Skript API)
215
 
                 \/                                        \/
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
........................................
218
247
 
219
248
[[pointers]]
257
286
Skript API ist "Data" ein String der jeden Wert haben darf (es handelt sich
258
287
nicht um einen Pointer).
259
288
 
260
 
Beispiel:
 
289
callback Beispiele, für jede Skriptsprache:
 
290
 
 
291
* python:
261
292
 
262
293
[source,python]
263
294
----------------------------------------
264
 
weechat.hook_timer(1000, 0, 1, "mein_timer_cb", "mein data")
265
 
 
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
 
298
 
 
299
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
 
300
----------------------------------------
 
301
 
 
302
* perl:
 
303
 
 
304
[source,perl]
 
305
----------------------------------------
 
306
sub timer_cb {
 
307
    my ($data, $remaining_calls) = @_;
 
308
    weechat::print("", "timer! data=$data");
 
309
    return weechat::WEECHAT_RC_OK;
 
310
}
 
311
 
 
312
weechat::hook_timer(1000, 0, 1, "timer_cb", "test");
 
313
----------------------------------------
 
314
 
 
315
* ruby:
 
316
 
 
317
[source,ruby]
 
318
----------------------------------------
 
319
def timer_cb(data, remaining_calls)
 
320
  Weechat.print("", "timer! data=#{data}");
 
321
  return Weechat::WEECHAT_RC_OK
 
322
end
 
323
 
 
324
Weechat.hook_timer(1000, 0, 1, "timer_cb", "test");
 
325
----------------------------------------
 
326
 
 
327
* lua:
 
328
 
 
329
[source,lua]
 
330
----------------------------------------
 
331
function timer_cb(data, remaining_calls)
 
332
    weechat.print("", "timer! data="..data)
 
333
    return weechat.WEECHAT_RC_OK
 
334
end
 
335
 
 
336
weechat.hook_timer(1000, 0, 1, "timer_cb", "test")
 
337
----------------------------------------
 
338
 
 
339
* tcl:
 
340
 
 
341
[source,tcl]
 
342
----------------------------------------
 
343
proc timer_cb { data remaining_calls } {
 
344
    weechat::print {} "timer! data=$data"
 
345
    return $::weechat::WEECHAT_RC_OK
 
346
}
 
347
 
 
348
weechat::hook_timer 1000 0 1 timer_cb test
 
349
----------------------------------------
 
350
 
 
351
* guile (scheme):
 
352
 
 
353
[source,lisp]
 
354
----------------------------------------
 
355
(define (timer_cb data remaining_calls)
 
356
  (weechat:print "" (string-append "timer! data=" data))
 
357
  weechat:WEECHAT_RC_OK
 
358
)
 
359
 
 
360
(weechat:hook_timer 1000 0 1 "timer_cb" "test")
270
361
----------------------------------------
271
362
 
272
363
[[script_api]]
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
355
446
| hdata               |
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
360
452
| Upgrade             |
361
453
  upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
362
454
|========================================
648
740
 
649
741
[source,python]
650
742
----------------------------------------
651
 
# Zeigt die Versionen der Linux-Kerne.
652
 
kernel_txt = ""
 
743
# Zeigt die aktuelle stabile Version von WeeChat an.
 
744
weechat_version = ""
653
745
 
654
 
def kernel_process_cb(data, command, rc, out, err):
655
 
    global kernel_txt
 
746
def weechat_process_cb(data, command, rc, out, err):
 
747
    global weechat_version
656
748
    if out != "":
657
 
        kernel_txt += out
 
749
        weechat_version += out
658
750
    if int(rc) >= 0:
659
 
        weechat.prnt("", kernel_txt)
 
751
        weechat.prnt("", "aktuelle stabile WeeChat-Version: %s" % weechat_version)
660
752
    return weechat.WEECHAT_RC_OK
661
753
 
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
----------------------------------------
665
757
 
 
758
[TIP]
 
759
Alle Informationen die WeeChat betreffen findet man auf: http://weechat.org/info
 
760
 
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:
668
763