diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-11-28 11:29:03 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-11-28 11:29:03 +0100 |
commit | 8dec307b5c563e419806e0024e9ca11b8340c5c4 (patch) | |
tree | 9246249274ab396c8fd79f542f98970aa4c908fe | |
parent | fa469a08c02a4c7afcc860d2241707d3d219fab3 (diff) |
Handle translating between colors internally.
URXVT internal color indices, which are accepted by SET_COLOR are offset
from the SGR color indices by 2.
-rw-r--r-- | reselect | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -257,10 +257,20 @@ sub status_msg { } sub get_rend { - my ($self, $name, $default) = @_; - urxvt::SET_COLOR $default, - $self->my_resource("$name.foregroundColor") || urxvt::GET_BASEFG $default, - $self->my_resource("$name.backgroundColor") || urxvt::GET_BASEBG $default; + my ($self, $name, $rend) = @_; + # urxvt internal color indices are offset by 2 from the standard values + my $color_offset = 2; + + my $fg = $self->my_resource("$name.foregroundColor"); + if ($fg) { + $rend = urxvt::SET_FGCOLOR($rend, $color_offset + $fg); + } + my $bg = $self->my_resource("$name.backgroundColor"); + if ($bg) { + $rend = urxvt::SET_BGCOLOR($rend, $color_offset + $bg); + } + + return $rend; } sub on_key_release { |