aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-12-17 00:36:05 +0100
committerTeddy Wing2017-12-17 00:36:05 +0100
commit3f54e141e69452d97fdd08f164dab3da83e14f68 (patch)
treeb7a9336a7e156e173958b27e19ff9af79b976a7c
parentc9bec2cd5af8fb779f93727f63a4ae60b0eb2347 (diff)
downloadirssi-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.pl18
1 files changed, 16 insertions, 2 deletions
diff --git a/vimput.pl b/vimput.pl
index 0305c6c..091a7d3 100644
--- a/vimput.pl
+++ b/vimput.pl
@@ -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) = @_;