Skip to content

Commit 255b63a

Browse files
demo/sdl3_renderer: switch to native Nuklear UTF8 clipboard support
Co-authored-by: sleeptightAnsiC <91839286+sleeptightAnsiC@users.noreply.github.com>
1 parent f6332bb commit 255b63a

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

demo/sdl3_renderer/nuklear_sdl3_renderer.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,12 @@ nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
319319
char *text;
320320
int len;
321321
NK_UNUSED(usr);
322-
323322
/* this function returns empty string on failure, not NULL */
324323
text = SDL_GetClipboardText();
325324
NK_ASSERT(text);
326325

327326
if (text[0] != '\0') {
328-
/* FIXME: there is a bug in Nuklear that affects UTF8 clipboard handling
329-
* "len" should be a buffer length, but due to bug it must be a glyph count
330-
* see: https://github.com/Immediate-Mode-UI/Nuklear/pull/841 */
331-
#if 0
332327
len = nk_strlen(text);
333-
#else
334-
len = SDL_utf8strlen(text);
335-
#endif
336328
nk_textedit_paste(edit, text, len);
337329
}
338330
SDL_free(text);
@@ -341,26 +333,13 @@ nk_sdl_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
341333
NK_INTERN void
342334
nk_sdl_clipboard_copy(nk_handle usr, const char *text, int len)
343335
{
344-
const char *ptext;
345336
char *str;
346337
size_t buflen;
347338
struct nk_sdl* sdl = (struct nk_sdl*)usr.ptr;
348339
NK_ASSERT(sdl);
349340
if (len <= 0 || text == NULL) return;
350341

351-
/* FIXME: there is a bug in Nuklear that affects UTF8 clipboard handling
352-
* "len" is expected to be a buffer length, but due to bug it actually is a glyph count
353-
* see: https://github.com/Immediate-Mode-UI/Nuklear/pull/841 */
354-
#if 0
355342
buflen = len + 1;
356-
NK_UNUSED(ptext);
357-
#else
358-
ptext = text;
359-
for (i = len; i > 0; i--)
360-
(void)SDL_StepUTF8(&ptext, NULL);
361-
buflen = (size_t)(ptext - text) + 1;
362-
#endif
363-
364343
str = sdl->allocator.alloc(sdl->allocator.userdata, 0, buflen);
365344
if (!str) return;
366345
SDL_strlcpy(str, text, buflen);

0 commit comments

Comments
 (0)