# Convert a terminal color scheme for 256 color terminals to a GUI color
# scheme by adding the appropriate gui* options.
-# Copyright (C) 2012 Simon Ruderich
+# Copyright (C) 2012-2014 Simon Ruderich
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
}
-while (my $line = <>) {
+while (<STDIN>) {
# Only handle lines with highlight commands.
- if ($line =~ /^\s*\bhi(?:ghlight)?\b/) {
- foreach my $setting ($line =~ m/\bcterm(?:fg|bg)?=\S+/g) {
+ if (/^\s*\bhi(?:ghlight)?\b/) {
+ foreach my $setting (m/\bcterm(?:fg|bg)?=\S+/g) {
my ($name, $value) = split /=/, $setting;
my $gui_name = $name;
}
# Update existing value.
- if ($line =~ /\b\Q$gui_name\E=/) {
- $line =~ s/\Q$gui_name\E=\S+/$gui_name=$new_value/;
+ if (/\b\Q$gui_name\E=/) {
+ s/\Q$gui_name\E=\S+/$gui_name=$new_value/;
# Append at the end of the line.
} else {
- $line =~ s/\n/ $gui_name=$new_value\n/;
+ s/\n/ $gui_name=$new_value\n/;
}
}
}
- print $line;
+ print;
}