示例#1
0
void
script_config_reload_scripts_cb (void *data, struct t_config_option *option)
{
    /* make C compiler happy */
    (void) data;
    (void) option;

    if (scripts_repo)
    {
        script_repo_remove_all ();
        script_repo_file_read (1);
        script_buffer_refresh (1);
    }
}
示例#2
0
int
script_buffer_input_cb (void *data, struct t_gui_buffer *buffer,
                        const char *input_data)
{
    char *actions[][2] = { { "A", "toggleautoload" },
                           { "l", "load"           },
                           { "u", "unload"         },
                           { "L", "reload"         },
                           { "i", "install"        },
                           { "r", "remove"         },
                           { "h", "hold"           },
                           { "v", "show"           },
                           { "d", "showdiff"       },
                           { NULL, NULL            } };
    char str_command[64];
    int i;

    /* make C compiler happy */
    (void) data;

    /* close buffer */
    if (strcmp (input_data, "q") == 0)
    {
        weechat_buffer_close (buffer);
        return WEECHAT_RC_OK;
    }

    if (!script_buffer_detail_script)
    {
        /* change sort keys on buffer */
        if (strncmp (input_data, "s:", 2) == 0)
        {
            if (input_data[2])
                weechat_config_option_set (script_config_look_sort, input_data + 2, 1);
            else
                weechat_config_option_reset (script_config_look_sort, 1);
            return WEECHAT_RC_OK;
        }

        /* refresh buffer */
        if (strcmp (input_data, "$") == 0)
        {
            script_get_loaded_plugins_and_scripts ();
            script_repo_remove_all ();
            script_repo_file_read (1);
            script_buffer_refresh (1);
            return WEECHAT_RC_OK;
        }
    }

    /* execute action on a script */
    for (i = 0; actions[i][0]; i++)
    {
        if (strcmp (input_data, actions[i][0]) == 0)
        {
            snprintf (str_command, sizeof (str_command),
                      "/script %s", actions[i][1]);
            weechat_command (buffer, str_command);
            return WEECHAT_RC_OK;
        }
    }

    /* filter scripts with given text */
    if (!script_buffer_detail_script)
        script_repo_filter_scripts (input_data);

    return WEECHAT_RC_OK;
}