The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Term::ExtendedColor::Xresources - Query and set various Xresources

SYNOPSIS

    use Term::ExtendedColor::Xresources qw(get_xterm_color set_xterm_color);

    # Get RGB values for all defined colors
    my $colors = get_xterm_color({
      index => [0 .. 255], # default
      type  => 'hex',      # default is base 10
    });

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};

Expects a hash reference where the keys are color indexes (0 .. 255) and the values hexadecimal representations of the color values.

Returns a hash with the indexes as keys and the appropriate escape sequences as values.

get_xterm_color()

  my $defined_colors = get_xterm_color( [ 0 .. 16 ] );

  print $defined_colors->{4}->{red}, "\n";
  print $defined_colors->{8}->{rgb}, "\n";

Expects an array reference with color indexes to operate on. 0 - 15 is the standard ANSI colors, all above are extended colors.

Returns a hash reference with the 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 response from the terminal, including escape sequences.

get_xterm_colors()

The same thing as get_xterm_color(). Will be deprecated.

SEE ALSO

Term::ExtendedColor

AUTHOR

  Magnus Woldrich
  CPAN ID: WOLDRICH
  magnus@trapd00r.se
  http://japh.se

Written by Magnus Woldrich

COPYRIGHT

Copyright 2010, 2011 Magnus Woldrich <magnus@trapd00r.se>. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.