From d03d6e606b40157d910ddf99ab018156abeb8ef0 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Mon, 28 Feb 2011 18:59:32 +0100 Subject: add wdk changes to named branch --- src/fe-gtk/menu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index d04be222..559211c2 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -20,7 +20,6 @@ #include #include #include -#include #ifdef WIN32 #include @@ -1203,6 +1202,12 @@ menu_resetmarker (GtkWidget * wid, gpointer none) gtk_xtext_reset_marker_pos (GTK_XTEXT (current_sess->gui->xtext)); } +static void +menu_copy_selection (GtkWidget * wid, gpointer none) +{ + gtk_xtext_copy_selection (GTK_XTEXT (current_sess->gui->xtext)); +} + static void menu_flushbuffer (GtkWidget * wid, gpointer none) { @@ -1645,6 +1650,7 @@ static struct mymenu mymenu[] = { {N_("URL Grabber..."), url_opengui, 0, M_MENUITEM, 0, 0, 1}, {0, 0, 0, M_SEP, 0, 0, 0}, {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m}, + {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l}, #define SEARCH_OFFSET 67 {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, @@ -2188,7 +2194,9 @@ normalitem: mymenu[i].key, mymenu[i].key == GDK_F1 ? 0 : mymenu[i].key == GDK_w ? close_mask : - GDK_CONTROL_MASK, + (g_ascii_isupper (mymenu[i].key)) ? + GDK_SHIFT_MASK | GDK_CONTROL_MASK : + GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); if (mymenu[i].callback) g_signal_connect (G_OBJECT (item), "activate", -- cgit 1.4.1 From 8877fe73b18c924d103b8eca08578dcfdfdbe7f9 Mon Sep 17 00:00:00 2001 From: "berkeviktor@aol.com" Date: Thu, 28 Jul 2011 02:22:22 +0200 Subject: fix attach/detach keyboard shortcut broken by the autocopy patch --- src/fe-gtk/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 559211c2..da90ca7f 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1585,7 +1585,7 @@ static struct mymenu mymenu[] = { #endif {0, 0, 0, M_SEP, 0, 0, 0}, /* 11 */ #define DETACH_OFFSET (12) - {0, menu_detach, GTK_STOCK_REDO, M_MENUSTOCK, 0, 0, 1, GDK_I}, /* 12 */ + {0, menu_detach, GTK_STOCK_REDO, M_MENUSTOCK, 0, 0, 1, GDK_i}, /* 12 */ #define CLOSE_OFFSET (13) {0, menu_close, GTK_STOCK_CLOSE, M_MENUSTOCK, 0, 0, 1, GDK_w}, {0, 0, 0, M_SEP, 0, 0, 0}, -- cgit 1.4.1 From 3e7adb9878d8fca9b14b48e340eecfe489e14d15 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 23 Nov 2011 12:38:51 +0100 Subject: update offset due to new menu item (copy selection) --- src/fe-gtk/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index da90ca7f..816c93ec 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1652,11 +1652,11 @@ static struct mymenu mymenu[] = { {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m}, {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l}, -#define SEARCH_OFFSET 67 +#define SEARCH_OFFSET 68 {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, {N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, - {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 69 */ + {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 70 */ {N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1}, #if 0 {N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1}, -- cgit 1.4.1 From 60bcde41ae44d90615930e7ce2e88e8b8c724274 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 23 Nov 2011 13:13:58 +0100 Subject: add menu item for saving preferences to disk --- src/fe-gtk/menu.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 816c93ec..8ba73a61 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1121,6 +1121,21 @@ usermenu_update (void) } } +static void +menu_saveconf (void) +{ + session *sess = current_sess; + + if (save_config ()) + { + PrintText (sess, "Preferences have been saved successfully.\n"); + } + else + { + PrintText (sess, "Error saving preferences.\n"); + } +} + static void menu_newserver_window (GtkWidget * wid, gpointer none) { @@ -1638,6 +1653,8 @@ static struct mymenu mymenu[] = { {N_("Userlist Popup..."), menu_ulpopup, 0, M_MENUITEM, 0, 0, 1}, {0, 0, 0, M_END, 0, 0, 0}, /* 53 */ + {N_("Save Settings to Disk"), menu_saveconf, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, + {N_("_Window"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("Ban List..."), menu_banlist, 0, M_MENUITEM, 0, 0, 1}, {N_("Character Chart..."), ascii_open, 0, M_MENUITEM, 0, 0, 1}, @@ -1652,11 +1669,11 @@ static struct mymenu mymenu[] = { {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m}, {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l}, -#define SEARCH_OFFSET 68 +#define SEARCH_OFFSET 69 {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, {N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, - {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 70 */ + {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 71 */ {N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1}, #if 0 {N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1}, -- cgit 1.4.1 From f8679494263312804cd4f296115d86c59a0540a2 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 23 Nov 2011 13:23:51 +0100 Subject: be consistent with menu item --- src/fe-gtk/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 8ba73a61..646839e8 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1128,11 +1128,11 @@ menu_saveconf (void) if (save_config ()) { - PrintText (sess, "Preferences have been saved successfully.\n"); + PrintText (sess, "Settings have been saved successfully.\n"); } else { - PrintText (sess, "Error saving preferences.\n"); + PrintText (sess, "Error saving settings.\n"); } } -- cgit 1.4.1 From 9ab089e2e49dd300fae7a76596b444dc974b40e9 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 23 Nov 2011 13:40:18 +0100 Subject: disable saveconf menu item, autosave will be added later --- src/fe-gtk/menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 646839e8..90c784f0 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1653,7 +1653,7 @@ static struct mymenu mymenu[] = { {N_("Userlist Popup..."), menu_ulpopup, 0, M_MENUITEM, 0, 0, 1}, {0, 0, 0, M_END, 0, 0, 0}, /* 53 */ - {N_("Save Settings to Disk"), menu_saveconf, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, + /* {N_("Save Settings to Disk"), menu_saveconf, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, don't use this, a /set auto-save approach will be added instead */ {N_("_Window"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("Ban List..."), menu_banlist, 0, M_MENUITEM, 0, 0, 1}, @@ -1669,11 +1669,11 @@ static struct mymenu mymenu[] = { {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m}, {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l}, -#define SEARCH_OFFSET 69 +#define SEARCH_OFFSET 68 {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, {N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, - {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 71 */ + {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 70 */ {N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1}, #if 0 {N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1}, -- cgit 1.4.1 From 132ef6cb50201cb6ab8ab0609a88ccce62aa6a21 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sun, 11 Dec 2011 17:34:02 +0100 Subject: initial patches for linux compatibility --- plugins/perl/perl.c | 2 +- plugins/perl/perl.def | 4 +++ plugins/python/python.c | 6 ++++ plugins/tcl/tclplugin.c | 2 ++ plugins/xdcc/xdcc.c | 4 +++ src/common/cfgfiles.c | 20 +++++++++--- src/common/chanopt.c | 4 +++ src/common/ctcp.c | 9 ++++++ src/common/dcc.c | 8 ++++- src/common/ignore.c | 4 +++ src/common/inbound.c | 4 +++ src/common/makefile.mak | 1 - src/common/msproxy.c | 4 +++ src/common/network.c | 4 +++ src/common/notify.c | 4 +++ src/common/outbound.c | 7 ++++- src/common/plugin-timer.c | 2 +- src/common/proto-irc.c | 4 +++ src/common/server.c | 5 +++ src/common/servlist.c | 4 +++ src/common/text.c | 71 +++++++++++++++++++++++++++++++++++++++++++ src/common/util.c | 42 +++++++++++++++++++++++-- src/common/util.h | 2 ++ src/common/wdkutil.c | 27 ---------------- src/common/wdkutil.h | 2 -- src/common/xchat.c | 4 +-- src/common/xchat.h | 4 +++ src/fe-gtk/about.c | 4 +-- src/fe-gtk/banlist.c | 4 +++ src/fe-gtk/chanlist.c | 4 +++ src/fe-gtk/editlist.c | 5 +++ src/fe-gtk/fe-gtk.c | 6 +++- src/fe-gtk/fkeys.c | 6 +++- src/fe-gtk/gtkutil.c | 4 +++ src/fe-gtk/joind.c | 4 +++ src/fe-gtk/maingui.c | 3 +- src/fe-gtk/menu.c | 8 ++++- src/fe-gtk/palette.c | 4 +++ src/fe-gtk/plugin-tray.c | 18 ++++++++--- src/fe-gtk/plugingui.c | 9 ++++-- src/fe-gtk/rawlog.c | 4 +++ src/fe-gtk/setup.c | 13 ++++++-- src/fe-gtk/sexy-spell-entry.c | 11 +++++++ src/fe-gtk/xtext.c | 2 ++ 44 files changed, 304 insertions(+), 59 deletions(-) create mode 100644 plugins/perl/perl.def delete mode 100644 src/common/wdkutil.c delete mode 100644 src/common/wdkutil.h (limited to 'src/fe-gtk/menu.c') diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index a454b43d..a2763771 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -27,7 +27,7 @@ #endif #ifdef WIN32 #include -#define _INC_DIRENT +#define _INC_DIRENT /* disable inclusion of perl's dirent.h, we use an own version for win32 */ #include "../../src/common/dirent.h" #else #include diff --git a/plugins/perl/perl.def b/plugins/perl/perl.def new file mode 100644 index 00000000..a2ec6566 --- /dev/null +++ b/plugins/perl/perl.def @@ -0,0 +1,4 @@ +EXPORTS + xchat_plugin_init + xchat_plugin_deinit + xchat_plugin_get_info \ No newline at end of file diff --git a/plugins/python/python.c b/plugins/python/python.c index 55adf989..3c535057 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -55,8 +55,14 @@ #include #include #include + +#ifdef WIN32 #include "../../src/common/dirent.h" #include "../../config.h" +#else +#include +#include +#endif #include "xchat-plugin.h" #include "Python.h" diff --git a/plugins/tcl/tclplugin.c b/plugins/tcl/tclplugin.c index 9289d01d..920a48ad 100644 --- a/plugins/tcl/tclplugin.c +++ b/plugins/tcl/tclplugin.c @@ -32,6 +32,8 @@ static char RCSID[] = "$Id: tclplugin.c,v 1.64 2010/03/10 04:24:16 mooooooo Exp #include #define bzero(mem, sz) memset((mem), 0, (sz)) #define bcopy(src, dest, count) memmove((dest), (src), (count)) +#else +#include #endif #include "xchat-plugin.h" diff --git a/plugins/xdcc/xdcc.c b/plugins/xdcc/xdcc.c index a8fda540..060dbbe3 100644 --- a/plugins/xdcc/xdcc.c +++ b/plugins/xdcc/xdcc.c @@ -5,6 +5,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat-plugin.h" #include "../../src/common/xchat.h" diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 22ef00d7..130ad9d9 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -29,11 +29,12 @@ #include "fe.h" #include "text.h" #include "xchatc.h" -#include "wdkutil.h" #ifndef WIN32 +#include #define XCHAT_DIR ".xchat2" #endif + #define DEF_FONT "Monospace 9" void @@ -402,7 +403,9 @@ const struct prefs vars[] = { {"dcc_blocksize", P_OFFINT (dcc_blocksize), TYPE_INT}, {"dcc_completed_dir", P_OFFSET (dcc_completed_dir), TYPE_STR}, {"dcc_dir", P_OFFSET (dccdir), TYPE_STR}, - /* {"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL}, */ +#ifndef WIN32 + {"dcc_fast_send", P_OFFINT (fastdccsend), TYPE_BOOL}, +#endif {"dcc_global_max_get_cps", P_OFFINT (dcc_global_max_get_cps), TYPE_INT}, {"dcc_global_max_send_cps", P_OFFINT (dcc_global_max_send_cps), TYPE_INT}, {"dcc_ip", P_OFFSET (dcc_ip_str), TYPE_STR}, @@ -440,7 +443,9 @@ const struct prefs vars[] = { {"gui_lagometer", P_OFFINT (lagometer), TYPE_INT}, {"gui_license", P_OFFSET (gui_license), TYPE_STR}, {"gui_mode_buttons", P_OFFINT (chanmodebuttons), TYPE_BOOL}, +#ifdef WIN32 {"gui_one_instance", P_OFFINT (gui_one_instance), TYPE_BOOL}, +#endif {"gui_pane_left_size", P_OFFINT (gui_pane_left_size), TYPE_INT}, {"gui_pane_right_size", P_OFFINT (gui_pane_right_size), TYPE_INT}, {"gui_quit_dialog", P_OFFINT (gui_quit_dialog), TYPE_BOOL}, @@ -547,7 +552,9 @@ const struct prefs vars[] = { {"tab_chans", P_OFFINT (tabchannels), TYPE_BOOL}, {"tab_dialogs", P_OFFINT (privmsgtab), TYPE_BOOL}, +#ifdef WIN32 {"tab_icons", P_OFFINT (tab_icons), TYPE_BOOL}, +#endif {"tab_layout", P_OFFINT (tab_layout), TYPE_INT}, {"tab_new_to_front", P_OFFINT (newtabstofront), TYPE_INT}, {"tab_notices", P_OFFINT (notices_tabs), TYPE_BOOL}, @@ -558,14 +565,18 @@ const struct prefs vars[] = { {"tab_sort", P_OFFINT (tab_sort), TYPE_BOOL}, {"tab_trunc", P_OFFINT (truncchans), TYPE_INT}, {"tab_utils", P_OFFINT (windows_as_tabs), TYPE_BOOL}, +#ifdef WIN32 {"tab_xp", P_OFFINT (tab_xp), TYPE_BOOL}, +#endif {"text_auto_copy_color", P_OFFINT (autocopy_color), TYPE_BOOL}, {"text_auto_copy_stamp", P_OFFINT (autocopy_stamp), TYPE_BOOL}, {"text_auto_copy_text", P_OFFINT (autocopy_text), TYPE_BOOL}, {"text_background", P_OFFSET (background), TYPE_STR}, {"text_color_nicks", P_OFFINT (colorednicks), TYPE_BOOL}, +#ifdef WIN32 {"text_emoticons", P_OFFINT (emoticons), TYPE_BOOL}, +#endif {"text_font", P_OFFSET (font_normal), TYPE_STR}, {"text_indent", P_OFFINT (indent_nicks), TYPE_BOOL}, {"text_max_indent", P_OFFINT (max_auto_indent), TYPE_INT}, @@ -642,7 +653,9 @@ load_config (void) prefs.indent_nicks = 1; prefs.thin_separator = 1; prefs._tabs_position = 2; /* 2 = left */ - /* prefs.fastdccsend = 1; */ +#ifndef WIN32 + prefs.fastdccsend = 1; +#endif prefs.wordwrap = 1; prefs.autosave = 1; prefs.autodialog = 1; @@ -667,7 +680,6 @@ load_config (void) prefs.dialog_height = 256; prefs.gui_join_dialog = 1; prefs.gui_quit_dialog = 1; - prefs.slist_skip = 1; prefs.dcctimeout = 180; prefs.dccstalltimeout = 60; prefs.notify_timeout = 15; diff --git a/src/common/chanopt.c b/src/common/chanopt.c index ce37157a..f8e16e8b 100644 --- a/src/common/chanopt.c +++ b/src/common/chanopt.c @@ -8,6 +8,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include "cfgfiles.h" diff --git a/src/common/ctcp.c b/src/common/ctcp.c index 37392372..2bb75746 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -20,6 +20,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include "cfgfiles.h" #include "util.h" @@ -133,8 +137,13 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, if (!strcasecmp (msg, "VERSION") && !prefs.hidever) { +#ifdef WIN32 snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" [x%d] / %s", get_cpu_arch (), get_cpu_str ()); +#else + snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" %s", + get_cpu_str ()); +#endif serv->p_nctcp (serv, nick, outbuf); } diff --git a/src/common/dcc.c b/src/common/dcc.c index 9375095e..d91b7e8e 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -40,6 +40,8 @@ #ifdef WIN32 #include +#else +#include #endif #include "xchat.h" @@ -56,7 +58,9 @@ #ifdef USE_DCC64 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10) +#ifdef WIN32 #define stat _stat64 +#endif #else #define BIG_STR_TO_INT(x) strtoul(x,NULL,10) #endif @@ -1983,7 +1987,9 @@ is_same_file (struct DCC *dcc, struct DCC *new_dcc) return TRUE; /* now handle case-insensitive Filesystems: HFS+, FAT */ -#ifndef WIN32 +#ifdef WIN32 + /* warning no win32 implementation - behaviour may be unreliable */ +#else /* this fstat() shouldn't really fail */ if ((dcc->fp == -1 ? stat (dcc->destfile_fs, &st_a) : fstat (dcc->fp, &st_a)) == -1) return FALSE; diff --git a/src/common/ignore.c b/src/common/ignore.c index adb61f37..0ed23daa 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -23,6 +23,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include "ignore.h" #include "cfgfiles.h" diff --git a/src/common/inbound.c b/src/common/inbound.c index 3485dfd4..bd7252c5 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -23,6 +23,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #define WANTARPA #define WANTDNS #include "inet.h" diff --git a/src/common/makefile.mak b/src/common/makefile.mak index 424316c0..8b350efc 100644 --- a/src/common/makefile.mak +++ b/src/common/makefile.mak @@ -25,7 +25,6 @@ tree.obj \ url.obj \ userlist.obj \ util.obj \ -wdkutil.obj \ xchat.obj all: $(COMMON_OBJECTS) xchatcommon.lib dirent.lib diff --git a/src/common/msproxy.c b/src/common/msproxy.c index 8ad37ffc..5103233a 100644 --- a/src/common/msproxy.c +++ b/src/common/msproxy.c @@ -28,6 +28,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #define WANTSOCKET #define WANTARPA #include "inet.h" diff --git a/src/common/network.c b/src/common/network.c index b7d9aa1f..eba24b05 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -23,6 +23,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "../../config.h" /* grab USE_IPV6 and LOOKUPD defines */ #define WANTSOCKET diff --git a/src/common/notify.c b/src/common/notify.c index 4aa5ea17..9c6e54de 100644 --- a/src/common/notify.c +++ b/src/common/notify.c @@ -24,6 +24,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include "notify.h" #include "cfgfiles.h" diff --git a/src/common/outbound.c b/src/common/outbound.c index 917562b9..8b0432ec 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -30,6 +30,7 @@ #ifndef WIN32 #include +#include #endif #include @@ -2880,6 +2881,7 @@ cmd_recv (struct session *sess, char *tbuf, char *word[], char *word_eol[]) return FALSE; } +#if 0 /* manual command for flushing prefs to disk, but we use an autosave-upon-set approach instead */ static int cmd_saveconf (struct session *sess, char *tbuf, char *word[], char *word_eol[]) { @@ -2894,6 +2896,7 @@ cmd_saveconf (struct session *sess, char *tbuf, char *word[], char *word_eol[]) return TRUE; } +#endif static int cmd_say (struct session *sess, char *tbuf, char *word[], char *word_eol[]) @@ -3647,7 +3650,9 @@ const struct commands xc_cmds[] = { #endif {"RECV", cmd_recv, 1, 0, 1, N_("RECV , send raw data to xchat, as if it was received from the irc server")}, - /*{"SAVECONF", cmd_saveconf, 0, 0, 1, N_("SAVECONF, saves the current settings to disk")},*/ +#if 0 + {"SAVECONF", cmd_saveconf, 0, 0, 1, N_("SAVECONF, saves the current settings to disk")}, +#endif {"SAY", cmd_say, 0, 0, 1, N_("SAY , sends the text to the object in the current window")}, {"SEND", cmd_send, 0, 0, 1, N_("SEND []")}, diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c index 2524439d..f09074a8 100644 --- a/src/common/plugin-timer.c +++ b/src/common/plugin-timer.c @@ -1,7 +1,7 @@ #include #include #include -#include "../../plugins/xchat-plugin.h" +#include "xchat-plugin.h" #ifdef WIN32 #define strcasecmp stricmp diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 3d45e1b0..91a57abe 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -24,6 +24,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include "ctcp.h" #include "fe.h" diff --git a/src/common/server.c b/src/common/server.c index f7347052..cdd67cda 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -36,6 +36,7 @@ #ifndef WIN32 #include #include +#include #else #include #endif @@ -1763,7 +1764,11 @@ server_connect (server *serv, char *hostname, int port, int no_login) } #endif serv->childpid = pid; +#ifdef WIN32 serv->iotag = fe_input_add (serv->childread, FIA_READ|FIA_FD, server_read_child, +#else + serv->iotag = fe_input_add (serv->childread, FIA_READ, server_read_child, +#endif serv); } diff --git a/src/common/servlist.c b/src/common/servlist.c index 1ca63201..a94c260a 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -22,6 +22,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "xchat.h" #include diff --git a/src/common/text.c b/src/common/text.c index fcde5870..fd5d25e9 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -25,6 +25,11 @@ #include #include +#ifndef WIN32 +#include +#include +#endif + #include "xchat.h" #include #include "cfgfiles.h" @@ -270,6 +275,12 @@ scrollback_load (session *sess) time_t stamp; int lines; +#ifndef WIN32 + char *map, *end_map; + struct stat statbuf; + const char *begin, *eol; +#endif + if (sess->text_scrollback == SET_DEFAULT) { if (!prefs.text_replay) @@ -288,6 +299,65 @@ scrollback_load (session *sess) if (fh == -1) return; +#ifndef WIN32 + if (fstat (fh, &statbuf) < 0) + return; + + map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0); + if (map == MAP_FAILED) + return; + + end_map = map + statbuf.st_size; + + lines = 0; + begin = map; + while (begin < end_map) + { + int n_bytes; + + eol = memchr (begin, '\n', end_map - begin); + + if (!eol) + eol = end_map; + + n_bytes = MIN (eol - begin, sizeof (buf) - 1); + + strncpy (buf, begin, n_bytes); + + buf[n_bytes] = 0; + + if (buf[0] == 'T') + { + if (sizeof (time_t) == 4) + stamp = strtoul (buf + 2, NULL, 10); + else + stamp = strtoull (buf + 2, NULL, 10); /* just incase time_t is 64 bits */ + text = strchr (buf + 3, ' '); + if (text) + { + text = strip_color (text + 1, -1, STRIP_COLOR); + fe_print_text (sess, text, stamp); + g_free (text); + } + lines++; + } + + begin = eol + 1; + } + + sess->scrollwritten = lines; + + if (lines) + { + text = ctime (&stamp); + text[24] = 0; /* get rid of the \n */ + snprintf (buf, sizeof (buf), "\n*\t%s %s\n\n", _("Loaded log from"), text); + fe_print_text (sess, buf, 0); + /*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/ + } + + munmap (map, statbuf.st_size); +#else lines = 0; while (waitline (fh, buf, sizeof buf, FALSE) != -1) { @@ -318,6 +388,7 @@ scrollback_load (session *sess) fe_print_text (sess, buf, 0); /*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/ } +#endif close (fh); } diff --git a/src/common/util.c b/src/common/util.c index c16d41f5..ccc48657 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -27,17 +27,21 @@ #include #include #include + #ifdef WIN32 #include #include +#include +#include "dirent.h" #else -#include +#include #include #include #include +#include #endif + #include -#include "dirent.h" #include #include "xchat.h" #include "xchatc.h" @@ -1848,3 +1852,37 @@ canonalize_key (char *key) } } } + +int +portable_mode () +{ +#ifdef WIN32 + if ((_access( "portable-mode", 0 )) != -1) + { + return 1; + } + else + { + return 0; + } +#else + return 0; +#endif +} + +int +xtray_mode () +{ +#ifdef WIN32 + if ((_access( "plugins/xtray.dll", 0 )) != -1) + { + return 1; + } + else + { + return 0; + } +#else + return 0; +#endif +} diff --git a/src/common/util.h b/src/common/util.h index bee6ec3c..82d74366 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -57,5 +57,7 @@ guint32 str_hash (const char *key); guint32 str_ihash (const unsigned char *key); void safe_strcpy (char *dest, const char *src, int bytes_left); void canonalize_key (char *key); +int portable_mode (); +int xtray_mode (); #endif diff --git a/src/common/wdkutil.c b/src/common/wdkutil.c deleted file mode 100644 index 5bf4f0c0..00000000 --- a/src/common/wdkutil.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -int -portable_mode () -{ - if ((_access( "portable-mode", 0 )) != -1) - { - return 1; - } - else - { - return 0; - } -} - -int -xtray_mode () -{ - if ((_access( "plugins/xtray.dll", 0 )) != -1) - { - return 1; - } - else - { - return 0; - } -} diff --git a/src/common/wdkutil.h b/src/common/wdkutil.h deleted file mode 100644 index 2e4c693a..00000000 --- a/src/common/wdkutil.h +++ /dev/null @@ -1,2 +0,0 @@ -int portable_mode (); -int xtray_mode (); diff --git a/src/common/xchat.c b/src/common/xchat.c index c0847a32..22c4eddb 100644 --- a/src/common/xchat.c +++ b/src/common/xchat.c @@ -31,6 +31,7 @@ #else #include #include +#include #endif #include "xchat.h" @@ -39,7 +40,7 @@ #include "cfgfiles.h" #include "chanopt.h" #include "ignore.h" -#include "../../plugins/xchat-plugin.h" +#include "xchat-plugin.h" #include "plugin.h" #include "plugin-timer.h" #include "notify.h" @@ -49,7 +50,6 @@ #include "text.h" #include "url.h" #include "xchatc.h" -#include "wdkutil.h" #ifdef USE_OPENSSL #include /* SSL_() */ diff --git a/src/common/xchat.h b/src/common/xchat.h index 08177e20..91e2d50e 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -186,7 +186,9 @@ struct xchatprefs int gui_usermenu; int gui_join_dialog; int gui_quit_dialog; +#ifdef WIN32 int gui_one_instance; +#endif int dialog_left; int dialog_top; int dialog_width; @@ -304,10 +306,12 @@ struct xchatprefs unsigned int wait_on_exit; unsigned int confmode; unsigned int utf8_locale; +#ifdef WIN32 unsigned int identd; unsigned int emoticons; unsigned int tab_icons; unsigned int tab_xp; +#endif unsigned int ctcp_number_limit; /*flood */ unsigned int ctcp_time_limit; /*seconds of floods */ diff --git a/src/fe-gtk/about.c b/src/fe-gtk/about.c index a5772e39..41f3c09b 100644 --- a/src/fe-gtk/about.c +++ b/src/fe-gtk/about.c @@ -39,7 +39,6 @@ #include "../common/xchat.h" #include "../common/util.h" -#include "../common/wdkutil.h" #include "../common/xchatc.h" #include "palette.h" #include "pixmaps.h" @@ -71,7 +70,7 @@ menu_about (GtkWidget * wid, gpointer sess) "(C) 1998-2005 Peter Zelezny", author, buf, 0)); } -#else +#endif static GtkWidget *about = 0; @@ -171,4 +170,3 @@ menu_about (GtkWidget * wid, gpointer sess) gtk_widget_show_all (about); } -#endif diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c index a714d186..fecb62a5 100644 --- a/src/fe-gtk/banlist.c +++ b/src/fe-gtk/banlist.c @@ -22,6 +22,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index 6203083b..4dca935b 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -22,6 +22,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include diff --git a/src/fe-gtk/editlist.c b/src/fe-gtk/editlist.c index fd2d6810..d374d064 100644 --- a/src/fe-gtk/editlist.c +++ b/src/fe-gtk/editlist.c @@ -22,6 +22,11 @@ #include #include #include + +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index c11f5235..88a1138c 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -31,7 +31,11 @@ #include #include +#ifdef WIN32 #include +#else +#include +#endif #include "../common/xchat.h" #include "../common/fe.h" @@ -411,7 +415,7 @@ log_handler (const gchar *log_domain, { session *sess; - /* if (getenv ("XCHAT_WARNING_IGNORE")) */ + /* if (getenv ("XCHAT_WARNING_IGNORE")) this gets ignored sometimes, so simply just disable all warnings */ return; sess = find_dialog (serv_list->data, "(warnings)"); diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index 7330854a..b9690731 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -24,6 +24,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include @@ -314,7 +318,7 @@ key_handle_key_press (GtkWidget *wid, GdkEventKey *evt, session *sess) key_action_tab_clean (); break; -#if defined(USE_GTKSPELL)/* && !defined(WIN32) +#if defined(USE_GTKSPELL)/* && !defined(WIN32) */ /* gtktextview has no 'activate' event, so we trap ENTER here */ case GDK_Return: case GDK_KP_Enter: diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index 522b44df..fe4e1737 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -23,6 +23,7 @@ #include #include #include + #include "fe-gtk.h" #include @@ -50,9 +51,12 @@ #include "../common/util.h" #include "gtkutil.h" #include "pixmaps.h" + #ifdef WIN32 #include "../common/fe.h" #include "../common/thread.h" +#else +#include #endif /* gtkutil.c, just some gtk wrappers */ diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c index 6cd812cf..e645f0bc 100644 --- a/src/fe-gtk/joind.c +++ b/src/fe-gtk/joind.c @@ -12,6 +12,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include #include #include diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 74157a7f..28cf46a9 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -53,7 +53,8 @@ #include "../common/plugin.h" #include "../common/modes.h" #include "../common/url.h" -#include "../common/wdkutil.h" +#include "../common/util.h" + #include "fe-gtk.h" #include "banlist.h" #include "gtkutil.h" diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 90c784f0..e6a5eca0 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -23,6 +23,8 @@ #ifdef WIN32 #include +#else +#include #endif #include "fe-gtk.h" @@ -1121,6 +1123,7 @@ usermenu_update (void) } } +#if 0 static void menu_saveconf (void) { @@ -1135,6 +1138,7 @@ menu_saveconf (void) PrintText (sess, "Error saving settings.\n"); } } +#endif static void menu_newserver_window (GtkWidget * wid, gpointer none) @@ -1653,7 +1657,9 @@ static struct mymenu mymenu[] = { {N_("Userlist Popup..."), menu_ulpopup, 0, M_MENUITEM, 0, 0, 1}, {0, 0, 0, M_END, 0, 0, 0}, /* 53 */ - /* {N_("Save Settings to Disk"), menu_saveconf, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, don't use this, a /set auto-save approach will be added instead */ +#if 0 + {N_("Save Settings to Disk"), menu_saveconf, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, /* don't use this, a /set auto-save approach will be added instead */ +#endif {N_("_Window"), 0, 0, M_NEWMENU, 0, 0, 1}, {N_("Ban List..."), menu_banlist, 0, M_MENUITEM, 0, 0, 1}, diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index b94ac874..104700c2 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -22,6 +22,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include "palette.h" diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 62a726a4..b9f60f8d 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -1,20 +1,23 @@ /* Copyright (C) 2006-2007 Peter Zelezny. */ #include -#include "../../plugins/xchat-plugin.h" +#include "../common/xchat-plugin.h" #include "../common/xchat.h" #include "../common/xchatc.h" #include "../common/inbound.h" #include "../common/server.h" #include "../common/fe.h" #include "../common/util.h" -#include "../common/wdkutil.h" #include "fe-gtk.h" #include "pixmaps.h" #include "maingui.h" #include "menu.h" #include +#ifndef WIN32 +#include +#endif + #ifdef USE_LIBNOTIFY #include #ifndef NOTIFY_CHECK_VERSION @@ -510,7 +513,7 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); -#if 0 +#ifndef WIN32 /* somehow this is broken on win32 */ submenu = mg_submenu (menu, _("_Blink on")); blink_item (&prefs.input_tray_chans, submenu, _("Channel Message")); blink_item (&prefs.input_tray_priv, submenu, _("Private Message")); @@ -528,6 +531,7 @@ tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); #endif + mg_create_icon_item (_("_Quit"), GTK_STOCK_QUIT, menu, tray_menu_quit_cb, NULL); menu_add_plugin_items (menu, "\x5$TRAY", NULL); @@ -553,8 +557,12 @@ tray_init (void) sticon = gtk_status_icon_new_from_pixbuf (ICON_NORMAL); if (!sticon) return; - /* g_signal_connect (G_OBJECT (sticon), "popup-menu", - G_CALLBACK (tray_menu_cb), sticon); */ + +#ifndef WIN32 + g_signal_connect (G_OBJECT (sticon), "popup-menu", + G_CALLBACK (tray_menu_cb), sticon); +#endif + g_signal_connect (G_OBJECT (sticon), "activate", G_CALLBACK (tray_menu_restore_cb), NULL); } diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 0edfc62b..71d2f02e 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -35,7 +35,7 @@ #include "../common/xchat.h" #define PLUGIN_C typedef struct session xchat_context; -#include "../../plugins/xchat-plugin.h" +#include "../common/xchat-plugin.h" #include "../common/plugin.h" #include "../common/util.h" #include "../common/outbound.h" @@ -146,10 +146,13 @@ plugingui_load_cb (session *sess, char *file) void plugingui_load (void) { - gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, - current_sess, + gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, +#ifdef WIN32 "Plugins and Scripts\0*.dll;*.lua;*.pl;*.py;*.tcl\0" "All files\0*.*\0\0", 0); +#else + NULL, FRF_ADDFOLDER); +#endif } static void diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index a3e1a63b..593468c1 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -21,6 +21,10 @@ #include #include +#ifndef WIN32 +#include +#endif + #include "fe-gtk.h" #include diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 5b242508..1f1be0b4 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -14,7 +14,6 @@ #include "../common/text.h" #include "../common/userlist.h" #include "../common/util.h" -#include "../common/wdkutil.h" #include "../common/xchatc.h" #include "fe-gtk.h" #include "gtkutil.h" @@ -111,7 +110,7 @@ static const setting textbox_settings[] = {ST_TOGGLR, N_("Indent nick names"), P_OFFINTNL(indent_nicks), N_("Make nick names right-justified"),0,0}, {ST_TOGGLE, N_("Transparent background"), P_OFFINTNL(transparent),0,0,0}, - {ST_TOGGLE, N_("Show marker line"), P_OFFINTNL(show_marker), + {ST_TOGGLR, N_("Show marker line"), P_OFFINTNL(show_marker), N_("Insert a red line after the last read text."),0,0}, {ST_HEADER, N_("Transparency Settings"), 0,0,0}, {ST_HSCALE, N_("Red:"), P_OFFINTNL(tint_red),0,0,0}, @@ -153,7 +152,11 @@ static const setting inputbox_settings[] = #if defined(USE_GTKSPELL) || defined(USE_LIBSEXY) {ST_TOGGLE, N_("Spell checking"), P_OFFINTNL(gui_input_spell),0,0,0}, {ST_ENTRY, N_("Dictionaries to use:"), P_OFFSETNL(spell_langs),0,0,sizeof prefs.spell_langs}, +#ifdef WIN32 {ST_LABEL, N_("Use language codes (as in \"share\\myspell\\dicts\").\nSeparate multiple entries with commas.")}, +#else + {ST_LABEL, N_("Use language codes. Separate multiple entries with commas.")}, +#endif #endif {ST_HEADER, N_("Nick Completion"),0,0,0}, @@ -413,6 +416,7 @@ static const setting advanced_settings[] = {ST_END, 0, 0, 0, 0, 0} }; +#ifdef WIN32 static const setting advanced_settings_oneinstance[] = { {ST_HEADER, N_("Advanced Settings"),0,0,0}, @@ -429,6 +433,7 @@ static const setting advanced_settings_oneinstance[] = {ST_END, 0, 0, 0, 0, 0} }; +#endif static const setting logging_settings[] = { @@ -1797,6 +1802,7 @@ setup_create_pages (GtkWidget *box) setup_add_page (cata[10], book, setup_create_page (logging_settings)); setup_add_page (cata[11], book, setup_create_sound_page ()); +#ifdef WIN32 if (portable_mode ()) { setup_add_page (cata[12], book, setup_create_page (advanced_settings)); @@ -1805,6 +1811,9 @@ setup_create_pages (GtkWidget *box) { setup_add_page (cata[12], book, setup_create_page (advanced_settings_oneinstance)); } +#else + setup_add_page (cata[12], book, setup_create_page (advanced_settings)); +#endif setup_add_page (cata[14], book, setup_create_page (network_settings)); setup_add_page (cata[15], book, setup_create_page (filexfer_settings)); diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 8f21e977..9483f04b 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -33,7 +33,9 @@ #include "sexy-iso-codes.h" #include "sexy-marshal.h" +#ifdef WIN32 #include "typedef.h" +#endif #include "../common/cfgfiles.h" #include "../common/xchatc.h" @@ -141,9 +143,18 @@ initialize_enchant () GModule *enchant; gpointer funcptr; +#ifdef WIN32 enchant = g_module_open("libenchant.dll", 0); +#else + enchant = g_module_open("libenchant", 0); +#endif if (enchant == NULL) { +#ifndef WIN32 + enchant = g_module_open("libenchant.so.1", 0); + if (enchant == NULL) + return; +#endif return; } diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 5a83062b..3bc9b6a8 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -74,6 +74,8 @@ #ifdef WIN32 #include #include +#else +#include #endif /* is delimiter */ -- cgit 1.4.1 From a6cc734b3802846f6ffd1cb1123bf4ca978e6056 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Mon, 28 May 2012 23:17:09 +0200 Subject: Search window improvements (Richard Hitt) --- src/common/cfgfiles.c | 8 + src/common/xchat.h | 6 + src/fe-gtk/maingui.c | 7 +- src/fe-gtk/menu.c | 47 ++- src/fe-gtk/search.c | 120 ++++++-- src/fe-gtk/xtext.c | 800 +++++++++++++++++++++++++++++++++++++++++--------- src/fe-gtk/xtext.h | 19 +- 7 files changed, 850 insertions(+), 157 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 443538d2..6bbdb3f7 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -451,6 +451,7 @@ const struct prefs vars[] = { #endif {"gui_pane_left_size", P_OFFINT (gui_pane_left_size), TYPE_INT}, {"gui_pane_right_size", P_OFFINT (gui_pane_right_size), TYPE_INT}, + {"gui_pane_right_size_min", P_OFFINT (gui_pane_right_size_min), TYPE_INT}, {"gui_quit_dialog", P_OFFINT (gui_quit_dialog), TYPE_BOOL}, {"gui_slist_fav", P_OFFINT (slist_fav), TYPE_INT}, {"gui_slist_select", P_OFFINT (slist_select), TYPE_INT}, @@ -589,6 +590,11 @@ const struct prefs vars[] = { {"text_max_indent", P_OFFINT (max_auto_indent), TYPE_INT}, {"text_max_lines", P_OFFINT (max_lines), TYPE_INT}, {"text_replay", P_OFFINT (text_replay), TYPE_BOOL}, + {"text_search_case_match", P_OFFINT (text_search_case_match), TYPE_BOOL}, + {"text_search_backward", P_OFFINT (text_search_backward), TYPE_BOOL}, + {"text_search_highlight_all", P_OFFINT (text_search_highlight_all), TYPE_BOOL}, + {"text_search_follow", P_OFFINT (text_search_follow), TYPE_BOOL}, + {"text_search_regexp", P_OFFINT (text_search_regexp), TYPE_BOOL}, {"text_show_marker", P_OFFINT (show_marker), TYPE_BOOL}, {"text_show_sep", P_OFFINT (show_separator), TYPE_BOOL}, {"text_spell_langs", P_OFFSET (spell_langs), TYPE_STR}, @@ -715,6 +721,7 @@ load_config (void) prefs.gui_tray = 1; prefs.gui_pane_left_size = 100; prefs.gui_pane_right_size = 100; + prefs.gui_pane_right_size_min = 80; prefs.mainwindow_save = 1; prefs.bantype = 2; prefs.input_balloon_time = 20; @@ -723,6 +730,7 @@ load_config (void) prefs.autodccsend = 2; /* browse mode */ prefs.url_grabber = 1; prefs.url_grabber_limit = 0; /* 0 means unlimited for backcompat */ + prefs.text_search_follow = 1; #ifdef WIN32 prefs.identd = 1; #endif diff --git a/src/common/xchat.h b/src/common/xchat.h index 95fb1324..9db44c3f 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -162,6 +162,7 @@ struct xchatprefs int gui_pane_left_size; int gui_pane_right_size; + int gui_pane_right_size_min; int gui_ulist_pos; int tab_pos; @@ -327,6 +328,11 @@ struct xchatprefs This is so that we continue using internal defaults (which can change in the next release) until the user edits them. */ unsigned int save_pevents:1; + unsigned int text_search_case_match; + unsigned int text_search_backward; + unsigned int text_search_highlight_all; + unsigned int text_search_follow; + unsigned int text_search_regexp; }; /* Session types */ diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 31f9fbc5..0b7f7c43 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -800,6 +800,9 @@ mg_userlist_showhide (session *sess, int show) { session_gui *gui = sess->gui; int handle_size; + int right_size; + + right_size = MAX (prefs.gui_pane_right_size, prefs.gui_pane_right_size_min); if (show) { @@ -807,7 +810,7 @@ mg_userlist_showhide (session *sess, int show) gui->ul_hidden = 0; gtk_widget_style_get (GTK_WIDGET (gui->hpane_right), "handle-size", &handle_size, NULL); - gtk_paned_set_position (GTK_PANED (gui->hpane_right), GTK_WIDGET (gui->hpane_right)->allocation.width - (prefs.gui_pane_right_size + handle_size)); + gtk_paned_set_position (GTK_PANED (gui->hpane_right), GTK_WIDGET (gui->hpane_right)->allocation.width - (right_size + handle_size)); } else { @@ -2848,7 +2851,7 @@ mg_create_entry (session *sess, GtkWidget *box) #else gui->input_box = entry = gtk_entry_new (); #endif - gtk_entry_set_max_length (GTK_ENTRY (gui->input_box), 2048); + gtk_entry_set_max_length (GTK_ENTRY (gui->input_box), 0); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (mg_inputbox_cb), gui); gtk_container_add (GTK_CONTAINER (hbox), entry); diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index e6a5eca0..4760ba93 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -1215,6 +1215,41 @@ menu_search () search_open (current_sess); } +static void +menu_search_next () +{ + GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext); + xtext_buffer *buf = xtext->buffer; + + if (!gtk_xtext_search (xtext, buf->search_text, + (buf->search_flags & (case_match | follow | regexp)), NULL)) + { + fe_message (_("Search hit end, not found."), FE_MSG_ERROR); + } +} + +static void +menu_search_prev () +{ + GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext); + xtext_buffer *buf = xtext->buffer; + + if (!gtk_xtext_search(xtext, buf->search_text, + (buf->search_flags & (case_match | follow | regexp) | backward), NULL)) + { + fe_message (_("Search hit end, not found."), FE_MSG_ERROR); + } +} + +static void +menu_search_reset () +{ + GtkXText *xtext = GTK_XTEXT (current_sess->gui->xtext); + xtext_buffer *buf = xtext->buffer; + + gtk_xtext_search (xtext, "", 0, NULL); +} + static void menu_resetmarker (GtkWidget * wid, gpointer none) { @@ -1675,11 +1710,17 @@ static struct mymenu mymenu[] = { {N_("Reset Marker Line"), menu_resetmarker, 0, M_MENUITEM, 0, 0, 1, GDK_m}, {N_("_Copy Selection"), menu_copy_selection, 0, M_MENUITEM, 0, 0, 1, GDK_C}, {N_("C_lear Text"), menu_flushbuffer, GTK_STOCK_CLEAR, M_MENUSTOCK, 0, 0, 1, GDK_l}, -#define SEARCH_OFFSET 68 - {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, {N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0, 1}, +#define SEARCH_OFFSET 70 + {N_("Search"), 0, GTK_STOCK_JUSTIFY_LEFT, M_MENUSUB, 0, 0, 1}, + {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_f}, + {N_("Reset Search"), menu_search_reset, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_F}, + {N_("Search Next" ), menu_search_next, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_g}, + {N_("Search Previous" ), menu_search_prev, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_G}, + {0, 0, 0, M_END, 0, 0, 0}, + + {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 74 */ - {N_("_Help"), 0, 0, M_NEWMENU, 0, 0, 1}, /* 70 */ {N_("_Contents"), menu_docs, GTK_STOCK_HELP, M_MENUSTOCK, 0, 0, 1, GDK_F1}, #if 0 {N_("Check for updates"), menu_update, 0, M_MENUITEM, 0, 1}, diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c index bbde9c5c..30ef266f 100644 --- a/src/fe-gtk/search.c +++ b/src/fe-gtk/search.c @@ -42,15 +42,20 @@ #include "xtext.h" #include "maingui.h" - -static textentry *last; /* our last search pos */ -static int case_match = 0; -static int search_backward = 0; - +GtkWidget *searchwin; static void search_search (session * sess, const gchar *text) { + gtk_xtext_search_flags flags; + textentry *last; + GError *err = NULL; + + flags = ((prefs.text_search_case_match == 1? case_match: 0) | + (prefs.text_search_backward == 1? backward: 0) | + (prefs.text_search_highlight_all == 1? highlight: 0) | + (prefs.text_search_follow == 1? follow: 0) | + (prefs.text_search_regexp == 1? regexp: 0)); if (!is_session (sess)) { fe_message (_("The window you opened this Search " @@ -58,10 +63,20 @@ search_search (session * sess, const gchar *text) return; } - last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, - last, case_match, search_backward); - if (!last) + last = gtk_xtext_search (GTK_XTEXT (sess->gui->xtext), text, flags, &err); + if (text == NULL || text[0] == 0) + { + return; + } + if (err) + { + fe_message (_(err->message), FE_MSG_ERROR); + g_error_free (err); + } + else if (!last) + { fe_message (_("Search hit end, not found."), FE_MSG_ERROR); + } } static void @@ -79,6 +94,23 @@ static void search_close_cb (GtkWidget * button, GtkWidget * win) { gtk_widget_destroy (win); + searchwin = NULL; +} + +static void +search_reset_cb (GtkWidget * button, session * sess) +{ + search_search (sess, ""); + if (searchwin) + { + search_close_cb (button, searchwin); + } +} + +static void +search_cleanup_cb (GtkWidget * button, GtkWidget * win) +{ + searchwin = NULL; } static void @@ -98,13 +130,26 @@ search_key_cb (GtkWidget * window, GdkEventKey * key, gpointer userdata) static void search_caseign_cb (GtkToggleButton * but, session * sess) { - case_match = (but->active)? 1: 0; + prefs.text_search_case_match = (but->active)? 1: 0; } static void search_dirbwd_cb (GtkToggleButton * but, session * sess) { - search_backward = (but->active)? 1: 0; + prefs.text_search_backward = (but->active)? 1: 0; +} + +static void +search_regexp_cb (GtkToggleButton * but, session * sess) +{ + prefs.text_search_regexp = (but->active)? 1: 0; +} + +static void +search_highlight_cb (GtkToggleButton * but, session * sess) +{ + prefs.text_search_highlight_all = (but->active)? 1: 0; + search_search (sess, NULL); } void @@ -112,18 +157,21 @@ search_open (session * sess) { GtkWidget *win, *hbox, *vbox, *entry, *wid; - last = NULL; + if (searchwin) + { + gtk_widget_destroy (searchwin); + searchwin = NULL; + } win = mg_create_generic_tab ("search", _("XChat: Search"), TRUE, FALSE, - NULL, NULL, 0, 0, &vbox, 0); + search_cleanup_cb, NULL, 0, 0, &vbox, 0); gtk_container_set_border_width (GTK_CONTAINER (win), 12); gtk_box_set_spacing (GTK_BOX (vbox), 4); + /* First line: _____________________ _Find */ hbox = gtk_hbox_new (0, 10); gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); - gtkutil_label_new (_("Find:"), hbox); - entry = gtk_entry_new (); g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (search_entry_cb), sess); @@ -131,29 +179,61 @@ search_open (session * sess) gtk_widget_show (entry); gtk_widget_grab_focus (entry); + wid = gtk_hbutton_box_new (); + gtk_container_add (GTK_CONTAINER (hbox), wid); + gtk_widget_show (wid); + wid = gtkutil_button (wid, GTK_STOCK_FIND, 0, search_find_cb, sess, + _("_Find")); + g_object_set_data (G_OBJECT (wid), "e", entry); + + /* Second line: X Match case */ wid = gtk_check_button_new_with_mnemonic (_("_Match case")); - GTK_TOGGLE_BUTTON (wid)->active = case_match; + GTK_TOGGLE_BUTTON (wid)->active = prefs.text_search_case_match; g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_caseign_cb), sess); gtk_container_add (GTK_CONTAINER (vbox), wid); + add_tip (wid, "Perform a case-sensitive search."); gtk_widget_show (wid); + /* Third line: X Search backwards */ wid = gtk_check_button_new_with_mnemonic (_("Search _backwards")); - GTK_TOGGLE_BUTTON (wid)->active = search_backward; + GTK_TOGGLE_BUTTON (wid)->active = prefs.text_search_backward; g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_dirbwd_cb), sess); gtk_container_add (GTK_CONTAINER (vbox), wid); + add_tip (wid, "Search from the newest text line to the oldest."); + gtk_widget_show (wid); + + /* Fourth line: X Highlight all */ + wid = gtk_check_button_new_with_mnemonic (_("_Highlight all")); + GTK_TOGGLE_BUTTON (wid)->active = prefs.text_search_highlight_all; + g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_highlight_cb), sess); + gtk_container_add (GTK_CONTAINER (vbox), wid); + add_tip (wid, "Highlight all occurrences, and underline the current occurrence."); gtk_widget_show (wid); + /* Fifth line: X Regular expression */ + wid = gtk_check_button_new_with_mnemonic (_("R_egular expression")); + GTK_TOGGLE_BUTTON (wid)->active = prefs.text_search_regexp; + g_signal_connect (G_OBJECT (wid), "toggled", G_CALLBACK (search_regexp_cb), sess); + gtk_container_add (GTK_CONTAINER (vbox), wid); + add_tip (wid, "Regard search string as a regular expression."); + gtk_widget_show (wid); + + /* Sixth line: _Close Close and _Reset */ hbox = gtk_hbutton_box_new (); gtk_box_pack_start (GTK_BOX (vbox), hbox, 0, 0, 4); gtk_widget_show (hbox); - gtkutil_button (hbox, GTK_STOCK_CLOSE, 0, search_close_cb, win, + wid = gtkutil_button (hbox, GTK_STOCK_CLOSE, 0, search_close_cb, win, _("_Close")); - wid = gtkutil_button (hbox, GTK_STOCK_FIND, 0, search_find_cb, sess, - _("_Find")); - g_object_set_data (G_OBJECT (wid), "e", entry); + add_tip (wid, "Close this box, but continue searching new lines."); + wid = gtkutil_button (hbox, "gtk-reset", 0, search_reset_cb, sess, + _("Close and _Reset")); + add_tip (wid, "Close this box, reset highlighted search items, and stop searching new lines."); + /* Add recognition of the ESC key to close the box */ g_signal_connect (G_OBJECT (win), "key_press_event", G_CALLBACK (search_key_cb), win); + /* That's all, folks */ + searchwin = win; gtk_widget_show (win); } diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 3bc9b6a8..2899ba68 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -65,6 +65,11 @@ #include "mmx_cmod.h" #endif +#include "../common/xchat.h" +#include "../common/fe.h" +#include "../common/util.h" +#include "../common/xchatc.h" +#include "fe-gtk.h" #include "xtext.h" #include "../common/xchat.h" #include "../common/xchatc.h" @@ -92,6 +97,20 @@ static GtkWidgetClass *parent_class = NULL; +/* + * offsets_t is used for retaining search information. + * It is stored in the 'data' member of a GList, + * as chained from ent->marks. It saves starting and + * ending+1 offset of a found occurrence. + */ +typedef union offsets_u { + struct offsets_s { + guint16 start; + guint16 end; + } o; + guint32 u; +} offsets_t; + struct textentry { struct textentry *next; @@ -111,6 +130,7 @@ struct textentry guchar tag; guchar pad1; guchar pad2; /* 32-bit align : 44 bytes total */ + GList *marks; /* List of found strings */ }; enum @@ -149,11 +169,25 @@ static void gtk_xtext_recalc_widths (xtext_buffer *buf, int); static void gtk_xtext_fix_indent (xtext_buffer *buf); static int gtk_xtext_find_subline (GtkXText *xtext, textentry *ent, int line); static char *gtk_xtext_conv_color (unsigned char *text, int len, int *newlen); +/* For use by gtk_xtext_strip_color() and its callers -- */ +typedef union offlen_u { + struct offlen_s { + guint16 off; + guint16 len; + } o; + guint32 u; +} offlen_t; static unsigned char * gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, - int *newlen, int *mb_ret, int strip_hidden); + int *newlen, int *mb_ret, GSList **slp, int strip_hidden); static gboolean gtk_xtext_check_ent_visibility (GtkXText * xtext, textentry *find_ent, int add); static int gtk_xtext_render_page_timeout (GtkXText * xtext); +static int gtk_xtext_search_offset (xtext_buffer *buf, textentry *ent, unsigned int off); +static void gtk_xtext_search_textentry (xtext_buffer *, textentry *, int); +static void gtk_xtext_search_textentry_del (xtext_buffer *, textentry *); +static void gtk_xtext_search_textentry_fini (gpointer, gpointer); +static void gtk_xtext_search_fini (xtext_buffer *); +static gboolean gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr); /* some utility functions first */ @@ -770,9 +804,8 @@ gtk_xtext_adjustment_set (xtext_buffer *buf, int fire_signal) if (adj->upper == 0) adj->upper = 1; - adj->page_size = - (GTK_WIDGET (buf->xtext)->allocation.height - - buf->xtext->font->descent) / buf->xtext->fontsize; + adj->page_size = GTK_WIDGET (buf->xtext)->allocation.height / + buf->xtext->fontsize; adj->page_increment = adj->page_size; if (adj->value > adj->upper - adj->page_size) @@ -1100,6 +1133,7 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation) xtext->avoid_trans = FALSE; + allocation->height = allocation->height / xtext->fontsize * xtext->fontsize; widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) { @@ -1129,18 +1163,6 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation) } } -static void -gtk_xtext_selection_clear_full (xtext_buffer *buf) -{ - textentry *ent = buf->text_first; - while (ent) - { - ent->mark_start = -1; - ent->mark_end = -1; - ent = ent->next; - } -} - static int gtk_xtext_selection_clear (xtext_buffer *buf) { @@ -1724,13 +1746,6 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren offset_end = tmp; } - /* has the selection changed? Dont render unless necessary */ - if (xtext->buffer->last_ent_start == ent_start && - xtext->buffer->last_ent_end == ent_end && - xtext->buffer->last_offset_start == offset_start && - xtext->buffer->last_offset_end == offset_end) - return; - /* set all the old mark_ fields to -1 */ gtk_xtext_selection_clear (xtext->buffer); @@ -1760,10 +1775,24 @@ gtk_xtext_selection_draw (GtkXText * xtext, GdkEventMotion * event, gboolean ren gtk_xtext_selection_render (xtext, ent_start, offset_start, ent_end, offset_end); } +static int +gtk_xtext_timeout_ms (GtkXText *xtext, int pixes) +{ + int apixes = abs(pixes); + + if (apixes < 6) return 100; + if (apixes < 12) return 50; + if (apixes < 20) return 20; + return 10; +} + static gint gtk_xtext_scrolldown_timeout (GtkXText * xtext) { int p_y, win_height; + xtext_buffer *buf = xtext->buffer; + GtkAdjustment *adj = xtext->adj; + textentry *ent; gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0); gdk_drawable_get_size (GTK_WIDGET (xtext)->window, 0, &win_height); @@ -1771,13 +1800,30 @@ gtk_xtext_scrolldown_timeout (GtkXText * xtext) if (p_y > win_height && xtext->adj->value < (xtext->adj->upper - xtext->adj->page_size)) { - xtext->adj->value++; - gtk_adjustment_changed (xtext->adj); - gtk_xtext_render_page (xtext); - return 1; + xtext->adj->value += buf->pagetop_ent->lines_taken; + ent = buf->last_ent_end->next; + if (ent) + { + gtk_adjustment_value_changed (xtext->adj); + } + else + { + buf->scrollbar_down = TRUE; + } + xtext->scroll_tag = g_timeout_add (gtk_xtext_timeout_ms (xtext, p_y - win_height), + (GSourceFunc) + gtk_xtext_scrolldown_timeout, + xtext); + xtext->select_start_y -= (adj->value - xtext->select_start_adj) * xtext->fontsize; + xtext->select_start_adj = adj->value; + gtk_xtext_selection_draw (xtext, NULL, TRUE); + gtk_xtext_render_ents (xtext, ent, buf->last_ent_end); + } + else + { + xtext->scroll_tag = 0; } - xtext->scroll_tag = 0; return 0; } @@ -1785,18 +1831,35 @@ static gint gtk_xtext_scrollup_timeout (GtkXText * xtext) { int p_y; + xtext_buffer *buf = xtext->buffer; + GtkAdjustment *adj = xtext->adj; + textentry *ent; gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0); - if (p_y < 0 && xtext->adj->value > 0.0) + if (p_y < 0 && adj->value >= 0) { - xtext->adj->value--; - gtk_adjustment_changed (xtext->adj); - gtk_xtext_render_page (xtext); - return 1; + buf->scrollbar_down = FALSE; + ent = buf->last_ent_start->prev; + if (ent) + { + adj->value -= ent->lines_taken; + gtk_adjustment_value_changed (adj); + } + xtext->select_start_y -= (adj->value - xtext->select_start_adj) * xtext->fontsize; + xtext->select_start_adj = adj->value; + gtk_xtext_selection_draw (xtext, NULL, TRUE); + gtk_xtext_render_ents (xtext, ent, buf->last_ent_end); + xtext->scroll_tag = g_timeout_add (gtk_xtext_timeout_ms (xtext, p_y), + (GSourceFunc) + gtk_xtext_scrollup_timeout, + xtext); + } + else + { + xtext->scroll_tag = 0; } - xtext->scroll_tag = 0; return 0; } @@ -1806,35 +1869,32 @@ gtk_xtext_selection_update (GtkXText * xtext, GdkEventMotion * event, int p_y, g int win_height; int moved; + if (xtext->scroll_tag) + { + return; + } + gdk_drawable_get_size (GTK_WIDGET (xtext)->window, 0, &win_height); /* selecting past top of window, scroll up! */ if (p_y < 0 && xtext->adj->value >= 0) { - if (!xtext->scroll_tag) - xtext->scroll_tag = g_timeout_add (100, - (GSourceFunc) - gtk_xtext_scrollup_timeout, - xtext); - return; + gtk_xtext_scrollup_timeout (xtext); } /* selecting past bottom of window, scroll down! */ - if (p_y > win_height && + else if (p_y > win_height && xtext->adj->value < (xtext->adj->upper - xtext->adj->page_size)) { - if (!xtext->scroll_tag) - xtext->scroll_tag = g_timeout_add (100, - (GSourceFunc) - gtk_xtext_scrolldown_timeout, - xtext); - return; + gtk_xtext_scrolldown_timeout (xtext); + } + else + { + moved = (int)xtext->adj->value - xtext->select_start_adj; + xtext->select_start_y -= (moved * xtext->fontsize); + xtext->select_start_adj = xtext->adj->value; + gtk_xtext_selection_draw (xtext, event, render); } - - moved = (int)xtext->adj->value - xtext->select_start_adj; - xtext->select_start_y -= (moved * xtext->fontsize); - xtext->select_start_adj = xtext->adj->value; - gtk_xtext_selection_draw (xtext, event, render); } static char * @@ -1890,7 +1950,7 @@ gtk_xtext_get_word (GtkXText * xtext, int x, int y, textentry ** ret_ent, if (ret_len) *ret_len = str - word; - return gtk_xtext_strip_color (word, len, xtext->scratch_buffer, NULL, NULL, FALSE); + return gtk_xtext_strip_color (word, len, xtext->scratch_buffer, NULL, NULL, NULL, FALSE); } #ifdef MOTION_MONITOR @@ -2190,6 +2250,11 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event) if (event->button == 1) { xtext->button_down = FALSE; + if (xtext->scroll_tag) + { + g_source_remove (xtext->scroll_tag); + xtext->scroll_tag = 0; + } gtk_grab_remove (widget); /*gdk_pointer_ungrab (0);*/ @@ -2416,7 +2481,7 @@ gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret) len = strlen (txt); } else { - stripped = gtk_xtext_strip_color (txt, strlen (txt), NULL, &len, 0, FALSE); + stripped = gtk_xtext_strip_color (txt, strlen (txt), NULL, &len, NULL, NULL, FALSE); free (txt); } @@ -2456,12 +2521,14 @@ gtk_xtext_selection_get (GtkWidget * widget, #if (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 0) gdk_string_to_compound_text ( + stripped, &encoding, &format, &new_text, + &new_length); #else gdk_string_to_compound_text_for_display ( gdk_drawable_get_display (widget->window), -#endif stripped, &encoding, &format, &new_text, &new_length); +#endif gtk_selection_data_set (selection_data_ptr, encoding, format, new_text, new_length); gdk_free_compound_text (new_text); @@ -2576,19 +2643,26 @@ gtk_xtext_get_type (void) static unsigned char * gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, - int *newlen, int *mb_ret, int strip_hidden) + int *newlen, int *mb_ret, GSList **slp, int strip_hidden) { int i = 0; int rcol = 0, bgcol = 0; int hidden = FALSE; unsigned char *new_str; int mb = FALSE; + GSList *sl = NULL; + unsigned char *text0 = text; + int off1, len1; + offlen_t data; if (outbuf == NULL) new_str = malloc (len + 2); else new_str = outbuf; + off1 = 0; + len1 = 0; + data.u = 0; while (len > 0) { if (*text >= 128) @@ -2622,12 +2696,32 @@ gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, break; default: if (!(hidden && strip_hidden)) + { + if (text - text0 - off1 != len1) + { + if (len1) + { + data.o.off = off1; + data.o.len = len1; + sl = g_slist_append (sl, GUINT_TO_POINTER (data.u)); + len1 = 0; + } + off1 = text - text0; + } + len1++; new_str[i++] = *text; + } } } text++; len--; } + if (len1) + { + data.o.off = off1; + data.o.len = len1; + sl = g_slist_append (sl, GUINT_TO_POINTER (data.u)); + } new_str[i] = 0; @@ -2637,9 +2731,15 @@ gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, if (mb_ret != NULL) *mb_ret = mb; + if (slp) + *slp = sl; + else + g_slist_free (sl); + return new_str; } + /* GeEkMaN: converts mIRC control codes to literal control codes */ static char * @@ -2743,7 +2843,7 @@ gtk_xtext_text_width (GtkXText *xtext, unsigned char *text, int len, int new_len, mb; new_buf = gtk_xtext_strip_color (text, len, xtext->scratch_buffer, - &new_len, &mb, !xtext->ignore_hidden); + &new_len, &mb, NULL, !xtext->ignore_hidden); if (mb_ret) *mb_ret = mb; @@ -2909,6 +3009,63 @@ gtk_xtext_reset (GtkXText * xtext, int mark, int attribs) xtext->nc = 0; } +/* + * gtk_xtext_search_offset (buf, ent, off) -- + * Look for arg offset in arg textentry + * Return one or more flags: + * GTK_MATCH_MID if we are in a match + * GTK_MATCH_START if we're at the first byte of it + * GTK_MATCH_END if we at the first byte past it + * GTK_MATCH_CUR if it is the current match + */ +#define GTK_MATCH_START 1 +#define GTK_MATCH_MID 2 +#define GTK_MATCH_END 4 +#define GTK_MATCH_CUR 8 +static int +gtk_xtext_search_offset (xtext_buffer *buf, textentry *ent, unsigned int off) +{ + GList *gl; + offsets_t o; + int flags = 0; + + for (gl = g_list_first (ent->marks); gl; gl = g_list_next (gl)) + { + o.u = GPOINTER_TO_UINT (gl->data); + if (off < o.o.start || off > o.o.end) + continue; + flags = GTK_MATCH_MID; + if (off == o.o.start) + flags |= GTK_MATCH_START; + if (off == o.o.end) + { + gl = g_list_next (gl); + if (gl) + { + o.u = GPOINTER_TO_UINT (gl->data); + if (off == o.o.start) /* If subseq match is adjacent */ + { + flags |= (gl == buf->curmark)? GTK_MATCH_CUR: 0; + } + else /* If subseq match is not adjacent */ + { + flags |= GTK_MATCH_END; + } + } + else /* If there is no subseq match */ + { + flags |= GTK_MATCH_END; + } + } + else if (gl == buf->curmark) /* If not yet at the end of this match */ + { + flags |= GTK_MATCH_CUR; + } + break; + } + return flags; +} + /* render a single line, which WONT wrap, and parse mIRC colors */ static int @@ -2923,6 +3080,9 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, int offset; int mark = FALSE; int ret = 1; + int k; + int srch_underline = FALSE; + int srch_mark = FALSE; xtext->in_hilight = FALSE; @@ -3074,6 +3234,50 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, } } + if (!left_only && !mark && + (k = gtk_xtext_search_offset (xtext->buffer, ent, offset + i))) + { + x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb); + pstr += j; + j = 0; + if (!(xtext->buffer->search_flags & highlight)) + { + if (k & GTK_MATCH_CUR) + { + xtext_set_bg (xtext, gc, XTEXT_MARK_BG); + xtext_set_fg (xtext, gc, XTEXT_MARK_FG); + xtext->backcolor = TRUE; + srch_mark = TRUE; + } else + { + xtext_set_bg (xtext, gc, xtext->col_back); + xtext_set_fg (xtext, gc, xtext->col_fore); + xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE; + srch_mark = FALSE; + } + } + else + { + xtext->underline = (k & GTK_MATCH_CUR)? TRUE: FALSE; + if (k & (GTK_MATCH_START | GTK_MATCH_MID)) + { + xtext_set_bg (xtext, gc, XTEXT_MARK_BG); + xtext_set_fg (xtext, gc, XTEXT_MARK_FG); + xtext->backcolor = TRUE; + srch_mark = TRUE; + } + if (k & GTK_MATCH_END) + { + xtext_set_bg (xtext, gc, xtext->col_back); + xtext_set_fg (xtext, gc, xtext->col_fore); + xtext->backcolor = (xtext->col_back != XTEXT_BG)? TRUE: FALSE; + srch_mark = FALSE; + xtext->underline = FALSE; + } + srch_underline = xtext->underline; + } + } + switch (str[i]) { case '\n': @@ -3223,6 +3427,11 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, xtext_set_bg (xtext, gc, XTEXT_MARK_BG); xtext_set_fg (xtext, gc, XTEXT_MARK_FG); xtext->backcolor = TRUE; + if (srch_underline) + { + xtext->underline = FALSE; + srch_underline = FALSE; + } mark = TRUE; } @@ -3245,7 +3454,7 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, if (j) x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb); - if (mark) + if (mark || srch_mark) { xtext_set_bg (xtext, gc, xtext->col_back); xtext_set_fg (xtext, gc, xtext->col_fore); @@ -4413,7 +4622,7 @@ gtk_xtext_save (GtkXText * xtext, int fh) while (ent) { buf = gtk_xtext_strip_color (ent->str, ent->str_len, NULL, - &newlen, NULL, FALSE); + &newlen, NULL, NULL, FALSE); write (fh, buf, newlen); write (fh, "\n", 1); free (buf); @@ -4800,6 +5009,11 @@ gtk_xtext_kill_ent (xtext_buffer *buffer, textentry *ent) if (buffer->marker_pos == ent) buffer->marker_pos = NULL; + if (ent->marks) + { + gtk_xtext_search_textentry_del (buffer, ent); + } + free (ent); return visible; } @@ -4864,7 +5078,23 @@ gtk_xtext_remove_bottom (xtext_buffer *buffer) else buffer->text_first = NULL; - gtk_xtext_kill_ent (buffer, ent); + if (gtk_xtext_kill_ent (buffer, ent)) + { + if (!buffer->xtext->add_io_tag) + { + /* remove scrolling events */ + if (buffer->xtext->io_tag) + { + g_source_remove (buffer->xtext->io_tag); + buffer->xtext->io_tag = 0; + } + buffer->xtext->force_render = TRUE; + buffer->xtext->add_io_tag = g_timeout_add (REFRESH_TIMEOUT * 2, + (GSourceFunc) + gtk_xtext_render_page_timeout, + buffer->xtext); + } + } } /* If lines=0 => clear all */ @@ -4899,6 +5129,8 @@ gtk_xtext_clear (xtext_buffer *buf, int lines) else { /* delete all */ + if (buf->search_found) + gtk_xtext_search_fini (buf); if (buf->xtext->auto_indent) buf->indent = MARGIN; buf->scrollbar_down = TRUE; @@ -4930,21 +5162,37 @@ static gboolean gtk_xtext_check_ent_visibility (GtkXText * xtext, textentry *find_ent, int add) { textentry *ent; - int lines_max; - int line = 0; + int lines; + xtext_buffer *buf = xtext->buffer; int width; int height; - gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height); + if (find_ent == NULL) + { + return FALSE; + } - lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + add; - ent = xtext->buffer->pagetop_ent; + gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height); - while (ent && line < lines_max) + ent = buf->pagetop_ent; + /* If top line not completely displayed return FALSE */ + if (ent == find_ent && buf->pagetop_subline > 0) { - if (find_ent == ent) + return FALSE; + } + /* Loop through line positions looking for find_ent */ + lines = ((height + xtext->pixel_offset) / xtext->fontsize) + buf->pagetop_subline + add; + while (ent) + { + lines -= ent->lines_taken; + if (lines <= 0) + { + return FALSE; + } + if (ent == find_ent) + { return TRUE; - line += ent->lines_taken; + } ent = ent->next; } @@ -4958,90 +5206,369 @@ gtk_xtext_check_marker_visibility (GtkXText * xtext) xtext->buffer->marker_seen = TRUE; } -textentry * -gtk_xtext_search (GtkXText * xtext, const gchar *text, textentry *start, gboolean case_match, gboolean backward) +static void +gtk_xtext_unstrip_color (gint start, gint end, GSList *slp, GList **gl, gint maxo) { - textentry *ent, *fent; - int line; - gchar *str, *nee, *hay; /* needle in haystack */ - - gtk_xtext_selection_clear_full (xtext->buffer); - xtext->buffer->last_ent_start = NULL; - xtext->buffer->last_ent_end = NULL; + gint off1, off2, curlen; + GSList *cursl; + offsets_t marks; - /* set up text comparand for Case Match or Ignore */ - if (case_match) - nee = g_strdup (text); - else - nee = g_utf8_casefold (text, strlen (text)); + off1 = 0; + curlen = 0; + cursl = slp; + while (cursl) + { + offlen_t ol; + ol.u = GPOINTER_TO_UINT(cursl->data); + if (start < ol.o.len) + { + off1 = ol.o.off + start; + break; + } + curlen += ol.o.len; + start -= ol.o.len; + end -= ol.o.len; + cursl = g_slist_next (cursl); + } - /* Validate that start gives a currently valid ent pointer */ - ent = xtext->buffer->text_first; - while (ent) + off2 = off1; + while (cursl) { - if (ent == start) + offlen_t ol; + ol.u = GPOINTER_TO_UINT(cursl->data); + if (end < ol.o.len) + { + off2 = ol.o.off + end; break; - ent = ent->next; + } + curlen += ol.o.len; + end -= ol.o.len; + cursl = g_slist_next (cursl); + } + if (!cursl) + { + off2 = maxo; } - if (!ent) - start = NULL; - /* Choose first ent to look at */ - if (start) - ent = backward? start->prev: start->next; - else - ent = backward? xtext->buffer->text_last: xtext->buffer->text_first; + marks.o.start = off1; + marks.o.end = off2; + *gl = g_list_append (*gl, GUINT_TO_POINTER (marks.u)); +} - /* Search from there to one end or the other until found */ - while (ent) +/* Search a single textentry for occurrence(s) of search arg string */ +static void +gtk_xtext_search_textentry (xtext_buffer *buf, textentry *ent, int pre) +{ + gchar *str; /* text string to be searched */ + GList *gl = NULL; + GSList *slp; + gint lstr; + + if (buf->search_text == NULL) { - /* If Case Ignore, fold before & free after calling strstr */ - if (case_match) - hay = g_strdup (ent->str); - else - hay = g_utf8_casefold (ent->str, strlen (ent->str)); - /* Try to find the needle in this haystack */ - str = g_strstr_len (hay, strlen (hay), nee); + return; + } + + str = gtk_xtext_strip_color (ent->str, ent->str_len, buf->xtext->scratch_buffer, + &lstr, NULL, &slp, !buf->xtext->ignore_hidden); + + /* Regular-expression matching --- */ + if (buf->search_flags & regexp) + { + GMatchInfo *gmi; + gint start, end; + + if (buf->search_re == NULL) + { + return; + } + g_regex_match (buf->search_re, str, 0, &gmi); + while (g_match_info_matches (gmi)) + { + g_match_info_fetch_pos (gmi, 0, &start, &end); + gtk_xtext_unstrip_color (start, end, slp, &gl, ent->str_len); + g_match_info_next (gmi, NULL); + } + g_match_info_free (gmi); + + /* Non-regular-expression matching --- */ + } else { + gchar *hay, *pos; + gint lhay, off, len; + gint match = buf->search_flags & case_match; + + hay = match? g_strdup (str): g_utf8_casefold (str, lstr); + lhay = strlen (hay); + off = 0; + + for (pos = hay, len = lhay; len; + off += buf->search_lnee, pos = hay + off, len = lhay - off) + { + str = g_strstr_len (pos, len, buf->search_nee); + if (str == NULL) + { + break; + } + off = str - hay; + gtk_xtext_unstrip_color (off, off + buf->search_lnee, + slp, &gl, ent->str_len); + } + g_free (hay); - if (str) - break; - ent = backward? ent->prev: ent->next; } - fent = ent; - /* Save distance to start, end of found string */ - if (ent) + /* Common processing --- */ + g_slist_free (slp); + ent->marks = gl; + if (gl) + { + buf->search_found = (pre? g_list_prepend: g_list_append) (buf->search_found, ent); + if (pre == FALSE && buf->hintsearch == NULL) + { + buf->hintsearch = ent; + } + } + return; +} + +/* Free all search information for a textentry */ +static void +gtk_xtext_search_textentry_del (xtext_buffer *buf, textentry *ent) +{ + g_list_free (ent->marks); + ent->marks = NULL; + if (buf->cursearch && buf->cursearch->data == ent) + { + buf->cursearch = NULL; + buf->curmark = NULL; + } + if (buf->pagetop_ent == ent) + { + buf->pagetop_ent = NULL; + } + if (buf->hintsearch == ent) + { + buf->hintsearch = NULL; + } + buf->search_found = g_list_remove (buf->search_found, ent); +} + +/* Used only by glist_foreach */ +static void +gtk_xtext_search_textentry_fini (gpointer entp, gpointer dummy) +{ + textentry *ent = entp; + + g_list_free (ent->marks); + ent->marks = NULL; +} + +/* Free all search information for all textentrys and the xtext_buffer */ +static void +gtk_xtext_search_fini (xtext_buffer *buf) +{ + g_list_foreach (buf->search_found, gtk_xtext_search_textentry_fini, 0); + g_list_free (buf->search_found); + buf->search_found = NULL; + g_free (buf->search_text); + buf->search_text = NULL; + g_free (buf->search_nee); + buf->search_nee = NULL; + buf->search_flags = 0; + buf->cursearch = NULL; + buf->curmark = NULL; + if (buf->search_re) + { + g_regex_unref (buf->search_re); + buf->search_re = NULL; + } +} + +/* Returns TRUE if the base search information exists and is still okay to use */ +static gboolean +gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr) +{ + /* Of the five flags, backward and highlight_all do not need a new search */ + if (buf->search_found && + strcmp (buf->search_text, text) == 0 && + (buf->search_flags & case_match) == (flags & case_match) && + (buf->search_flags & follow) == (flags & follow) && + (buf->search_flags & regexp) == (flags & regexp)) + { + return TRUE; + } + buf->hintsearch = buf->cursearch? buf->cursearch->data: NULL; + gtk_xtext_search_fini (buf); + buf->search_text = g_strdup (text); + if (flags & regexp) + { + buf->search_re = g_regex_new (text, (flags & case_match)? 0: G_REGEX_CASELESS, 0, perr); + if (perr && *perr) + { + return FALSE; + } + } + else + { + if (flags & case_match) + { + buf->search_nee = g_strdup (text); + } + else + { + buf->search_nee = g_utf8_casefold (text, strlen (text)); + } + buf->search_lnee = strlen (buf->search_nee); + } + buf->search_flags = flags; + buf->cursearch = NULL; + buf->curmark = NULL; + return FALSE; +} + +#define BACKWARD (flags & backward) +#define FIRSTLAST(lp) (BACKWARD? g_list_last(lp): g_list_first(lp)) +#define NEXTPREVIOUS(lp) (BACKWARD? g_list_previous(lp): g_list_next(lp)) +textentry * +gtk_xtext_search (GtkXText * xtext, const gchar *text, gtk_xtext_search_flags flags, GError **perr) +{ + textentry *ent = NULL; + xtext_buffer *buf = xtext->buffer; + GList *gl; + + if (buf->text_first == NULL) + { + return NULL; + } + + /* If the text arg is NULL, one of these has been toggled: highlight follow */ + if (text == NULL) /* Here on highlight or follow toggle */ { - ent->mark_start = str - hay; - ent->mark_end = ent->mark_start + strlen (nee); + gint oldfollow = buf->search_flags & follow; + gint newfollow = flags & follow; - /* is the match visible? Might need to scroll */ - if (!gtk_xtext_check_ent_visibility (xtext, ent, 0)) + /* If "Follow" has just been checked, search possible new textentries --- */ + if (newfollow && (newfollow != oldfollow)) { - ent = xtext->buffer->text_first; - line = 0; - while (ent) + gl = g_list_last (buf->search_found); + ent = gl? gl->data: buf->text_first; + for (; ent; ent = ent->next) { - line += ent->lines_taken; - ent = ent->next; - if (ent == fent) - break; + gtk_xtext_search_textentry (buf, ent, FALSE); + } + } + buf->search_flags = flags; + ent = buf->pagetop_ent; + } + + /* if the text arg is "", the reset button has been clicked or Control-Shift-F has been hit */ + else if (text[0] == 0) /* Let a null string do a reset. */ + { + gtk_xtext_search_fini (buf); + } + + /* If the text arg is neither NULL nor "", it's the search string */ + else + { + if (gtk_xtext_search_init (buf, text, flags, perr) == FALSE) /* If a new search: */ + { + if (perr && *perr) + { + return NULL; + } + for (ent = buf->text_first; ent; ent = ent->next) + { + gtk_xtext_search_textentry (buf, ent, TRUE); + } + buf->search_found = g_list_reverse (buf->search_found); + } + + /* Now base search results are in place. */ + + if (buf->search_found) + { + /* If we're in the midst of moving among found items */ + if (buf->cursearch) + { + ent = buf->cursearch->data; + buf->curmark = NEXTPREVIOUS (buf->curmark); + if (buf->curmark == NULL) + { + /* We've returned all the matches for this textentry. */ + buf->cursearch = NEXTPREVIOUS (buf->cursearch); + if (buf->cursearch) + { + ent = buf->cursearch->data; + buf->curmark = FIRSTLAST (ent->marks); + } + else /* We've returned all the matches for all textentries */ + { + ent = NULL; + } + } + } +#if 0 + /* If user changed the search, let's look starting where he was */ + else if (buf->hintsearch) + { + for (ent = buf->hintsearch; ent; ent = BACKWARD? ent->prev: ent->next) + if (ent->marks) + break; + if (ent == NULL) + for (ent = buf->hintsearch; ent; ent = BACKWARD? ent->next: ent->prev) + if (ent->marks) + break; + if (ent) + { + buf->cursearch = g_list_find (buf->search_found, ent); + buf->curmark = FIRSTLAST (ent->marks); + } + } +#endif + /* This is a fresh search */ + else + { + buf->cursearch = FIRSTLAST (buf->search_found); + ent = buf->cursearch->data; + buf->curmark = FIRSTLAST (ent->marks); + } + } + } + buf->hintsearch = ent; + + if (!gtk_xtext_check_ent_visibility (xtext, ent, 1)) + { + GtkAdjustment *adj = xtext->adj; + float value; + + buf->pagetop_ent = NULL; + for (value = 0, ent = buf->text_first; + ent && ent != buf->hintsearch; ent = ent->next) + { + value += ent->lines_taken; + } + if (value > adj->upper - adj->page_size) + { + value = adj->upper - adj->page_size; + } + else if ((flags & backward) && ent) + { + value -= adj->page_size - ent->lines_taken; + if (value < 0) + { + value = 0; } - while (line > xtext->adj->upper - xtext->adj->page_size) - line--; - if (backward) - line -= xtext->adj->page_size - ent->lines_taken; - xtext->adj->value = line; - xtext->buffer->scrollbar_down = FALSE; - gtk_adjustment_changed (xtext->adj); } + gtk_adjustment_set_value (adj, value); } - g_free (nee); gtk_widget_queue_draw (GTK_WIDGET (xtext)); - return fent; + return buf->hintsearch; } +#undef BACKWARD +#undef FIRSTLAST +#undef NEXTPREVIOUS static int gtk_xtext_render_page_timeout (GtkXText * xtext) @@ -5104,6 +5631,7 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp) ent->mark_start = -1; ent->mark_end = -1; ent->next = NULL; + ent->marks = NULL; if (ent->indent < MARGIN) ent->indent = MARGIN; /* 2 pixels is the left margin */ @@ -5122,10 +5650,11 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp) if (buf->reset_marker_pos || ((buf->marker_pos == NULL || buf->marker_seen) && (buf->xtext->buffer != buf || #if GTK_CHECK_VERSION(2,4,0) - !gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (buf->xtext))))))) + !gtk_window_has_toplevel_focus (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (buf->xtext)))) #else - !(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (buf->xtext))))->has_focus))) + !(GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (buf->xtext))))->has_focus #endif + ))) { buf->marker_pos = ent; dontscroll (buf); /* force scrolling off */ @@ -5165,6 +5694,10 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp) if (buf->old_value < 0) buf->old_value = 0; } + if (buf->search_flags & follow) + { + gtk_xtext_search_textentry (buf, ent, FALSE); + } } /* the main two public functions */ @@ -5491,6 +6024,11 @@ gtk_xtext_buffer_free (xtext_buffer *buf) if (buf->xtext->selection_buffer == buf) buf->xtext->selection_buffer = NULL; + if (buf->search_found) + { + gtk_xtext_search_fini (buf); + } + ent = buf->text_first; while (ent) { diff --git a/src/fe-gtk/xtext.h b/src/fe-gtk/xtext.h index 90fa1bca..6c126346 100644 --- a/src/fe-gtk/xtext.h +++ b/src/fe-gtk/xtext.h @@ -43,6 +43,13 @@ typedef struct _GtkXText GtkXText; typedef struct _GtkXTextClass GtkXTextClass; typedef struct textentry textentry; +typedef enum gtk_xtext_search_flags_e { + case_match = 1, + backward = 2, + highlight = 4, + follow = 8, + regexp = 16 +} gtk_xtext_search_flags; typedef struct { GtkXText *xtext; /* attached to this widget */ @@ -77,6 +84,16 @@ typedef struct { unsigned int grid_dirty:1; unsigned int marker_seen:1; unsigned int reset_marker_pos:1; + + GList *search_found; /* list of textentries where search found strings */ + gchar *search_text; /* desired text to search for */ + gchar *search_nee; /* prepared needle to look in haystack for */ + gint search_lnee; /* its length */ + gtk_xtext_search_flags search_flags; /* match, bwd, highlight */ + GList *cursearch; /* GList whose 'data' pts to current textentry */ + GList *curmark; /* current item in ent->marks */ + GRegex *search_re; /* Compiled regular expression */ + textentry *hintsearch; /* textentry found for last search */ } xtext_buffer; struct _GtkXText @@ -247,7 +264,7 @@ void gtk_xtext_clear (xtext_buffer *buf, int lines); void gtk_xtext_save (GtkXText * xtext, int fh); void gtk_xtext_refresh (GtkXText * xtext, int do_trans); int gtk_xtext_lastlog (xtext_buffer *out, xtext_buffer *search_area, int (*cmp_func) (char *, void *userdata), void *userdata); -textentry *gtk_xtext_search (GtkXText * xtext, const gchar *text, textentry *start, gboolean case_match, gboolean backward); +textentry *gtk_xtext_search (GtkXText * xtext, const gchar *text, gtk_xtext_search_flags flags, GError **err); void gtk_xtext_reset_marker_pos (GtkXText *xtext); void gtk_xtext_check_marker_visibility(GtkXText *xtext); -- cgit 1.4.1 From 35821f3875e4a718932f7f67debdeacaa8c6cc3d Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Sat, 16 Jun 2012 13:01:47 +0200 Subject: Fix string handling for Turkish locale --- src/common/cfgfiles.c | 24 ++++++------ src/common/chanopt.c | 8 ++-- src/common/ctcp.c | 10 ++--- src/common/dcc.c | 14 +++---- src/common/inbound.c | 2 +- src/common/modes.c | 10 ++--- src/common/outbound.c | 88 +++++++++++++++++++++---------------------- src/common/plugin-timer.c | 10 ++--- src/common/plugin.c | 16 ++++---- src/common/proto-irc.c | 10 ++--- src/common/server.c | 18 ++++----- src/common/servlist.c | 10 ++--- src/common/url.c | 8 ++-- src/common/util.c | 4 +- src/common/xchat.h | 4 +- src/fe-gtk/fkeys.c | 6 +-- src/fe-gtk/maingui.c | 4 +- src/fe-gtk/menu.c | 10 ++--- src/fe-gtk/notifygui.c | 2 +- src/fe-gtk/plugingui.c | 6 +-- src/fe-gtk/sexy-spell-entry.c | 4 +- src/fe-gtk/xtext.c | 2 +- 22 files changed, 135 insertions(+), 135 deletions(-) (limited to 'src/fe-gtk/menu.c') diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 081137b8..111234e9 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -84,11 +84,11 @@ list_load_from_data (GSList ** list, char *ibuf, int size) { if (*buf != '#') { - if (!strncasecmp (buf, "NAME ", 5)) + if (!g_ascii_strncasecmp (buf, "NAME ", 5)) { safe_strcpy (name, buf + 5, sizeof (name)); } - else if (!strncasecmp (buf, "CMD ", 4)) + else if (!g_ascii_strncasecmp (buf, "CMD ", 4)) { safe_strcpy (cmd, buf + 4, sizeof (cmd)); if (*name) @@ -154,7 +154,7 @@ list_delentry (GSList ** list, char *name) while (alist) { pop = (struct popup *) alist->data; - if (!strcasecmp (name, pop->name)) + if (!g_ascii_strcasecmp (name, pop->name)) { *list = g_slist_remove (*list, pop); free (pop); @@ -174,7 +174,7 @@ cfg_get_str (char *cfg, char *var, char *dest, int dest_len) while (1) { - if (!strncasecmp (buffer, cfg, strlen (var) + 1)) + if (!g_ascii_strncasecmp (buffer, cfg, strlen (var) + 1)) { char *value, t; cfg += strlen (var); @@ -1000,7 +1000,7 @@ cfg_get_bool (char *var) do { - if (!strcasecmp (var, vars[i].name)) + if (!g_ascii_strcasecmp (var, vars[i].name)) { return *((int *) &prefs + vars[i].offset); } @@ -1023,27 +1023,27 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[]) int idx = 2; char *var, *val; - if (strcasecmp (word[2], "-e") == 0) + if (g_ascii_strcasecmp (word[2], "-e") == 0) { idx++; erase = TRUE; } /* turn a bit OFF */ - if (strcasecmp (word[idx], "-off") == 0) + if (g_ascii_strcasecmp (word[idx], "-off") == 0) { idx++; off = TRUE; } /* turn a bit ON */ - if (strcasecmp (word[idx], "-or") == 0 || strcasecmp (word[idx], "-on") == 0) + if (g_ascii_strcasecmp (word[idx], "-or") == 0 || g_ascii_strcasecmp (word[idx], "-on") == 0) { idx++; or = TRUE; } - if (strcasecmp (word[idx], "-quiet") == 0) + if (g_ascii_strcasecmp (word[idx], "-quiet") == 0) { idx++; quiet = TRUE; @@ -1069,7 +1069,7 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[]) if (wild) found = !match (var, vars[i].name); else - found = strcasecmp (var, vars[i].name); + found = g_ascii_strcasecmp (var, vars[i].name); if (found == 0) { @@ -1098,9 +1098,9 @@ cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[]) *((int *) &prefs + vars[i].offset) = 1; else *((int *) &prefs + vars[i].offset) = 0; - if (!strcasecmp (val, "YES") || !strcasecmp (val, "ON")) + if (!g_ascii_strcasecmp (val, "YES") || !g_ascii_strcasecmp (val, "ON")) *((int *) &prefs + vars[i].offset) = 1; - if (!strcasecmp (val, "NO") || !strcasecmp (val, "OFF")) + if (!g_ascii_strcasecmp (val, "NO") || !g_ascii_strcasecmp (val, "OFF")) *((int *) &prefs + vars[i].offset) = 0; } else { diff --git a/src/common/chanopt.c b/src/common/chanopt.c index f8e16e8b..198ebe6c 100644 --- a/src/common/chanopt.c +++ b/src/common/chanopt.c @@ -84,9 +84,9 @@ chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[]) if (word[offset][0]) { - if (!strcasecmp (word[offset], "ON")) + if (!g_ascii_strcasecmp (word[offset], "ON")) newval = 1; - else if (!strcasecmp (word[offset], "OFF")) + else if (!g_ascii_strcasecmp (word[offset], "OFF")) newval = 0; else if (word[offset][0] == 'u') newval = SET_DEFAULT; @@ -186,8 +186,8 @@ chanopt_find (char *network, char *channel, gboolean add_new) for (list = chanopt_list; list; list = list->next) { co = list->data; - if (!strcasecmp (co->channel, channel) && - !strcasecmp (co->network, network)) + if (!g_ascii_strcasecmp (co->channel, channel) && + !g_ascii_strcasecmp (co->network, network)) return co; } diff --git a/src/common/ctcp.c b/src/common/ctcp.c index 2bb75746..36952db7 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -73,7 +73,7 @@ ctcp_check (session *sess, char *nick, char *word[], char *word_eol[], while (list) { pop = (struct popup *) list->data; - if (!strcasecmp (ctcp, pop->name)) + if (!g_ascii_strcasecmp (ctcp, pop->name)) { ctcp_reply (sess, nick, word, word_eol, pop->cmd); ret = 1; @@ -97,7 +97,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, ctcp_offset = 3; /* consider DCC to be different from other CTCPs */ - if (!strncasecmp (msg, "DCC", 3)) + if (!g_ascii_strncasecmp (msg, "DCC", 3)) { /* but still let CTCP replies override it */ if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) @@ -110,7 +110,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, /* consider ACTION to be different from other CTCPs. Check ignore as if it was a PRIV/CHAN. */ - if (!strncasecmp (msg, "ACTION ", 7)) + if (!g_ascii_strncasecmp (msg, "ACTION ", 7)) { if (is_channel (serv, to)) { @@ -135,7 +135,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, if (ignore_check (word[1], IG_CTCP)) return; - if (!strcasecmp (msg, "VERSION") && !prefs.hidever) + if (!g_ascii_strcasecmp (msg, "VERSION") && !prefs.hidever) { #ifdef WIN32 snprintf (outbuf, sizeof (outbuf), "VERSION XChat-WDK "PACKAGE_VERSION" [x%d] / %s", @@ -149,7 +149,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip, if (!ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset)) { - if (!strncasecmp (msg, "SOUND", 5)) + if (!g_ascii_strncasecmp (msg, "SOUND", 5)) { po = strchr (word[5], '\001'); if (po) diff --git a/src/common/dcc.c b/src/common/dcc.c index d91b7e8e..4c8724d9 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -572,7 +572,7 @@ dcc_chat_line (struct DCC *dcc, char *line) url_check_line (line, len); - if (line[0] == 1 && !strncasecmp (line + 1, "ACTION", 6)) + if (line[0] == 1 && !g_ascii_strncasecmp (line + 1, "ACTION", 6)) { po = strchr (line + 8, '\001'); if (po) @@ -1940,9 +1940,9 @@ find_dcc (char *nick, char *file, int type) { if (!file[0]) return dcc; - if (!strcasecmp (file, file_part (dcc->file))) + if (!g_ascii_strcasecmp (file, file_part (dcc->file))) return dcc; - if (!strcasecmp (file, dcc->file)) + if (!g_ascii_strcasecmp (file, dcc->file)) return dcc; } } @@ -2406,7 +2406,7 @@ handle_dcc (struct session *sess, char *nick, char *word[], DCC_SIZE size; int psend = 0; - if (!strcasecmp (type, "CHAT")) + if (!g_ascii_strcasecmp (type, "CHAT")) { port = atoi (word[8]); addr = strtoul (word[7], NULL, 10); @@ -2453,7 +2453,7 @@ handle_dcc (struct session *sess, char *nick, char *word[], return; } - if (!strcasecmp (type, "Resume")) + if (!g_ascii_strcasecmp (type, "Resume")) { port = atoi (word[7]); @@ -2497,7 +2497,7 @@ handle_dcc (struct session *sess, char *nick, char *word[], } return; } - if (!strcasecmp (type, "Accept")) + if (!g_ascii_strcasecmp (type, "Accept")) { port = atoi (word[7]); dcc = find_dcc_from_port (port, TYPE_RECV); @@ -2507,7 +2507,7 @@ handle_dcc (struct session *sess, char *nick, char *word[], } return; } - if (!strcasecmp (type, "SEND")) + if (!g_ascii_strcasecmp (type, "SEND")) { char *file = file_part (word[6]); diff --git a/src/common/inbound.c b/src/common/inbound.c index 1c124db4..89899655 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -886,7 +886,7 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id) if (msg[0] == '[' && (!serv->have_idmsg || id)) { /* guess where chanserv meant to post this -sigh- */ - if (!strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) + if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) { char *dest = strdup (msg + 1); char *end = strchr (dest, ']'); diff --git a/src/common/modes.c b/src/common/modes.c index 1acf7f54..6eb63f3b 100644 --- a/src/common/modes.c +++ b/src/common/modes.c @@ -789,20 +789,20 @@ inbound_005 (server * serv, char *word[]) } /* use /NICKSERV */ - if (strcasecmp (word[w] + 8, "RusNet") == 0) + if (g_ascii_strcasecmp (word[w] + 8, "RusNet") == 0) serv->nickservtype = 1; - else if (strcasecmp (word[w] + 8, "UniBG") == 0) + else if (g_ascii_strcasecmp (word[w] + 8, "UniBG") == 0) serv->nickservtype = 3; - else if (strcasecmp (word[w] + 8, "QuakeNet") == 0) + else if (g_ascii_strcasecmp (word[w] + 8, "QuakeNet") == 0) serv->nickservtype = 4; } else if (strncmp (word[w], "CASEMAPPING=", 12) == 0) { if (strcmp (word[w] + 12, "ascii") == 0) /* bahamut */ - serv->p_cmp = (void *)strcasecmp; + serv->p_cmp = (void *)g_ascii_strcasecmp; } else if (strncmp (word[w], "CHARSET=", 8) == 0) { - if (strcasecmp (word[w] + 8, "UTF-8") == 0) + if (g_ascii_strcasecmp (word[w] + 8, "UTF-8") == 0) { server_set_encoding (serv, "UTF-8"); } diff --git a/src/common/outbound.c b/src/common/outbound.c index b13a33a1..872ef50b 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -617,13 +617,13 @@ cmd_clear (struct session *sess, char *tbuf, char *word[], char *word_eol[]) GSList *list = sess_list; char *reason = word_eol[2]; - if (strcasecmp (reason, "HISTORY") == 0) + if (g_ascii_strcasecmp (reason, "HISTORY") == 0) { history_free (&sess->history); return TRUE; } - if (strncasecmp (reason, "all", 3) == 0) + if (g_ascii_strncasecmp (reason, "all", 3) == 0) { while (list) { @@ -750,26 +750,26 @@ cmd_dcc (struct session *sess, char *tbuf, char *word[], char *word_eol[]) char *type = word[2]; if (*type) { - if (!strcasecmp (type, "HELP")) + if (!g_ascii_strcasecmp (type, "HELP")) return FALSE; - if (!strcasecmp (type, "CLOSE")) + if (!g_ascii_strcasecmp (type, "CLOSE")) { if (*word[3] && *word[4]) { goodtype = 0; - if (!strcasecmp (word[3], "SEND")) + if (!g_ascii_strcasecmp (word[3], "SEND")) { dcc = find_dcc (word[4], word[5], TYPE_SEND); dcc_abort (sess, dcc); goodtype = TRUE; } - if (!strcasecmp (word[3], "GET")) + if (!g_ascii_strcasecmp (word[3], "GET")) { dcc = find_dcc (word[4], word[5], TYPE_RECV); dcc_abort (sess, dcc); goodtype = TRUE; } - if (!strcasecmp (word[3], "CHAT")) + if (!g_ascii_strcasecmp (word[3], "CHAT")) { dcc = find_dcc (word[4], "", TYPE_CHATRECV); if (!dcc) @@ -789,20 +789,20 @@ cmd_dcc (struct session *sess, char *tbuf, char *word[], char *word_eol[]) } return FALSE; } - if ((!strcasecmp (type, "CHAT")) || (!strcasecmp (type, "PCHAT"))) + if ((!g_ascii_strcasecmp (type, "CHAT")) || (!g_ascii_strcasecmp (type, "PCHAT"))) { char *nick = word[3]; - int passive = (!strcasecmp(type, "PCHAT")) ? 1 : 0; + int passive = (!g_ascii_strcasecmp(type, "PCHAT")) ? 1 : 0; if (*nick) dcc_chat (sess, nick, passive); return TRUE; } - if (!strcasecmp (type, "LIST")) + if (!g_ascii_strcasecmp (type, "LIST")) { dcc_show_list (sess); return TRUE; } - if (!strcasecmp (type, "GET")) + if (!g_ascii_strcasecmp (type, "GET")) { char *nick = word[3]; char *file = word[4]; @@ -820,18 +820,18 @@ cmd_dcc (struct session *sess, char *tbuf, char *word[], char *word_eol[]) } return TRUE; } - if ((!strcasecmp (type, "SEND")) || (!strcasecmp (type, "PSEND"))) + if ((!g_ascii_strcasecmp (type, "SEND")) || (!g_ascii_strcasecmp (type, "PSEND"))) { int i = 3, maxcps; char *nick, *file; - int passive = (!strcasecmp(type, "PSEND")) ? 1 : 0; + int passive = (!g_ascii_strcasecmp(type, "PSEND")) ? 1 : 0; nick = word[i]; if (!*nick) return FALSE; maxcps = prefs.dcc_max_send_cps; - if (!strncasecmp(nick, "-maxcps=", 8)) + if (!g_ascii_strncasecmp(nick, "-maxcps=", 8)) { maxcps = atoi(nick + 8); i++; @@ -1312,7 +1312,7 @@ cmd_menu (struct session *sess, char *tbuf, char *word[], char *word_eol[]) *p = '/'; } - if (!strcasecmp (word[idx], "ADD")) + if (!g_ascii_strcasecmp (word[idx], "ADD")) { if (toggle) { @@ -1327,7 +1327,7 @@ cmd_menu (struct session *sess, char *tbuf, char *word[], char *word_eol[]) return TRUE; } - if (!strcasecmp (word[idx], "DEL")) + if (!g_ascii_strcasecmp (word[idx], "DEL")) { menu_del (tbuf, label); return TRUE; @@ -2045,7 +2045,7 @@ cmd_gui (struct session *sess, char *tbuf, char *word[], char *word_eol[]) case 0xc0851aaa: fe_message (word[3], FE_MSG_INFO|FE_MSG_MARKUP); break; /* MSGBOX */ case 0x0035dafd: fe_ctrl_gui (sess, 1, 0); break; /* SHOW */ case 0x0033155f: /* MENU */ - if (!strcasecmp (word[3], "TOGGLE")) + if (!g_ascii_strcasecmp (word[3], "TOGGLE")) fe_ctrl_gui (sess, 6, 0); else return FALSE; @@ -2247,25 +2247,25 @@ cmd_ignore (struct session *sess, char *tbuf, char *word[], char *word_eol[]) } return TRUE; } - if (!strcasecmp (word[i], "UNIGNORE")) + if (!g_ascii_strcasecmp (word[i], "UNIGNORE")) type |= IG_UNIG; - else if (!strcasecmp (word[i], "ALL")) + else if (!g_ascii_strcasecmp (word[i], "ALL")) type |= IG_PRIV | IG_NOTI | IG_CHAN | IG_CTCP | IG_INVI | IG_DCC; - else if (!strcasecmp (word[i], "PRIV")) + else if (!g_ascii_strcasecmp (word[i], "PRIV")) type |= IG_PRIV; - else if (!strcasecmp (word[i], "NOTI")) + else if (!g_ascii_strcasecmp (word[i], "NOTI")) type |= IG_NOTI; - else if (!strcasecmp (word[i], "CHAN")) + else if (!g_ascii_strcasecmp (word[i], "CHAN")) type |= IG_CHAN; - else if (!strcasecmp (word[i], "CTCP")) + else if (!g_ascii_strcasecmp (word[i], "CTCP")) type |= IG_CTCP; - else if (!strcasecmp (word[i], "INVI")) + else if (!g_ascii_strcasecmp (word[i], "INVI")) type |= IG_INVI; - else if (!strcasecmp (word[i], "QUIET")) + else if (!g_ascii_strcasecmp (word[i], "QUIET")) quiet = 1; - else if (!strcasecmp (word[i], "NOSAVE")) + else if (!g_ascii_strcasecmp (word[i], "NOSAVE")) type |= IG_NOSAVE; - else if (!strcasecmp (word[i], "DCC")) + else if (!g_ascii_strcasecmp (word[i], "DCC")) type |= IG_DCC; else { @@ -2456,12 +2456,12 @@ cmd_load (struct session *sess, char *tbuf, char *word[], char *word_eol[]) #ifdef USE_PLUGIN len = strlen (word[2]); #ifdef WIN32 - if (len > 4 && strcasecmp (".dll", word[2] + len - 4) == 0) + if (len > 4 && g_ascii_strcasecmp (".dll", word[2] + len - 4) == 0) #else #if defined(__hpux) - if (len > 3 && strcasecmp (".sl", word[2] + len - 3) == 0) + if (len > 3 && g_ascii_strcasecmp (".sl", word[2] + len - 3) == 0) #else - if (len > 3 && strcasecmp (".so", word[2] + len - 3) == 0) + if (len > 3 && g_ascii_strcasecmp (".so", word[2] + len - 3) == 0) #endif #endif { @@ -2613,8 +2613,8 @@ cmd_msg (struct session *sess, char *tbuf, char *word[], char *word_eol[]) else { /* mask out passwords */ - if (strcasecmp (nick, "nickserv") == 0 && - strncasecmp (msg, "identify ", 9) == 0) + if (g_ascii_strcasecmp (nick, "nickserv") == 0 && + g_ascii_strncasecmp (msg, "identify ", 9) == 0) msg = "identify ****"; EMIT_SIGNAL (XP_TE_MSGSEND, sess, nick, msg, NULL, NULL, 0); } @@ -2825,7 +2825,7 @@ cmd_reconnect (struct session *sess, char *tbuf, char *word[], char *word_eol[]) prefs.recon_delay = 0; - if (!strcasecmp (word[2], "ALL")) + if (!g_ascii_strcasecmp (word[2], "ALL")) { list = serv_list; while (list) @@ -2997,7 +2997,7 @@ parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], in { char *co; #ifdef USE_OPENSSL - if (strncasecmp ("ircs://", url, 7) == 0) + if (g_ascii_strncasecmp ("ircs://", url, 7) == 0) { *use_ssl = TRUE; *server_name = url + 7; @@ -3005,7 +3005,7 @@ parse_irc_url (char *url, char *server_name[], char *port[], char *channel[], in } #endif - if (strncasecmp ("irc://", url, 6) == 0) + if (g_ascii_strncasecmp ("irc://", url, 6) == 0) { *server_name = url + 6; #ifdef USE_OPENSSL @@ -3076,7 +3076,7 @@ cmd_server (struct session *sess, char *tbuf, char *word[], char *word_eol[]) sess->server->network = NULL; /* dont clear it for /servchan */ - if (strncasecmp (word_eol[1], "SERVCHAN ", 9)) + if (g_ascii_strncasecmp (word_eol[1], "SERVCHAN ", 9)) sess->willjoinchannel[0] = 0; if (channel) @@ -3206,7 +3206,7 @@ cmd_unignore (struct session *sess, char *tbuf, char *word[], { if (ignore_del (mask, NULL)) { - if (strcasecmp (arg, "QUIET")) + if (g_ascii_strcasecmp (arg, "QUIET")) EMIT_SIGNAL (XP_TE_IGNOREREMOVE, sess, mask, NULL, NULL, NULL, 0); } return TRUE; @@ -3222,12 +3222,12 @@ cmd_unload (struct session *sess, char *tbuf, char *word[], char *word_eol[]) len = strlen (word[2]); #ifdef WIN32 - if (len > 4 && strcasecmp (word[2] + len - 4, ".dll") == 0) + if (len > 4 && g_ascii_strcasecmp (word[2] + len - 4, ".dll") == 0) #else #if defined(__hpux) - if (len > 3 && strcasecmp (word[2] + len - 3, ".sl") == 0) + if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".sl") == 0) #else - if (len > 3 && strcasecmp (word[2] + len - 3, ".so") == 0) + if (len > 3 && g_ascii_strcasecmp (word[2] + len - 3, ".so") == 0) #endif #endif by_file = TRUE; @@ -3257,7 +3257,7 @@ find_server_from_hostname (char *hostname) while (list) { serv = list->data; - if (!strcasecmp (hostname, serv->hostname) && serv->connected) + if (!g_ascii_strcasecmp (hostname, serv->hostname) && serv->connected) return serv; list = list->next; } @@ -3310,7 +3310,7 @@ cmd_url (struct session *sess, char *tbuf, char *word[], char *word_eol[]) /* maybe we're already connected to this net */ /* check for "FreeNode" */ - net = servlist_net_find (server_name, NULL, strcasecmp); + net = servlist_net_find (server_name, NULL, g_ascii_strcasecmp); /* check for "irc.eu.freenode.net" */ if (!net) net = servlist_net_find_from_server (server_name); @@ -3705,7 +3705,7 @@ const struct commands xc_cmds[] = { static int command_compare (const void *a, const void *b) { - return strcasecmp (a, ((struct commands *)b)->name); + return g_ascii_strcasecmp (a, ((struct commands *)b)->name); } static struct commands * @@ -4277,7 +4277,7 @@ handle_command (session *sess, char *cmd, int check_spch) while (list) { pop = (struct popup *) list->data; - if (!strcasecmp (pop->name, word[1])) + if (!g_ascii_strcasecmp (pop->name, word[1])) { user_command (sess, tbuf, pop->cmd, word, word_eol); user_cmd = TRUE; diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c index f09074a8..431ce8ab 100644 --- a/src/common/plugin-timer.c +++ b/src/common/plugin-timer.c @@ -4,7 +4,7 @@ #include "xchat-plugin.h" #ifdef WIN32 -#define strcasecmp stricmp +#define g_ascii_strcasecmp stricmp #endif static xchat_plugin *ph; /* plugin handle */ @@ -151,25 +151,25 @@ timer_cb (char *word[], char *word_eol[], void *userdata) return XCHAT_EAT_XCHAT; } - if (strcasecmp (word[2], "-quiet") == 0) + if (g_ascii_strcasecmp (word[2], "-quiet") == 0) { quiet = TRUE; offset++; } - if (strcasecmp (word[2 + offset], "-delete") == 0) + if (g_ascii_strcasecmp (word[2 + offset], "-delete") == 0) { timer_del_ref (atoi (word[3 + offset]), quiet); return XCHAT_EAT_XCHAT; } - if (strcasecmp (word[2 + offset], "-refnum") == 0) + if (g_ascii_strcasecmp (word[2 + offset], "-refnum") == 0) { ref = atoi (word[3 + offset]); offset += 2; } - if (strcasecmp (word[2 + offset], "-repeat") == 0) + if (g_ascii_strcasecmp (word[2 + offset], "-repeat") == 0) { repeat = atoi (word[3 + offset]); offset += 2; diff --git a/src/common/plugin.c b/src/common/plugin.c index 2e81c1f1..0a265d16 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -309,9 +309,9 @@ plugin_kill (char *name, int by_filename) { pl = list->data; /* static-plugins (plugin-timer.c) have a NULL filename */ - if ((by_filename && pl->filename && strcasecmp (name, pl->filename) == 0) || - (by_filename && pl->filename && strcasecmp (name, file_part (pl->filename)) == 0) || - (!by_filename && strcasecmp (name, pl->name) == 0)) + if ((by_filename && pl->filename && g_ascii_strcasecmp (name, pl->filename) == 0) || + (by_filename && pl->filename && g_ascii_strcasecmp (name, file_part (pl->filename)) == 0) || + (!by_filename && g_ascii_strcasecmp (name, pl->name) == 0)) { /* statically linked plugins have a NULL filename */ if (pl->filename != NULL && !pl->fake) @@ -472,12 +472,12 @@ plugin_hook_find (GSList *list, int type, char *name) hook = list->data; if (hook->type == type) { - if (strcasecmp (hook->name, name) == 0) + if (g_ascii_strcasecmp (hook->name, name) == 0) return list; if (type == HOOK_SERVER) { - if (strcasecmp (hook->name, "RAW LINE") == 0) + if (g_ascii_strcasecmp (hook->name, "RAW LINE") == 0) return list; } } @@ -947,8 +947,8 @@ xchat_find_context (xchat_plugin *ph, const char *servname, const char *channel) if (servname == NULL || rfc_casecmp (servname, serv->servername) == 0 || - strcasecmp (servname, serv->hostname) == 0 || - strcasecmp (servname, netname) == 0) + g_ascii_strcasecmp (servname, serv->hostname) == 0 || + g_ascii_strcasecmp (servname, netname) == 0) { if (channel == NULL) return serv->front_session; @@ -1121,7 +1121,7 @@ xchat_get_prefs (xchat_plugin *ph, const char *name, const char **string, int *i do { - if (!strcasecmp (name, vars[i].name)) + if (!g_ascii_strcasecmp (name, vars[i].name)) { switch (vars[i].type) { diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index a5ebc366..d8a6be7c 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -475,12 +475,12 @@ process_numeric (session * sess, int n, } /* use /NICKSERV */ - if (strcasecmp (word[7], "DALnet") == 0 || - strcasecmp (word[7], "BRASnet") == 0) + if (g_ascii_strcasecmp (word[7], "DALnet") == 0 || + g_ascii_strcasecmp (word[7], "BRASnet") == 0) serv->nickservtype = 1; /* use /NS */ - else if (strcasecmp (word[7], "FreeNode") == 0) + else if (g_ascii_strcasecmp (word[7], "FreeNode") == 0) serv->nickservtype = 2; goto def; @@ -1075,9 +1075,9 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[]) { text[len - 1] = 0; text++; - if (strncasecmp (text, "ACTION", 6) != 0) + if (g_ascii_strncasecmp (text, "ACTION", 6) != 0) flood_check (nick, ip, serv, sess, 0); - if (strncasecmp (text, "DCC ", 4) == 0) + if (g_ascii_strncasecmp (text, "DCC ", 4) == 0) /* redo this with handle_quotes TRUE */ process_data_init (word[1], word_eol[1], word, word_eol, TRUE, FALSE); ctcp_handle (sess, to, nick, ip, text, word, word_eol, id); diff --git a/src/common/server.c b/src/common/server.c index 919d9119..c8cc59e0 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -238,17 +238,17 @@ tcp_send_len (server *serv, char *buf, int len) dbuf[len + 1] = 0; /* privmsg and notice get a lower priority */ - if (strncasecmp (dbuf + 1, "PRIVMSG", 7) == 0 || - strncasecmp (dbuf + 1, "NOTICE", 6) == 0) + if (g_ascii_strncasecmp (dbuf + 1, "PRIVMSG", 7) == 0 || + g_ascii_strncasecmp (dbuf + 1, "NOTICE", 6) == 0) { dbuf[0] = 1; } else { /* WHO/MODE get the lowest priority */ - if (strncasecmp (dbuf + 1, "WHO ", 4) == 0 || + if (g_ascii_strncasecmp (dbuf + 1, "WHO ", 4) == 0 || /* but only MODE queries, not changes */ - (strncasecmp (dbuf + 1, "MODE", 4) == 0 && + (g_ascii_strncasecmp (dbuf + 1, "MODE", 4) == 0 && strchr (dbuf, '-') == NULL && strchr (dbuf, '+') == NULL)) dbuf[0] = 0; @@ -319,8 +319,8 @@ server_inline (server *serv, char *line, int len) if (serv->using_irc || /* 1. using CP1252/UTF-8 Hybrid */ (serv->encoding == NULL && prefs.utf8_locale) || /* OR 2. using system default->UTF-8 */ (serv->encoding != NULL && /* OR 3. explicitly set to UTF-8 */ - (strcasecmp (serv->encoding, "UTF8") == 0 || - strcasecmp (serv->encoding, "UTF-8") == 0))) + (g_ascii_strcasecmp (serv->encoding, "UTF8") == 0 || + g_ascii_strcasecmp (serv->encoding, "UTF-8") == 0))) { /* The user has the UTF-8 charset set, either via /charset command or from his UTF-8 locale. Thus, we first try the @@ -1824,10 +1824,10 @@ server_set_encoding (server *serv, char *new_encoding) space[0] = 0; /* server_inline() uses these flags */ - if (!strcasecmp (serv->encoding, "CP1255") || - !strcasecmp (serv->encoding, "WINDOWS-1255")) + if (!g_ascii_strcasecmp (serv->encoding, "CP1255") || + !g_ascii_strcasecmp (serv->encoding, "WINDOWS-1255")) serv->using_cp1255 = TRUE; - else if (!strcasecmp (serv->encoding, "IRC")) + else if (!g_ascii_strcasecmp (serv->encoding, "IRC")) serv->using_irc = TRUE; } } diff --git a/src/common/servlist.c b/src/common/servlist.c index c9d4b6a8..aa32aa4d 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -588,7 +588,7 @@ servlist_connect_by_netname (session *sess, char *network, gboolean join) { net = list->data; - if (strcasecmp (net->name, network) == 0) + if (g_ascii_strcasecmp (net->name, network) == 0) { servlist_connect (sess, net, join); return 1; @@ -733,7 +733,7 @@ servlist_net_find_from_server (char *server_name) while (slist) { serv = slist->data; - if (strcasecmp (serv->hostname, server_name) == 0) + if (g_ascii_strcasecmp (serv->hostname, server_name) == 0) return net; slist = slist->next; } @@ -1018,7 +1018,7 @@ servlist_check_encoding (char *charset) if (c) c[0] = 0; - if (!strcasecmp (charset, "IRC")) /* special case */ + if (!g_ascii_strcasecmp (charset, "IRC")) /* special case */ { if (c) c[0] = ' '; @@ -1093,8 +1093,8 @@ servlist_save (void) fprintf (fp, "J=%s\n", net->autojoin); if (net->nickserv) fprintf (fp, "B=%s\n", net->nickserv); - if (net->encoding && strcasecmp (net->encoding, "System") && - strcasecmp (net->encoding, "System default")) + if (net->encoding && g_ascii_strcasecmp (net->encoding, "System") && + g_ascii_strcasecmp (net->encoding, "System default")) { fprintf (fp, "E=%s\n", net->encoding); if (!servlist_check_encoding (net->encoding)) diff --git a/src/common/url.c b/src/common/url.c index b83732d1..9fa2d75c 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -82,7 +82,7 @@ url_find (char *urltext) { int pos; - if (tree_find (url_tree, urltext, (tree_cmp_func *)strcasecmp, NULL, &pos)) + if (tree_find (url_tree, urltext, (tree_cmp_func *)g_ascii_strcasecmp, NULL, &pos)) return 1; return 0; } @@ -117,7 +117,7 @@ url_add (char *urltext, int len) } if (!url_tree) - url_tree = tree_new ((tree_cmp_func *)strcasecmp, NULL); + url_tree = tree_new ((tree_cmp_func *)g_ascii_strcasecmp, NULL); size = tree_size (url_tree); /* 0 is unlimited */ @@ -186,7 +186,7 @@ url_check_word (char *word, int len) { int j; - /* This is pretty much strncasecmp(). */ + /* This is pretty much g_ascii_strncasecmp(). */ for (j = 0; j < l; j++) { unsigned char c = word[j]; @@ -238,7 +238,7 @@ url_check_word (char *word, int len) const unsigned char *p = &word[len - l]; int j; - /* This is pretty much strncasecmp(). */ + /* This is pretty much g_ascii_strncasecmp(). */ for (j = 0; j < l; j++) { if (tolower(p[j]) != suffix[i].s[j]) diff --git a/src/common/util.c b/src/common/util.c index 73e1b29a..fb4cd23e 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -283,7 +283,7 @@ nocasestrstr (const char *s, const char *wanted) if (len == 0) return (char *)s; - while (rfc_tolower(*s) != rfc_tolower(*wanted) || strncasecmp (s, wanted, len)) + while (rfc_tolower(*s) != rfc_tolower(*wanted) || g_ascii_strncasecmp (s, wanted, len)) if (*s++ == '\0') return (char *)NULL; return (char *)s; @@ -945,7 +945,7 @@ typedef struct static int country_compare (const void *a, const void *b) { - return strcasecmp (a, ((domain_t *)b)->code); + return g_ascii_strcasecmp (a, ((domain_t *)b)->code); } static const domain_t domain[] = diff --git a/src/common/xchat.h b/src/common/xchat.h index 540a7e1a..85c20186 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -41,8 +41,8 @@ void *xchat_realloc (char *old, int len, char *file, int line); #ifdef __EMX__ /* for o/s 2 */ #define OFLAGS O_BINARY -#define strcasecmp stricmp -#define strncasecmp strnicmp +#define g_ascii_strcasecmp stricmp +#define g_ascii_strncasecmp strnicmp #define PATH_MAX MAXPATHLEN #define FILEPATH_LEN_MAX MAXPATHLEN #endif diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index b9690731..4fbbebf6 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -1260,11 +1260,11 @@ key_action_scroll_page (GtkWidget * wid, GdkEventKey * evt, char *d1, if (d1) { - if (!strcasecmp (d1, "up")) + if (!g_ascii_strcasecmp (d1, "up")) type = PAGE_UP; - else if (!strcasecmp (d1, "+1")) + else if (!g_ascii_strcasecmp (d1, "+1")) type = LINE_DOWN; - else if (!strcasecmp (d1, "-1")) + else if (!g_ascii_strcasecmp (d1, "-1")) type = LINE_UP; } diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 0b7f7c43..1ff59354 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -1688,7 +1688,7 @@ mg_dnd_drop_file (session *sess, char *target, char *uri) while (*p) { next = strchr (p, '\r'); - if (strncasecmp ("file:", p, 5) == 0) + if (g_ascii_strncasecmp ("file:", p, 5) == 0) { if (next) *next = 0; @@ -2911,7 +2911,7 @@ mg_tabs_compare (session *a, session *b) if (a->type != SESS_CHANNEL && b->type == SESS_CHANNEL) return 1; - return strcasecmp (a->channel, b->channel); + return g_ascii_strcasecmp (a->channel, b->channel); } static void diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index 4760ba93..2a683604 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -484,18 +484,18 @@ menu_create (GtkWidget *menu, GSList *list, char *target, int check_path) { pop = (struct popup *) list->data; - if (!strncasecmp (pop->name, "SUB", 3)) + if (!g_ascii_strncasecmp (pop->name, "SUB", 3)) { childcount = 0; tempmenu = menu_quick_sub (pop->cmd, tempmenu, &subitem, XCMENU_DOLIST|XCMENU_MNEMONIC, -1); - } else if (!strncasecmp (pop->name, "TOGGLE", 6)) + } else if (!g_ascii_strncasecmp (pop->name, "TOGGLE", 6)) { childcount++; menu_toggle_item (pop->name + 7, tempmenu, toggle_cb, pop->cmd, cfg_get_bool (pop->cmd)); - } else if (!strncasecmp (pop->name, "ENDSUB", 6)) + } else if (!g_ascii_strncasecmp (pop->name, "ENDSUB", 6)) { /* empty sub menu due to no programs in PATH? */ if (check_path && childcount < 1) @@ -506,7 +506,7 @@ menu_create (GtkWidget *menu, GSList *list, char *target, int check_path) tempmenu = menu_quick_endsub (); /* If we get here and tempmenu equals menu that means we havent got any submenus to exit from */ - } else if (!strncasecmp (pop->name, "SEP", 3)) + } else if (!g_ascii_strncasecmp (pop->name, "SEP", 3)) { menu_quick_item (0, 0, tempmenu, XCMENU_SHADED, 0, 0); @@ -2190,7 +2190,7 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel, g_object_get (settings, "gtk-key-theme-name", &key_theme, NULL); if (key_theme) { - if (!strcasecmp (key_theme, "Emacs")) + if (!g_ascii_strcasecmp (key_theme, "Emacs")) { close_mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK; mymenu[SEARCH_OFFSET].key = 0; diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index 5acb683a..135a548d 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -321,7 +321,7 @@ notifygui_add_cb (GtkDialog *dialog, gint response, gpointer entry) if (text[0] && response == GTK_RESPONSE_ACCEPT) { networks = GTK_ENTRY (g_object_get_data (G_OBJECT (entry), "net"))->text; - if (strcasecmp (networks, "ALL") == 0 || networks[0] == 0) + if (g_ascii_strcasecmp (networks, "ALL") == 0 || networks[0] == 0) notify_adduser (text, NULL); else notify_adduser (text, networks); diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 71d2f02e..7d2dc85d 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -176,12 +176,12 @@ plugingui_unload (GtkWidget * wid, gpointer unused) len = strlen (file); #ifdef WIN32 - if (len > 4 && strcasecmp (file + len - 4, ".dll") == 0) + if (len > 4 && g_ascii_strcasecmp (file + len - 4, ".dll") == 0) #else #if defined(__hpux) - if (len > 3 && strcasecmp (file + len - 3, ".sl") == 0) + if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".sl") == 0) #else - if (len > 3 && strcasecmp (file + len - 3, ".so") == 0) + if (len > 3 && g_ascii_strcasecmp (file + len - 3, ".so") == 0) #endif #endif { diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 9483f04b..d6f4ad63 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -976,7 +976,7 @@ sexy_spell_entry_activate_default_languages(SexySpellEntry *entry) enchant_langs = sexy_spell_entry_get_languages(entry); /*for (i = 0; langs[i]; i++) { - if ((g_strncasecmp(langs[i], "C", 1) != 0) && + if ((g_ascii_strncasecmp(langs[i], "C", 1) != 0) && (strlen(langs[i]) >= 2) && enchant_has_lang(langs[i], enchant_langs)) { if ((lastprefix == NULL) || (g_str_has_prefix(langs[i], lastprefix) == FALSE)) @@ -1013,7 +1013,7 @@ sexy_spell_entry_activate_default_languages(SexySpellEntry *entry) lang = (gchar *) g_getenv("LANG"); if (lang != NULL) { - if (g_strncasecmp(lang, "C", 1) == 0) + if (g_ascii_strncasecmp(lang, "C", 1) == 0) lang = NULL; else if (lang[0] == '\0') lang = NULL; diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 6e314f68..547affee 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -198,7 +198,7 @@ nocasestrstr (const char *s, const char *tofind) if (len == 0) return (char *)s; - while (toupper(*s) != toupper(*tofind) || strncasecmp (s, tofind, len)) + while (toupper(*s) != toupper(*tofind) || g_ascii_strncasecmp (s, tofind, len)) if (*s++ == '\0') return (char *)NULL; return (char *)s; -- cgit 1.4.1