ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/perl/background
(Generate patch)

Comparing rxvt-unicode/src/perl/background (file contents):
Revision 1.103 by root, Fri Nov 26 18:49:48 2021 UTC vs.
Revision 1.110 by sf-exg, Tue Dec 6 09:02:19 2022 UTC

56is behind the text, replacing the normal background colour. 56is behind the text, replacing the normal background colour.
57 57
58It does so by evaluating a Perl expression that I<calculates> the image on 58It does so by evaluating a Perl expression that I<calculates> the image on
59the fly, for example, by grabbing the root background or loading a file. 59the fly, for example, by grabbing the root background or loading a file.
60 60
61While the full power of Perl is available, the operators have been design 61While the full power of Perl is available, the operators have been
62to be as simple as possible. 62designed to be as simple as possible.
63 63
64For example, to load an image and scale it to the window size, you would 64For example, to load an image and scale it to the window size, you would
65use: 65use:
66 66
67 urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }' 67 urxvt --background-expr 'scale keep { load "/path/to/mybg.png" }'
986 986
987 return $img 987 return $img
988 if FOCUS; 988 if FOCUS;
989 989
990 my $fade = @_ >= 1 ? $_[0] : defined $self->resource ("fade") ? $self->resource ("fade") * 0.01 : 0; 990 my $fade = @_ >= 1 ? $_[0] : defined $self->resource ("fade") ? $self->resource ("fade") * 0.01 : 0;
991 my $color = @_ >= 2 ? $_[1] : $self->resource ("color+" . urxvt::Color_fade); 991 my $color = @_ >= 2 ? $_[1] : $self->resource ("color+" . &urxvt::Color_fade ()); # Color_fade not always available
992 992
993 $img = $img->tint ($color) if $color ne "rgb:00/00/00"; 993 $img = $img->tint ($color) if $color ne "rgb:00/00/00";
994 $img = $img->muladd (1 - $fade, 0) if $fade; 994 $img = $img->muladd (1 - $fade, 0) if $fade;
995 995
996 $img 996 $img
1448 } 1448 }
1449 } 1449 }
1450} 1450}
1451 1451
1452# helper function, quote string as perl without allowing 1452# helper function, quote string as perl without allowing
1453# any code execution or other shenanigans. does not 1453# any code execution or other shenanigans.
1454# support binary NULs in string.
1455sub q0 { 1454sub q0 {
1456 (my $str = shift) =~ s/\x00//g; # make sure there really aren't any embedded NULs 1455 "qq\x00\Q$_[0]\E\x00"
1457 "q\x00$str\x00"
1458} 1456}
1459 1457
1460sub old_bg_expr { 1458sub old_bg_expr {
1461 my ($self) = @_; 1459 my ($self) = @_;
1462 1460
1579} 1577}
1580 1578
1581sub on_osc_seq { 1579sub on_osc_seq {
1582 my ($self, $op, $arg) = @_; 1580 my ($self, $op, $arg) = @_;
1583 1581
1584 $op eq "20" or $op eq "706" 1582 $op eq "20" or $op eq "705"
1585 or return; 1583 or return;
1586 1584
1587 $self->{bg_opts} 1585 $self->{bg_opts}
1588 or $self->parse_bgopts; 1586 or $self->parse_bgopts;
1589 1587

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines