weechat::register test_script "Dmitry" "0.0.1" GPL3 "test script for Tcl plugin" "bye_bye" "UTF8" proc bye_bye {} { weechat::print "" "=== TEST ENDS ===" return $weechat::WEECHAT_RC_OK } ################## # String functions ################## weechat::charset_set "koi8r" weechat::print "" "### TEST SCRIPT ###" set iternal_rep [weechat::iconv_to_internal "KOI8-R" "строка koi8-r"] set some_text asdf set foreign_rep [weechat::iconv_from_internal "KOI8-R" $some_text] set some_text [weechat::gettext "непонятно зачем эта функция"] set some_text [weechat::ngettext "и эта" "unknown" 3] ##################### # Directory functions ##################### weechat::mkdir_home "test_dir" 0711 weechat::mkdir "/tmp/test_dir" 0755 ################# ## List functions ################# weechat::print "" "some_list = [set some_list [weechat::list_new]]" weechat::list_add $some_list "element 0" end weechat::list_add $some_list "element 1" end weechat::print "" "search 1 = [weechat::list_search $some_list {element 0}]" weechat::print "" "search 2 = [weechat::list_casesearch $some_list {ELEMENT 1}]" weechat::print "" "search 3 = [weechat::list_get $some_list 1]" weechat::list_set [weechat::list_get $some_list 1] "Oh, I must learn English better" weechat::print "" "string = [weechat::list_string [weechat::list_get $some_list 1]]" weechat::print "" "size = [weechat::list_size $some_list]" set next_item [weechat::list_next $some_list] set prev_item [weechat::list_prev $some_list] weechat::list_remove $some_list "element 0" #weechat::list_remove_all $some_list # if uncomment command above weechat crashes weechat::list_free $some_list ######################## # Config files functions ######################## # I don't know what values callback must return, so in some function callbacks are empty proc conf_cb {args} { weechat::print "" "conf_cb was called with args = $args" return $weechat::WEECHAT_CONFIG_WRITE_OK } set config_h [weechat::config_new test_tcl conf_cb] weechat::print "" "config_h = $config_h" weechat::print "" "section_h = [weechat::config_new_section \ $config_h test_section 1 1 conf_cb {} conf_cb conf_cb]" weechat::print "" "search section_h = [set section_h [weechat::config_search_section $config_h test_section]]" weechat::print "" "option_h = [set option_h [weechat::config_new_option \ $config_h $section_h test_option boolean "test description" yes 0 10 no {} {} {}]]" weechat::print "" "search option_h = [weechat::config_search_option $config_h $section_h test_option]" weechat::print "" "string_to_bool = [weechat::config_string_to_boolean yes]" weechat::print "" "reset return = [weechat::config_option_reset $option_h 0]" weechat::print "" "option set = [weechat::config_option_set $option_h yes 1]" #weechat::print "" "option unset = [weechat::config_option_unset $option_h]" weechat::print "" "rename return = [weechat::config_option_rename $option_h test_option_renamed]" # not work? weechat::print "" "boolean return = [weechat::config_boolean $option_h]" set int_opt [weechat::config_new_option \ $config_h $section_h int_option integer "some int description" 4 0 10 9 {} {} {}] weechat::print "" "integer return = [weechat::config_integer $int_opt]" set str_opt [weechat::config_new_option \ $config_h $section_h str_option string "some string description" sdata 0 0 sdata {} {} {}] weechat::print "" "string return = [weechat::config_integer $str_opt]" weechat::print "" "color return = [weechat::config_color $str_opt]" #crash here #weechat::config_write_line $config_h wl_option "write line value" #hm what values it must return? weechat::print "" "config_write return = [weechat::config_write $config_h]" weechat::print "" "config_read return = [weechat::config_read $config_h]" weechat::print "" "config_reload return = [weechat::config_reload $config_h]" #weechat::config_free $config_h weechat::print "" "config_get = [weechat::config_get test_tcl.test_section.int_option]" weechat::print "" "config_set_plugin = [weechat::config_set_plugin option1 value1]" #not work? weechat::print "" "config_get_plugin = [weechat::config_get_plugin tcl.test_script.option1]" #################### ## Display functions #################### weechat::print "" "prefix = [weechat::prefix error]" weechat::print "" "color = [weechat::color green,white] test green on white" weechat::print "" "print already tested :)" weechat::print "" "buffer_new = [set buffer_h [weechat::buffer_new new_buffer {} cb_close]]" proc cb_close {args} { weechat::print "" "cb_close was called with args = $args" return $weechat::WEECHAT_RC_OK } #weechat::print "" "print_date_tags = [weechat::print_date_tags $buffer_h 100 {hm} {i dont know how parameters must look like}]" # return value is OK, but nothing is displayed weechat::print "" "print_y1 = [weechat::print_y {} 5 HHHHHHHHHHHHHHH]" weechat::print $buffer_h "print_y2 = [weechat::print_y $buffer_h 5 message_here]" set msg "[weechat::color red,default] TEST_MESSAGE" weechat::print "" "print_y3 = [weechat::print_y $buffer_h 2 $msg]" weechat::print "" "log_print = [weechat::log_print log_message]" ######### ## Hooks ######### weechat::print "" "hook_command = [weechat::hook_command tcommand {test description} \ {i don't understand what args shoud be here} {args_description} {} hook_function]" proc hook_function {args} { weechat::print "" "hook_function was called with args=$args" return $weechat::WEECHAT_RC_OK } #weechat::print "" "hook_timer = [weechat::hook_timer 4000 0 4 hook_function]" #set fd [open ~/.bash_profile r] #weechat::print "" "hook_fd = [weechat::hook_fd [string range $fd 4 end] 1 0 0 hook_function]" #read $fd #close $fd #not work? weechat::print "" "hook_print = [weechat::hook_print $buffer_h {} message 0 hook_function]" weechat::print $buffer_h "test hook" weechat::print "" "hook_signal = [weechat::hook_signal {buffer_*} hook_function]" #hm #weechat::print "" "hook_signal_send = [weechat::hook_signal buffer_switch string signal_data]" #not work? weechat::print "" "hook_config = [weechat::hook_config test_tcl.test_section.int_option hook_function]" weechat::config_option_set $int_opt yes 1 # how it works? #weechat::print "" "hook_completion = [weechat::hook_completion %s hook_function]" # i did not test other hooks ########## ## Buffers ########## weechat::print "" "buffer_search = [weechat::buffer_search tcl new_buffer]" #weechat::print "" "buffer_clear = [weechat::buffer_clear $buffer_h]" #weechat::print "" "buffer_close = [weechat::buffer_close $buffer_h 1]" weechat::print "" "buffer_set = [weechat::buffer_set $buffer_h property1 51]" #not work? weechat::print "" "buffer_get_integer = [weechat::buffer_get_integer $buffer_h property1]" weechat::print "" "buffer_get_string = [weechat::buffer_get_integer $buffer_h property1]" weechat::print "" "buffer_get_pointer = [weechat::buffer_get_pointer $buffer_h property1]" ########### ## Nicklist ########### # not tested ####### ## Bars ####### # not tested ######### # Command ######### #not tested ################## ## Info / infolist ################## #not tested