- +sub preserve_style(@) { #{{{
- + my ($colors, $text) = @_;
- + $colors = '' unless $colors; # foreground and background colors
- + $text = '' unless $text; # text
- +
- + # Check colors
- + my ($color1, $color2) = ();
- + $colors = lc($colors); # Regexps on lower case strings are simpler
- + if ($colors =~ /,/) {
- + # Probably defined both foreground and background color
- + ($color1, $color2) = ($colors =~ /(.*),(.*)/);
- + }
- + else {
- + # Probably defined only foreground color
- + ($color1, $color2) = ($colors, '');
- + }
- +
+ +sub preserve_style($$$) { #{{{
+ + my $foreground = shift;
+ + my $background = shift;
+ + my $text = shift;
+ +
+ + $foreground = defined $foreground ? lc($foreground) : '';
+ + $background = defined $background ? lc($background) : '';
+ + $text = '' unless (defined $text);
+ +