forked from Mirrorlandia_minetest/minetest
Use utf-8 for the Irrlicht clipboard (#11538)
This commit is contained in:
parent
fad835cf64
commit
dad87a360b
@ -580,8 +580,7 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
|
|||||||
const c8 *text = os_operator->getTextFromClipboard();
|
const c8 *text = os_operator->getTextFromClipboard();
|
||||||
if (!text)
|
if (!text)
|
||||||
return true;
|
return true;
|
||||||
std::basic_string<unsigned char> str((const unsigned char*)text);
|
prompt.input(utf8_to_wide(text));
|
||||||
prompt.input(std::wstring(str.begin(), str.end()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control)
|
else if(event.KeyInput.Key == KEY_KEY_X && event.KeyInput.Control)
|
||||||
|
@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "IGUIFont.h"
|
#include "IGUIFont.h"
|
||||||
|
|
||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
|
||||||
GUIEditBox::~GUIEditBox()
|
GUIEditBox::~GUIEditBox()
|
||||||
{
|
{
|
||||||
@ -517,8 +518,7 @@ void GUIEditBox::onKeyControlC(const SEvent &event)
|
|||||||
const s32 realmbgn = m_mark_begin < m_mark_end ? m_mark_begin : m_mark_end;
|
const s32 realmbgn = m_mark_begin < m_mark_end ? m_mark_begin : m_mark_end;
|
||||||
const s32 realmend = m_mark_begin < m_mark_end ? m_mark_end : m_mark_begin;
|
const s32 realmend = m_mark_begin < m_mark_end ? m_mark_end : m_mark_begin;
|
||||||
|
|
||||||
core::stringc s;
|
std::string s = stringw_to_utf8(Text.subString(realmbgn, realmend - realmbgn));
|
||||||
s = Text.subString(realmbgn, realmend - realmbgn).c_str();
|
|
||||||
m_operator->copyToClipboard(s.c_str());
|
m_operator->copyToClipboard(s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,29 +567,28 @@ bool GUIEditBox::onKeyControlV(const SEvent &event, s32 &mark_begin, s32 &mark_e
|
|||||||
|
|
||||||
// add new character
|
// add new character
|
||||||
if (const c8 *p = m_operator->getTextFromClipboard()) {
|
if (const c8 *p = m_operator->getTextFromClipboard()) {
|
||||||
|
core::stringw inserted_text = utf8_to_stringw(p);
|
||||||
if (m_mark_begin == m_mark_end) {
|
if (m_mark_begin == m_mark_end) {
|
||||||
// insert text
|
// insert text
|
||||||
core::stringw s = Text.subString(0, m_cursor_pos);
|
core::stringw s = Text.subString(0, m_cursor_pos);
|
||||||
s.append(p);
|
s.append(inserted_text);
|
||||||
s.append(Text.subString(
|
s.append(Text.subString(
|
||||||
m_cursor_pos, Text.size() - m_cursor_pos));
|
m_cursor_pos, Text.size() - m_cursor_pos));
|
||||||
|
|
||||||
if (!m_max || s.size() <= m_max) {
|
if (!m_max || s.size() <= m_max) {
|
||||||
Text = s;
|
Text = s;
|
||||||
s = p;
|
m_cursor_pos += inserted_text.size();
|
||||||
m_cursor_pos += s.size();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// replace text
|
// replace text
|
||||||
|
|
||||||
core::stringw s = Text.subString(0, realmbgn);
|
core::stringw s = Text.subString(0, realmbgn);
|
||||||
s.append(p);
|
s.append(inserted_text);
|
||||||
s.append(Text.subString(realmend, Text.size() - realmend));
|
s.append(Text.subString(realmend, Text.size() - realmend));
|
||||||
|
|
||||||
if (!m_max || s.size() <= m_max) {
|
if (!m_max || s.size() <= m_max) {
|
||||||
Text = s;
|
Text = s;
|
||||||
s = p;
|
m_cursor_pos = realmbgn + inserted_text.size();
|
||||||
m_cursor_pos = realmbgn + s.size();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user