summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2023-11-24 18:21:18 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2023-11-24 18:21:18 +0100
commitc272713bdd663582c7942a88e9bf3a9cef3b15ce (patch)
treea3b9037ba8cc248ec672cc46442a93f1775c86bf
parent0183a72df72a4a374e31c75f917ca03b9eff2e39 (diff)
hafas-m: disable in-line messages; show messages after departure board
-rwxr-xr-xbin/hafas-m35
1 files changed, 20 insertions, 15 deletions
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