From 94aa19c42b640fc58aeb954628862748bf08750b Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 29 Jan 2023 10:00:51 +0100 Subject: urxvt: add an extension for toggling reverse video --- dotfiles/Xresources | 2 ++ install.conf.yaml | 2 ++ urxvt/reverse | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100755 urxvt/reverse diff --git a/dotfiles/Xresources b/dotfiles/Xresources index 874d827..e832883 100644 --- a/dotfiles/Xresources +++ b/dotfiles/Xresources @@ -34,6 +34,8 @@ URxvt.scrollTTYKeyPress: true URxvt.inputMethod: ibus URxvt.preeditType: OverTheSpot +URxvt.keysym.M-r: reverse:toggle + URxvt.keysym.M-u: reselect:url URxvt.keysym.M-g: reselect:git_hash URxvt.keysym.M-i: reselect:message_id diff --git a/install.conf.yaml b/install.conf.yaml index 5298f4b..c3808eb 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -9,6 +9,7 @@ - ~/.local/var/dotfiles - ~/.local/var/less - ~/.local/var/vim/undo + - ~/.urxvt/ext - ~/.vim/colors - ~/.vim/ftplugin/rst - ~/.vim/pack/dotfiles/start @@ -30,6 +31,7 @@ ~/.local/var/cron/daily/dotfiles_status: cron/dotfiles_status ~/.profile: dotfiles/profile ~/.tmux.conf: dotfiles/tmux.conf + ~/.urxvt/ext/reverse: urxvt/reverse # TODO: clean up and install linediff script ~/.vimrc: vim/vimrc ~/.vim/colors/inkpot.vim: vim/inkpot.vim diff --git a/urxvt/reverse b/urxvt/reverse new file mode 100755 index 0000000..8e99201 --- /dev/null +++ b/urxvt/reverse @@ -0,0 +1,22 @@ +#!/usr/bin/perl + +# Implement a 'toggle' command that toggles reverse video on and off + +sub on_action +{ + my ($self, $cmd) = @_; + + if ($cmd eq "toggle") { + my $e = $self->{enabled}; + my $act = $e ? "l" : "h"; + $self->{enabled} = not $e; + $self->cmd_parse("\033[?5" . $act) + } +} + +sub on_start +{ + my ($self) = @_; + + $self->{enabled} = 0; +} -- cgit v1.2.3