blob: 1f38c3b2330fc534c28a7cf9e0e927e0d51d73e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#! perl
=head1 NAME
eval - evaluate arbitrary perl code using actions
=head1 EXAMPLES
URxvt.keysym.M-c: eval:selection_to_clipboard
URxvt.keysym.M-v: eval:paste_clipboard
URxvt.keysym.M-V: eval:paste_primary
URxvt.keysym.M-Up: eval:scroll_up 1
URxvt.keysym.M-Down: eval:scroll_down 1
URxvt.keysym.M-Home: eval:scroll_to_top
URxvt.keysym.M-End: eval:scroll_to_bottom
=head1 DESCRIPTION
Add support for evaluating arbitrary perl code using actions in keysym
resources. If a keysym I<action> takes the form C<eval:STRING>, the
specified B<STRING> is evaluated as a Perl expression. While the full
urxvt API is available, the following methods are also provided for
users' convenience, as they implement basic actions:
=cut
our ($self);
=over 4
=item scroll_up $count
=item scroll_up_pages $count
=item scroll_down $count
=item scroll_down_pages $count
Scroll up or down by C<$count> lines or pages.
=cut
sub scroll_up ($) {
my $lines = $_[0];
$self->view_start ($self->view_start - $lines);
}
sub scroll_up_pages ($) {
my $lines = $_[0] * ($self->nrow - 1);
$self->view_start ($self->view_start - $lines);
}
sub scroll_down ($) {
my $lines = $_[0];
$self->view_start ($self->view_start + $lines);
}
sub scroll_down_pages ($) {
my $lines = $_[0] * ($self->nrow - 1);
$self->view_start ($self->view_start + $lines);
}
=item scroll_to_top
=item scroll_to_bottom
Scroll to the top or bottom of the scrollback.
=cut
sub scroll_to_top () {
$self->view_start ($self->top_row);
}
sub scroll_to_bottom () {
$self->view_start (0);
}
=item selection_to_clipboard
Copy the selection to the CLIPBOARD.
=cut
sub selection_to_clipboard () {
$self->selection ($self->selection, 1);
$self->selection_grab (urxvt::CurrentTime, 1);
}
=item paste_primary
=item paste_clipboard
Paste the value of the PRIMARY or CLIPBOARD selection.
=cut
sub paste_primary () {
$self->selection_request (urxvt::CurrentTime, 1);
}
sub paste_clipboard () {
$self->selection_request (urxvt::CurrentTime, 3);
}
=back
=cut
sub on_action {
my ($arg_self, $action) = @_;
local $self = $arg_self;
eval "#line 1 \"$action\"\n$action";
die $@ if $@;
()
}
|