void rmodifier_hook_modifiers (struct t_rmodifier *rmodifier) { char **argv, str_modifier[128]; int argc, i; argv = weechat_string_split (rmodifier->modifiers, ",", 0, 0, &argc); if (argv) { rmodifier->hooks = malloc (sizeof (*rmodifier->hooks) * argc); if (rmodifier->hooks) { for (i = 0; i < argc; i++) { /* * we use a high priority here, so that other modifiers * (from other plugins) will be called after this one */ snprintf (str_modifier, sizeof (str_modifier) - 1, "5000|%s", argv[i]); rmodifier->hooks[i] = weechat_hook_modifier (str_modifier, &rmodifier_modifier_cb, rmodifier); } rmodifier->hooks_count = argc; } weechat_string_free_split (argv); } }
int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { /* make C compiler happy */ (void) argc; (void) argv; weechat_plugin = plugin; /* get terminal & internal charsets */ charset_terminal = weechat_info_get ("charset_terminal", ""); charset_internal = weechat_info_get ("charset_internal", ""); /* display message */ if (weechat_charset_plugin->debug >= 1) charset_display_charsets (); if (!charset_config_init ()) { weechat_printf (NULL, _("%s%s: error creating configuration file"), weechat_prefix("error"), CHARSET_PLUGIN_NAME); return WEECHAT_RC_OK; } charset_config_read (); /* /charset command */ weechat_hook_command ("charset", N_("change charset for current buffer"), N_("decode|encode <charset>" " || reset"), N_(" decode: change decoding charset\n" " encode: change encoding charset\n" "charset: new charset for current buffer\n" " reset: reset charsets for current buffer"), "decode|encode|reset", &charset_command_cb, NULL); /* modifiers hooks */ weechat_hook_modifier ("charset_decode", &charset_decode_cb, NULL); weechat_hook_modifier ("charset_encode", &charset_encode_cb, NULL); return WEECHAT_RC_OK; }
int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { /* make C compiler happy */ (void) argc; (void) argv; weechat_plugin = plugin; #ifdef USE_ENCHANT /* acquire enchant broker */ broker = enchant_broker_init (); if (!broker) return WEECHAT_RC_ERROR; #endif /* USE_ENCHANT */ if (!weechat_aspell_speller_init ()) return WEECHAT_RC_ERROR; if (!weechat_aspell_config_init ()) return WEECHAT_RC_ERROR; weechat_aspell_config_read (); weechat_aspell_command_init (); weechat_aspell_completion_init (); /* * callback for spell checking input text * we use a low priority here, so that other modifiers "input_text_display" * (from other plugins) will be called before this one */ weechat_hook_modifier ("500|input_text_display", &weechat_aspell_modifier_cb, NULL, NULL); weechat_aspell_bar_item_init (); weechat_aspell_info_init (); weechat_hook_signal ("buffer_switch", &weechat_aspell_buffer_switch_cb, NULL, NULL); weechat_hook_signal ("window_switch", &weechat_aspell_window_switch_cb, NULL, NULL); weechat_hook_signal ("buffer_closed", &weechat_aspell_buffer_closed_cb, NULL, NULL); weechat_hook_signal ("debug_libs", &weechat_aspell_debug_libs_cb, NULL, NULL); return WEECHAT_RC_OK; }
int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { /* make C compiler happy */ (void) argc; (void) argv; weechat_plugin = plugin; if (!weechat_aspell_config_init ()) return WEECHAT_RC_ERROR; if (weechat_aspell_config_read () < 0) return WEECHAT_RC_ERROR; /* command /aspell */ weechat_hook_command ("aspell", N_("aspell plugin configuration"), N_("dictlist | enable lang | disable | " "addword [lang] word"), N_("dictlist: show installed dictionaries\n" " enable: enable aspell on current buffer\n" " disable: disable aspell on current buffer\n" " addword: add a word in your personal aspell " "dictionary\n" "\n" "Input line beginning with a '/' is not checked, " "except for some commands."), "dictlist" " || enable %(aspell_langs)" " || disable" " || addword", &weechat_aspell_command_cb, NULL); weechat_hook_completion ("aspell_langs", N_("list of supported langs for aspell"), &weechat_aspell_completion_langs_cb, NULL); /* callback for buffer_switch */ weechat_hook_signal ("buffer_switch", &weechat_aspell_buffer_switch_cb, NULL); /* callback for spell checking input text */ weechat_hook_modifier ("input_text_display", &weechat_aspell_modifier_cb, NULL); weechat_aspell_create_spellers (weechat_current_buffer ()); return WEECHAT_RC_OK; }
void trigger_hook (struct t_trigger *trigger) { char **argv, **argv_eol, *tags, *message, *error1, *error2, *error3; int i, argc, strip_colors; long interval, align_second, max_calls; trigger_unhook (trigger); argv = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]), ";", 0, 0, &argc); argv_eol = weechat_string_split (weechat_config_string (trigger->options[TRIGGER_OPTION_ARGUMENTS]), ";", 1, 0, NULL); switch (weechat_config_integer (trigger->options[TRIGGER_OPTION_HOOK])) { case TRIGGER_HOOK_SIGNAL: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_signal ( argv[i], &trigger_callback_signal_cb, trigger); } } } break; case TRIGGER_HOOK_HSIGNAL: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_hsignal ( argv[i], &trigger_callback_hsignal_cb, trigger); } } } break; case TRIGGER_HOOK_MODIFIER: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_modifier ( argv[i], &trigger_callback_modifier_cb, trigger); } } } break; case TRIGGER_HOOK_PRINT: tags = NULL; message = NULL; strip_colors = 0; if (argv && (argc >= 1)) { if (strcmp (argv[0], "*") != 0) trigger->hook_print_buffers = strdup (argv[0]); if ((argc >= 2) && (strcmp (argv[1], "*") != 0)) tags = argv[1]; if ((argc >= 3) && (strcmp (argv[2], "*") != 0)) message = argv[2]; if (argc >= 4) strip_colors = (strcmp (argv[3], "0") != 0) ? 1 : 0; } trigger->hooks = malloc (sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = 1; trigger->hooks[0] = weechat_hook_print ( NULL, tags, message, strip_colors, &trigger_callback_print_cb, trigger); } break; case TRIGGER_HOOK_COMMAND: if (argv && (argc >= 1)) { trigger->hooks = malloc (sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = 1; trigger->hooks[0] = weechat_hook_command ( argv[0], /* command */ (argc > 1) ? argv[1] : "", /* description */ (argc > 2) ? argv[2] : "", /* arguments */ (argc > 3) ? argv[3] : "", /* description of args */ (argc > 4) ? argv[4] : "", /* completion */ &trigger_callback_command_cb, trigger); } } break; case TRIGGER_HOOK_COMMAND_RUN: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_command_run ( argv[i], &trigger_callback_command_run_cb, trigger); } } } break; case TRIGGER_HOOK_TIMER: if (argv && (argc >= 1)) { error1 = NULL; error2 = NULL; error3 = NULL; interval = strtol (argv[0], &error1, 10); align_second = strtol ((argc >= 2) ? argv[1] : "0", &error2, 10); max_calls = strtol ((argc >= 3) ? argv[2] : "0", &error3, 10); if (error1 && !error1[0] && error2 && !error2[0] && error3 && !error3[0] && (interval > 0) && (align_second >= 0) && (max_calls >= 0)) { trigger->hooks = malloc (sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = 1; trigger->hooks[0] = weechat_hook_timer ( interval, (int)align_second, (int)max_calls, &trigger_callback_timer_cb, trigger); } } } break; case TRIGGER_HOOK_CONFIG: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_config ( argv[i], &trigger_callback_config_cb, trigger); } } } break; case TRIGGER_HOOK_FOCUS: if (argv && (argc >= 1)) { trigger->hooks = malloc (argc * sizeof (trigger->hooks[0])); if (trigger->hooks) { trigger->hooks_count = argc; for (i = 0; i < argc; i++) { trigger->hooks[i] = weechat_hook_focus ( argv[i], &trigger_callback_focus_cb, trigger); } } } break; } if (!trigger->hooks) { weechat_printf (NULL, _("%s%s: unable to create hook for trigger \"%s\" " "(bad arguments)"), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, trigger->name); } if (argv) weechat_string_free_split (argv); if (argv_eol) weechat_string_free_split (argv_eol); }
int weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) { /* make C compiler happy */ (void) argc; (void) argv; weechat_plugin = plugin; if (!weechat_aspell_config_init ()) return WEECHAT_RC_ERROR; if (weechat_aspell_config_read () < 0) return WEECHAT_RC_ERROR; /* command /aspell */ weechat_hook_command ("aspell", N_("aspell plugin configuration"), N_("enable|disable|toggle" " || listdict" " || setdict <lang>" " || deldict" " || addword [<lang>] <word>"), N_(" enable: enable aspell\n" " disable: disable aspell\n" " toggle: toggle aspell\n" "listdict: show installed dictionaries\n" " setdict: set dictionary for current buffer\n" " deldict: delete dictionary used on current " "buffer\n" " addword: add a word in personal aspell " "dictionary\n" "\n" "Input line beginning with a '/' is not checked, " "except for some commands (see /set " "aspell.check.commands).\n\n" "To enable aspell on all buffers, use option " "\"default_dict\", then enable aspell, for " "example:\n" " /set aspell.check.default_dict \"en\"\n" " /aspell enable\n\n" "Default key to toggle aspell is alt-s."), "enable" " || disable" " || toggle" " || listdict" " || setdict %(aspell_langs)" " || deldict" " || addword", &weechat_aspell_command_cb, NULL); weechat_hook_completion ("aspell_langs", N_("list of supported langs for aspell"), &weechat_aspell_completion_langs_cb, NULL); /* * callback for spell checking input text * we use a low priority here, so that other modifiers "input_text_display" * (from other plugins) will be called before this one */ weechat_hook_modifier ("500|input_text_display", &weechat_aspell_modifier_cb, NULL); return WEECHAT_RC_OK; }