1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | sub on_keyboard_command { |
3 | sub on_user_command { |
4 | my ($self, $cmd) = @_; |
4 | my ($self, $cmd) = @_; |
5 | |
5 | |
6 | $cmd eq "selection:rot13" |
6 | $cmd eq "selection:rot13" |
7 | and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection); |
7 | and $self->selection (map { y/A-Za-z/N-ZA-Mn-za-m/; $_ } $self->selection); |
8 | |
8 | |
… | |
… | |
20 | for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) { |
20 | for (my $idx = 0; defined (my $res = $self->x_resource ("selection.pattern-$idx")); $idx++) { |
21 | $res = $self->locale_decode ($res); |
21 | $res = $self->locale_decode ($res); |
22 | utf8::encode $res; |
22 | utf8::encode $res; |
23 | push @{ $self->{patterns} }, qr/$res/; |
23 | push @{ $self->{patterns} }, qr/$res/; |
24 | } |
24 | } |
|
|
25 | |
|
|
26 | $self->{enabled} = 1; |
|
|
27 | |
|
|
28 | push @{ $self->{term}{option_popup_hook} }, sub { |
|
|
29 | ("new selection" => $self->{enabled}, sub { $self->{enabled} = shift }) |
|
|
30 | }; |
25 | |
31 | |
26 | () |
32 | () |
27 | } |
33 | } |
28 | |
34 | |
29 | # "find interesting things"-patterns |
35 | # "find interesting things"-patterns |
… | |
… | |
61 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
67 | qr{^(.*)[,\-]$}, # strip off trailing , and - |
62 | ); |
68 | ); |
63 | |
69 | |
64 | sub on_sel_extend { |
70 | sub on_sel_extend { |
65 | my ($self, $time) = @_; |
71 | my ($self, $time) = @_; |
|
|
72 | |
|
|
73 | $self->{enabled} |
|
|
74 | or return; |
66 | |
75 | |
67 | my ($row, $col) = $self->selection_mark; |
76 | my ($row, $col) = $self->selection_mark; |
68 | my $line = $self->line ($row); |
77 | my $line = $self->line ($row); |
69 | my $text = $line->t; |
78 | my $text = $line->t; |
70 | my $markofs = $line->offset_of ($row, $col); |
79 | my $markofs = $line->offset_of ($row, $col); |