-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What:
/lastlog, once this patch is applied, accepts a new parameter, -output
<refnum|window>.  This lets you set where lastlog should place the
output (if not the current window).  This output also works with -clear,
clearing the selected window of any lastlog output.

Why:
Ok, this was discussed in #irssi on freenode for a bit.  I obviously use
lastlog strangely, but I like having lastlog results in a seperate
"logs" window.  This is so I can keep reading the current channel, while
still checking through a lastlog.  Rather than having to switch to a new
channel and running lastlog, I wrote this patch.

Patch is attached, or can also be retrieved from
http://www.strudel-hound.com/irssi-lastlog-output.patch

Signed-off-by: William Pettersson <[EMAIL PROTECTED]>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHlGoZNSpXjKoV00kRAp7iAKCE6m9pJ36dxFxMJgaRU42Uhf2WkACZAUdB
ZZPd+yhrM871zWdAYJr2qqw=
=oGkj
-----END PGP SIGNATURE-----
--- src/fe-text/lastlog.c.old   2008-01-21 17:52:32.000000000 +1000
+++ src/fe-text/lastlog.c       2008-01-21 18:19:18.000000000 +1000
@@ -77,7 +77,7 @@
 static void show_lastlog(const char *searchtext, GHashTable *optlist,
                         int start, int count, FILE *fhandle)
 {
-       WINDOW_REC *window;
+       WINDOW_REC *window, *output;
         LINE_REC *startline;
        GList *list, *tmp;
        GString *line;
@@ -88,8 +88,22 @@
        if (level == -1) return; /* error in options */
         if (level == 0) level = MSGLEVEL_ALL;
 
+        /* which window to output to */
+        output = active_win;
+        str = g_hash_table_lookup(optlist, "output");
+       if (str != NULL) {
+               output = is_numeric(str, '\0') ?
+                       window_find_refnum(atoi(str)) :
+                       window_find_item(NULL, str);
+               if (output == NULL) {
+                       printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+                                    TXT_REFNUM_NOT_FOUND, str);
+                       return;
+               }
+        }
+
        if (g_hash_table_lookup(optlist, "clear") != NULL) {
-               
textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, 
MSGLEVEL_LASTLOG);
+               textbuffer_view_remove_lines_by_level(WINDOW_GUI(output)->view, 
MSGLEVEL_LASTLOG);
                if (*searchtext == '\0')
                         return;
        }
@@ -151,7 +165,7 @@
        }
 
        if (g_hash_table_lookup(optlist, "count") != NULL) {
-               printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
+               printformat_window(output, MSGLEVEL_CLIENTNOTICE,
                                   TXT_LASTLOG_COUNT, len);
                g_list_free(list);
                return;
@@ -159,7 +173,7 @@
 
        if (len > MAX_LINES_WITHOUT_FORCE && fhandle == NULL &&
            g_hash_table_lookup(optlist, "force") == NULL) {
-               printformat_window(active_win,
+               printformat_window(output,
                                   MSGLEVEL_CLIENTNOTICE|MSGLEVEL_LASTLOG,
                                   TXT_LASTLOG_TOO_LONG, len);
                g_list_free(list);
@@ -167,7 +181,7 @@
        }
 
        if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
-               printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_START);
+               printformat_window(output, MSGLEVEL_LASTLOG, TXT_LASTLOG_START);
 
        line = g_string_new(NULL);
         while (tmp != NULL && (count < 0 || count > 0)) {
@@ -179,7 +193,7 @@
                        if (fhandle != NULL) {
                                fwrite("--\n", 3, 1, fhandle);
                        } else {
-                               printformat_window(active_win,
+                               printformat_window(output,
                                                   MSGLEVEL_LASTLOG,
                                                   TXT_LASTLOG_SEPARATOR);
                        }
@@ -204,7 +218,7 @@
                        fwrite(line->str, line->len, 1, fhandle);
                        fputc('\n', fhandle);
                } else {
-                       printtext_window(active_win, MSGLEVEL_LASTLOG,
+                       printtext_window(output, MSGLEVEL_LASTLOG,
                                         "%s", line->str);
                }
 
@@ -214,7 +228,7 @@
         g_string_free(line, TRUE);
 
        if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
-               printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_END);
+               printformat_window(output, MSGLEVEL_LASTLOG, TXT_LASTLOG_END);
 
        textbuffer_view_set_bookmark_bottom(WINDOW_GUI(window)->view,
                                            "lastlog_last_check");
@@ -224,8 +238,8 @@
 }
 
 /* SYNTAX: LASTLOG [-] [-file <filename>] [-window <ref#|name>] [-new | -away]
-                  [-<level> -<level...>] [-clear] [-count] [-case]
-                  [-regexp | -word] [-before [<#>]] [-after [<#>]]
+                  [-<level> -<level...>] [-clear] [-count] [-output 
<ref#|name>]
+                  [-regexp | -word] [-before [<#>]] [-after [<#>]] [-case]
                   [-<# before+after>] [<pattern>] [<count> [<start>]] */
 static void cmd_lastlog(const char *data)
 {
@@ -286,7 +300,7 @@
 {
        command_bind("lastlog", NULL, (SIGNAL_FUNC) cmd_lastlog);
 
-       command_set_options("lastlog", "!- # force clear -file -window new away 
word regexp case count @a @after @before");
+       command_set_options("lastlog", "!- # force clear -file -window -output 
new away word regexp case count @a @after @before");
 }
 
 void lastlog_deinit(void)

Reply via email to