1
0
mirror of https://github.com/irssi/irssi.git synced 2025-01-03 14:56:47 -05:00

make foreach send commands

This commit is contained in:
ailin-nemui 2017-02-27 13:43:58 +01:00
parent 540639e0fa
commit 9aaa6449a0
2 changed files with 47 additions and 14 deletions

View File

@ -439,40 +439,65 @@ static void cmd_foreach(const char *data, SERVER_REC *server,
static void cmd_foreach_server(const char *data, SERVER_REC *server)
{
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);
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;
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);
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;
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);
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

@ -841,6 +841,12 @@ static void cmd_foreach_window(const char *data)
{
WINDOW_REC *old;
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);
old = active_win;
@ -849,13 +855,15 @@ static void cmd_foreach_window(const char *data)
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);
}
if (g_slist_find(windows, old) != NULL)
active_win = old;
g_free(str);
}
void window_commands_init(void)