+Wed May 15 19:01:42 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Merged with Irssi CVS for Irssi SILC client.
+
Tue May 14 19:37:48 EEST 2002 Pekka Riikonen <priikone@silcnet.org>
* Completed the protocol specifications.
#ifndef __COMMON_H
#define __COMMON_H
-#define IRSSI_AUTHOR "Timo Sirainen <cras@irssi.org>"
#define IRSSI_WEBSITE "http://irssi.org/"
+#define IRSSI_AUTHOR_EMAIL "cras@irssi.org"
+#define IRSSI_AUTHOR "Timo Sirainen <"IRSSI_AUTHOR_EMAIL">"
#define IRSSI_DIR_SHORT "~/.silc"
#define IRSSI_DIR_FULL "%s/.silc" /* %s == g_get_home_dir() */
typedef struct _NET_SENDBUF_REC NET_SENDBUF_REC;
typedef struct _RAWLOG_REC RAWLOG_REC;
+typedef struct _CHAT_PROTOCOL_REC CHAT_PROTOCOL_REC;
typedef struct _CHATNET_REC CHATNET_REC;
typedef struct _SERVER_REC SERVER_REC;
typedef struct _WI_ITEM_REC WI_ITEM_REC;
#ifndef __CHAT_PROTOCOLS_H
#define __CHAT_PROTOCOLS_H
-typedef struct {
+struct _CHAT_PROTOCOL_REC {
int id;
unsigned int not_initialized:1;
SERVER_REC *(*server_connect) (SERVER_CONNECT_REC *);
CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *, int);
QUERY_REC *(*query_create) (const char *, const char *, int);
-} CHAT_PROTOCOL_REC;
+};
extern GSList *chat_protocols;
struct utsname un;
#endif
settings_add_str("misc", "STATUS_OPER", "*");
- settings_add_str("misc", "timestamp_format", "%H:%M");
+ settings_add_str("lookandfeel", "timestamp_format", "%H:%M");
client_start_time = time(NULL);
last_sent_msg = NULL; last_sent_msg_body = NULL;
if (g_slist_find(setupservers, rec) == NULL)
setupservers = g_slist_append(setupservers, rec);
server_setup_save(rec);
+
+ signal_emit("server setup updated", 1, rec);
}
void server_setup_remove(SERVER_SETUP_REC *rec)
settings_add_bool("lookandfeel", "beep_when_away", TRUE);
settings_add_bool("lookandfeel", "hide_text_style", FALSE);
- settings_add_bool("lookandfeel", "hide_mirc_colors", FALSE);
+ settings_add_bool("lookandfeel", "hide_colors", FALSE);
settings_add_bool("lookandfeel", "hide_server_tags", FALSE);
settings_add_bool("lookandfeel", "use_status_window", TRUE);
g_return_if_fail(rec != NULL);
if (rec->destroying) return;
- rec->destroying = TRUE;
+ rec->destroying = TRUE;
+ rec->process->target_item = NULL;
if (window_item_window((WI_ITEM_REC *) rec) != NULL)
window_item_destroy((WI_ITEM_REC *) rec);
g_free_and_null(rec->target);
rec->target_win = active_win;
- if (rec->target_item != NULL) {
+ if (rec->target_item != NULL)
exec_wi_destroy(rec->target_item);
- rec->target_item = NULL;
- }
if (interactive) {
rec->target_item =
static int show_help_file(const char *file)
{
const char *helppath;
- char tmpbuf[1024], *str, *path;
+ char tmpbuf[1024], *str, *path, **paths, **tmp;
LINEBUF_REC *buffer = NULL;
int f, ret, recvlen;
helppath = settings_get_str("help_path");
- /* helpdir/command or helpdir/category/command */
- path = g_strdup_printf("%s/%s", helppath, file);
- f = open(path, O_RDONLY);
- g_free(path);
+ paths = g_strsplit(helppath, ":", -1);
+
+ f = -1;
+ for (tmp = paths; *tmp != NULL; tmp++) {
+ /* helpdir/command or helpdir/category/command */
+ path = g_strdup_printf("%s/%s", *tmp, file);
+ f = open(path, O_RDONLY);
+ g_free(path);
+
+ if (f != -1)
+ break;
+
+ }
+
+ g_strfreev(paths);
if (f == -1)
return FALSE;
if (nickrec == NULL && chanrec != NULL)
nickrec = nicklist_find(chanrec, nick);
- for_me = nick_match_msg(chanrec, msg, server->nick);
+ for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
+ nick_match_msg(chanrec, msg, server->nick);
color = for_me ? NULL :
hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC, msg);
printnicks = g_hash_table_new((GHashFunc) g_direct_hash,
(GCompareFunc) g_direct_equal);
+ settings_add_bool("lookandfeel", "hilight_nick_matches", TRUE);
settings_add_bool("lookandfeel", "emphasis", TRUE);
settings_add_bool("lookandfeel", "emphasis_replace", FALSE);
settings_add_bool("lookandfeel", "emphasis_multiword", FALSE);
window_auto_destroy(window);
else {
/* eg. connection lost to dcc chat */
- window_bind_add(window, query->server->tag, query->name);
+ window_bind_add(window, query->server_tag, query->name);
}
}
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_ALIAS_REMOVED, alias);
iconfig_set_str("aliases", alias, NULL);
+
+ signal_emit("alias removed", 1, alias);
}
}
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_ALIAS_ADDED, alias);
iconfig_set_str("aliases", alias, value);
+ signal_emit("alias added", 2, alias, value);
}
cmd_params_free(free_arg);
}
static const char *format_boldfores = "KBGCRMYW";
static int signal_gui_print_text;
-static int hide_text_style, hide_server_tags, hide_mirc_colors;
+static int hide_text_style, hide_server_tags, hide_colors;
static int timestamp_level;
static int timestamp_timeout;
switch (format->paramtypes[num]) {
case FORMAT_STRING:
arglist[num] = (char *) va_arg(va, char *);
- if (arglist[num] == NULL) {
- g_warning("format_read_arglist(%s) : parameter %d is NULL", format->tag, num);
+ if (arglist[num] == NULL)
arglist[num] = "";
- }
break;
case FORMAT_INT: {
int d = (int) va_arg(va, int);
case 3:
/* MIRC color */
get_mirc_color((const char **) &ptr,
- hide_mirc_colors || hide_text_style ? NULL : &fgcolor,
- hide_mirc_colors || hide_text_style ? NULL : &bgcolor);
- if (!hide_mirc_colors && !hide_text_style)
+ hide_colors ? NULL : &fgcolor,
+ hide_colors ? NULL : &bgcolor);
+ if (!hide_colors)
flags |= GUI_PRINT_FLAG_MIRC_COLOR;
break;
case 4:
/* ansi color code */
ptr = (char *)
get_ansi_color(theme, ptr,
- hide_text_style ? NULL : &fgcolor,
- hide_text_style ? NULL : &bgcolor,
- hide_text_style ? NULL : &flags);
+ hide_colors ? NULL : &fgcolor,
+ hide_colors ? NULL : &bgcolor,
+ hide_colors ? NULL : &flags);
break;
}
hide_server_tags = settings_get_bool("hide_server_tags");
hide_text_style = settings_get_bool("hide_text_style");
- hide_mirc_colors = settings_get_bool("hide_mirc_colors");
+ hide_colors = hide_text_style || settings_get_bool("hide_colors");
}
void formats_init(void)
@PERL_LINK_FLAGS@ \
@PROG_LIBS@ \
-L../../../lib -lsilcclient
+silc_LDFLAGS = -export-dynamic
tparm_sources = \
tparm.c
/* they're forcing us smaller than minimum size.. */
len = format_real_length(tmpstr, item->size);
tmpstr[len] = '\0';
+ } else {
+ /* make sure the str is big enough to fill the
+ requested size, so it won't corrupt screen */
+ len = format_get_length(tmpstr);
+ if (len < item->size) {
+ char *fill;
+
+ len = item->size-len;
+ fill = g_malloc(len + 1);
+ memset(fill, ' ', len); fill[len] = '\0';
+
+ tmpstr2 = g_strconcat(tmpstr, fill, NULL);
+ g_free(fill);
+ g_free(tmpstr);
+ tmpstr = tmpstr2;
+ }
}
tmpstr2 = update_statusbar_bg(tmpstr, item->bar->color);
However, next term_move() really shouldn't try to cache
the move, otherwise terminals would try to combine the
last word in upper line with first word in lower line. */
- cforcemove = TRUE;
vcx += count;
while (vcx >= term_width) {
vcx -= term_width;
if (vcy < term_height-1) vcy++;
if (vcx > 0) term_lines_empty[vcy] = FALSE;
}
+
+ crealx += count;
+ if (crealx >= term_width)
+ cforcemove = TRUE;
}
void term_addch(TERM_WINDOW *window, int chr)
if (vcmove) term_move_real();
- /* With UTF-8, move cursor only if this char is either single-byte
- (8. bit on) or beginning of multibyte (7+8 bits on) */
- if (term_type != TERM_TYPE_UTF8 ||
- (chr & 0x80) == 0 || (chr & 0x40) == 0) {
- term_printed_text(1);
- }
+ if (vcy < term_height-1 || vcx < term_width-1) {
+ /* With UTF-8, move cursor only if this char is either
+ single-byte (8. bit off) or beginning of multibyte
+ (7. bit off) */
+ if (term_type != TERM_TYPE_UTF8 ||
+ (chr & 0x80) == 0 || (chr & 0x40) == 0) {
+ term_printed_text(1);
+ }
- if (vcy != term_height || vcx != 0)
putc(chr, window->term->out);
+ }
}
static void term_addch_utf8(TERM_WINDOW *window, unichar chr)
if (term_detached) return;
if (vcmove) term_move_real();
- term_printed_text(1);
- if (vcy == term_height && vcx == 0)
+ if (vcy == term_height-1 && vcx == term_width-1)
return; /* last char in screen */
+ term_printed_text(1);
switch (term_type) {
case TERM_TYPE_UTF8:
term_addch_utf8(window, chr);
terminfo_set_cursor_visible(TRUE);
curs_visible = TRUE;
}
+
term_set_color(window, ATTR_RESET);
fflush(window != NULL ? window->term->out : current_term->out);
}
void term_refresh_freeze(void)
{
freeze_counter++;
-
- if (!term_detached && curs_visible) {
- terminfo_set_cursor_visible(FALSE);
- curs_visible = FALSE;
- }
}
void term_refresh_thaw(void)
if (ioctl(0, TIOCGWINSZ, &ws) < 0)
return FALSE;
+ if (ws.ws_row == 0 && ws.ws_col == 0)
+ return FALSE;
+
*width = ws.ws_col;
*height = ws.ws_row;
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define G_LOG_DOMAIN "TextBufferView"
+
#include "module.h"
#include "textbuffer-view.h"
#include "utf8.h"
break;
}
+ if ((*lines)->next == NULL)
+ break;
+
*lines = (*lines)->next;
}
{
LINE_CACHE_REC *cache;
- g_return_val_if_fail(view != NULL, NULL);
- g_return_val_if_fail(line != NULL, NULL);
+ g_assert(view != NULL);
+ g_assert(line != NULL);
cache = g_hash_table_lookup(view->cache->line_cache, line);
if (cache == NULL)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define G_LOG_DOMAIN "TextBuffer"
+
#include "module.h"
#include "misc.h"
#include "formats.h"
croak("Irssi::timeout() : msecs must be >= 10");
RETVAL = -1;
} else {
- RETVAL = perl_timeout_add(msecs, func, data);
+ RETVAL = perl_timeout_add(msecs, func, data, FALSE);
+ }
+OUTPUT:
+ RETVAL
+
+int
+timeout_add_once(msecs, func, data)
+ int msecs
+ SV *func
+ SV *data
+CODE:
+ if (msecs < 10) {
+ croak("Irssi::timeout_once() : msecs must be >= 10");
+ RETVAL = -1;
+ } else {
+ RETVAL = perl_timeout_add(msecs, func, data, TRUE);
}
OUTPUT:
RETVAL
level2bits(str)
char *str
-char *
+void
bits2level(bits)
int bits
+PREINIT:
+ char *ret;
+PPCODE:
+ ret = bits2level(bits);
+ XPUSHs(sv_2mortal(new_pv(ret)));
+ g_free(ret);
int
combine_level(level, str)
pidwait_remove(pid)
int pid
-char *
+void
parse_special(cmd, data="", flags=0)
char *cmd
char *data
typedef struct {
PERL_SCRIPT_REC *script;
int tag;
- int refcount;
+ int refcount;
+ int once; /* run only once */
SV *func;
SV *data;
rec->refcount++;
}
-static void perl_source_unref(PERL_SOURCE_REC *rec)
+static int perl_source_unref(PERL_SOURCE_REC *rec)
{
if (--rec->refcount != 0)
- return;
+ return TRUE;
SvREFCNT_dec(rec->data);
SvREFCNT_dec(rec->func);
g_free(rec);
+ return FALSE;
}
static void perl_source_destroy(PERL_SOURCE_REC *rec)
static int perl_source_event(PERL_SOURCE_REC *rec)
{
dSP;
+ int retcount;
ENTER;
SAVETMPS;
PUTBACK;
perl_source_ref(rec);
- perl_call_sv(rec->func, G_EVAL|G_DISCARD);
+ retcount = perl_call_sv(rec->func, G_EVAL|G_SCALAR);
SPAGAIN;
if (SvTRUE(ERRSV)) {
signal_emit("script error", 2, rec->script, error);
g_free(error);
}
- perl_source_unref(rec);
+
+ if (perl_source_unref(rec) && rec->once)
+ perl_source_destroy(rec);
PUTBACK;
FREETMPS;
return 1;
}
-int perl_timeout_add(int msecs, SV *func, SV *data)
+int perl_timeout_add(int msecs, SV *func, SV *data, int once)
{
PERL_SCRIPT_REC *script;
PERL_SOURCE_REC *rec;
rec = g_new0(PERL_SOURCE_REC, 1);
perl_source_ref(rec);
- rec->script = script;
+ rec->once = once;
+ rec->script = script;
rec->func = perl_func_sv_inc(func, pkg);
rec->data = SvREFCNT_inc(data);
rec->tag = g_timeout_add(msecs, (GSourceFunc) perl_source_event, rec);
return rec->tag;
}
-int perl_input_add(int source, int condition, SV *func, SV *data)
+int perl_input_add(int source, int condition, SV *func, SV *data, int once)
{
PERL_SCRIPT_REC *script;
PERL_SOURCE_REC *rec;
rec = g_new0(PERL_SOURCE_REC, 1);
perl_source_ref(rec);
+ rec->once = once;
rec->script =script;
rec->func = perl_func_sv_inc(func, pkg);
rec->data = SvREFCNT_inc(data);
#include "module.h"
-MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::Window
+static int magic_free_text_dest(SV *sv, MAGIC *mg)
+{
+ TEXT_DEST_REC *dest = (TEXT_DEST_REC *) mg->mg_ptr;
+ g_free((char *) dest->target);
+ g_free(dest);
+ mg->mg_ptr = NULL;
+ return 0;
+}
+
+static MGVTBL vtbl_free_text_dest =
+{
+ NULL, NULL, NULL, NULL, magic_free_text_dest
+};
+
+static SV *perl_format_create_dest(SERVER_REC *server, char *target,
+ int level, WINDOW_REC *window)
+{
+ TEXT_DEST_REC *dest;
+ SV *sv, *ret_sv;
+
+ dest = g_new0(TEXT_DEST_REC, 1);
+ format_create_dest(dest, server, g_strdup(target), level, window);
+
+ ret_sv = plain_bless(dest, "Irssi::UI::TextDest");
+
+ sv = *hv_fetch(hvref(ret_sv), "_irssi", 6, 0);
+ sv_magic(sv, NULL, '~', NULL, 0);
+
+ SvMAGIC(sv)->mg_private = 0x1551; /* HF */
+ SvMAGIC(sv)->mg_virtual = &vtbl_free_text_dest;
+ SvMAGIC(sv)->mg_ptr = (char *) dest;
+
+ return ret_sv;
+}
+
+MODULE = Irssi::UI::Formats PACKAGE = Irssi
PROTOTYPES: ENABLE
+int
+format_get_length(str)
+ char *str
+
+int
+format_real_length(str, len)
+ char *str
+ int len
+
+void
+strip_codes(input)
+ char *input
+PREINIT:
+ char *ret;
+PPCODE:
+ ret = strip_codes(input);
+ XPUSHs(sv_2mortal(new_pv(ret)));
+ g_free(ret);
+
+
+void
+format_create_dest(target, level=MSGLEVEL_CLIENTNOTICE, window=NULL)
+ char *target
+ int level
+ Irssi::UI::Window window
+PPCODE:
+ XPUSHs(sv_2mortal(perl_format_create_dest(NULL, target, level, window)));
+
+#*******************************
+MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::Window
+#*******************************
+
void
format_get_text(window, module, server, target, formatnum, ...)
Irssi::UI::Window window
XPUSHs(sv_2mortal(new_pv(ret)));
g_free_not_null(ret);
+
+#*******************************
+MODULE = Irssi::UI::Formats PACKAGE = Irssi::Window
+#*******************************
+
+void
+format_create_dest(window=NULL, level=MSGLEVEL_CLIENTNOTICE)
+ Irssi::UI::Window window
+ int level
+PPCODE:
+ XPUSHs(sv_2mortal(perl_format_create_dest(NULL, NULL, level, window)));
+
+#*******************************
+MODULE = Irssi::UI::Formats PACKAGE = Irssi::Server
+#*******************************
+
+void
+format_create_dest(server, target=NULL, level=MSGLEVEL_CLIENTNOTICE, window=NULL)
+ Irssi::Server server
+ char *target
+ int level
+ Irssi::UI::Window window
+PPCODE:
+ XPUSHs(sv_2mortal(perl_format_create_dest(server, target, level, window)));
+
+#*******************************
+MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::TextDest
+#*******************************
+
+void
+print(dest, str)
+ Irssi::UI::TextDest dest
+ char *str
+CODE:
+ printtext_dest(dest, str);
PREINIT:
MODULE_THEME_REC *modtheme;
FORMAT_REC *formats;
- char *ret;
int i;
CODE:
formats = g_hash_table_lookup(default_formats, module);