summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-29 10:00:51 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-29 10:00:51 +0100
commit94aa19c42b640fc58aeb954628862748bf08750b (patch)
tree10ab9277cd8648d195d541f6239048bc003cf752
parente1077922f687cc8d5482d3b53f5d54d58c3d534b (diff)
urxvt: add an extension for toggling reverse video
-rw-r--r--dotfiles/Xresources2
-rw-r--r--install.conf.yaml2
-rwxr-xr-xurxvt/reverse22
3 files changed, 26 insertions, 0 deletions
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;
+}