]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Added utf-8 support and auto-completion.
authorDawid Ł <redacted>
Sun, 10 Mar 2019 02:23:41 +0000 (03:23 +0100)
committerGitHub <redacted>
Sun, 10 Mar 2019 02:23:41 +0000 (03:23 +0100)
- fixed messages containing utf-8 characters
- added tab-completion to emotes
- added "rud_emotes_space_after_completion" settings flag

scripts/rud_emotes.pl

index de55cbaad19317ab66346d9a68d1636081ac9cc3..bef005327818103abe8ee19d60afa72b37d21624 100644 (file)
@@ -1,4 +1,4 @@
-#    Copyright (C) 2016  Dawid Lekawski
+#    Copyright (C) 2016-2019  Dawid 'rud0lf' Lekawski
 #      contact: xxrud0lf@gmail.com
 #
 #       --- INFORMATION ---
 #   - moved text output messages into nice and clean theme_register
 #
 #
+#   -- CHANGES: -- ( v 1.20, 10-03-2019 )
+#
+#   - fixed messages containing utf-8 characters
+#   - added tab-completion to emotes
+#   - added "rud_emotes_space_after_completion" settings flag
 
 use strict;
 use warnings;
 use utf8;
 
+use Encode qw(decode_utf8 encode_utf8);
 use Irssi qw(signal_add signal_continue command_bind theme_register
-       printformat);
+       printformat settings_add_bool);
 
-our $VERSION = "1.10";
+our $VERSION = "1.20";
 our %IRSSI = (
        authors         => "Dawid 'rud0lf' Lekawski",
        contact         => 'rud0lf/IRCnet; rud0lf/freenode; xxrud0lf@gmail.com',
@@ -131,7 +137,9 @@ sub process_emotes {
                return $line;
        }
 
+    $line = decode_utf8($line);
        $line =~ s/:($pattern):/$emotes{$1}/g;
+    $line = encode_utf8($line);
 
        return $line;
 }
@@ -166,8 +174,23 @@ sub cmd_emotes {
        printformat(MSGLEVEL_CLIENTCRAP, 'rud_emotes_total', scalar(keys %emotes));
 }
 
+sub sig_complete_word {
+    my ($list, $win, $word, $prefix, $want_space) = @_;
+    return unless ($word =~ /:(\w+)/);
+    my $p = $1;
+    my $sp = Irssi::settings_get_bool('rud_emotes_space_after_completion');
+    foreach (keys %emotes) {
+        if ($_ =~ /$p\w+/) {
+            push @$list, ":$_:";
+            $$want_space = $sp;
+        } 
+    }
+}
+
 init();
 
 signal_add("send text", "sig_send_text");
 signal_add("command me", "sig_command_me");
+signal_add("complete word", "sig_complete_word");
 command_bind("emotes", "cmd_emotes");
+settings_add_bool('rud_emotes', 'rud_emotes_space_after_completion', 1);
git clone https://git.99rst.org/PROJECT