]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
[colon_emoji] Add tab completion signal (#847)
authorRhonda D'Vine <redacted>
Sun, 21 May 2023 07:47:31 +0000 (09:47 +0200)
committerGitHub <redacted>
Sun, 21 May 2023 07:47:31 +0000 (09:47 +0200)
* Add tab completion signal

If your colon emoji completes, this will get processed now

scripts/colon_emoji.pl

index e7f98c4d2862347101bdb12ce676d0a118de92ed..43072a8b2ec89fdbe6e1e9203f1dc3d161e02769 100644 (file)
@@ -1,10 +1,10 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.3';
+our $VERSION = '0.4';
 our %IRSSI = (
-    authors     => 'Lars Djerf, Nei, Phoenix616',
-    contact     => 'lars.djerf@gmail.com, Nei @ anti@conference.jabber.teamidiot.de, Phoenix616 @ mail@moep.tv',
+    authors     => 'Lars Djerf, Nei, Phoenix616, Rhonda D\'Vine',
+    contact     => 'lars.djerf@gmail.com, Nei @ anti@conference.jabber.teamidiot.de, Phoenix616 @ mail@moep.tv, rhonda @ deb.at',
     name        => 'colon_emoji',
     description => 'Replace words between :...: in messages according to a text file. Was intended for Unicode Emoji on certain proprietary platforms.',
     license     => 'GPLv3',
@@ -36,6 +36,8 @@ our %IRSSI = (
 # Changelog
 # =========
 # 0.2: Handle outgoing messages
+# 0.3: ???
+# 0.4: tab completion added
 #
 
 use File::Basename 'dirname';
@@ -76,6 +78,18 @@ sub sig_send {
     }
 }
 
+sub sig_complete {
+    my ($list, $window, $word, $linestart, $want_space) = @_;
+    return unless $word =~ /^:/i;
+    my @newlist;
+    my ($str) = $word =~ /^:(.*):?$/;
+    foreach (keys %emojie) {
+        push @newlist, $emojie{$_} if /^(\Q$str\E.*)$/;
+    }
+    push @$list, $_ foreach @newlist;
+    Irssi::signal_stop();
+}
+
 sub event_message {
     my ($server, $msg, @rest) = @_;
     $msg =~ s/$regex/$emojie{$1}/g;
@@ -142,5 +156,6 @@ Irssi::signal_add_first('message public' => 'sig_message_public');
 Irssi::signal_add_first('message private' => 'sig_message_private');
 Irssi::signal_add_first('send command' => 'sig_send');
 Irssi::signal_add_first('send text' => 'sig_send');
+Irssi::signal_add_first('complete word', 'sig_complete');
 
 init();
git clone https://git.99rst.org/PROJECT