使用 shift-Insert 在 WSL 中粘贴

Phi*_*ppe 5 terminal windows-subsystem-for-linux

# When I do just Shift-Insert, I get
~$ 2~
# When I do Ctrl-V, then Shift-Insert, I get
~$ ^[[2;2~
Run Code Online (Sandbox Code Playgroud)

Shift-insert 在其他情况下也能很好地工作,比如 Windows CMD 或 Git-Bash

在 wsl 中,我可以使用 Ctrl-Shift-V 进行粘贴,但更喜欢使用 shift-insert。

有什么解决办法吗?

Tho*_*key 7

microsoft/WSL报道:

\n
\n

请注意,WSL 发行版在 Windows 控制台中启动(除非您已采取措施启动第 3 方控制台/终端)。因此,请在Windows 控制台问题跟踪器中记录 UI/UX 相关问题。

\n
\n

但Windows 控制台的给定链接指向Windows 终端

\n
\n

新的 Windows 终端和原来的 Windows 控制台主机都在同一个地方!

\n
\n

没有(可用的)文档,因此必须通过指向其源代码来回答您的问题。

\n

相关的块(你想要练习的)在这里,在windowio.cpp

\n
    // handle shift-ins paste\n    if (inputKeyInfo.IsShiftOnly() && ShouldTakeOverKeyboardShortcuts())\n    {\n        if (!bKeyDown)\n        {\n            return;\n        }\n        else if (VirtualKeyCode == VK_INSERT && !(pSelection->IsInSelectingState() && pSelection->IsKeyboardMarkSelection()))\n        {\n            Clipboard::Instance().Paste();\n            return;\n        }\n    }\n
Run Code Online (Sandbox Code Playgroud)\n

一半的条件(达到该条件Paste())似乎可能得到满足(除非该程序中存在一些错误)。那些不明显的:

\n
    \n
  • ShouldTakeOverKeyboardShortcuts()\xe2\x80\x94 但这在ctrl+shift+加/减代码中使用

    \n
  • \n
  • pSelection->IsKeyboardMarkSelection()\xe2\x80\x94 我们假设使用鼠标进行选择。

    \n
  • \n
\n

但这是假设此HandleKeyEvent方法平等对待两个不同的按键序列。来自^[[2;2~程序的另一部分,在 中terminalInput.cpp,使用内置表

\n
// Sequences to send when a modifier is pressed with any of these keys\n// Basically, the \'m\' will be replaced with a character indicating which\n//      modifier keys are pressed.\nstatic constexpr std::array<TermKeyMap, 22> s_modifierKeyMapping{\n
Run Code Online (Sandbox Code Playgroud)\n

在这里应用

\n
// If a modifier key was pressed, then we need to try and send the modified sequence.\nif (keyEvent.IsModifierPressed() && _searchWithModifier(keyEvent, senderFunc))\n{\n    return true;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

从阅读代码来看,这似乎都是逻辑的上游windowio.cpp,因此永远不会达到组合。开发人员没有提供覆盖或修改此行为的方法。

\n

正如 @Rody-Oldenhuis 的评论中所建议的:

\n
\n

您可以使用wsltty;这支持开箱即用的 Ctrl+Ins/Shift-Ins

\n
\n

(源自薄荷)。

\n


art*_*tol 5

如果您使用Windows Terminal运行 WSL ,则 Shift-Insert 可以直接用于粘贴。(正如您所料,Ctrl-Insert 也适用于复制)