Add support to copy text to clipboard.

Fix \n handling in paste from clipboard.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-05-22 17:55:51 +01:00
parent 16c70e4cde
commit 9af407a089
3 changed files with 27 additions and 3 deletions

View file

@ -36,6 +36,10 @@ Some of the configuration options are exposed in the ``Settings`` menu. This is
``Left Alt`` and ``Right Alt`` emulate the Open and Solid Apple key.
``Shift-Insert`` pastes the clipboard to the input key buffer.
``Ctrl-Insert`` copies the text screen (in AppleWin this is ``Ctrl-PrintScreen``).
## Audio
Audio works reasonably well, using AppleWin adaptive algorithm.

View file

@ -433,6 +433,17 @@ namespace sa2
SDL_free(text);
}
}
else if (key.keysym.mod & KMOD_CTRL)
{
// in AppleWin this is Ctrl-PrintScreen
// but PrintScreen is not passed to SDL
char *pText;
const size_t size = Util_GetTextScreen(pText);
if (size)
{
SDL_SetClipboardText(pText);
}
}
break;
}
}

View file

@ -110,10 +110,19 @@ void addTextToBuffer(const char * text)
{
while (*text)
{
if (*text >= 0x20 && *text <= 0x7e)
switch (*text)
{
addKeyToBuffer(*text);
++text;
case '\n':
{
addKeyToBuffer(0x0d);
break;
}
case 0x20 ... 0x7e:
{
addKeyToBuffer(*text);
break;
}
}
++text;
}
}