📄 readline.pm
字号:
qq/"\eC"/, 'ForwardChar', # right arrow qq/"\eD"/, 'BackwardChar', # left arrow qq/"\eS"/, 'BeginningOfHistory', # shift up arrow qq/"\eT"/, 'EndOfHistory', # shift down arrow qq/"\e&r1R"/, 'EndOfLine', # shift right arrow qq/"\e&r1L"/, 'BeginningOfLine', # shift left arrow qq/"\eJ"/, 'ClearScreen', # clear display qq/"\eM"/, 'UnixLineDiscard', # delete line qq/"\eK"/, 'KillLine', # clear line qq/"\eG\eK"/, 'BackwardKillLine', # shift clear line qq/"\eP"/, 'DeleteChar', # delete char qq/"\eL"/, 'Yank', # insert line qq/"\eQ"/, 'ToggleInsertMode', # insert char qq/"\eV"/, 'HistorySearchBackward',# prev qq/"\eU"/, 'HistorySearchForward',# next qq/"\eh"/, 'BeginningOfLine', # home qq/"\eF"/, 'EndOfLine', # shift home qq/"\ei"/, 'Suspend', # shift tab ) : () ), ($inDOS ? ( qq/"\0\2"/, 'SetMark', # 2: <Control>+<Space> qq/"\0\3"/, 'SetMark', # 3: <Control>+<@> qq/"\0\4"/, 'YankClipboard', # 4: <Shift>+<Insert> qq/"\0\5"/, 'KillRegionClipboard', # 5: <Shift>+<Delete> qq/"\0\16"/, 'Undo', # 14: <Alt>+<Backspace># qq/"\0\23"/, 'RevertLine', # 19: <Alt>+<R># qq/"\0\24"/, 'TransposeWords', # 20: <Alt>+<T># qq/"\0\25"/, 'YankPop', # 21: <Alt>+<Y># qq/"\0\26"/, 'UpcaseWord', # 22: <Alt>+<U># qq/"\0\31"/, 'ReverseSearchHistory', # 25: <Alt>+<P># qq/"\0\40"/, 'KillWord', # 32: <Alt>+<D># qq/"\0\41"/, 'ForwardWord', # 33: <Alt>+<F># qq/"\0\46"/, 'DownCaseWord', # 38: <Alt>+<L> #qq/"\0\51"/, 'TildeExpand', # 41: <Alt>+<\'># qq/"\0\56"/, 'CapitalizeWord', # 46: <Alt>+<C># qq/"\0\60"/, 'BackwardWord', # 48: <Alt>+<B># qq/"\0\61"/, 'ForwardSearchHistory', # 49: <Alt>+<N> #qq/"\0\64"/, 'YankLastArg', # 52: <Alt>+<.> qq/"\0\65"/, 'PossibleCompletions', # 53: <Alt>+</> qq/"\0\107"/, 'BeginningOfLine', # 71: <Home> qq/"\0\110"/, 'previous-history', # 72: <Up arrow> qq/"\0\111"/, 'HistorySearchBackward', # 73: <Page Up> qq/"\0\113"/, 'backward-char', # 75: <Left arrow> qq/"\0\115"/, 'forward-char', # 77: <Right arrow> qq/"\0\117"/, 'EndOfLine', # 79: <End> qq/"\0\120"/, 'next-history', # 80: <Down arrow> qq/"\0\121"/, 'HistorySearchForward', # 81: <Page Down> qq/"\0\122"/, 'ToggleInsertMode', # 82: <Insert> qq/"\0\123"/, 'DeleteChar', # 83: <Delete> qq/"\0\163"/, 'BackwardWord', # 115: <Ctrl>+<Left arrow> qq/"\0\164"/, 'ForwardWord', # 116: <Ctrl>+<Right arrow> qq/"\0\165"/, 'KillLine', # 117: <Ctrl>+<End> qq/"\0\166"/, 'EndOfHistory', # 118: <Ctrl>+<Page Down> qq/"\0\167"/, 'BackwardKillLine', # 119: <Ctrl>+<Home> qq/"\0\204"/, 'BeginningOfHistory', # 132: <Ctrl>+<Page Up> qq/"\0\x92"/, 'CopyRegionAsKillClipboard', # 146: <Ctrl>+<Insert> qq/"\0\223"/, 'KillWord', # 147: <Ctrl>+<Delete> qq/"\0#"/, 'PrintHistory', # Alt-H ) : ( 'C-@', 'Ding') ) ); *KeyMap = *emacs_keymap; my @add_bindings = (); foreach ('-', '0' .. '9') { push(@add_bindings, "M-$_", 'DigitArgument'); } foreach ("A" .. "Z") { next if # defined($KeyMap[27]) && defined (%{"$KeyMap{name}_27"}) && defined $ {"$KeyMap{name}_27"}[ord $_]; push(@add_bindings, "M-$_", 'DoLowercaseVersion'); } if ($inDOS) { # Default translation of Alt-char $ {"$KeyMap{name}_0"}{'Esc'} = *{"$KeyMap{name}_27"}; $ {"$KeyMap{name}_0"}{'default'} = 'F_DoEscVersion'; } &rl_bind(@add_bindings); # Vi input mode. &InitKeymap(*vi_keymap, 'SelfInsert', 'vi_keymap', "\e", 'ViEndInsert', 'C-c', 'Interrupt', 'C-h', 'BackwardDeleteChar', 'C-w', 'UnixWordRubout', 'C-u', 'UnixLineDiscard', 'C-v', 'QuotedInsert', 'DEL', 'BackwardDeleteChar', "\n", 'ViAcceptInsert', "\r", 'ViAcceptInsert', ); # Vi command mode. &InitKeymap(*vicmd_keymap, 'Ding', 'vicmd_keymap', 'C-c', 'Interrupt', 'C-e', 'EmacsEditingMode', 'C-h', 'ViMoveCursor', 'C-l', 'ClearScreen', "\n", 'ViAcceptLine', "\r", 'ViAcceptLine', ' ', 'ViMoveCursor', '#', 'SaveLine', '$', 'ViMoveCursor', '%', 'ViMoveCursor', '*', 'ViInsertPossibleCompletions', '+', 'NextHistory', ',', 'ViMoveCursor', '-', 'PreviousHistory', '.', 'ViRepeatLastCommand', '/', 'ViSearch', '0', 'ViMoveCursor', '1', 'ViDigit', '2', 'ViDigit', '3', 'ViDigit', '4', 'ViDigit', '5', 'ViDigit', '6', 'ViDigit', '7', 'ViDigit', '8', 'ViDigit', '9', 'ViDigit', ';', 'ViMoveCursor', '=', 'ViPossibleCompletions', '?', 'ViSearch', 'A', 'ViAppendLine', 'B', 'ViMoveCursor', 'C', 'ViChangeLine', 'D', 'ViDeleteLine', 'E', 'ViMoveCursor', 'F', 'ViMoveCursor', 'G', 'ViHistoryLine', 'H', 'PrintHistory', 'I', 'ViBeginInput', 'N', 'ViRepeatSearch', 'P', 'ViPutBefore', 'R', 'ViReplaceMode', 'S', 'ViChangeEntireLine', 'T', 'ViMoveCursor', 'U', 'ViUndoAll', 'W', 'ViMoveCursor', 'X', 'ViBackwardDeleteChar', 'Y', 'ViYankLine', '\\', 'ViComplete', '^', 'ViMoveCursor', 'a', 'ViAppend', 'b', 'ViMoveCursor', 'c', 'ViChange', 'd', 'ViDelete', 'e', 'ViMoveCursor', 'f', 'ViMoveCursorFind', 'h', 'ViMoveCursor', 'i', 'ViInput', 'j', 'NextHistory', 'k', 'PreviousHistory', 'l', 'ViMoveCursor', 'n', 'ViRepeatSearch', 'p', 'ViPut', 'r', 'ViReplaceChar', 's', 'ViChangeChar', 't', 'ViMoveCursorTo', 'u', 'ViUndo', 'w', 'ViMoveCursor', 'x', 'ViDeleteChar', 'y', 'ViYank', '|', 'ViMoveCursor', '~', 'ViToggleCase', (($inDOS and (not $ENV{'TERM'} or $ENV{'TERM'} !~ /^(vt|xterm)/i)) ? ( qq/"\0\110"/, 'PreviousHistory', # 72: <Up arrow> qq/"\0\120"/, 'NextHistory', # 80: <Down arrow> qq/"\0\113"/, 'BackwardChar', # 75: <Left arrow> qq/"\0\115"/, 'ForwardChar', # 77: <Right arrow> "\e", 'ViCommandMode', ) : (('M-C-j','EmacsEditingMode'), # Conflicts with \e otherwise (($ENV{'TERM'} and $ENV{'TERM'} eq 'hpterm') ? ( qq/"\eA"/, 'PreviousHistory', # up arrow qq/"\eB"/, 'NextHistory', # down arrow qq/"\eC"/, 'ForwardChar', # right arrow qq/"\eD"/, 'BackwardChar', # left arrow qq/"\e\\*"/, 'ViAfterEsc', ) : # Default ( qq/"\e[A"/, 'PreviousHistory', # up arrow qq/"\e[B"/, 'NextHistory', # down arrow qq/"\e[C"/, 'ForwardChar', # right arrow qq/"\e[D"/, 'BackwardChar', # left arrow qq/"\e\\*"/, 'ViAfterEsc', qq/"\e[\\*"/, 'ViAfterEsc', ) ))), ); # Vi positioning commands (suffixed to vi commands like 'd'). &InitKeymap(*vipos_keymap, 'ViNonPosition', 'vipos_keymap', '^', 'ViFirstWord', '0', 'BeginningOfLine', '1', 'ViDigit', '2', 'ViDigit', '3', 'ViDigit', '4', 'ViDigit', '5', 'ViDigit', '6', 'ViDigit', '7', 'ViDigit', '8', 'ViDigit', '9', 'ViDigit', '$', 'EndOfLine', 'h', 'BackwardChar', 'l', 'ForwardChar', ' ', 'ForwardChar', 'C-h', 'BackwardChar', 'f', 'ViForwardFindChar', 'F', 'ViBackwardFindChar', 't', 'ViForwardToChar', 'T', 'ViBackwardToChar', ';', 'ViRepeatFindChar', ',', 'ViInverseRepeatFindChar', '%', 'ViFindMatchingParens', '|', 'ViMoveToColumn', # Arrow keys ($inDOS ? ( qq/"\0\115"/, 'ForwardChar', # 77: <Right arrow> qq/"\0\113"/, 'BackwardChar', # 75: <Left arrow> "\e", 'ViPositionEsc', ) : ($ENV{'TERM'} and $ENV{'TERM'} eq 'hpterm') ? ( qq/"\eC"/, 'ForwardChar', # right arrow qq/"\eD"/, 'BackwardChar', # left arrow qq/"\e\\*"/, 'ViPositionEsc', ) : # Default ( qq/"\e[C"/, 'ForwardChar', # right arrow qq/"\e[D"/, 'BackwardChar', # left arrow qq/"\e\\*"/, 'ViPositionEsc', qq/"\e[\\*"/, 'ViPositionEsc', ) ), ); # Vi search string input mode for '/' and '?'. &InitKeymap(*visearch_keymap, 'SelfInsert', 'visearch_keymap', "\e", 'Ding', 'C-c', 'Interrupt', 'C-h', 'ViSearchBackwardDeleteChar', 'C-w', 'UnixWordRubout', 'C-u', 'UnixLineDiscard', 'C-v', 'QuotedInsert', 'DEL', 'ViSearchBackwardDeleteChar', "\n", 'ViEndSearch', "\r", 'ViEndSearch', ); # These constant hashes hold the arguments to &forward_scan() or # &backward_scan() for vi positioning commands, which all # behave a little differently for delete, move, change, and yank. # # Note: I originally coded these as qr{}, but changed them to q{} for # compatibility with older perls at the expense of some performance. # # Note: Some of the more obscure key combinations behave slightly # differently in different vi implementation. This module matches # the behavior of /usr/ucb/vi, which is different from the # behavior of vim, nvi, and the ksh command line. One example is # the command '2de', when applied to the string ('^' represents the # cursor, not a character of the string): # # ^5.6 7...88888888 # # With /usr/ucb/vi and with this module, the result is # # ^...88888888 # # but with the other three vi implementations, the result is # # ^ 7...88888888 $Vi_delete_patterns = { ord('w') => q{(?:\w+|[^\w\s]+|)\s*}, ord('W') => q{\S*\s*}, ord('b') => q{\w+\s*|[^\w\s]+\s*|^\s+}, ord('B') => q{\S+\s*|^\s+}, ord('e') => q{.\s*\w+|.\s*[^\w\s]+|.\s*$}, ord('E') => q{.\s*\S+|.\s*$}, }; $Vi_move_patterns = { ord('w') => q{(?:\w+|[^\w\s]+|)\s*}, ord('W') => q{\S*\s*}, ord('b') => q{\w+\s*|[^\w\s]+\s*|^\s+}, ord('B') => q{\S+\s*|^\s+}, ord('e') => q{.\s*\w*(?=\w)|.\s*[^\w\s]*(?=[^\w\s])|.?\s*(?=\s$)}, ord('E') => q{.\s*\S*(?=\S)|.?\s*(?=\s$)}, }; $Vi_change_patterns = { ord('w') => q{\w+|[^\w\s]+|\s}, ord('W') => q{\S+|\s}, ord('b') => q{\w+\s*|[^\w\s]+\s*|^\s+}, ord('B') => q{\S+\s*|^\s+}, ord('e') => q{.\s*\w+|.\s*[^\w\s]+|.\s*$}, ord('E') => q{.\s*\S+|.\s*$}, }; $Vi_yank_patterns = { ord('w') => q{(?:\w+|[^\w\s]+|)\s*}, ord('W') => q{\S*\s*}, ord('b') => q{\w+\s*|[^\w\s]+\s*|^\s+}, ord('B') => q{\S+\s*|^\s+}, ord('e') => q{.\s*\w*(?=\w)|.\s*[^\w\s]*(?=[^\w\s])|.?\s*(?=\s$)}, ord('E') => q{.\s*\S*(?=\S)|.?\s*(?=\s$)}, }; my $default_mode = 'emacs'; *KeyMap = $var_EditingMode = $var_EditingMode{$default_mode};## my $name;## for $name ( keys %{'readline::'} ) {## # Create aliases accessible via tied interface## *{"rl_$1"} = \$ {"var_$1"} if $name =~ /$var_(.*)/;## } 1; # Returning a glob causes a bug in db5.001m}sub init{ if ($ENV{'TERM'} and ($ENV{'TERM'} eq 'emacs' || $ENV{'TERM'} eq 'dumb')) { $dumb_term = 1; } elsif (! -c $term_IN && $term_IN eq \*STDIN) { # Believe if it is given $stdin_not_tty = 1; } else { &get_window_size; &F_ReReadInitFile if !defined($rl_NoInitFromFile); $InputLocMsg = ''; *KeyMap = $var_EditingMode; } $initialized = 1;}#### InitKeymap(*keymap, 'default', 'name', bindings.....)##sub InitKeymap{ local(*KeyMap) = shift(@_); my $default = shift(@_); my $name = $KeyMap{'name'} = shift(@_); # 'default' is now optional - if '', &do_command() defaults it to # 'F_Ding'. Meta-maps now don't set a default - this lets # us detect multiple '\*' default declarations. JP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -