NAME
Term::ExtendedColor::Xresources - Query and set various Xresources
SYNOPSIS
use Term::ExtendedColor::Xresources qw(
get_xterm_color
set_xterm_color
set_foreground_color
set_background_color
);
# make color index 220 represent red instead of yellow
set_xterm_color({ 220 => 'ff0000'});
# get RGB values for all defined colors
my $colors = get_xterm_color({
index => [0 .. 255], # default
type => 'hex', # default is base 10
});
# change the background color to red...
set_background_color('ff0000');
# .. and the foreground color to yellow
set_foreground_color('ffff00');
DESCRIPTION
Term::ExtendedColor::Xresources provides functions for changing and querying the underlying X terminal emulator for various X resources.
EXPORTS
None by default.
FUNCTIONS
set_xterm_color()
# Switch yellow and red
my $new_colors = set_xterm_color({
220 => 'ff0000',
196 => 'ffff00',
});
print $_ for values %{$new_colors};
# or just...
set_xterm_color({ 100 => ff0066});
Expects a hash reference where the keys are color indexes (0 .. 255) and the values hexadecimal representations of the color values.
Changes the colors if called in void context. Else, returns a hash with the indexes as keys and the appropriate escape sequences as values.
get_xterm_color()
my $defined_colors = get_xterm_color({ index => [0 .. 255], type => 'dec' });
print $defined_colors->{4}->{red}, "\n";
print $defined_colors->{8}->{rgb}, "\n";
0 - 15 is the standard ANSI colors, all above them are extended colors.
Returns a hash reference with the index colors as keys. By default the color values are in decimal.
The color values can be accessed by using their name:
my $red = $colors->{10}->{red};
Or by using the short notation:
my $red = $colors->{10}->{r};
The full color string can be retrieved like so:
my $rgb = $colors->{10}->{rgb};
The raw
element is the full, raw response from the terminal, including escape sequences.
The following arguments are supported:
- index => $index | \@indexes
-
Arrayref of color indexes to look up and return. Defaults to [0..255], i.e. all indexes. Alternately a single index may be passed.
- type => 'dec' | 'hex'
-
May be 'dec' or 'hex'. The default is 'dec' (decimal) which returns color values as integers between 0 and 255, and returns a 'rgb' string of the form '$r/$g/$b' e.g. '255/0/0'. If 'hex' is passed, returns color values in base 16, zero-padded to two characters (between 00 and ff) and a 'rgb' string of the form '$r$g$b' e.g. 'ff0000'
get_xterm_colors()
The same thing as get_xterm_color(). Will be deprecated.
set_foreground_color()
set_foreground_color('ff0000');
my $fg = set_foreground_color('c0ffee');
Sets the foreground color if called in void context. Else, the appropriate escape sequence is returned.
set_background_color()
set_background_color('121212');
my $bg = set_foreground_color('000000');
Sets the foreground color if called in void context. Else, the appropriate escape sequence is returned.
SEE ALSO
AUTHOR
Magnus Woldrich
CPAN ID: WOLDRICH
magnus@trapd00r.se
http://japh.se
CONTRIBUTORS
None required yet.
COPYRIGHT
Copyright 2010, 2011 the Term::ExtendedColor::Xresources "AUTHOR" and "CONTRIBUTORS" as listed above.
LICENSE
This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.