|
@@ -9528,13 +9528,13 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
|
#include <TargetConditionals.h>
|
|
#include <TargetConditionals.h>
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-// Win32 API clipboard implementation
|
|
|
|
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
|
|
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
#ifdef _MSC_VER
|
|
#pragma comment(lib, "user32")
|
|
#pragma comment(lib, "user32")
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+// Win32 clipboard implementation
|
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
{
|
|
{
|
|
static ImVector<char> buf_local;
|
|
static ImVector<char> buf_local;
|
|
@@ -9579,18 +9579,20 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
}
|
|
}
|
|
|
|
|
|
#elif defined(__APPLE__) && TARGET_OS_OSX && !defined(IMGUI_DISABLE_OSX_FUNCTIONS)
|
|
#elif defined(__APPLE__) && TARGET_OS_OSX && !defined(IMGUI_DISABLE_OSX_FUNCTIONS)
|
|
-#include <Carbon/Carbon.h> // use ye olde worlde API to avoid need for separate .mm file
|
|
|
|
|
|
+
|
|
|
|
+#include <Carbon/Carbon.h> // Use old API to avoid need for separate .mm file
|
|
static PasteboardRef main_clipboard = 0;
|
|
static PasteboardRef main_clipboard = 0;
|
|
|
|
|
|
|
|
+// OSX clipboard implementation
|
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
{
|
|
{
|
|
if (!main_clipboard)
|
|
if (!main_clipboard)
|
|
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
|
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
|
|
PasteboardClear(main_clipboard);
|
|
PasteboardClear(main_clipboard);
|
|
- CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*) text, strlen(text));
|
|
|
|
|
|
+ CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text));
|
|
if (cf_data)
|
|
if (cf_data)
|
|
{
|
|
{
|
|
- PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID) 1, CFSTR("public.utf8-plain-text"), cf_data, 0);
|
|
|
|
|
|
+ PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0);
|
|
CFRelease(cf_data);
|
|
CFRelease(cf_data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -9603,7 +9605,6 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
|
|
|
|
ItemCount item_count = 0;
|
|
ItemCount item_count = 0;
|
|
PasteboardGetItemCount(main_clipboard, &item_count);
|
|
PasteboardGetItemCount(main_clipboard, &item_count);
|
|
-
|
|
|
|
for (int i = 0; i < item_count; i++)
|
|
for (int i = 0; i < item_count; i++)
|
|
{
|
|
{
|
|
PasteboardItemID item_id = 0;
|
|
PasteboardItemID item_id = 0;
|
|
@@ -9616,30 +9617,27 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr)
|
|
if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr)
|
|
{
|
|
{
|
|
static ImVector<char> clipboard_text;
|
|
static ImVector<char> clipboard_text;
|
|
-
|
|
|
|
- int length = (int) CFDataGetLength(cf_data);
|
|
|
|
|
|
+ int length = (int)CFDataGetLength(cf_data);
|
|
clipboard_text.resize(length + 1);
|
|
clipboard_text.resize(length + 1);
|
|
- CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*) clipboard_text.Data);
|
|
|
|
|
|
+ CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)clipboard_text.Data);
|
|
clipboard_text[length] = 0;
|
|
clipboard_text[length] = 0;
|
|
-
|
|
|
|
CFRelease(cf_data);
|
|
CFRelease(cf_data);
|
|
return clipboard_text.Data;
|
|
return clipboard_text.Data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return "";
|
|
|
|
|
|
+ return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
#else
|
|
#else
|
|
|
|
|
|
-// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
|
|
|
|
|
+// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
|
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
|
|
return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
|
|
}
|
|
}
|
|
|
|
|
|
-// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
|
|
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -9653,7 +9651,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// Win32 API IME support (for Asian languages, etc.)
|
|
// Win32 API IME support (for Asian languages, etc.)
|
|
-#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
|
|
|
|
|
+#if defined(_WIN32) && !defined(__GNUC__) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS)
|
|
|
|
|
|
#include <imm.h>
|
|
#include <imm.h>
|
|
#ifdef _MSC_VER
|
|
#ifdef _MSC_VER
|