summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-12-26 09:29:46 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-12-26 09:29:46 +0100
commita2e2c50c4a856492e980d0d3f9114573d06a5c1c (patch)
tree4345f912a64859edbae7e6690dc25b8635f5b9ad /bin
parent3aec797b3ecd147621b7e9f5020596e74a587869 (diff)
Use color-coding for class distinction
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dbwagenreihung46
1 files changed, 20 insertions, 26 deletions
diff --git a/bin/dbwagenreihung b/bin/dbwagenreihung
index fe0961a..d15bf85 100755
--- a/bin/dbwagenreihung
+++ b/bin/dbwagenreihung
@@ -12,6 +12,11 @@ use Travel::Status::DE::DBWagenreihung;
my ( $station, $train_number ) = @ARGV;
+my $col_first = "\e[38;5;11m";
+my $col_mixed = "\e[38;5;208m";
+my $col_second = "\e[38;5;9m";
+my $col_reset = "\e[0m";
+
my $res = Travel::Status::DE::IRIS->new(
station => $station,
with_related => 1
@@ -52,8 +57,7 @@ for my $section ( $wr->sections ) {
print "\n";
my @start_percentages = map { $_->{position}{start_percent} } $wr->wagons;
-print ' ' x ( ( min @start_percentages ) - 1 );
-print '[';
+print ' ' x ( min @start_percentages );
for my $wagon ( $wr->wagons ) {
my $wagon_length
@@ -71,33 +75,23 @@ for my $wagon ( $wr->wagons ) {
$wagon_desc = '<->';
}
- printf( "%s%3s%s", ' ' x $spacing_left, $wagon_desc, ' ' x $spacing_right );
-}
-print "]\n";
-
-print ' ' x ( min @start_percentages );
-for my $wagon ( $wr->wagons ) {
- my $wagon_length
- = $wagon->{position}->{end_percent} - $wagon->{position}->{start_percent};
- my $spacing_left = int( $wagon_length / 2 ) - 2;
- my $spacing_right = int( $wagon_length / 2 ) - 1;
-
- if ( $wagon_length % 2 ) {
- $spacing_left++;
+ my $class_color = '';
+ if ($wagon->class_type == 1 ) {
+ $class_color = $col_first;
}
-
- my $class = '';
-
- if ( $wagon->class_type == 1 ) {
- $class = ' 1 ';
+ elsif ($wagon->class_type == 2 ) {
+ $class_color = $col_second;
}
- elsif ( $wagon->class_type == 2 ) {
- $class = ' 2 ';
- }
- elsif ( $wagon->class_type == 12 ) {
- $class = '1/2';
+ elsif ($wagon->class_type == 12 ) {
+ $class_color = $col_mixed;
}
- printf( "%s%3s%s", ' ' x $spacing_left, $class, ' ' x $spacing_right );
+ printf( "%s%s%3s%s%s",
+ ' ' x $spacing_left,
+ $class_color,
+ $wagon_desc,
+ $col_reset,
+ ' ' x $spacing_right
+ );
}
print "\n";