Commit fce2b8fd authored by cutealien's avatar cutealien

Merge branch releases/1.8 revisions 4722 to 4748 into trunk:

- CGUIEditBox and the GUI-Editor now convert pasted text correctly using mbstowcs.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4749 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f21b7b9c
...@@ -51,6 +51,7 @@ Changes in 1.9 (not yet released) ...@@ -51,6 +51,7 @@ Changes in 1.9 (not yet released)
-------------------------- --------------------------
Changes in 1.8.2 Changes in 1.8.2
- CGUIEditBox and the GUI-Editor now convert pasted text correctly using mbstowcs.
- C::B project files work again on newer Linux-distributions which have cleaned up their dev-lib dependencies. - C::B project files work again on newer Linux-distributions which have cleaned up their dev-lib dependencies.
- Makefile for the new IrrFontTool links now correctly to libfontconfig - Makefile for the new IrrFontTool links now correctly to libfontconfig
......
...@@ -344,17 +344,25 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -344,17 +344,25 @@ bool CGUIEditBox::processKey(const SEvent& event)
const c8* p = Operator->getTextFromClipboard(); const c8* p = Operator->getTextFromClipboard();
if (p) if (p)
{ {
// TODO: we should have such a function in core::string
size_t lenOld = strlen(p);
wchar_t *ws = new wchar_t[lenOld + 1];
size_t len = mbstowcs(ws,p,lenOld);
ws[len] = 0;
irr::core::stringw widep(ws);
delete[] ws;
if (MarkBegin == MarkEnd) if (MarkBegin == MarkEnd)
{ {
// insert text // insert text
core::stringw s = Text.subString(0, CursorPos); core::stringw s = Text.subString(0, CursorPos);
s.append(p); s.append(widep);
s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); s.append( Text.subString(CursorPos, Text.size()-CursorPos) );
if (!Max || s.size()<=Max) // thx to Fish FH for fix if (!Max || s.size()<=Max) // thx to Fish FH for fix
{ {
Text = s; Text = s;
s = p; s = widep;
CursorPos += s.size(); CursorPos += s.size();
} }
} }
...@@ -363,13 +371,13 @@ bool CGUIEditBox::processKey(const SEvent& event) ...@@ -363,13 +371,13 @@ bool CGUIEditBox::processKey(const SEvent& event)
// replace text // replace text
core::stringw s = Text.subString(0, realmbgn); core::stringw s = Text.subString(0, realmbgn);
s.append(p); s.append(widep);
s.append( Text.subString(realmend, Text.size()-realmend) ); s.append( Text.subString(realmend, Text.size()-realmend) );
if (!Max || s.size()<=Max) // thx to Fish FH for fix if (!Max || s.size()<=Max) // thx to Fish FH for fix
{ {
Text = s; Text = s;
s = p; s = widep;
CursorPos = realmbgn + s.size(); CursorPos = realmbgn + s.size();
} }
} }
......
...@@ -875,9 +875,16 @@ void CGUIEditWorkspace::CopySelectedElementXML() ...@@ -875,9 +875,16 @@ void CGUIEditWorkspace::CopySelectedElementXML()
void CGUIEditWorkspace::PasteXMLToSelectedElement() void CGUIEditWorkspace::PasteXMLToSelectedElement()
{ {
// get clipboard data // get clipboard data
core::stringc XMLText = Environment->getOSOperator()->getTextFromClipboard(); const char * p = Environment->getOSOperator()->getTextFromClipboard();
// convert to stringw // convert to stringw
core::stringw wXMLText = XMLText.c_str(); // TODO: we should have such a function in core::string
size_t lenOld = strlen(p);
wchar_t *ws = new wchar_t[lenOld + 1];
size_t len = mbstowcs(ws,p,lenOld);
ws[len] = 0;
irr::core::stringw wXMLText(ws);
delete[] ws;
io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#"); io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment