diff options
Diffstat (limited to 'src/plugins/demo')
-rw-r--r-- | src/plugins/demo/demo.c | 129 |
1 files changed, 87 insertions, 42 deletions
diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c index ebb1a8745..53b37fa09 100644 --- a/src/plugins/demo/demo.c +++ b/src/plugins/demo/demo.c @@ -100,68 +100,98 @@ demo_print_list (void *list, char *item_name) } /* - * demo_buffer_infos: display buffer infos + * demo_list_command: demo command for list */ -static void -demo_buffer_infos () +static int +demo_list_command (void *data, int argc, char **argv, char **argv_eol) { struct t_plugin_list *list; - list = weechat_list_get ("buffer", NULL); - if (list) + /* make C compiler happy */ + (void) data; + (void) argv_eol; + + if (argc > 1) { - demo_print_list (list, "buffer"); - weechat_list_free (list); + if (weechat_strcasecmp (argv[1], "buffer") == 0) + { + list = weechat_list_get ("buffer", NULL); + if (list) + { + demo_print_list (list, "buffer"); + weechat_list_free (list); + } + return PLUGIN_RC_SUCCESS; + } + if (weechat_strcasecmp (argv[1], "buffer_lines") == 0) + { + list = weechat_list_get ("buffer_lines", NULL); + if (list) + { + demo_print_list (list, "buffer_line"); + weechat_list_free (list); + } + return PLUGIN_RC_SUCCESS; + } } + + weechat_printf (NULL, + "Demo: missing argument for /demo_list command " + "(try /help demo_list)"); + + return PLUGIN_RC_SUCCESS; } /* - * demo_buffer_lines: display buffer lines + * demo_printf_command: demo command for printf */ -static void -demo_buffer_lines () +static int +demo_printf_command (void *data, int argc, char **argv, char **argv_eol) { - struct t_plugin_list *list; + (void) data; + (void) argc; + (void) argv; + (void) argv_eol; - list = weechat_list_get ("buffer_lines", NULL); - if (list) - { - demo_print_list (list, "buffer_line"); - weechat_list_free (list); - } + weechat_printf (NULL, "demo message without prefix"); + weechat_printf (NULL, "%sdemo message with info prefix", + weechat_prefix ("info")); + weechat_printf (NULL, "%sdemo message with error prefix", + weechat_prefix ("error")); + weechat_printf (NULL, + "colors: %s buffer %s server %s nick1 %s nick2 %s nick3", + weechat_color ("col_chat_buffer"), + weechat_color ("col_chat_server"), + weechat_color ("col_chat_nick_color1"), + weechat_color ("col_chat_nick_color2"), + weechat_color ("col_chat_nick_color3")); + + return PLUGIN_RC_SUCCESS; } /* - * demo_command: demo command + * demo_info_command: demo command for info_get */ static int -demo_command (void *data, int argc, char **argv, char **argv_eol) +demo_info_command (void *data, int argc, char **argv, char **argv_eol) { /* make C compiler happy */ (void) data; (void) argv_eol; if (argc > 1) - { - if (weechat_strcasecmp (argv[1], "buffer") == 0) - { - demo_buffer_infos (); - return PLUGIN_RC_SUCCESS; - } - if (weechat_strcasecmp (argv[1], "buffer_lines") == 0) - { - demo_buffer_lines (); - return PLUGIN_RC_SUCCESS; - } - } - - weechat_printf (NULL, - "Demo: missing argument for /demo command " - "(try /help demo)"); - + weechat_printf (NULL, "%sinfo \"%s\" = \"%s\"", + weechat_prefix ("info"), + argv[1], + weechat_info_get (argv[1])); + else + weechat_printf (NULL, + "Demo: missing argument for /demo_info command " + "(try /help demo_info)"); + return PLUGIN_RC_SUCCESS; } @@ -174,12 +204,27 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) { weechat_plugin = plugin; - weechat_hook_command ("demo", "demo command", "[action]", - "action: one of following actions:\n" - " buffer display infos about buffers", - "buffer|buffer_lines", demo_command, NULL); - - weechat_buffer_new ("categ", "nam"); + weechat_hook_command ("demo_list", "demo command: get and display list", + "list", + "list: list to display (values: buffer, " + "buffer_lines)", + "buffer|buffer_lines", + demo_list_command, NULL); + + weechat_hook_command ("demo_printf", "demo command: print some messages", + "", "", "", + demo_printf_command, NULL); + + weechat_hook_command ("demo_info", "demo command: get and display info", + "info", + "info: info to display (values: version, " + "weechat_dir, weechat_libdir, weechar_sharedir, " + "charset_terminal, charset_internal, inactivity, " + "input, input_mask, input_pos)", + "version|weechat_dir|weechat_libdir|" + "weechar_sharedir|charset_terminal|charset_internal|" + "inactivity|input|input_mask|input_pos", + demo_info_command, NULL); return PLUGIN_RC_SUCCESS; } |