mirror of https://github.com/buggins/dlangui.git
fix clipboard paste operation - normalize line endings - close #473
This commit is contained in:
parent
df95bc35b1
commit
782ca5f46d
|
@ -560,3 +560,31 @@ string toUTF8(dstring str) {
|
||||||
}
|
}
|
||||||
return cast(string)buf;
|
return cast(string)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// normalize end of line style - convert to '\n'
|
||||||
|
dstring normalizeEndOfLineCharacters(dstring s) {
|
||||||
|
bool crFound = false;
|
||||||
|
foreach(ch; s) {
|
||||||
|
if (ch == '\r') {
|
||||||
|
crFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!crFound)
|
||||||
|
return s;
|
||||||
|
dchar[] res;
|
||||||
|
res.reserve(s.length);
|
||||||
|
dchar prevCh = 0;
|
||||||
|
foreach(ch; s) {
|
||||||
|
if (ch == '\r') {
|
||||||
|
res ~= '\n';
|
||||||
|
} else if (ch == '\n') {
|
||||||
|
if (prevCh != '\r')
|
||||||
|
res ~= '\n';
|
||||||
|
} else {
|
||||||
|
res ~= ch;
|
||||||
|
}
|
||||||
|
prevCh = ch;
|
||||||
|
}
|
||||||
|
return cast(dstring)res;
|
||||||
|
}
|
||||||
|
|
|
@ -1185,7 +1185,7 @@ class Win32Platform : Platform {
|
||||||
if (lptstr != NULL)
|
if (lptstr != NULL)
|
||||||
{
|
{
|
||||||
wstring w = fromWStringz(lptstr);
|
wstring w = fromWStringz(lptstr);
|
||||||
res = toUTF32(w);
|
res = normalizeEndOfLineCharacters(toUTF32(w));
|
||||||
|
|
||||||
GlobalUnlock(hglb);
|
GlobalUnlock(hglb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
v0.9.159
|
v0.9.160
|
Loading…
Reference in New Issue