irssi-import / bugs.irssi.org

bugs.irssi.org archive
https://github.com/irssi/irssi/issues
0 stars 0 forks source link

[PATCH] add -refnum option to /join, for opening channels in the background #203

Open irssibot opened 19 years ago

irssibot commented 19 years ago

I would like to be able to specify -refnum xx in /join, so that a channel is opened in a background window without stealing focus or interrupting the user.

In my case I am using this to facilitate scripted background reconnects on servers that are anal-retentive about nick ident, vhosts, etc. Example usage:

/join -window -refnum 3 -freenode #linux

irssibot commented 19 years ago

window_refnum.patch

see bug text

diff -ru irssi/src/fe-common/core/fe-channels.c irssi.new/src/fe-common/core/fe-channels.c
--- irssi/src/fe-common/core/fe-channels.c  Sun Feb 20 23:27:24 2005
+++ irssi.new/src/fe-common/core/fe-channels.c  Mon Feb 21 00:02:26 2005
@@ -47,10 +47,28 @@
    }
 }

+static int dst_refnum = 0;
+
 static void signal_channel_created_curwin(CHANNEL_REC *channel)
 {
+   GSList *tmp, *sorted;
+
    g_return_if_fail(channel != NULL);

+   if(dst_refnum > 0)
+   {
+       sorted = windows_get_sorted();
+       for (tmp = sorted ; tmp != NULL ; tmp = tmp->next) {
+           WINDOW_REC *rec = tmp->data;
+
+           if(rec->refnum == dst_refnum)
+           {
+               window_item_add(rec, (WI_ITEM_REC *)channel,
+                   TRUE);
+               return;
+           }
+       }
+   }
    window_item_add(active_win, (WI_ITEM_REC *) channel, FALSE);
 }

@@ -115,6 +133,7 @@
    GHashTable *optlist;
    char *nick;
    void *free_arg;
+   char *refnum_s;

    if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
                PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
@@ -130,6 +149,11 @@
    if (g_hash_table_lookup(optlist, "window") != NULL) {
        signal_add("channel created",
               (SIGNAL_FUNC) signal_channel_created_curwin);
+       refnum_s = g_hash_table_lookup(optlist, "refnum");
+       if(refnum_s && is_numeric(refnum_s, 0))
+       {
+           dst_refnum = atoi(refnum_s);
+       }
         }
    cmd_params_free(free_arg);
 }
@@ -178,6 +202,7 @@
               (SIGNAL_FUNC) signal_channel_created_curwin);
    }
    cmd_params_free(free_arg);
+   dst_refnum = 0;
 }

 static void cmd_channel_list_joined(void)
@@ -646,7 +671,7 @@

    command_set_options("channel add", "auto noauto -bots -botcmd");
    command_set_options("names", "count ops halfops voices normal");
-   command_set_options("join", "window");
+   command_set_options("join", "window -refnum");
 }

 void fe_channels_deinit(void)