From e74cee141916a43a11ac1210cb00e88152c67bbb Mon Sep 17 00:00:00 2001 From: Takase <20792268+takase1121@users.noreply.github.com> Date: Fri, 24 May 2024 04:19:15 +0800 Subject: [PATCH] api/system: fix newlines returned by get_clipboard (#1788) --- src/api/system.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/system.c b/src/api/system.c index b13a7754..f599e800 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -830,7 +830,14 @@ static int f_mkdir(lua_State *L) { static int f_get_clipboard(lua_State *L) { char *text = SDL_GetClipboardText(); if (!text) { return 0; } +#ifdef _WIN32 + // on windows, text-based clipboard formats must terminate with \r\n + // we need to convert it to \n for Lite XL to read them properly + // https://learn.microsoft.com/en-us/windows/win32/dataxchg/standard-clipboard-formats + luaL_gsub(L, text, "\r\n", "\n"); +#else lua_pushstring(L, text); +#endif SDL_free(text); return 1; }