api/system: fix newlines returned by get_clipboard (#1788)
This commit is contained in:
parent
5549c0bd29
commit
e74cee1419
|
@ -830,7 +830,14 @@ static int f_mkdir(lua_State *L) {
|
||||||
static int f_get_clipboard(lua_State *L) {
|
static int f_get_clipboard(lua_State *L) {
|
||||||
char *text = SDL_GetClipboardText();
|
char *text = SDL_GetClipboardText();
|
||||||
if (!text) { return 0; }
|
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);
|
lua_pushstring(L, text);
|
||||||
|
#endif
|
||||||
SDL_free(text);
|
SDL_free(text);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue