nicer status area, fixed [fF;,] in keyboard-select
This commit is contained in:
parent
2810529c44
commit
f63af26b81
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
# Use Meta-Escape to activate selection mode, then use the following keys:
|
# Use Meta-Escape to activate selection mode, then use the following keys:
|
||||||
# h/j/k/l: Move cursor left/down/up/right (also with arrow keys)
|
# h/j/k/l: Move cursor left/down/up/right (also with arrow keys)
|
||||||
# g/G/0/^/$/H/M/L: More vi-like cursor movement keys
|
# g/G/0/^/$/H/M/L/f/F/;/,: More vi-like cursor movement keys
|
||||||
# Ctrl-f/b: Scroll down/up one screen
|
# Ctrl-f/b: Scroll down/up one screen
|
||||||
# Ctrl-d/u: Scroll down/up half a screen
|
# Ctrl-d/u: Scroll down/up half a screen
|
||||||
# v/V/Ctrl-v: Toggle normal/linewise/blockwise selection
|
# v/V/Ctrl-v: Toggle normal/linewise/blockwise selection
|
||||||
@ -36,14 +36,19 @@ sub on_user_command {
|
|||||||
|
|
||||||
|
|
||||||
sub key_press {
|
sub key_press {
|
||||||
my ($self, $event, $keysym) = @_;
|
my ($self, $event, $keysym, $char) = @_;
|
||||||
my $key = chr($keysym);
|
my $key = chr($keysym);
|
||||||
|
|
||||||
if ($self->{move_to} && $key !~ m/[\x00-\x1f\x80-\xaf]/ &&
|
if ($self->{move_to}) {
|
||||||
length($key) > 0) {
|
if ($keysym == 0xff1b) {
|
||||||
$self->{move_char} = $key;
|
|
||||||
move_to($self, $self->{move_to});
|
|
||||||
$self->{move_to} = 0;
|
$self->{move_to} = 0;
|
||||||
|
status_area($self);
|
||||||
|
} elsif (length($char) > 0) {
|
||||||
|
$self->{move_char} = $key;
|
||||||
|
$self->{move_to} = 0;
|
||||||
|
move_to($self, $self->{move_dir});
|
||||||
|
status_area($self);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,9 +97,11 @@ sub key_press {
|
|||||||
('fbdu' =~ m/\Q$key\E/ && $event->{state} & urxvt::ControlMask)) {
|
('fbdu' =~ m/\Q$key\E/ && $event->{state} & urxvt::ControlMask)) {
|
||||||
move_cursor($self, $key);
|
move_cursor($self, $key);
|
||||||
} elsif (lc($key) eq 'f') {
|
} elsif (lc($key) eq 'f') {
|
||||||
$self->{move_to} = $key eq 'F' ? -1 : 1;
|
$self->{move_to} = 1;
|
||||||
} elsif ($key eq ';' || $key eq ',') {
|
$self->{move_dir} = $key eq 'F' ? -1 : 1;
|
||||||
move_to($self, $key eq ',' ? -1 : 1) if $self->{move_char};
|
status_area($self, $key);
|
||||||
|
} elsif (($key eq ';' || $key eq ',') && $self->{move_char}) {
|
||||||
|
move_to($self, $self->{move_dir} * ($key eq ',' ? -1 : 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -177,8 +184,6 @@ sub move_to {
|
|||||||
my $line = $self->line($cr);
|
my $line = $self->line($cr);
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
|
|
||||||
print "move_to: " . $self->{move_char} . " (" . ord($self->locale_decode($self->{move_char})) . ")\n";
|
|
||||||
|
|
||||||
if ($dir > 0 && $self->{offset} < $line->l - 1) {
|
if ($dir > 0 && $self->{offset} < $line->l - 1) {
|
||||||
my $text = substr($line->t, $self->{offset} + 1);
|
my $text = substr($line->t, $self->{offset} + 1);
|
||||||
if ($text =~ m/\Q$self->{move_char}\E/) {
|
if ($text =~ m/\Q$self->{move_char}\E/) {
|
||||||
@ -304,15 +309,11 @@ sub deactivate {
|
|||||||
|
|
||||||
|
|
||||||
sub status_area {
|
sub status_area {
|
||||||
my ($self) = @_;
|
my ($self, $extra) = @_;
|
||||||
my ($stat, $stat_len);
|
my ($stat, $stat_len);
|
||||||
|
|
||||||
if ($self->{select}) {
|
if ($self->{select}) {
|
||||||
$stat = "V";
|
$stat = "-V" . ($self->{select} ne 'n' ? uc($self->{select}) : "") . "- ";
|
||||||
if ($self->{select} ne 'n') {
|
|
||||||
$stat .= uc($self->{select});
|
|
||||||
}
|
|
||||||
$stat .= " -- ";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($self->top_row == 0) {
|
if ($self->top_row == 0) {
|
||||||
@ -326,7 +327,8 @@ sub status_area {
|
|||||||
($self->top_row - $self->view_start) * 100 / $self->top_row);
|
($self->top_row - $self->view_start) * 100 / $self->top_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stat_len = length($stat);
|
$stat = "$extra $stat" if $extra;
|
||||||
|
$stat_len = length($stat) + 2;
|
||||||
|
|
||||||
if (!$self->{overlay} || $self->{overlay_len} != $stat_len) {
|
if (!$self->{overlay} || $self->{overlay_len} != $stat_len) {
|
||||||
delete $self->{overlay} if $self->{overlay};
|
delete $self->{overlay} if $self->{overlay};
|
||||||
@ -335,7 +337,7 @@ sub status_area {
|
|||||||
$self->{overlay_len} = $stat_len;
|
$self->{overlay_len} = $stat_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{overlay}->set(0, 0, $self->special_encode($stat));
|
$self->{overlay}->set(1, 0, $self->special_encode($stat));
|
||||||
$self->{overlay}->show();
|
$self->{overlay}->show();
|
||||||
|
|
||||||
()
|
()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# Author: Bert Muennich
|
# Author: Bert Muennich
|
||||||
# Website: http://www.github.com/muennich/urxvt-perls
|
# Website: http://www.github.com/muennich/urxvt-perls
|
||||||
# Based on: http://www.jukie.net/~bart/blog/urxvt-url-yank
|
# Based on: http://www.jukie.net/~bart/blog/urxvt-url-yank
|
||||||
# Version: 1.3
|
# Version: git-20100820
|
||||||
# License: GPLv2
|
# License: GPLv2
|
||||||
|
|
||||||
# Use keyboard shortcuts to select URLs.
|
# Use keyboard shortcuts to select URLs.
|
||||||
@ -239,7 +239,7 @@ sub status_area {
|
|||||||
($self->top_row - $self->view_start) * 100 / $self->top_row);
|
($self->top_row - $self->view_start) * 100 / $self->top_row);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $text_len = length($text);
|
my $text_len = length($text) + 2;
|
||||||
|
|
||||||
if ($self->{overlay_len} != $text_len) {
|
if ($self->{overlay_len} != $text_len) {
|
||||||
delete $self->{overlay} if $self->{overlay};
|
delete $self->{overlay} if $self->{overlay};
|
||||||
@ -248,7 +248,7 @@ sub status_area {
|
|||||||
$self->{overlay_len} = $text_len;
|
$self->{overlay_len} = $text_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{overlay}->set(0, 0, $self->special_encode($text));
|
$self->{overlay}->set(1, 0, $self->special_encode($text));
|
||||||
$self->{overlay}->show();
|
$self->{overlay}->show();
|
||||||
|
|
||||||
()
|
()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user