mirror of https://github.com/buggins/dlangui.git
Add Platform.hasClipboardText() to speed up checking clipboard.
This commit is contained in:
parent
ee28496955
commit
888acfb7d3
|
@ -575,6 +575,12 @@ class AndroidPlatform : Platform {
|
|||
}
|
||||
|
||||
protected dstring _clipboardText;
|
||||
|
||||
/// check has clipboard text
|
||||
override bool hasClipboardText(bool mouseBuffer = false) {
|
||||
return (_clipboardText.length > 0);
|
||||
}
|
||||
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||
return _clipboardText;
|
||||
|
|
|
@ -1823,6 +1823,8 @@ class Platform {
|
|||
* When returned from this method, application is shutting down.
|
||||
*/
|
||||
abstract int enterMessageLoop();
|
||||
/// check has clipboard text
|
||||
abstract bool hasClipboardText(bool mouseBuffer = false);
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
abstract dstring getClipboardText(bool mouseBuffer = false);
|
||||
/// sets text to clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
|
|
|
@ -240,6 +240,12 @@ class ConsolePlatform : Platform {
|
|||
return 0;
|
||||
}
|
||||
private dstring _clipboardText;
|
||||
|
||||
/// check has clipboard text
|
||||
override bool hasClipboardText(bool mouseBuffer = false) {
|
||||
return (_clipboardText.length > 0);
|
||||
}
|
||||
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||
return _clipboardText;
|
||||
|
|
|
@ -1462,10 +1462,13 @@ class SDLPlatform : Platform {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// check has clipboard text
|
||||
override bool hasClipboardText(bool mouseBuffer = false) {
|
||||
return (SDL_HasClipboardText() == SDL_TRUE);
|
||||
}
|
||||
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||
if (!SDL_HasClipboardText())
|
||||
return ""d;
|
||||
char * txt = SDL_GetClipboardText();
|
||||
if (!txt)
|
||||
return ""d;
|
||||
|
|
|
@ -1158,6 +1158,13 @@ class Win32Platform : Platform {
|
|||
_windowsToDestroy.length = 0;
|
||||
}
|
||||
|
||||
/// check has clipboard text
|
||||
override bool hasClipboardText(bool mouseBuffer = false) {
|
||||
if (mouseBuffer)
|
||||
return false;
|
||||
return IsClipboardFormatAvailable(CF_UNICODETEXT);
|
||||
}
|
||||
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||
dstring res = null;
|
||||
|
|
|
@ -1633,6 +1633,11 @@ class X11Platform : Platform {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/// check has clipboard text
|
||||
override bool hasClipboardText(bool mouseBuffer = false) {
|
||||
return (localClipboardContent.length != 0);
|
||||
}
|
||||
|
||||
/// retrieves text from clipboard (when mouseBuffer == true, use mouse selection clipboard - under linux)
|
||||
override dstring getClipboardText(bool mouseBuffer = false) {
|
||||
return toUTF32(localClipboardContent);
|
||||
|
|
Loading…
Reference in New Issue