diff options
| author | Teddy Wing | 2017-12-17 00:36:05 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-12-17 00:36:05 +0100 |
| commit | 3f54e141e69452d97fdd08f164dab3da83e14f68 (patch) | |
| tree | b7a9336a7e156e173958b27e19ff9af79b976a7c | |
| parent | c9bec2cd5af8fb779f93727f63a4ae60b0eb2347 (diff) | |
| download | irssi-vimput-3f54e141e69452d97fdd08f164dab3da83e14f68.tar.bz2 | |
pipe_input: Make subroutines for message prefix conditions
Make this more readable by giving names to these `index` tests.
| -rw-r--r-- | vimput.pl | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -142,12 +142,12 @@ sub pipe_input { my $input = <$read_handle>; - if (index($input, ERROR_PREFIX) == 0) { + if (is_error_message($input)) { $input = substr($input, length(ERROR_PREFIX)); Irssi::print($input, MSGLEVEL_CLIENTERROR); } - elsif (index($input, OK_PREFIX) == 0) { + elsif (is_ok_message($input)) { $input = substr($input, length(OK_PREFIX)); chomp $input; @@ -168,6 +168,20 @@ sub is_child_fork { } +sub is_error_message { + my ($string) = @_; + + return index($string, ERROR_PREFIX) == 0; +} + + +sub is_ok_message { + my ($string) = @_; + + return index($string, OK_PREFIX) == 0; +} + + # TODO: Find out if it's possible to do this is a command Irssi::signal_add_last 'gui key pressed' => sub { my ($key) = @_; |
