From c272713bdd663582c7942a88e9bf3a9cef3b15ce Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 24 Nov 2023 18:21:18 +0100 Subject: hafas-m: disable in-line messages; show messages after departure board --- bin/hafas-m | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/hafas-m b/bin/hafas-m index d6e5c41..2626eca 100755 --- a/bin/hafas-m +++ b/bin/hafas-m @@ -216,7 +216,7 @@ sub display_result { my $d = $line->[6]; my $first_message = 1; for my $msg ( $d->messages ) { - if ( $msg->ref_count == 1 ) { + if ( $msg->ref_count == 0 ) { if ($first_message) { print "\n"; $first_message = 0; @@ -399,19 +399,6 @@ elsif ( $opt{journey} ) { exit 0; } -my $message_id = 1; -for my $m ( $status->messages ) { - if ( $m->ref_count > 1 ) { - $m->{id} = $message_id++; - if ( $m->short ) { - printf( "# (%d) %s\n# %s\n\n", $m->{id}, $m->short, $m->text ); - } - else { - printf( "# (%d) %s\n\n", $m->{id}, $m->text ); - } - } -} - my @results = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ $_->datetime->epoch, $_ ] } $status->results; @@ -427,12 +414,19 @@ for my $d (@results) { } } +my $message_id = 1; +for my $m ( $status->messages ) { + if ( $m->ref_count > 0 ) { + $m->{id} = $message_id++; + } +} + for my $d (@results) { my $info_line = q{}; for my $message ( $d->messages ) { - if ( $message->ref_count > 1 ) { + if ( $message->ref_count > 0 ) { $info_line = sprintf( '(%d) %s', $message->{id}, $info_line ); } } @@ -462,6 +456,17 @@ for my $d (@results) { display_result(@output); +for my $m ( $status->messages ) { + if ( $m->ref_count > 0 ) { + if ( $m->short ) { + printf( "\n# (%d) %s\n# %s\n", $m->{id}, $m->short, $m->text ); + } + else { + printf( "\n# (%d) %s\n", $m->{id}, $m->text ); + } + } +} + __END__ =head1 NAME -- cgit v1.2.3