diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-01-26 08:22:04 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-01-26 08:22:04 +0100 |
commit | 95bcc4906313e3c30a3cc89f44f4a71dff9f4cd3 (patch) | |
tree | 5cc571bacefa4d81040d790ef8ce44f47cbbbbc7 /doc/ja | |
parent | 3d9886f82eac4b76aca772c42158d7a914d85609 (diff) | |
download | weechat-95bcc4906313e3c30a3cc89f44f4a71dff9f4cd3.zip |
doc: add example of callback in each language (scripting guide)
Diffstat (limited to 'doc/ja')
-rw-r--r-- | doc/ja/weechat_scripting.ja.txt | 73 |
1 files changed, 68 insertions, 5 deletions
diff --git a/doc/ja/weechat_scripting.ja.txt b/doc/ja/weechat_scripting.ja.txt index ca25206e4..37c5792a7 100644 --- a/doc/ja/weechat_scripting.ja.txt +++ b/doc/ja/weechat_scripting.ja.txt @@ -255,16 +255,79 @@ weechat.prnt("", "hi!") C コールバックはポインタ型の "data" 引数を利用します。スクリプト API では、"data" は文字列型で任意の値を取れます (ポインタ型ではありません)。 -例: +// TRANSLATION MISSING +Example of callback, for each language: + +* python: [source,python] ---------------------------------------- -weechat.hook_timer(1000, 0, 1, "my_timer_cb", "my data") +def timer_cb(data, remaining_calls): + weechat.prnt("", "timer! data=%s" % data) + return weechat.WEECHAT_RC_OK + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test") +---------------------------------------- + +* perl: + +[source,perl] +---------------------------------------- +sub timer_cb { + my ($data, $remaining_calls) = @_; + weechat::print("", "timer! data=$data"); + return weechat::WEECHAT_RC_OK; +} + +weechat::hook_timer(1000, 0, 1, "timer_cb", "test"); +---------------------------------------- + +* ruby: + +[source,ruby] +---------------------------------------- +def timer_cb(data, remaining_calls) + Weechat.print("", "timer! data=#{data}"); + return Weechat::WEECHAT_RC_OK +end + +Weechat.hook_timer(1000, 0, 1, "timer_cb", "test"); +---------------------------------------- + +* lua: -def my_timer_cb(data, remaining_calls): - # "my data" と表示 - weechat.prnt("", data) +[source,lua] +---------------------------------------- +function timer_cb(data, remaining_calls) + weechat.print("", "timer! data="..data) return weechat.WEECHAT_RC_OK +end + +weechat.hook_timer(1000, 0, 1, "timer_cb", "test") +---------------------------------------- + +* tcl: + +[source,tcl] +---------------------------------------- +proc timer_cb { data remaining_calls } { + weechat::print {} "timer! data=$data" + return $::weechat::WEECHAT_RC_OK +} + +weechat::hook_timer 1000 0 1 timer_cb test +---------------------------------------- + +* guile (scheme): + +[source,lisp] +---------------------------------------- +(define (timer_cb args) + (weechat:print "" (string-append "timer! data=" (list-ref args 0))) + weechat:WEECHAT_RC_OK +) + +(weechat:hook_timer 1000 0 1 "timer_cb" "test") ---------------------------------------- [[script_api]] |