diff --git a/emojis.pl b/emojis.pl index 0b66ff0..46d918a 100644 --- a/emojis.pl +++ b/emojis.pl @@ -3,7 +3,7 @@ use Irssi; -$VERSION = '1.21'; +$VERSION = '1.22'; %IRSSI = ( authors => 'Alexandre Gauthier', @@ -93,28 +93,36 @@ sub knifaize { $locked = 0; } -sub emojitable { - Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tblh', "List of emojis"); - while ( my($trigger, $emoji) = each(%EMOJIS) ) { - Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tbl', $trigger); - Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tbl', " $emoji"); - } - Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tblf', "End emojis"); -} - +# void complete_emoji($complist, $window, $word, $linerestart, $wspace) +# Tab completion hook for emoji triggers, completes to emoji on match. sub complete_emoji { my ($complist, $window, $word, $linestart, $want_space) = @_; - my $word_regexp = quotemeta ($word); + my $word_regexp = quotemeta($word); $word_regexp = qr/^$word_regexp/i; # Compile regexp + my @matches = (); foreach my $trigger (keys %EMOJIS) { - push(@matches, $trigger) if ($trigger =~ m/$word_regexp/); + push(@matches, $trigger) if ($trigger =~ m/$word_regexp/); } + if (scalar(@matches) > 0) { - push(@{$complist}, $EMOJIS{@matches[0]}); + push(@{$complist}, $EMOJIS{$matches[0]}); } # TODO if more than one match, do something smart? } + +# void emojitable() +# Display a list of all emojis and keys in a crappy table. +# TODO: Eventually reconcile this with Oliver Uvman's pretty printing +sub emojitable { + Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tblh', "List of emojis"); + while ( my($trigger, $emoji) = each(%EMOJIS) ) { + Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tbl', $trigger); + Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tbl', " $emoji"); + } + Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'tblf', "End emojis"); +} + # Settings Irssi::settings_add_bool('lookandfeel', 'knifamode_enable', 1); Irssi::settings_add_str('lookandfeel', 'knifamode_dbfile',