mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Update changelog, comments, made empty/no-text clipboard return NULL as with other implementation. Minor style tweaks. (#2546)
Fixed IMGUI_DISABLE_WIN32_FUNCTIONS not disabling IME code.
This commit is contained in:
24
imgui.cpp
24
imgui.cpp
@ -9528,13 +9528,13 @@ static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandl
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
// Win32 API clipboard implementation
|
||||
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "user32")
|
||||
#endif
|
||||
|
||||
// Win32 clipboard implementation
|
||||
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
||||
{
|
||||
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)
|
||||
#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;
|
||||
|
||||
// OSX clipboard implementation
|
||||
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
||||
{
|
||||
if (!main_clipboard)
|
||||
PasteboardCreate(kPasteboardClipboard, &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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -9603,7 +9605,6 @@ static const char* GetClipboardTextFn_DefaultImpl(void*)
|
||||
|
||||
ItemCount item_count = 0;
|
||||
PasteboardGetItemCount(main_clipboard, &item_count);
|
||||
|
||||
for (int i = 0; i < item_count; i++)
|
||||
{
|
||||
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)
|
||||
{
|
||||
static ImVector<char> clipboard_text;
|
||||
|
||||
int length = (int) CFDataGetLength(cf_data);
|
||||
int length = (int)CFDataGetLength(cf_data);
|
||||
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;
|
||||
|
||||
CFRelease(cf_data);
|
||||
return clipboard_text.Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#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*)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
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)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -9653,7 +9651,7 @@ static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
||||
#endif
|
||||
|
||||
// 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>
|
||||
#ifdef _MSC_VER
|
||||
|
Reference in New Issue
Block a user