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:
commit
ddba68ad77
@ -438,41 +438,66 @@ static void cmd_foreach(const char *data, SERVER_REC *server,
|
|||||||
/* SYNTAX: FOREACH SERVER <command> */
|
/* SYNTAX: FOREACH SERVER <command> */
|
||||||
static void cmd_foreach_server(const char *data, SERVER_REC *server)
|
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);
|
list = g_slist_copy(servers);
|
||||||
while (list != NULL) {
|
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);
|
list = g_slist_remove(list, list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: FOREACH CHANNEL <command> */
|
/* SYNTAX: FOREACH CHANNEL <command> */
|
||||||
static void cmd_foreach_channel(const char *data)
|
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);
|
list = g_slist_copy(channels);
|
||||||
while (list != NULL) {
|
while (list != NULL) {
|
||||||
CHANNEL_REC *rec = list->data;
|
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);
|
list = g_slist_remove(list, list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SYNTAX: FOREACH QUERY <command> */
|
/* SYNTAX: FOREACH QUERY <command> */
|
||||||
static void cmd_foreach_query(const char *data)
|
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);
|
list = g_slist_copy(queries);
|
||||||
while (list != NULL) {
|
while (list != NULL) {
|
||||||
QUERY_REC *rec = list->data;
|
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);
|
list = g_slist_remove(list, list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void chat_commands_init(void)
|
void chat_commands_init(void)
|
||||||
|
@ -839,23 +839,31 @@ static void cmd_layout(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
|||||||
/* SYNTAX: FOREACH WINDOW <command> */
|
/* SYNTAX: FOREACH WINDOW <command> */
|
||||||
static void cmd_foreach_window(const char *data)
|
static void cmd_foreach_window(const char *data)
|
||||||
{
|
{
|
||||||
WINDOW_REC *old;
|
WINDOW_REC *old;
|
||||||
GSList *list;
|
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);
|
list = g_slist_copy(windows);
|
||||||
while (list != NULL) {
|
while (list != NULL) {
|
||||||
WINDOW_REC *rec = list->data;
|
WINDOW_REC *rec = list->data;
|
||||||
|
|
||||||
active_win = rec;
|
active_win = rec;
|
||||||
signal_emit("send command", 3, data, rec->active_server,
|
signal_emit("send command", 3, str, rec->active_server,
|
||||||
rec->active);
|
rec->active);
|
||||||
list = g_slist_remove(list, list->data);
|
list = g_slist_remove(list, list->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_slist_find(windows, old) != NULL)
|
if (g_slist_find(windows, old) != NULL)
|
||||||
active_win = old;
|
active_win = old;
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_commands_init(void)
|
void window_commands_init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user