Skip to content

Commit

Permalink
Bump version, reformat blocks, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdaemon committed Jul 31, 2012
1 parent 241312c commit e826409
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions emojis.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Irssi;

$VERSION = '1.21';
$VERSION = '1.22';

%IRSSI = (
authors => 'Alexandre Gauthier',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit e826409

Please sign in to comment.