merges from irssi.org cvs. silc.client.0.8.3
authorPekka Riikonen <priikone@silcnet.org>
Mon, 25 Mar 2002 15:15:00 +0000 (15:15 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 25 Mar 2002 15:15:00 +0000 (15:15 +0000)
15 files changed:
CHANGES
apps/irssi/docs/help/in/bind.in
apps/irssi/docs/help/in/list.in
apps/irssi/docs/help/in/script.in [new file with mode: 0644]
apps/irssi/src/core/expandos.c
apps/irssi/src/fe-common/core/fe-help.c
apps/irssi/src/fe-common/core/fe-log.c
apps/irssi/src/fe-common/core/keyboard.c
apps/irssi/src/fe-text/statusbar-items.c
apps/irssi/src/fe-text/term-terminfo.c
apps/irssi/src/fe-text/textbuffer-commands.c
apps/irssi/src/perl/common/Irssi.pm
apps/irssi/src/perl/perl-core.c
apps/irssi/src/perl/ui/UI.pm
doc/draft-riikonen-silc-flags-payloads-00.nroff

diff --git a/CHANGES b/CHANGES
index 757cb6490f764b6068c40968d031a85b9a472358..1af5295f0222ff88a8f14e91624d5dda997074ce 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+Mon Mar 25 17:19:46 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Merged bugfixes for Irssi SILC client from irssi.org CVS.
+
 Sun Mar 24 11:21:04 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Added `type' argument to silc_id_payload_parse_id function which
index 89cfbdda34861517e027f25602ddf9f7c830eb87..51e0c0d00a63173c95fbfbdf24fd1c88e16fe4ea 100644 (file)
@@ -89,6 +89,7 @@ Command can be one of:
   check_replaces - Check word replaces
 
 (Misc)
+  nothing - use this to disable a built-in key
   refresh_screen
   yank_from_cutbuffer - "Undelete" line
   transpose_characters - Swap current and previous character
index 32a3cdbd597e215be7ffa920480213c7ec239316..a1f697e7348fb85b34ec2f275e714417e08377f9 100644 (file)
@@ -3,7 +3,14 @@
 
 Lists the channel names. Trying to list all the channel 
 names usually causes you to be disconnected from the 
-server with the reason "Excessive flood".
+server with the reason "Excess flood", as usually all
+40000 channels form together and server naively attempts
+to send you them.
 
-See also:
+Thus, on IRCNet, you should rather use service ALIS
+(Advanced Listing Service), which will allow you to query
+for channel with specific name, topic, mode or usercount.
+Type /SQUERY ALIS HELP to get more info about it.
+
+See also: SQUERY
 
diff --git a/apps/irssi/docs/help/in/script.in b/apps/irssi/docs/help/in/script.in
new file mode 100644 (file)
index 0000000..0354512
--- /dev/null
@@ -0,0 +1,19 @@
+
+@SYNTAX:script@
+
+Irssi has very powerful support for scripts written in Perl - they can extend functionality of Irssi in almost unlimited way, and they still keep the client's core unbloated, light and fast. You can control loading and execution of such scripts by this command.
+
+Without any parameters, /SCRIPT acts in same way as if you would call /SCRIPT LIST.
+
+/SCRIPT LIST displays list of all currently loaded scripts, together with full path to their source files.
+
+/SCRIPT EXEC executes the <commands> as a little perl script. It doesn't preserve it loaded in memory, unless -permanent is specified.
+
+/SCRIPT LOAD loads the <script> in memory and executes it.
+
+/SCRIPT UNLOAD unloads the <script> from memory.
+
+/SCRIPT RESET unloads all loaded scripts and resets the perl interpreter.
+
+See also: LOAD, UNLOAD
+
index 777d50e1e38d61d565c3e0633cdd69f86a3cd341..130d6025d3e2ad1bb023f9221401a8df471c02e1 100644 (file)
@@ -431,8 +431,21 @@ static char *expando_sysarch(SERVER_REC *server, void *item, int *free_ret)
 /* Topic of active channel (or address of queried nick) */
 static char *expando_topic(SERVER_REC *server, void *item, int *free_ret)
 {
-       return IS_CHANNEL(item) ? CHANNEL(item)->topic :
-               IS_QUERY(item) ? QUERY(item)->address : "";
+       if (IS_CHANNEL(item))
+               return CHANNEL(item)->topic;
+       if (IS_QUERY(item)) {
+               QUERY_REC *query = QUERY(item);
+
+               if (query->server_tag == NULL)
+                       return "";
+
+                *free_ret = TRUE;
+               return query->address == NULL ?
+                       g_strdup_printf("(%s)", query->server_tag) :
+                       g_strdup_printf("%s (%s)", query->address,
+                                       query->server_tag);
+       }
+        return "";
 }
 
 /* Server tag */
index fa90473d308bcf7efc7358d09d5766e5674b99e2..c087771b1bfde5a875b8feecb5f8e030f9b968d2 100644 (file)
 
 static int commands_equal(COMMAND_REC *rec, COMMAND_REC *rec2)
 {
+       int i;
+
        if (rec->category == NULL && rec2->category != NULL)
                return -1;
        if (rec2->category == NULL && rec->category != NULL)
                return 1;
+       if (rec->category != NULL && rec2->category != NULL) {
+               i = strcmp(rec->category, rec2->category);
+               if (i != 0)
+                       return i;
+       }
 
        return strcmp(rec->cmd, rec2->cmd);
 }
index e7b4ae534d5aa113e67583e1220caa95cf6a72b5..bebff7f587bec2d96be823139c4d414d2a4b3862 100644 (file)
@@ -407,7 +407,7 @@ static void autolog_open(SERVER_REC *server, const char *server_tag,
                         const char *target)
 {
        LOG_REC *log;
-       char *fname, *dir, *fixed_target;
+       char *fname, *dir, *fixed_target, *params;
 
        log = logs_find_item(LOG_ITEM_TARGET, target, server_tag, NULL);
        if (log != NULL && !log->failed) {
@@ -423,10 +423,14 @@ static void autolog_open(SERVER_REC *server, const char *server_tag,
        if (CHAT_PROTOCOL(server)->case_insensitive)
                g_strdown(fixed_target);
 
-       fname = parse_special_string(autolog_path, server, NULL,
-                                    fixed_target, NULL, 0);
+        /* $0 = target, $1 = server tag */
+        params = g_strconcat(fixed_target, " ", server_tag, NULL);
        g_free(fixed_target);
 
+       fname = parse_special_string(autolog_path, server, NULL,
+                                    params, NULL, 0);
+       g_free(params);
+
        if (log_find(fname) == NULL) {
                log = log_create_rec(fname, autolog_level);
                 if (!settings_get_bool("autolog_colors"))
index e622f973ce769b8809f052e1f804c3d091215676..3c0efade7b5d47de73529de8fcecf46e1df03f59 100644 (file)
@@ -633,6 +633,10 @@ static void sig_multi(const char *data, void *gui_data)
         g_strfreev(list);
 }
 
+static void sig_nothing(const char *data)
+{
+}
+
 static void cmd_show_keys(const char *searchkey, int full)
 {
        GSList *info, *key;
@@ -816,6 +820,7 @@ void keyboard_init(void)
        key_bind("command", "Run any IRC command", NULL, NULL, (SIGNAL_FUNC) sig_command);
        key_bind("key", "Specify name for key binding", NULL, NULL, (SIGNAL_FUNC) sig_key);
        key_bind("multi", "Run multiple commands", NULL, NULL, (SIGNAL_FUNC) sig_multi);
+       key_bind("nothing", "Do nothing", NULL, NULL, (SIGNAL_FUNC) sig_nothing);
 
        /* read the keyboard config when all key binds are known */
        signal_add("irssi init read settings", (SIGNAL_FUNC) read_keyboard_config);
index fc1d526fb820130e4a4f79c6a11737c67ca2a7d2..fe74a748276c42e32f662c2eb47042c5a1610dd1 100644 (file)
@@ -344,12 +344,13 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
 {
        GUI_ENTRY_REC *rec;
 
-       rec = g_hash_table_lookup(input_entries, item->bar);
+       rec = g_hash_table_lookup(input_entries, item->bar->config->name);
        if (rec == NULL) {
                rec = gui_entry_create(item->xpos, item->bar->real_ypos,
                                       item->size, term_type == TERM_TYPE_UTF8);
                gui_entry_set_active(rec);
-               g_hash_table_insert(input_entries, item->bar, rec);
+               g_hash_table_insert(input_entries,
+                                   g_strdup(item->bar->config->name), rec);
        }
 
        if (get_size_only) {
@@ -363,17 +364,6 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
        gui_entry_redraw(rec); /* FIXME: this is only necessary with ^L.. */
 }
 
-static void sig_statusbar_destroyed(STATUSBAR_REC *bar)
-{
-       GUI_ENTRY_REC *rec;
-
-       rec = g_hash_table_lookup(input_entries, bar);
-       if (rec != NULL) {
-               gui_entry_destroy(rec);
-               g_hash_table_remove(input_entries, bar);
-       }
-}
-
 static void read_settings(void)
 {
        if (active_entry != NULL)
@@ -418,9 +408,8 @@ void statusbar_items_init(void)
         lag_timeout_tag = g_timeout_add(5000, (GSourceFunc) sig_lag_timeout, NULL);
 
         /* input */
-       input_entries = g_hash_table_new((GHashFunc) g_direct_hash,
-                                        (GCompareFunc) g_direct_equal);
-       signal_add("statusbar destroyed", (SIGNAL_FUNC) sig_statusbar_destroyed);
+       input_entries = g_hash_table_new((GHashFunc) g_str_hash,
+                                        (GCompareFunc) g_str_equal);
 
        read_settings();
         signal_add_last("setup changed", (SIGNAL_FUNC) read_settings);
@@ -450,8 +439,8 @@ void statusbar_items_deinit(void)
         g_source_remove(lag_timeout_tag);
 
         /* input */
-       signal_remove("statusbar destroyed", (SIGNAL_FUNC) sig_statusbar_destroyed);
-        g_hash_table_destroy(input_entries);
+        g_hash_table_foreach(input_entries, (GHFunc) g_free, NULL);
+       g_hash_table_destroy(input_entries);
 
         signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
 }
index 5716b36c0655fa3f8dc383ef506fe472e321a955..54a02a6b4caa000aab5ef597fb233a5a92f538d7 100644 (file)
@@ -119,6 +119,7 @@ int term_init(void)
 void term_deinit(void)
 {
        if (current_term != NULL) {
+               signal(SIGCONT, SIG_DFL);
                g_source_remove(redraw_tag);
 
                term_common_deinit();
index db5bc782f93aef69e9db49cf742ad40fd60a52d9..61350a3ee35f3346816d5a33cc29dff989181ff3 100644 (file)
 #include "gui-windows.h"
 #include "textbuffer-reformat.h"
 
-/* SYNTAX: CLEAR */
+/* SYNTAX: CLEAR [-all] [<refnum>] */
 static void cmd_clear(const char *data)
 {
+        WINDOW_REC *window;
        GHashTable *optlist;
+        char *refnum;
        void *free_arg;
         GSList *tmp;
 
        g_return_if_fail(data != NULL);
 
-       if (!cmd_get_params(data, &free_arg, PARAM_FLAG_OPTIONS,
-                           "clear", &optlist)) return;
+       if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
+                           "clear", &optlist, &refnum)) return;
 
-       if (g_hash_table_lookup(optlist, "all") == NULL) {
-                /* clear active window */
-               textbuffer_view_clear(WINDOW_GUI(active_win)->view);
-       } else {
+       if (g_hash_table_lookup(optlist, "all") != NULL) {
                 /* clear all windows */
                for (tmp = windows; tmp != NULL; tmp = tmp->next) {
                        WINDOW_REC *window = tmp->data;
 
                        textbuffer_view_clear(WINDOW_GUI(window)->view);
                }
+       } else if (*refnum != '\0') {
+                /* clear specified window */
+               window = window_find_refnum(atoi(refnum));
+                if (window != NULL)
+                       textbuffer_view_clear(WINDOW_GUI(window)->view);
+       } else {
+                /* clear active window */
+               textbuffer_view_clear(WINDOW_GUI(active_win)->view);
        }
 
        cmd_params_free(free_arg);
index 14d3f4dca3a559a65b3c1a864de815a414b27710..eb1d367b88a2451392d3a5965cd27f05c78b8537 100644 (file)
@@ -5,8 +5,101 @@
 package Irssi;
 
 use strict;
+use Carp;
 use vars qw($VERSION $in_irssi @ISA @EXPORT @EXPORT_OK);
 
+# TIEHANDLE methods
+
+sub TIEHANDLE {
+  my ($class, $level, $object, $target) = @_;
+  return bless [ $level, $object, $target ], $class;
+}
+
+sub WRITE {
+  croak "Cannot syswrite() to an Irssi handle"
+}
+
+sub PRINT {
+  my ($self, @list) = @_;
+  if (defined $self->[1]) {
+    if (defined $self->[2]) {
+      $self->[1]->print($self->[2], join('', @list), $self->[0]);
+    } else {
+      $self->[1]->print(join('', @list), $self->[0]);
+    }
+  } else {
+    Irssi::print(join('', @list), $self->[0]);
+  }
+}
+
+sub PRINTF {
+  my ($self, $format, @list) = @_;
+  if (defined $self->[1]) {
+    if (defined $self->[2]) {
+      $self->[1]->print($self->[2], sprintf($format, @list), $self->[0]);
+    } else {
+      $self->[1]->print(sprintf($format, @list), $self->[0]);
+    }
+  } else {
+    Irssi::print(sprintf($format, @list), $self->[0]);
+  }
+}
+
+sub READ {
+  croak "Cannot [sys]read() from an Irssi handle"
+}
+
+sub READLINE {
+  croak "Cannot readline() from an Irssi handle"
+}
+
+sub GETC {
+  croak "Cannot getc() from an Irssi handle"
+}
+
+sub CLOSE {}
+sub UNTIE {}
+sub DESTROY {}
+
+# End of TIEHANDLE methods
+
+# Handle creators
+
+sub create_window_handle {
+  my ($object, $level) = @_;
+  $object = eval 'active_win'          unless defined $object;
+  $level  = eval 'MSGLEVEL_CLIENTCRAP' unless defined $level;
+  croak 'Usage: create_window_handle([$window[, $level]])'
+    if ref $object !~ /::Window$/i;
+  no strict 'refs';
+  my $symref = 'Irssi::Handles::' . $object . '/' . $level;
+  my $fh = \*{$symref};
+  tie *{$symref}, __PACKAGE__, $level, $object;
+  return $fh;
+}
+
+sub create_server_handle {
+  my ($object, $target, $level) = @_;
+  croak 'Usage: create_server_handle($server, $target[, $level])'
+    if not defined $object
+    or not defined $target
+    or ref $object !~ /::Server$/i;
+  $level = eval 'MSGLEVEL_CLIENTCRAP' unless defined $level;
+  no strict 'refs';
+  my $symref = 'Irssi::Handles::' . $object . '/' . $target . '/' . $level;
+  my $fh = \*{$symref};
+  tie *{$symref}, __PACKAGE__, $level, $object, $target;
+  return $fh;
+}
+
+# Object interface for create_server_handle
+
+sub Irssi::Server::create_handle {
+  goto &Irssi::create_server_handle;
+}
+
+# Normal Irssi.pm stuff
+
 sub VERSION {
   my $version = $_[1];
   die "This script requires irssi version $version or later"
@@ -14,8 +107,20 @@ sub VERSION {
 }
 
 sub EXPORT_ALL () {
+  my %exports = map { $_ => undef } @EXPORT, @EXPORT_OK;
   no strict 'refs';
-  @EXPORT_OK = grep { /[a-z]/ && defined *{$_}{CODE} } keys %Irssi::;
+  for (keys %Irssi::) {
+    if (/^MSGLEVEL_/) {
+      (my $short = $_) =~ s///;
+      next if exists $exports{"*$short"};
+      tie *{ $short }, __PACKAGE__, &$_();
+      push @EXPORT, "*$short";
+    } else {
+      next if exists $exports{$_};
+      push @EXPORT_OK, $_ if /[a-z]/ && defined *{$_}{CODE};
+    }
+  }
+  select CLIENTCRAP;
 }
 
 sub in_irssi {
@@ -37,7 +142,6 @@ require DynaLoader;
        MSGLEVEL_CLIENTERROR MSGLEVEL_HILIGHT MSGLEVEL_ALL MSGLEVEL_NOHILIGHT
        MSGLEVEL_NO_ACT MSGLEVEL_NEVER MSGLEVEL_LASTLOG
 );
-@EXPORT_OK = qw();
 
 my $static = 0;
 
@@ -60,4 +164,3 @@ if (!in_irssi()) {
 }
 
 1;
-
index 1ed95c373fdfaf9492600686ce1005f4c5a05175..accd5ef478aa1957ab7f974614c2dc635b5b72a5 100644 (file)
@@ -444,7 +444,7 @@ void perl_core_init(void)
         print_script_errors = 1;
        settings_add_str("perl", "perl_use_lib", PERL_USE_LIB);
 
-       PL_perl_destruct_level = 1;
+       /*PL_perl_destruct_level = 1; - this crashes with some people.. */
        perl_signals_init();
         signal_add_last("script error", (SIGNAL_FUNC) sig_script_error);
 
index 5bab7b6bd419aa1a644bb236ef058628a72a03e3..83b9ef29ad61d27ebcffacf2dc2ff89e72d1464c 100644 (file)
@@ -12,6 +12,10 @@ $VERSION = "0.9";
 require Exporter;
 require DynaLoader;
 
+sub Irssi::UI::Window::create_handle {
+  goto &Irssi::create_window_handle;
+}
+
 @ISA = qw(Exporter DynaLoader);
 @EXPORT = qw();
 @EXPORT_OK = qw();
index 00c7902f59fd55ce3052f08adafb6d97bddf67a0..8ba7d4516587f13780ac89685cb812fc7d5492da 100644 (file)
@@ -95,7 +95,7 @@ Message Flags to the Private Message Payload and Channel Message Payload
 and how it should be interpreted.  Some of the Message Flags may define 
 additional payloads to be associated with the flag, but the [SILC2] does 
 not define them.  This memo defines the payloads for those Message Flags 
-that was marked to include additional payloads in [SILC1].
+that was marked to include additional payloads in [SILC2].
 
 By defining the payloads for the Message Flags the SILC message payloads 
 can be augmented to support any kind of data, which can be easily