urxvt.secondaryscroll: True
urxvt.answerbackString: urxvt
! Change font size.
-urxvt.keysym.M-minus: command:\033]50;xft:DejaVu Sans Mono:pixelsize=10:aspect=0.9,xft:AR PL UMing HK\007
-urxvt.keysym.M-equal: command:\033]50;xft:DejaVu Sans Mono:pixelsize=12:aspect=0.9,xft:AR PL UMing HK\007
+urxvt.perl-lib: .urxvt
+urxvt.perl-ext: font
+urxvt.keysym.M-minus: perl:font:smaller
+urxvt.keysym.M-equal: perl:font:bigger
! transparency
!rxvt*inheritPixmap: True
--- /dev/null
+#!/usr/bin/perl
+
+# Perl extension to resize the terminal.
+sub on_user_command {
+ my ($self, $cmd) = @_;
+
+ # Get existing fontset, something like:
+ # xft:DejaVu Sans Mono:pixelsize=12:aspect=0.9,xft:AR PL Uming HK
+ my $fontset = $self->{term}->resource("font");
+ my @fonts = split /,/, $fontset;
+ my @new = ();
+
+ # Split into individual font definitions.
+ foreach my $font (@fonts) {
+ if ($font =~ /:pixelsize=(\d+)/) {
+ my $size = $1;
+ my $adjusted = $size;
+
+ # Rewrite the font definition to be resized.
+ if ($cmd =~ /:bigger/) { $adjusted++ }
+ elsif ($cmd =~ /:smaller/) { $adjusted-- }
+
+ $font =~ s/:pixelsize=$size/:pixelsize=$adjusted/;
+ }
+
+ push @new, $font;
+ }
+
+ # Set the new fontset. Just putting the resource doesn't work so
+ # use an escape sequence.
+ $fontset = join(",", @new);
+ $self->{term}->cmd_parse("\033]50;$fontset\007");
+}