From ed034bf80a39a337803df0161d7f80fd226a6856 Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Tue, 28 Aug 2012 19:10:03 -0700 Subject: Enhance LASTLOG to use gtk_xtext_search_textentry() --- src/common/fe.h | 2 +- src/common/outbound.c | 53 +++++++++++++++++++++++++++++++++++++-------------- src/common/xchat.c | 2 +- src/common/xchat.h | 11 ++++++++++- 4 files changed, 51 insertions(+), 17 deletions(-) (limited to 'src/common') diff --git a/src/common/fe.h b/src/common/fe.h index e330ef3e..3fa4e2bc 100644 --- a/src/common/fe.h +++ b/src/common/fe.h @@ -98,7 +98,7 @@ void fe_set_nonchannel (struct session *sess, int state); void fe_set_nick (struct server *serv, char *newnick); void fe_ignore_update (int level); void fe_beep (void); -void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gboolean regexp); +void fe_lastlog (session *sess, session *lastlog_sess, char *sstr, gtk_xtext_search_flags flags); void fe_set_lag (server *serv, int lag); void fe_set_throttle (server *serv); void fe_set_away (server *serv); diff --git a/src/common/outbound.c b/src/common/outbound.c index 060c6742..2e79d59e 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -2362,7 +2362,7 @@ cmd_lagcheck (struct session *sess, char *tbuf, char *word[], char *word_eol[]) } static void -lastlog (session *sess, char *search, gboolean regexp) +lastlog (session *sess, char *search, gtk_xtext_search_flags flags) { session *lastlog_sess; @@ -2374,29 +2374,50 @@ lastlog (session *sess, char *search, gboolean regexp) lastlog_sess = new_ircwindow (sess->server, "(lastlog)", SESS_DIALOG, 0); lastlog_sess->lastlog_sess = sess; - lastlog_sess->lastlog_regexp = regexp; /* remember the search type */ + lastlog_sess->lastlog_flags = flags; fe_text_clear (lastlog_sess, 0); - fe_lastlog (sess, lastlog_sess, search, regexp); + fe_lastlog (sess, lastlog_sess, search, flags); } static int cmd_lastlog (struct session *sess, char *tbuf, char *word[], char *word_eol[]) { - if (*word_eol[2]) + int j = 2; + gtk_xtext_search_flags flags = 0; + gboolean doublehyphen = FALSE; + + while (word_eol[j] != NULL && word_eol [j][0] == '-' && !doublehyphen) { - if (!strcmp (word[2], "-r")) - { - lastlog (sess, word_eol[3], TRUE); - } - else + switch (word_eol [j][1]) { - lastlog (sess, word_eol[2], FALSE); + case 'r': + flags |= regexp; + break; + case 'm': + flags |= case_match; + break; + case 'h': + flags |= highlight; + break; + case '-': + doublehyphen = TRUE; + break; + default: + break; + /* O dear whatever shall we do here? */ } + j++; + } + if (*word_eol[j]) + { + lastlog (sess, word_eol[j], flags); return TRUE; } - - return FALSE; + else + { + return FALSE; + } } static int @@ -3602,7 +3623,11 @@ const struct commands xc_cmds[] = { {"LAGCHECK", cmd_lagcheck, 0, 0, 1, N_("LAGCHECK, forces a new lag check")}, {"LASTLOG", cmd_lastlog, 0, 0, 1, - N_("LASTLOG [-r] , searches for a string in the buffer")}, + N_("LASTLOG [-h] [-m] [-r] [--] , searches for a string in the buffer\n" + " Use -h to highlight the found string(s)\n" + " Use -m to match case\n" + " Use -r when string is a Regular Expression\n" + " Use -- (double hyphen) to end options when searching for, say, the string '-r'")}, {"LIST", cmd_list, 1, 0, 1, 0}, {"LOAD", cmd_load, 0, 0, 1, N_("LOAD [-e] , loads a plugin or script")}, @@ -4099,7 +4124,7 @@ handle_say (session *sess, char *text, int check_spch) if (strcmp (sess->channel, "(lastlog)") == 0) { - lastlog (sess->lastlog_sess, text, sess->lastlog_regexp); + lastlog (sess->lastlog_sess, text, sess->lastlog_flags); return; } diff --git a/src/common/xchat.c b/src/common/xchat.c index f90a6291..21e2bd9e 100644 --- a/src/common/xchat.c +++ b/src/common/xchat.c @@ -591,7 +591,7 @@ static char defaultconf_commands[] = "NAME DIALOG\n" "CMD query %2\n\n"\ "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ "NAME EXIT\n" "CMD quit\n\n"\ - "NAME GREP\n" "CMD lastlog -r &2\n\n"\ + "NAME GREP\n" "CMD lastlog -r -- &2\n\n"\ "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ "NAME J\n" "CMD join &2\n\n"\ "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ diff --git a/src/common/xchat.h b/src/common/xchat.h index 66f43522..0ebe83cf 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -346,6 +346,15 @@ struct xchatprefs #define SET_ON 1 #define SET_DEFAULT 2 /* use global setting */ +/* Moved from fe-gtk for use in outbound.c as well -- */ +typedef enum gtk_xtext_search_flags_e { + case_match = 1, + backward = 2, + highlight = 4, + follow = 8, + regexp = 16 +} gtk_xtext_search_flags; + typedef struct session { /* Per-Channel Alerts */ @@ -405,7 +414,7 @@ typedef struct session int end_of_names:1; int doing_who:1; /* /who sent on this channel */ int done_away_check:1; /* done checking for away status changes */ - unsigned int lastlog_regexp:1; /* this is a lastlog and using regexp */ + gtk_xtext_search_flags lastlog_flags; } session; struct msproxy_state_t -- cgit 1.4.1