mirror of
https://github.com/irssi/irssi.git
synced 2026-08-13 05:32:11 +02:00
.. lots of changes ..
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@197 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
bacfcb060c
commit
d3dc9a1307
106 changed files with 4864 additions and 1597 deletions
|
|
@ -17,7 +17,7 @@ libfe_common_core_la_SOURCES = \
|
|||
hilight-text.c \
|
||||
keyboard.c \
|
||||
module-formats.c \
|
||||
nick-hilight.c \
|
||||
window-activity.c \
|
||||
printtext.c \
|
||||
themes.c \
|
||||
translation.c \
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ static void sig_autorun(void)
|
|||
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
||||
|
||||
ret = line_split(tmpbuf, recvlen, &str, &buffer);
|
||||
eval_special_string(str, "", active_win->active_server, active_win->active);
|
||||
if (ret > 0) eval_special_string(str, "", active_win->active_server, active_win->active);
|
||||
} while (ret > 0);
|
||||
line_split_free(buffer);
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ static char *special_history_func(const char *text, void *item, int *free_ret)
|
|||
|
||||
static void read_settings(void)
|
||||
{
|
||||
window_history = settings_get_bool("toggle_window_history");
|
||||
window_history = settings_get_bool("window_history");
|
||||
}
|
||||
|
||||
void command_history_init(void)
|
||||
|
|
@ -159,7 +159,7 @@ void command_history_init(void)
|
|||
settings_add_int("history", "max_textwidget_lines", 1000);
|
||||
settings_add_int("history", "block_remove_lines", 20);
|
||||
settings_add_int("history", "max_command_history", 100);
|
||||
settings_add_bool("history", "toggle_window_history", FALSE);
|
||||
settings_add_bool("history", "window_history", FALSE);
|
||||
|
||||
special_history_func_set(special_history_func);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,37 +47,34 @@ void fe_server_deinit(void);
|
|||
void fe_settings_init(void);
|
||||
void fe_settings_deinit(void);
|
||||
|
||||
void nick_hilight_init(void);
|
||||
void nick_hilight_deinit(void);
|
||||
void window_activity_init(void);
|
||||
void window_activity_deinit(void);
|
||||
|
||||
void fe_core_commands_init(void);
|
||||
void fe_core_commands_deinit(void);
|
||||
|
||||
void fe_common_core_init(void)
|
||||
{
|
||||
settings_add_bool("lookandfeel", "toggle_show_menubar", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_toolbar", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_statusbar", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_nicklist", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_timestamps", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_msgs_timestamps", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_hide_text_style", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_bell_beeps", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_actlist_moves", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_nickmode", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_show_topicbar", TRUE);
|
||||
/*settings_add_bool("lookandfeel", "show_menubar", TRUE);
|
||||
settings_add_bool("lookandfeel", "show_toolbar", FALSE);
|
||||
settings_add_bool("lookandfeel", "show_statusbar", TRUE);
|
||||
settings_add_bool("lookandfeel", "show_nicklist", TRUE);*/
|
||||
settings_add_bool("lookandfeel", "timestamps", TRUE);
|
||||
settings_add_bool("lookandfeel", "msgs_timestamps", FALSE);
|
||||
settings_add_bool("lookandfeel", "hide_text_style", FALSE);
|
||||
settings_add_bool("lookandfeel", "bell_beeps", FALSE);
|
||||
settings_add_bool("lookandfeel", "show_nickmode", TRUE);
|
||||
|
||||
settings_add_bool("lookandfeel", "toggle_use_status_window", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_use_msgs_window", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_autoraise_msgs_window", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_autocreate_query", TRUE);
|
||||
settings_add_bool("lookandfeel", "toggle_notifylist_popups", FALSE);
|
||||
settings_add_bool("lookandfeel", "toggle_use_tabbed_windows", TRUE);
|
||||
settings_add_int("lookandfeel", "tab_orientation", 3);
|
||||
settings_add_bool("lookandfeel", "use_status_window", FALSE);
|
||||
settings_add_bool("lookandfeel", "use_msgs_window", TRUE);
|
||||
/*settings_add_bool("lookandfeel", "autoraise_msgs_window", FALSE);*/
|
||||
settings_add_bool("lookandfeel", "autocreate_query", TRUE);
|
||||
/*settings_add_bool("lookandfeel", "use_tabbed_windows", TRUE);
|
||||
settings_add_int("lookandfeel", "tab_orientation", 3);*/
|
||||
settings_add_str("lookandfeel", "current_theme", "default");
|
||||
|
||||
autorun_init();
|
||||
nick_hilight_init();
|
||||
window_activity_init();
|
||||
hilight_text_init();
|
||||
command_history_init();
|
||||
keyboard_init();
|
||||
|
|
@ -95,7 +92,7 @@ void fe_common_core_init(void)
|
|||
void fe_common_core_deinit(void)
|
||||
{
|
||||
autorun_deinit();
|
||||
nick_hilight_deinit();
|
||||
window_activity_deinit();
|
||||
hilight_text_deinit();
|
||||
command_history_deinit();
|
||||
keyboard_deinit();
|
||||
|
|
@ -116,13 +113,15 @@ void fe_common_core_finish_init(void)
|
|||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (settings_get_bool("toggle_use_status_window")) {
|
||||
if (settings_get_bool("use_status_window")) {
|
||||
window = window_create(NULL, TRUE);
|
||||
window_set_name(window, "(status)");
|
||||
window_set_level(window, MSGLEVEL_ALL ^ (settings_get_bool("toggle_use_msgs_window") ? (MSGLEVEL_MSGS|MSGLEVEL_ACTIONS) : 0));
|
||||
window_set_level(window, MSGLEVEL_ALL ^
|
||||
(settings_get_bool("use_msgs_window") ?
|
||||
(MSGLEVEL_MSGS|MSGLEVEL_ACTIONS) : 0));
|
||||
}
|
||||
|
||||
if (settings_get_bool("toggle_use_msgs_window")) {
|
||||
if (settings_get_bool("use_msgs_window")) {
|
||||
window = window_create(NULL, TRUE);
|
||||
window_set_name(window, "(msgs)");
|
||||
window_set_level(window, MSGLEVEL_MSGS|MSGLEVEL_ACTIONS);
|
||||
|
|
|
|||
|
|
@ -23,35 +23,35 @@
|
|||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "levels.h"
|
||||
#include "misc.h"
|
||||
#include "line-split.h"
|
||||
#include "irssi-version.h"
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
static gchar *ret_texts[] =
|
||||
{
|
||||
"Invalid parameter",
|
||||
"Not enough parameters given",
|
||||
"Not connected to IRC server yet",
|
||||
"Not joined to any channels yet",
|
||||
"Error: getsockname() failed",
|
||||
"Error: listen() failed",
|
||||
"Multiple matches found, be more specific",
|
||||
"Nick not found",
|
||||
"Not joined to such channel",
|
||||
"Server not found",
|
||||
"Channel not fully synchronized yet, try again after a while",
|
||||
"Doing this is not a good idea. Add -YES if you really mean it",
|
||||
static const char *ret_texts[] = {
|
||||
"Invalid parameter",
|
||||
"Not enough parameters given",
|
||||
"Not connected to IRC server yet",
|
||||
"Not joined to any channels yet",
|
||||
"Error: getsockname() failed",
|
||||
"Error: listen() failed",
|
||||
"Multiple matches found, be more specific",
|
||||
"Nick not found",
|
||||
"Not joined to such channel",
|
||||
"Server not found",
|
||||
"Channel not fully synchronized yet, try again after a while",
|
||||
"Doing this is not a good idea. Add -YES if you really mean it",
|
||||
};
|
||||
|
||||
static gint commands_compare(COMMAND_REC *rec, COMMAND_REC *rec2)
|
||||
static int commands_compare(COMMAND_REC *rec, COMMAND_REC *rec2)
|
||||
{
|
||||
if (rec->category == NULL && rec2->category != NULL)
|
||||
return -1;
|
||||
if (rec2->category == NULL && rec->category != NULL)
|
||||
return 1;
|
||||
if (rec->category == NULL && rec2->category != NULL)
|
||||
return -1;
|
||||
if (rec2->category == NULL && rec->category != NULL)
|
||||
return 1;
|
||||
|
||||
return strcmp(rec->cmd, rec2->cmd);
|
||||
return strcmp(rec->cmd, rec2->cmd);
|
||||
}
|
||||
|
||||
static void help_category(GSList *cmdlist, gint items, gint max)
|
||||
|
|
@ -118,7 +118,7 @@ static int show_help(COMMAND_REC *cmd)
|
|||
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
||||
|
||||
ret = line_split(tmpbuf, recvlen, &str, &buffer);
|
||||
printtext(NULL, NULL, MSGLEVEL_NEVER, str);
|
||||
if (ret > 0) printtext(NULL, NULL, MSGLEVEL_NEVER, str);
|
||||
}
|
||||
while (ret > 0);
|
||||
line_split_free(buffer);
|
||||
|
|
@ -227,6 +227,37 @@ static void cmd_version(char *data)
|
|||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE, "Client: "PACKAGE" " IRSSI_VERSION);
|
||||
}
|
||||
|
||||
static void cmd_cat(const char *data)
|
||||
{
|
||||
char tmpbuf[1024], *str, *fname;
|
||||
LINEBUF_REC *buffer = NULL;
|
||||
int f, ret, recvlen;
|
||||
|
||||
fname = convert_home(data);
|
||||
f = open(fname, O_RDONLY);
|
||||
g_free(fname);
|
||||
if (f == -1) {
|
||||
/* file not found */
|
||||
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "%s", g_strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
||||
|
||||
ret = line_split(tmpbuf, recvlen, &str, &buffer);
|
||||
if (ret > 0) printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "%s", str);
|
||||
} while (ret > 0);
|
||||
line_split_free(buffer);
|
||||
|
||||
close(f);
|
||||
}
|
||||
|
||||
static void cmd_beep(void)
|
||||
{
|
||||
printbeep();
|
||||
}
|
||||
|
||||
static void cmd_unknown(const char *data, void *server, WI_ITEM_REC *item)
|
||||
{
|
||||
char *cmd;
|
||||
|
|
@ -248,6 +279,8 @@ void fe_core_commands_init(void)
|
|||
command_bind("help", NULL, (SIGNAL_FUNC) cmd_help);
|
||||
command_bind("echo", NULL, (SIGNAL_FUNC) cmd_echo);
|
||||
command_bind("version", NULL, (SIGNAL_FUNC) cmd_version);
|
||||
command_bind("cat", NULL, (SIGNAL_FUNC) cmd_cat);
|
||||
command_bind("beep", NULL, (SIGNAL_FUNC) cmd_beep);
|
||||
|
||||
signal_add("unknown command", (SIGNAL_FUNC) cmd_unknown);
|
||||
signal_add("default command", (SIGNAL_FUNC) cmd_unknown);
|
||||
|
|
@ -259,6 +292,8 @@ void fe_core_commands_deinit(void)
|
|||
command_unbind("help", (SIGNAL_FUNC) cmd_help);
|
||||
command_unbind("echo", (SIGNAL_FUNC) cmd_echo);
|
||||
command_unbind("version", (SIGNAL_FUNC) cmd_version);
|
||||
command_unbind("cat", (SIGNAL_FUNC) cmd_cat);
|
||||
command_unbind("beep", (SIGNAL_FUNC) cmd_beep);
|
||||
|
||||
signal_remove("unknown command", (SIGNAL_FUNC) cmd_unknown);
|
||||
signal_remove("default command", (SIGNAL_FUNC) cmd_unknown);
|
||||
|
|
|
|||
|
|
@ -43,16 +43,16 @@ static const char *autolog_path;
|
|||
|
||||
static void cmd_log_open(const char *data)
|
||||
{
|
||||
/* /LOG OPEN [-noopen] [-autoopen] [-channels <channels>] [-window]
|
||||
/* /LOG OPEN [-noopen] [-autoopen] [-targets <targets>] [-window]
|
||||
[-rotate hour|day|week|month] <fname> [<levels>] */
|
||||
char *params, *args, *itemarg, *rotatearg, *fname, *levels;
|
||||
char *params, *args, *targetarg, *rotatearg, *fname, *levels;
|
||||
char window[MAX_INT_STRLEN];
|
||||
LOG_REC *log;
|
||||
int opened, level, rotate;
|
||||
|
||||
args = "channels rotate";
|
||||
args = "targets rotate";
|
||||
params = cmd_get_params(data, 5 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST,
|
||||
&args, &itemarg, &rotatearg, &fname, &levels);
|
||||
&args, &targetarg, &rotatearg, &fname, &levels);
|
||||
if (*fname == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||
|
||||
rotate = LOG_ROTATE_NEVER;
|
||||
|
|
@ -67,10 +67,10 @@ static void cmd_log_open(const char *data)
|
|||
if (stristr(args, "-window")) {
|
||||
/* log by window ref# */
|
||||
ltoa(window, active_win->refnum);
|
||||
itemarg = window;
|
||||
targetarg = window;
|
||||
}
|
||||
|
||||
log = log_create_rec(fname, level, itemarg);
|
||||
log = log_create_rec(fname, level, targetarg);
|
||||
if (log != NULL && log->handle == -1 && stristr(args, "-noopen") == NULL) {
|
||||
/* start logging */
|
||||
opened = log_start_logging(log);
|
||||
|
|
@ -193,7 +193,7 @@ static void cmd_window_log(const char *data)
|
|||
open_log = log == NULL;
|
||||
close_log = log != NULL;
|
||||
} else {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NOT_TOGGLE);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_NOT_TOGGLE);
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
|
|
@ -230,17 +230,34 @@ static void cmd_window_logfile(const char *data)
|
|||
log = log_find_item(window);
|
||||
|
||||
if (log != NULL) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_WINDOWLOG_FILE_LOGGING);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_WINDOWLOG_FILE_LOGGING);
|
||||
return;
|
||||
}
|
||||
|
||||
log = log_create_rec(data, MSGLEVEL_ALL, window);
|
||||
if (log == NULL)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_WINDOWLOG_FILE, data);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_WINDOWLOG_FILE, data);
|
||||
else
|
||||
log_update(log);
|
||||
}
|
||||
|
||||
/* window's refnum changed - update the logs to log the new window refnum */
|
||||
static void sig_window_refnum_changed(WINDOW_REC *window, gpointer old_refnum)
|
||||
{
|
||||
char winnum[MAX_INT_STRLEN];
|
||||
LOG_REC *log;
|
||||
|
||||
ltoa(winnum, GPOINTER_TO_INT(old_refnum));
|
||||
log = log_find_item(winnum);
|
||||
|
||||
if (log != NULL) {
|
||||
ltoa(winnum, window->refnum);
|
||||
|
||||
g_strfreev(log->items);
|
||||
log->items = g_strsplit(winnum, " ", -1);
|
||||
}
|
||||
}
|
||||
|
||||
static void autologs_close_all(void)
|
||||
{
|
||||
GSList *tmp, *next;
|
||||
|
|
@ -379,6 +396,7 @@ void fe_log_init(void)
|
|||
command_bind("window logfile", NULL, (SIGNAL_FUNC) cmd_window_logfile);
|
||||
signal_add_first("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped);
|
||||
signal_add("window item remove", (SIGNAL_FUNC) sig_window_item_remove);
|
||||
signal_add("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
|
||||
signal_add("log locked", (SIGNAL_FUNC) sig_log_locked);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
|
@ -397,6 +415,7 @@ void fe_log_deinit(void)
|
|||
command_unbind("window logfile", (SIGNAL_FUNC) cmd_window_logfile);
|
||||
signal_remove("print text stripped", (SIGNAL_FUNC) sig_printtext_stripped);
|
||||
signal_remove("window item remove", (SIGNAL_FUNC) sig_window_item_remove);
|
||||
signal_remove("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
|
||||
signal_remove("log locked", (SIGNAL_FUNC) sig_log_locked);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ static void sig_server_disconnected(SERVER_REC *server)
|
|||
IRCTXT_CONNECTION_LOST, server->connrec->address);
|
||||
}
|
||||
|
||||
static void sig_server_quit(SERVER_REC *server, const char *msg)
|
||||
{
|
||||
g_return_if_fail(server != NULL);
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||
IRCTXT_SERVER_QUIT, server->connrec->address, msg);
|
||||
}
|
||||
|
||||
void fe_server_init(void)
|
||||
{
|
||||
signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
|
||||
|
|
@ -84,6 +92,7 @@ void fe_server_init(void)
|
|||
signal_add("server connected", (SIGNAL_FUNC) sig_server_connected);
|
||||
signal_add("server connect failed", (SIGNAL_FUNC) sig_connect_failed);
|
||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_add("server quit", (SIGNAL_FUNC) sig_server_quit);
|
||||
}
|
||||
|
||||
void fe_server_deinit(void)
|
||||
|
|
@ -93,4 +102,5 @@ void fe_server_deinit(void)
|
|||
signal_remove("server connected", (SIGNAL_FUNC) sig_server_connected);
|
||||
signal_remove("server connect failed", (SIGNAL_FUNC) sig_connect_failed);
|
||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_remove("server quit", (SIGNAL_FUNC) sig_server_quit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "server.h"
|
||||
#include "misc.h"
|
||||
#include "lib-config/iconfig.h"
|
||||
#include "settings.h"
|
||||
|
||||
|
|
@ -66,19 +67,17 @@ static void cmd_set(char *data)
|
|||
{
|
||||
GSList *sets, *tmp;
|
||||
char *params, *key, *value, *last_section;
|
||||
int keylen, found;
|
||||
int found;
|
||||
|
||||
params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &key, &value);
|
||||
|
||||
keylen = strlen(key);
|
||||
last_section = ""; found = 0;
|
||||
|
||||
sets = settings_get_sorted();
|
||||
for (tmp = sets; tmp != NULL; tmp = tmp->next) {
|
||||
SETTINGS_REC *rec = tmp->data;
|
||||
|
||||
if ((*value != '\0' && g_strcasecmp(rec->key, key) != 0) ||
|
||||
(*value == '\0' && keylen != 0 && g_strncasecmp(rec->key, key, keylen) != 0))
|
||||
(*value == '\0' && *key != '\0' && stristr(rec->key, key) == NULL))
|
||||
continue;
|
||||
|
||||
if (strcmp(last_section, rec->section) != 0) {
|
||||
|
|
@ -140,7 +139,7 @@ static void show_aliases(const char *alias)
|
|||
GSList *tmp;
|
||||
int aliaslen;
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_ALIASLIST_HEADER);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_ALIASLIST_HEADER);
|
||||
|
||||
node = iconfig_node_traverse("aliases", FALSE);
|
||||
tmp = node == NULL ? NULL : node->value;
|
||||
|
|
@ -155,11 +154,11 @@ static void show_aliases(const char *alias)
|
|||
if (aliaslen != 0 && g_strncasecmp(node->key, alias, aliaslen) != 0)
|
||||
continue;
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_ALIASLIST_LINE,
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_ALIASLIST_LINE,
|
||||
node->key, node->value);
|
||||
}
|
||||
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_ALIASLIST_FOOTER);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_ALIASLIST_FOOTER);
|
||||
}
|
||||
|
||||
static void alias_remove(const char *alias)
|
||||
|
|
|
|||
|
|
@ -314,7 +314,7 @@ static void cmd_dehilight(const char *data)
|
|||
|
||||
if (is_numeric(data, ' ')) {
|
||||
/* with index number */
|
||||
tmp = g_slist_nth(hilights, atol(data)-1);
|
||||
tmp = g_slist_nth(hilights, atoi(data)-1);
|
||||
rec = tmp == NULL ? NULL : tmp->data;
|
||||
} else {
|
||||
/* with mask */
|
||||
|
|
|
|||
|
|
@ -31,8 +31,13 @@ FORMAT_REC fecommon_core_formats[] =
|
|||
{ "line_start", "%B-%W!%B-%n ", 0 },
|
||||
{ "line_start_irssi", "%B-%W!%B- %WIrssi:%n ", 0 },
|
||||
{ "timestamp", "[$[-2.0]3:$[-2.0]4] ", 6, { 1, 1, 1, 1, 1, 1 } },
|
||||
{ "daychange", "Day changed to $[-2.0]1-$[-2.0]0 $2", 3, { 1, 1, 1 } },
|
||||
{ "daychange", "Day changed to ${[-2.0]1}-$[-2.0]0 $2", 3, { 1, 1, 1 } },
|
||||
{ "talking_with", "You are now talking with %_$0%_", 1, { 0 } },
|
||||
{ "refnum_too_low", "Window number must be greater than 1", 0 },
|
||||
{ "refnum_not_found", "No such window: $0", 1, { 0 } },
|
||||
{ "windowlist_header", "Ref Name Active item Server Level", 0 },
|
||||
{ "windowlist_line", "$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } },
|
||||
{ "windowlist_footer", "", 0 },
|
||||
|
||||
/* ---- */
|
||||
{ NULL, "Server", 0 },
|
||||
|
|
@ -42,6 +47,7 @@ FORMAT_REC fecommon_core_formats[] =
|
|||
{ "connection_established", "Connection to %_$0%_ established", 1, { 0 } },
|
||||
{ "cant_connect", "Unable to connect server %_$0%_ port %_$1%_ %K[%n$2%K]", 3, { 0, 1, 0 } },
|
||||
{ "connection_lost", "Connection lost to %_$0%_", 1, { 0 } },
|
||||
{ "server_quit", "Disconnecting from server $0: %K[%n$1%K]", 2, { 0, 0 } },
|
||||
{ "server_changed", "Changed to %_$2%_ server %_$1%_", 3, { 0, 0, 0 } },
|
||||
{ "unknown_server_tag", "Unknown server tag %_$0%_", 1, { 0 } },
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ enum {
|
|||
IRCTXT_TIMESTAMP,
|
||||
IRCTXT_DAYCHANGE,
|
||||
IRCTXT_TALKING_WITH,
|
||||
IRCTXT_REFNUM_TOO_LOW,
|
||||
IRCTXT_REFNUM_NOT_FOUND,
|
||||
IRCTXT_WINDOWLIST_HEADER,
|
||||
IRCTXT_WINDOWLIST_LINE,
|
||||
IRCTXT_WINDOWLIST_FOOTER,
|
||||
|
||||
IRCTXT_FILL_2,
|
||||
|
||||
|
|
@ -18,6 +23,7 @@ enum {
|
|||
IRCTXT_CONNECTION_ESTABLISHED,
|
||||
IRCTXT_CANT_CONNECT,
|
||||
IRCTXT_CONNECTION_LOST,
|
||||
IRCTXT_SERVER_QUIT,
|
||||
IRCTXT_SERVER_CHANGED,
|
||||
IRCTXT_UNKNOWN_SERVER_TAG,
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
printtext.c : irssi
|
||||
|
||||
Copyright (C) 1999 Timo Sirainen
|
||||
Copyright (C) 1999-2000 Timo Sirainen
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#include "themes.h"
|
||||
#include "windows.h"
|
||||
|
||||
static gboolean toggle_show_timestamps, toggle_show_msgs_timestamps, toggle_hide_text_style;
|
||||
static gboolean timestamps, msgs_timestamps, hide_text_style;
|
||||
static gint printtag;
|
||||
static gchar ansitab[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ static char *convert_ansi(char *str, int *fgcolor, int *bgcolor, int *flags)
|
|||
|
||||
if (*str == 'm')
|
||||
{
|
||||
if (!toggle_hide_text_style)
|
||||
if (!hide_text_style)
|
||||
{
|
||||
*fgcolor = fg;
|
||||
*bgcolor = bg == -1 ? -1 : bg;
|
||||
|
|
@ -410,7 +410,7 @@ static void add_timestamp(WINDOW_REC *window, GString *out, void *server, const
|
|||
struct tm *tm;
|
||||
GString *tmp;
|
||||
|
||||
if (!(level != MSGLEVEL_NEVER && (toggle_show_timestamps || (toggle_show_msgs_timestamps && (level & MSGLEVEL_MSGS) != 0))))
|
||||
if (!(level != MSGLEVEL_NEVER && (timestamps || (msgs_timestamps && (level & MSGLEVEL_MSGS) != 0))))
|
||||
return;
|
||||
|
||||
t = time(NULL);
|
||||
|
|
@ -574,6 +574,7 @@ static void sig_print_text(void *server, const char *target, gpointer level, con
|
|||
|
||||
flags = 0; fgcolor = -1; bgcolor = -1; type = '\0';
|
||||
|
||||
window->last_line = time(NULL);
|
||||
newline(window);
|
||||
|
||||
out = g_string_new(text);
|
||||
|
|
@ -612,7 +613,7 @@ static void sig_print_text(void *server, const char *target, gpointer level, con
|
|||
if (type == 7)
|
||||
{
|
||||
/* bell */
|
||||
if (settings_get_bool("toggle_bell_beeps"))
|
||||
if (settings_get_bool("bell_beeps"))
|
||||
flags |= PRINTFLAG_BEEP;
|
||||
}
|
||||
if (*str != '\0' || flags & PRINTFLAG_BEEP)
|
||||
|
|
@ -628,12 +629,12 @@ static void sig_print_text(void *server, const char *target, gpointer level, con
|
|||
{
|
||||
case 2:
|
||||
/* bold */
|
||||
if (!toggle_hide_text_style)
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case 6:
|
||||
/* blink */
|
||||
if (!toggle_hide_text_style)
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BLINK;
|
||||
break;
|
||||
case 15:
|
||||
|
|
@ -643,12 +644,12 @@ static void sig_print_text(void *server, const char *target, gpointer level, con
|
|||
break;
|
||||
case 22:
|
||||
/* reverse */
|
||||
if (!toggle_hide_text_style)
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_REVERSE;
|
||||
break;
|
||||
case 31:
|
||||
/* underline */
|
||||
if (!toggle_hide_text_style)
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_UNDERLINE;
|
||||
case 27:
|
||||
/* ansi color code */
|
||||
|
|
@ -711,7 +712,7 @@ static void sig_print_text(void *server, const char *target, gpointer level, con
|
|||
}
|
||||
|
||||
/* MIRC color */
|
||||
if (toggle_hide_text_style)
|
||||
if (hide_text_style)
|
||||
{
|
||||
/* don't show them. */
|
||||
if (isdigit((gint) *ptr))
|
||||
|
|
@ -776,7 +777,7 @@ static int sig_check_daychange(void)
|
|||
time_t t;
|
||||
struct tm *tm;
|
||||
|
||||
if (!toggle_show_timestamps)
|
||||
if (!timestamps)
|
||||
{
|
||||
/* display day change notice only when using timestamps */
|
||||
return TRUE;
|
||||
|
|
@ -800,6 +801,9 @@ static int sig_check_daychange(void)
|
|||
{
|
||||
WINDOW_REC *win = tmp->data;
|
||||
|
||||
if (win->active == NULL)
|
||||
continue; /* FIXME: how to print in these windows? */
|
||||
|
||||
printformat(win->active->server, win->active->name, MSGLEVEL_NEVER,
|
||||
IRCTXT_DAYCHANGE, tm->tm_mday, tm->tm_mon+1, 1900+tm->tm_year);
|
||||
}
|
||||
|
|
@ -833,9 +837,9 @@ static void sig_gui_dialog(const char *type, const char *text)
|
|||
|
||||
static void read_settings(void)
|
||||
{
|
||||
toggle_show_timestamps = settings_get_bool("toggle_show_timestamps");
|
||||
toggle_show_msgs_timestamps = settings_get_bool("toggle_show_msgs_timestamps");
|
||||
toggle_hide_text_style = settings_get_bool("toggle_hide_text_style");
|
||||
timestamps = settings_get_bool("timestamps");
|
||||
msgs_timestamps = settings_get_bool("msgs_timestamps");
|
||||
hide_text_style = settings_get_bool("hide_text_style");
|
||||
}
|
||||
|
||||
void printtext_init(void)
|
||||
|
|
@ -852,7 +856,6 @@ void printtext_init(void)
|
|||
signal_add("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_add("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
|
||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
command_bind("beep", NULL, (SIGNAL_FUNC) printbeep);
|
||||
}
|
||||
|
||||
void printtext_deinit(void)
|
||||
|
|
@ -861,5 +864,4 @@ void printtext_deinit(void)
|
|||
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
||||
signal_remove("gui dialog", (SIGNAL_FUNC) sig_gui_dialog);
|
||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||
command_unbind("beep", (SIGNAL_FUNC) printbeep);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ void printtext(void *server, const char *channel, int level, const char *str, ..
|
|||
void printtext_multiline(void *server, const char *channel, int level, const char *format, const char *text);
|
||||
void printbeep(void);
|
||||
|
||||
/* strip all color (etc.) codes from `input'. returns newly allocated string. */
|
||||
char *strip_codes(const char *input);
|
||||
|
||||
void printtext_init(void);
|
||||
void printtext_deinit(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
nick-hilight.c : irssi
|
||||
window-activity.c : irssi
|
||||
|
||||
Copyright (C) 1999-2000 Timo Sirainen
|
||||
|
||||
|
|
@ -57,6 +57,7 @@ static void sig_dehilight(WINDOW_REC *window, WI_ITEM_REC *item)
|
|||
|
||||
static void sig_dehilight_window(WINDOW_REC *window)
|
||||
{
|
||||
GSList *tmp;
|
||||
int oldlevel;
|
||||
|
||||
g_return_if_fail(window != NULL);
|
||||
|
|
@ -71,7 +72,8 @@ static void sig_dehilight_window(WINDOW_REC *window)
|
|||
}
|
||||
signal_emit("window activity", 2, window, GINT_TO_POINTER(oldlevel));
|
||||
|
||||
g_slist_foreach(window->items, (GFunc) sig_dehilight, NULL);
|
||||
for (tmp = window->items; tmp != NULL; tmp = tmp->next)
|
||||
sig_dehilight(window, tmp->data);
|
||||
}
|
||||
|
||||
static void sig_hilight_window_item(WI_ITEM_REC *item)
|
||||
|
|
@ -96,7 +98,7 @@ static void sig_hilight_window_item(WI_ITEM_REC *item)
|
|||
signal_emit("window activity", 2, window, GINT_TO_POINTER(oldlevel));
|
||||
}
|
||||
|
||||
void nick_hilight_init(void)
|
||||
void window_activity_init(void)
|
||||
{
|
||||
signal_add("print text", (SIGNAL_FUNC) sig_hilight_text);
|
||||
signal_add("window item changed", (SIGNAL_FUNC) sig_dehilight);
|
||||
|
|
@ -105,7 +107,7 @@ void nick_hilight_init(void)
|
|||
signal_add("window item hilight", (SIGNAL_FUNC) sig_hilight_window_item);
|
||||
}
|
||||
|
||||
void nick_hilight_deinit(void)
|
||||
void window_activity_deinit(void)
|
||||
{
|
||||
signal_remove("print text", (SIGNAL_FUNC) sig_hilight_text);
|
||||
signal_remove("window item changed", (SIGNAL_FUNC) sig_dehilight);
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "server.h"
|
||||
#include "misc.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "levels.h"
|
||||
|
|
@ -32,7 +33,8 @@
|
|||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
|
||||
GSList *windows;
|
||||
GSList *windows; /* first in the list is the active window,
|
||||
next is the last active, etc. */
|
||||
WINDOW_REC *active_win;
|
||||
|
||||
static int window_get_new_refnum(void)
|
||||
|
|
@ -65,7 +67,7 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
|||
rec = g_new0(WINDOW_REC, 1);
|
||||
rec->refnum = window_get_new_refnum();
|
||||
|
||||
windows = g_slist_append(windows, rec);
|
||||
windows = g_slist_prepend(windows, rec);
|
||||
signal_emit("window created", 2, rec, GINT_TO_POINTER(automatic));
|
||||
|
||||
if (item != NULL) window_add_item(rec, item, automatic);
|
||||
|
|
@ -77,8 +79,26 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
|
|||
return rec;
|
||||
}
|
||||
|
||||
/* removed_refnum was removed from the windows list, pack the windows so
|
||||
there won't be any holes. If there is any holes after removed_refnum,
|
||||
leave the windows behind it alone. */
|
||||
static void windows_pack(int removed_refnum)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
int refnum;
|
||||
|
||||
for (refnum = removed_refnum+1;; refnum++) {
|
||||
window = window_find_refnum(refnum);
|
||||
if (window == NULL) break;
|
||||
|
||||
window_set_refnum(window, refnum-1);
|
||||
}
|
||||
}
|
||||
|
||||
void window_destroy(WINDOW_REC *window)
|
||||
{
|
||||
int refnum;
|
||||
|
||||
g_return_if_fail(window != NULL);
|
||||
|
||||
if (window->destroying) return;
|
||||
|
|
@ -93,29 +113,25 @@ void window_destroy(WINDOW_REC *window)
|
|||
g_slist_foreach(window->waiting_channels, (GFunc) g_free, NULL);
|
||||
g_slist_free(window->waiting_channels);
|
||||
|
||||
refnum = window->refnum;
|
||||
g_free_not_null(window->name);
|
||||
g_free(window);
|
||||
}
|
||||
|
||||
void window_set_active_num(int number)
|
||||
{
|
||||
GSList *win;
|
||||
if (active_win == window && windows != NULL)
|
||||
window_set_active(windows->data);
|
||||
|
||||
win = g_slist_nth(windows, number);
|
||||
if (win == NULL) return;
|
||||
|
||||
active_win = win->data;
|
||||
signal_emit("window changed", 1, active_win);
|
||||
windows_pack(refnum);
|
||||
}
|
||||
|
||||
void window_set_active(WINDOW_REC *window)
|
||||
{
|
||||
int number;
|
||||
|
||||
number = g_slist_index(windows, window);
|
||||
if (number == -1) return;
|
||||
if (window == active_win)
|
||||
return;
|
||||
|
||||
active_win = window;
|
||||
windows = g_slist_remove(windows, active_win);
|
||||
windows = g_slist_prepend(windows, active_win);
|
||||
|
||||
signal_emit("window changed", 1, active_win);
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +141,30 @@ void window_change_server(WINDOW_REC *window, void *server)
|
|||
signal_emit("window server changed", 2, window, server);
|
||||
}
|
||||
|
||||
void window_set_refnum(WINDOW_REC *window, int refnum)
|
||||
{
|
||||
GSList *tmp;
|
||||
int old_refnum;
|
||||
|
||||
g_return_if_fail(window != NULL);
|
||||
g_return_if_fail(refnum >= 1);
|
||||
if (window->refnum == refnum) return;
|
||||
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->refnum == refnum) {
|
||||
rec->refnum = window->refnum;
|
||||
signal_emit("window refnum changed", 2, rec, GINT_TO_POINTER(refnum));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
old_refnum = window->refnum;
|
||||
window->refnum = refnum;
|
||||
signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
|
||||
}
|
||||
|
||||
void window_set_name(WINDOW_REC *window, const char *name)
|
||||
{
|
||||
g_free_not_null(window->name);
|
||||
|
|
@ -182,6 +222,68 @@ WINDOW_REC *window_find_closest(void *server, const char *name, int level)
|
|||
return active_win;
|
||||
}
|
||||
|
||||
WINDOW_REC *window_find_refnum(int refnum)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->refnum == refnum)
|
||||
return rec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int windows_refnum_last(void)
|
||||
{
|
||||
GSList *tmp;
|
||||
int max;
|
||||
|
||||
max = -1;
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->refnum > max)
|
||||
max = rec->refnum;
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
static int window_refnum_prev(int refnum)
|
||||
{
|
||||
GSList *tmp;
|
||||
int max;
|
||||
|
||||
max = -1;
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->refnum < refnum && (max == -1 || rec->refnum > max))
|
||||
max = rec->refnum;
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
static int window_refnum_next(int refnum)
|
||||
{
|
||||
GSList *tmp;
|
||||
int min;
|
||||
|
||||
min = -1;
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->refnum > refnum && (min == -1 || rec->refnum < min))
|
||||
min = rec->refnum;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
static void cmd_window(const char *data, void *server, WI_ITEM_REC *item)
|
||||
{
|
||||
command_runsub("window", data, server, item);
|
||||
|
|
@ -194,7 +296,7 @@ static void cmd_window_new(const char *data, void *server, WI_ITEM_REC *item)
|
|||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
type = (g_strcasecmp(data, "hide") == 0 || g_strcasecmp(data, "tab") == 0) ? 1 :
|
||||
type = (g_strncasecmp(data, "hid", 3) == 0 || g_strcasecmp(data, "tab") == 0) ? 1 :
|
||||
(g_strcasecmp(data, "split") == 0 ? 2 : 0);
|
||||
signal_emit("gui window create override", 1, GINT_TO_POINTER(type));
|
||||
|
||||
|
|
@ -210,13 +312,15 @@ static void cmd_window_close(const char *data)
|
|||
}
|
||||
|
||||
/* return the first window number with the highest activity */
|
||||
static int window_highest_activity(WINDOW_REC *window)
|
||||
static WINDOW_REC *window_highest_activity(WINDOW_REC *window)
|
||||
{
|
||||
WINDOW_REC *rec;
|
||||
WINDOW_REC *rec, *max_win;
|
||||
GSList *tmp;
|
||||
int max_num, max_act, through;
|
||||
int max_act, through;
|
||||
|
||||
max_num = 0; max_act = 0; through = FALSE;
|
||||
g_return_val_if_fail(window != NULL, NULL);
|
||||
|
||||
max_win = NULL; max_act = 0; through = FALSE;
|
||||
|
||||
tmp = g_slist_find(windows, window);
|
||||
for (;; tmp = tmp->next) {
|
||||
|
|
@ -232,20 +336,41 @@ static int window_highest_activity(WINDOW_REC *window)
|
|||
|
||||
if (rec->new_data && max_act < rec->new_data) {
|
||||
max_act = rec->new_data;
|
||||
max_num = g_slist_index(windows, rec)+1;
|
||||
max_win = rec;
|
||||
}
|
||||
}
|
||||
|
||||
return max_num;
|
||||
return max_win;
|
||||
}
|
||||
|
||||
/* channel name - first try channel from same server */
|
||||
static int window_find_name(WINDOW_REC *window, const char *name)
|
||||
WINDOW_REC *window_find_name(const char *name)
|
||||
{
|
||||
WI_ITEM_REC *item;
|
||||
int num;
|
||||
GSList *tmp;
|
||||
|
||||
item = window_item_find(window->active_server, name);
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
if (rec->name != NULL && g_strcasecmp(rec->name, name) == 0)
|
||||
return rec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name)
|
||||
{
|
||||
WINDOW_REC *rec;
|
||||
WI_ITEM_REC *item;
|
||||
|
||||
g_return_val_if_fail(name != NULL, NULL);
|
||||
|
||||
rec = window_find_name(name);
|
||||
if (rec != NULL) return rec;
|
||||
|
||||
item = window == NULL ? NULL :
|
||||
window_item_find(window->active_server, name);
|
||||
if (item == NULL && window->active_server != NULL) {
|
||||
/* not found from the active server - any server? */
|
||||
item = window_item_find(NULL, name);
|
||||
|
|
@ -257,7 +382,8 @@ static int window_find_name(WINDOW_REC *window, const char *name)
|
|||
/* still nothing? maybe user just left the # in front of
|
||||
channel, try again with it.. */
|
||||
chan = g_strdup_printf("#%s", name);
|
||||
item = window_item_find(window->active_server, chan);
|
||||
item = window == NULL ? NULL :
|
||||
window_item_find(window->active_server, chan);
|
||||
if (item == NULL) item = window_item_find(NULL, chan);
|
||||
g_free(chan);
|
||||
}
|
||||
|
|
@ -265,48 +391,63 @@ static int window_find_name(WINDOW_REC *window, const char *name)
|
|||
if (item == NULL)
|
||||
return 0;
|
||||
|
||||
/* get the window number */
|
||||
window = MODULE_DATA(item);
|
||||
if (window == NULL) return 0;
|
||||
return MODULE_DATA(item);
|
||||
}
|
||||
|
||||
num = g_slist_index(windows, window);
|
||||
return num < 0 ? 0 : num+1;
|
||||
static void cmd_window_refnum(const char *data)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
|
||||
if (!is_numeric(data, 0)) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_REFNUM_NOT_FOUND, data);
|
||||
return;
|
||||
}
|
||||
|
||||
window = window_find_refnum(atoi(data));
|
||||
if (window == NULL)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_REFNUM_NOT_FOUND, data);
|
||||
else
|
||||
window_set_active(window);
|
||||
}
|
||||
|
||||
static void cmd_window_goto(const char *data)
|
||||
{
|
||||
int num;
|
||||
WINDOW_REC *window;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
num = 0;
|
||||
if (is_numeric(data, 0)) {
|
||||
cmd_window_refnum(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_strcasecmp(data, "active") == 0)
|
||||
num = window_highest_activity(active_win);
|
||||
else if (isdigit(*data))
|
||||
num = atol(data);
|
||||
window = window_highest_activity(active_win);
|
||||
else
|
||||
num = window_find_name(active_win, data);
|
||||
window = window_find_item(active_win, data);
|
||||
|
||||
if (num > 0)
|
||||
window_set_active_num(num-1);
|
||||
if (window != NULL)
|
||||
window_set_active(window);
|
||||
}
|
||||
|
||||
static void cmd_window_next(const char *data)
|
||||
static void cmd_window_next(void)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = g_slist_index(windows, active_win)+1;
|
||||
if (num >= g_slist_length(windows)) num = 0;
|
||||
window_set_active_num(num);
|
||||
num = window_refnum_next(active_win->refnum);
|
||||
if (num < 1) num = windows_refnum_last();
|
||||
|
||||
window_set_active(window_find_refnum(num));
|
||||
}
|
||||
|
||||
static void cmd_window_prev(const char *data)
|
||||
static void cmd_window_prev(void)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = g_slist_index(windows, active_win)-1;
|
||||
if (num < 0) num = g_slist_length(windows)-1;
|
||||
window_set_active_num(num);
|
||||
num = window_refnum_prev(active_win->refnum);
|
||||
if (num < 1) num = window_refnum_next(0);
|
||||
|
||||
window_set_active(window_find_refnum(num));
|
||||
}
|
||||
|
||||
static void cmd_window_level(const char *data)
|
||||
|
|
@ -392,11 +533,155 @@ static void cmd_window_item_next(const char *data, void *server, WI_ITEM_REC *it
|
|||
window_item_set_active(window, next);
|
||||
}
|
||||
|
||||
static void cmd_window_number(const char *data)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = atoi(data);
|
||||
if (num < 1)
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_REFNUM_TOO_LOW);
|
||||
else
|
||||
window_set_refnum(active_win, num);
|
||||
}
|
||||
|
||||
static void cmd_window_name(const char *data)
|
||||
{
|
||||
window_set_name(active_win, data);
|
||||
}
|
||||
|
||||
/* we're moving the first window to last - move the first contiguous block
|
||||
of refnums to left. Like if there's windows 1..5 and 7..10, move 1 to
|
||||
11, 2..5 to 1..4 and leave 7..10 alone */
|
||||
static void windows_move_left(WINDOW_REC *move_window)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
int refnum;
|
||||
|
||||
window_set_refnum(move_window, windows_refnum_last()+1);
|
||||
for (refnum = 2;; refnum++) {
|
||||
window = window_find_refnum(refnum);
|
||||
if (window == NULL) break;
|
||||
|
||||
window_set_refnum(window, refnum-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* we're moving the last window to first - make some space so we can use the
|
||||
refnum 1 */
|
||||
static void windows_move_right(WINDOW_REC *move_window)
|
||||
{
|
||||
WINDOW_REC *window;
|
||||
int refnum;
|
||||
|
||||
/* find the first unused refnum, like if there's windows
|
||||
1..5 and 7..10, we only need to move 1..5 to 2..6 */
|
||||
refnum = 1;
|
||||
while (window_find_refnum(refnum) != NULL) refnum++;
|
||||
|
||||
refnum--;
|
||||
while (refnum > 0) {
|
||||
window = window_find_refnum(refnum);
|
||||
g_return_if_fail(window != NULL);
|
||||
window_set_refnum(window, window == move_window ? 1 : refnum+1);
|
||||
|
||||
refnum--;
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_window_move_left(void)
|
||||
{
|
||||
int refnum;
|
||||
|
||||
refnum = window_refnum_prev(active_win->refnum);
|
||||
if (refnum != -1) {
|
||||
window_set_refnum(active_win, active_win->refnum-1);
|
||||
return;
|
||||
}
|
||||
|
||||
windows_move_left(active_win);
|
||||
}
|
||||
|
||||
static void cmd_window_move_right(void)
|
||||
{
|
||||
int refnum;
|
||||
|
||||
refnum = window_refnum_next(active_win->refnum);
|
||||
if (refnum != -1) {
|
||||
window_set_refnum(active_win, active_win->refnum+1);
|
||||
return;
|
||||
}
|
||||
|
||||
windows_move_right(active_win);
|
||||
}
|
||||
|
||||
static void cmd_window_move(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
|
||||
{
|
||||
int new_refnum, refnum;
|
||||
|
||||
if (!is_numeric(data, 0)) {
|
||||
command_runsub("window move", data, server, item);
|
||||
return;
|
||||
}
|
||||
|
||||
new_refnum = atoi(data);
|
||||
if (new_refnum > active_win->refnum) {
|
||||
for (;;) {
|
||||
refnum = window_refnum_next(active_win->refnum);
|
||||
if (refnum == -1 || refnum > new_refnum)
|
||||
break;
|
||||
|
||||
window_set_refnum(active_win, refnum);
|
||||
}
|
||||
} else {
|
||||
for (;;) {
|
||||
refnum = window_refnum_prev(active_win->refnum);
|
||||
if (refnum == -1 || refnum < new_refnum)
|
||||
break;
|
||||
|
||||
window_set_refnum(active_win, refnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int windows_compare(WINDOW_REC *w1, WINDOW_REC *w2)
|
||||
{
|
||||
return w1->refnum < w2->refnum ? -1 : 1;
|
||||
}
|
||||
|
||||
GSList *windows_get_sorted(void)
|
||||
{
|
||||
GSList *tmp, *list;
|
||||
|
||||
list = NULL;
|
||||
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
|
||||
list = g_slist_insert_sorted(list, tmp->data, (GCompareFunc) windows_compare);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void cmd_window_list(void)
|
||||
{
|
||||
GSList *tmp, *sorted;
|
||||
char *levelstr;
|
||||
|
||||
sorted = windows_get_sorted();
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_WINDOWLIST_HEADER);
|
||||
for (tmp = sorted; tmp != NULL; tmp = tmp->next) {
|
||||
WINDOW_REC *rec = tmp->data;
|
||||
|
||||
levelstr = bits2level(rec->level);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_WINDOWLIST_LINE,
|
||||
rec->refnum, rec->name == NULL ? "" : rec->name,
|
||||
rec->active == NULL ? "" : rec->active->name,
|
||||
rec->active_server == NULL ? "" : ((SERVER_REC *) rec->active_server)->tag,
|
||||
levelstr);
|
||||
g_free(levelstr);
|
||||
}
|
||||
g_slist_free(sorted);
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_WINDOWLIST_FOOTER);
|
||||
}
|
||||
|
||||
static void sig_server_looking(void *server)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
|
@ -434,14 +719,21 @@ void windows_init(void)
|
|||
command_bind("window", NULL, (SIGNAL_FUNC) cmd_window);
|
||||
command_bind("window new", NULL, (SIGNAL_FUNC) cmd_window_new);
|
||||
command_bind("window close", NULL, (SIGNAL_FUNC) cmd_window_close);
|
||||
command_bind("window kill", NULL, (SIGNAL_FUNC) cmd_window_close);
|
||||
command_bind("window server", NULL, (SIGNAL_FUNC) cmd_window_server);
|
||||
command_bind("window refnum", NULL, (SIGNAL_FUNC) cmd_window_refnum);
|
||||
command_bind("window goto", NULL, (SIGNAL_FUNC) cmd_window_goto);
|
||||
command_bind("window prev", NULL, (SIGNAL_FUNC) cmd_window_prev);
|
||||
command_bind("window next", NULL, (SIGNAL_FUNC) cmd_window_next);
|
||||
command_bind("window level", NULL, (SIGNAL_FUNC) cmd_window_level);
|
||||
command_bind("window item prev", NULL, (SIGNAL_FUNC) cmd_window_item_prev);
|
||||
command_bind("window item next", NULL, (SIGNAL_FUNC) cmd_window_item_next);
|
||||
command_bind("window number", NULL, (SIGNAL_FUNC) cmd_window_number);
|
||||
command_bind("window name", NULL, (SIGNAL_FUNC) cmd_window_name);
|
||||
command_bind("window move", NULL, (SIGNAL_FUNC) cmd_window_move);
|
||||
command_bind("window move left", NULL, (SIGNAL_FUNC) cmd_window_move_left);
|
||||
command_bind("window move right", NULL, (SIGNAL_FUNC) cmd_window_move_right);
|
||||
command_bind("window list", NULL, (SIGNAL_FUNC) cmd_window_list);
|
||||
signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
|
||||
signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_add("server connect failed", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
|
|
@ -452,14 +744,21 @@ void windows_deinit(void)
|
|||
command_unbind("window", (SIGNAL_FUNC) cmd_window);
|
||||
command_unbind("window new", (SIGNAL_FUNC) cmd_window_new);
|
||||
command_unbind("window close", (SIGNAL_FUNC) cmd_window_close);
|
||||
command_unbind("window kill", (SIGNAL_FUNC) cmd_window_close);
|
||||
command_unbind("window server", (SIGNAL_FUNC) cmd_window_server);
|
||||
command_unbind("window refnum", (SIGNAL_FUNC) cmd_window_refnum);
|
||||
command_unbind("window goto", (SIGNAL_FUNC) cmd_window_goto);
|
||||
command_unbind("window prev", (SIGNAL_FUNC) cmd_window_prev);
|
||||
command_unbind("window next", (SIGNAL_FUNC) cmd_window_next);
|
||||
command_unbind("window level", (SIGNAL_FUNC) cmd_window_level);
|
||||
command_unbind("window item prev", (SIGNAL_FUNC) cmd_window_item_prev);
|
||||
command_unbind("window item next", (SIGNAL_FUNC) cmd_window_item_next);
|
||||
command_unbind("window number", (SIGNAL_FUNC) cmd_window_number);
|
||||
command_unbind("window name", (SIGNAL_FUNC) cmd_window_name);
|
||||
command_unbind("window move", (SIGNAL_FUNC) cmd_window_move);
|
||||
command_unbind("window move left", (SIGNAL_FUNC) cmd_window_move_left);
|
||||
command_unbind("window move right", (SIGNAL_FUNC) cmd_window_move_right);
|
||||
command_unbind("window list", (SIGNAL_FUNC) cmd_window_list);
|
||||
signal_remove("server looking", (SIGNAL_FUNC) sig_server_looking);
|
||||
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
signal_remove("server connect failed", (SIGNAL_FUNC) sig_server_disconnected);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ typedef struct {
|
|||
int level;
|
||||
int new_data;
|
||||
time_t last_timestamp; /* When was last timestamp printed */
|
||||
time_t last_line; /* When was last line printed */
|
||||
|
||||
gpointer gui_data;
|
||||
} WINDOW_REC;
|
||||
|
|
@ -55,11 +56,15 @@ void window_set_active_num(int number);
|
|||
void window_set_active(WINDOW_REC *window);
|
||||
void window_change_server(WINDOW_REC *window, void *server);
|
||||
|
||||
void window_set_refnum(WINDOW_REC *window, int refnum);
|
||||
void window_set_name(WINDOW_REC *window, const char *name);
|
||||
|
||||
void window_set_level(WINDOW_REC *window, int level);
|
||||
WINDOW_REC *window_find_level(void *server, int level);
|
||||
WINDOW_REC *window_find_closest(void *server, const char *name, int level);
|
||||
WINDOW_REC *window_find_refnum(int refnum);
|
||||
WINDOW_REC *window_find_name(const char *name);
|
||||
WINDOW_REC *window_find_item(WINDOW_REC *window, const char *name);
|
||||
|
||||
void windows_init(void);
|
||||
void windows_deinit(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue