X-Git-Url: https://ruderich.org/simon/gitweb/?p=fcscs%2Ffcscs.git;a=blobdiff_plain;f=bin%2Ffcscs;h=971cb8098e3d46bc47a455fcfdcb4cdbe1a2d314;hp=6e3d9cb0ca5800986ed8289fab9162c0f6400029;hb=8694357ab0e199a30166bf994a614ea0650a4981;hpb=1ef91de49d5a0337ebdd0254d9da659d7774657f diff --git a/bin/fcscs b/bin/fcscs index 6e3d9cb..971cb80 100755 --- a/bin/fcscs +++ b/bin/fcscs @@ -558,9 +558,6 @@ sub select_match { $number = int($number / 10); } elsif ($char eq "\n" or $char eq $config->{setting}{alternative_return}) { - if ($number == 0) { # number without selection matches last entry - $number = 1; - } last; # Selecting a new mode requires falling through into the main input @@ -570,7 +567,8 @@ sub select_match { return { key => $char }; # All other mappings stay in the current mode. } elsif (defined (my $m = $config->{mapping}{simple}{$char})) { - $m->($char, $screen, $config, $input); + my $result = $m->($char, $screen, $config, $input); + last if defined $result->{select_match}; next; } else { @@ -585,6 +583,10 @@ sub select_match { $screen->draw_matches($config, $matches, \@remaining); $screen->refresh; } + # Number without selection matches last entry. + if ($number == 0) { + $number = 1; + } $screen->draw_matches($config, $matches, []); # remove matches @@ -692,6 +694,18 @@ sub mapping_paste { return {}; } +sub mapping_paste_now { + my ($key, $screen, $config, $input) = @_; + + $screen->debug('mapping_paste_now', 'started'); + + $config->{state}{handler} = $config->{handler}{paste}; + + return { + select_match => 1, + }; +} + sub mapping_yank { my ($key, $screen, $config, $input) = @_; @@ -705,6 +719,17 @@ sub mapping_yank { return {}; } +sub mapping_yank_now { + my ($key, $screen, $config, $input) = @_; + + $screen->debug('mapping_yank_now', 'started'); + + $config->{state}{handler} = $config->{handler}{yank}; + + return { + select_match => 1, + }; +} =head2 NORMAL MODES @@ -1065,8 +1090,12 @@ The following simple mappings are available by default: =item B

enable pasting (C<\&mapping_paste>) +=item B

paste current selection (like C<\n> but paste) (C<\&mapping_paste_now>) + =item B enable yanking (copying) (C<\&mapping_yank>) +=item B yank current selection (like C<\n> but yank) (C<\&mapping_yank_now>) + =back Note that yanking only uses the GNU screen or Tmux paste buffer by default. To @@ -1107,7 +1136,9 @@ my %mapping_mode = ( ); my %mapping_simple = ( p => \&mapping_paste, + P => \&mapping_paste_now, y => \&mapping_yank, + Y => \&mapping_yank_now, ); =head2 ATTRIBUTES @@ -1291,7 +1322,9 @@ Create a new Curses attribute with the given fore- and background color. mapping_mode_search() mapping_paste() + mapping_paste_now() mapping_yank() + mapping_yank_now() mapping_quit() Used as mappings, see L above. @@ -1368,15 +1401,15 @@ package Fcscs { sub mapping_mode_search { return main::mapping_mode_search(@_); } sub mapping_paste { return main::mapping_paste(@_); } + sub mapping_paste_now { return main::mapping_paste_now(@_); } sub mapping_yank { return main::mapping_yank(@_); } + sub mapping_yank_now { return main::mapping_yank_now(@_); } sub mapping_quit { return main::mapping_quit(@_); } sub handler_yank { return main::handler_yank(@_); } sub handler_paste { return main::handler_paste(@_); } sub handler_url { return main::handler_url(@_); } - sub debug { return main::debug(@_); } - sub get_regex_matches { return main::get_regex_matches(@_); } sub select_match { return main::select_match(@_); } @@ -1416,10 +1449,10 @@ package Fcscs { } # Make sure the file is not writable by other users. Doesn't handle # ACLs and see comment above about race conditions. - my @stat = stat $path or die $!; + my @stat = stat $path or $screen->die("Config '$decoded': $!"); my $mode = $stat[2]; if (($mode & Fcntl::S_IWGRP) or ($mode & Fcntl::S_IWOTH)) { - die "Config '$decoded' must not be writable by other users."; + $screen->die("Config '$decoded' must not be writable by other users."); } my $result = do $path;