1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Merge pull request #659 from ailin-nemui/foreach_dontspam

make foreach send commands
This commit is contained in:
ailin-nemui 2017-03-07 23:37:23 +01:00 committed by GitHub
commit ddba68ad77
2 changed files with 47 additions and 14 deletions

View File

@ -438,41 +438,66 @@ static void cmd_foreach(const char *data, SERVER_REC *server,
/* SYNTAX: FOREACH SERVER <command> */
static void cmd_foreach_server(const char *data, SERVER_REC *server)
{
GSList *list;
GSList *list;
const char *cmdchars;
char *str;
cmdchars = settings_get_str("cmdchars");
str = strchr(cmdchars, *data) != NULL ? g_strdup(data) :
g_strdup_printf("%c%s", *cmdchars, data);
list = g_slist_copy(servers);
while (list != NULL) {
signal_emit("send command", 3, data, list->data, NULL);
list = g_slist_remove(list, list->data);
signal_emit("send command", 3, str, list->data, NULL);
list = g_slist_remove(list, list->data);
}
g_free(str);
}
/* SYNTAX: FOREACH CHANNEL <command> */
static void cmd_foreach_channel(const char *data)
{
GSList *list;
GSList *list;
const char *cmdchars;
char *str;
cmdchars = settings_get_str("cmdchars");
str = strchr(cmdchars, *data) != NULL ? g_strdup(data) :
g_strdup_printf("%c%s", *cmdchars, data);
list = g_slist_copy(channels);
while (list != NULL) {
CHANNEL_REC *rec = list->data;
signal_emit("send command", 3, data, rec->server, rec);
list = g_slist_remove(list, list->data);
signal_emit("send command", 3, str, rec->server, rec);
list = g_slist_remove(list, list->data);
}
g_free(str);
}
/* SYNTAX: FOREACH QUERY <command> */
static void cmd_foreach_query(const char *data)
{
GSList *list;
GSList *list;
const char *cmdchars;
char *str;
cmdchars = settings_get_str("cmdchars");
str = strchr(cmdchars, *data) != NULL ? g_strdup(data) :
g_strdup_printf("%c%s", *cmdchars, data);
list = g_slist_copy(queries);
while (list != NULL) {
QUERY_REC *rec = list->data;
signal_emit("send command", 3, data, rec->server, rec);
list = g_slist_remove(list, list->data);
signal_emit("send command", 3, str, rec->server, rec);
list = g_slist_remove(list, list->data);
}
g_free(str);
}
void chat_commands_init(void)

View File

@ -839,23 +839,31 @@ static void cmd_layout(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
/* SYNTAX: FOREACH WINDOW <command> */
static void cmd_foreach_window(const char *data)
{
WINDOW_REC *old;
GSList *list;
WINDOW_REC *old;
GSList *list;
const char *cmdchars;
char *str;
old = active_win;
cmdchars = settings_get_str("cmdchars");
str = strchr(cmdchars, *data) != NULL ? g_strdup(data) :
g_strdup_printf("%c%s", *cmdchars, data);
old = active_win;
list = g_slist_copy(windows);
while (list != NULL) {
WINDOW_REC *rec = list->data;
active_win = rec;
signal_emit("send command", 3, data, rec->active_server,
signal_emit("send command", 3, str, rec->active_server,
rec->active);
list = g_slist_remove(list, list->data);
list = g_slist_remove(list, list->data);
}
if (g_slist_find(windows, old) != NULL)
active_win = old;
g_free(str);
}
void window_commands_init(void)