使用 shift-Insert 貼上到 WSL 中

使用 shift-Insert 貼上到 WSL 中
# When I do just Shift-Insert, I get
~$ 2~
# When I do Ctrl-V, then Shift-Insert, I get
~$ ^[[2;2~

Shift-insert 在其他情況下效果很好,例如 Windows CMD 或 Git-Bash

在 wsl 中,我可以使用 Ctrl-Shift-V 進行貼上,但喜歡使用 shift-insert。

有什麼解決方法嗎?

答案1

根據微軟/WSL

請注意,WSL 發行版在 Windows 控制台中啟動(除非您已採取措施啟動第 3 方控制台/終端)。因此,請將 UI/UX 相關問題提交到Windows 主機問題追蹤器。

但給定的鏈接Windows 主機指著Windows 終端

新的 Windows 終端機和原來的 Windows 控制台主機都在同一個地方!

沒有(可用的)文檔,因此必須透過指向其原始程式碼來回答您的問題。

相關的塊(你想要練習的)在這裡,在windowio.cpp

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

一半的條件(達到該目標Paste())似乎可能得到滿足(除非某些條件)漏洞在這個程序中)。那些不明顯的:

  • ShouldTakeOverKeyboardShortcuts()——但這用在Ctrl+Shift+加/減程式碼

  • pSelection->IsKeyboardMarkSelection()- 我們假設使用滑鼠進行選擇。

但這是假設該HandleKeyEvent方法平等對待兩個不同的按鍵序列。來自^[[2;2~程式的另一部分,在 中terminalInput.cpp,使用內建表

// Sequences to send when a modifier is pressed with any of these keys
// Basically, the 'm' will be replaced with a character indicating which
//      modifier keys are pressed.
static constexpr std::array<TermKeyMap, 22> s_modifierKeyMapping{

在這裡應用

// If a modifier key was pressed, then we need to try and send the modified sequence.
if (keyEvent.IsModifierPressed() && _searchWithModifier(keyEvent, senderFunc))
{
    return true;
}

從閱讀程式碼來看,這就是全部上游windowio.cpp邏輯上看,這樣的組合永遠不會達到。開發人員沒有提供覆蓋或修改此行為的方法。

正如 @Rody-Oldenhuis 的評論中所建議的:

您可以使用沃斯蒂;這支援開箱即用的 Ctrl+Ins/Shift-Ins

(源自薄荷)。

答案2

如果您使用執行 WSLWindows 終端, Shift-Insert 可以直接用於貼上。 (如您所料,Ctrl-Insert 也適用於複製)

答案3

不太清楚為什麼要使用 shift+insert 來貼上或如何重新映射它,但預設貼上就像單擊滑鼠右鍵一樣簡單。

相關內容