workaround rxvt-unicode bug

This commit is contained in:
Michele Guerini Rocco 2021-06-04 11:07:26 +02:00
parent a80be3b6ea
commit 79d255272d
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
2 changed files with 21 additions and 42 deletions

View File

@ -1,32 +0,0 @@
#! perl
use v5.20;
use strict;
use warnings;
no warnings "experimental";
our @resources = (
qw(
background foreground cursorColor
pointerColor pointerColor2
highlight borderColor
font geometry
),
map { "color$_" } 0..15
);
sub on_start {
my %fallbacks = (
borderColor => "background",
cursorColor => "foreground");
for (@resources) {
my $val = $TERM->x_resource($_);
my $default = $TERM->x_resource($fallbacks{$_});
if (not $val and $default){
$val = $default
}
say "$_: " . $val;
}
exit;
}

View File

@ -17,16 +17,21 @@ my $libdir = dirname(__FILE__);
our @terms = ();
sub reload_all {
my @lines = `urxvt --perl-lib $libdir -pe config-print 2>&1`;
my %resource;
for (@lines) {
$resource{$1} = $2 if (/(.*?): (.*)/);
sub get_xresources {
my @entries = `xrdb -query`;
my %resources;
for (@entries) {
$resources{$2} = $3 if /^(URxvt)?\*([^:]+):\t+(.*)/;
}
$resources{borderColor} //= $resources{background};
$resources{cursorColor} //= $resources{foreground};
return %resources;
}
sub build_command {
my %resources = @_;
my $cmd = "";
my $i = 0;
RESOURCE:
for (keys %resource) {
for (keys %resources) {
my $key;
given ($_) {
$key = "4;$1" when (/color(\d+)/);
@ -39,16 +44,22 @@ RESOURCE:
$key = 708 when "borderColor";
$key = 710 when "font";
when ("geometry") {
if (my ($col, $row) = $resource{$_} =~ /(\d+)x(\d+)/) {
if (my ($col, $row) = $resources{$_} =~ /(\d+)x(\d+)/) {
$cmd .= "\e[8;${row};${col}t";
}
next RESOURCE;
}
default { next RESOURCE }
}
my $val = $resource{$_};
my $val = $resources{$_};
$cmd .= "\e]$key;$val\a";
}
return $cmd;
}
sub reload_all {
my %resources = get_xresources;
my $cmd = build_command(%resources);
for (@terms) {
$_->cmd_parse($cmd);
}