Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Minecraft.Client/Common/UI/UIControl_TextInput.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "UI.h"
#include "UIControl_TextInput.h"
#include "..\..\Screen.h"

UIControl_TextInput::UIControl_TextInput()
{
Expand Down Expand Up @@ -211,6 +212,31 @@ UIControl_TextInput::EDirectEditResult UIControl_TextInput::tickDirectEdit()
}
}

// Paste from clipboard
if (g_KBMInput.IsKeyPressed('V') && g_KBMInput.IsKeyDown(VK_CONTROL))
{
wstring pasted = Screen::getClipboard();
wstring sanitized;
sanitized.reserve(pasted.length());

for (wchar_t pc : pasted)
{
if (pc >= 0x20) // Keep printable characters
{
if (m_iCharLimit > 0 && (m_editBuffer.length() + sanitized.length()) >= (size_t)m_iCharLimit)
break;
sanitized += pc;
}
}

if (!sanitized.empty())
{
m_editBuffer.insert(m_iCursorPos, sanitized);
m_iCursorPos += (int)sanitized.length();
changed = true;
}
}

// Arrow keys, Home, End, Delete for cursor movement
if (g_KBMInput.IsKeyPressed(VK_LEFT) && m_iCursorPos > 0)
{
Expand Down
33 changes: 33 additions & 0 deletions Minecraft.Client/Common/UI/UIScene_Keyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "UI.h"
#include "UIScene_Keyboard.h"
#include "..\..\Screen.h"

#ifdef _WINDOWS64
// Global buffer that stores the text entered in the native keyboard scene.
Expand Down Expand Up @@ -224,6 +225,38 @@ void UIScene_Keyboard::tick()
}
}

// Paste from clipboard
if (g_KBMInput.IsKeyPressed('V') && g_KBMInput.IsKeyDown(VK_CONTROL))
{
wstring pasted = Screen::getClipboard();
wstring sanitized;
sanitized.reserve(pasted.length());

for (wchar_t pc : pasted)
{
if (pc >= 0x20) // Keep printable characters
{
if (static_cast<int>(m_win64TextBuffer.length() + sanitized.length()) >= m_win64MaxChars)
break;
sanitized += pc;
}
}

if (!sanitized.empty())
{
if (m_bPCMode)
{
m_win64TextBuffer.insert(m_iCursorPos, sanitized);
m_iCursorPos += (int)sanitized.length();
}
else
{
m_win64TextBuffer += sanitized;
}
changed = true;
}
}

if (m_bPCMode)
{
// Arrow keys, Home, End, Delete for cursor movement
Expand Down