CTRL+x and c for cut/copy to clipboard

This commit is contained in:
BjossiAlfreds 2024-08-02 00:42:40 +00:00
parent ced8be673e
commit d11ba119bc
4 changed files with 38 additions and 1 deletions

View file

@ -30,6 +30,7 @@
#include "header/client.h"
void IN_GetClipboardText(char *out, size_t n);
int IN_SetClipboardText(const char *s);
static cvar_t *cfg_unbindall;
@ -348,7 +349,8 @@ CompleteMapNameCommand(void)
void
Key_Console(int key)
{
char txt[2], cliptext[256];
char txt[2];
char cliptext[256];
/*
* Ignore keypad in console to prevent duplicate
@ -387,6 +389,21 @@ Key_Console(int key)
return;
}
if (key == 'c' || key == 'x')
{
if (IN_SetClipboardText(key_lines[edit_line] + 1))
{
Com_Printf("Copy to clipboard failed.\n");
}
else if (key == 'x')
{
key_lines[edit_line][1] = '\0';
key_linepos = 1;
}
return;
}
if (key == 'v')
{
IN_GetClipboardText(cliptext, sizeof(cliptext));

View file

@ -59,4 +59,12 @@ void IN_Update(void);
*/
void In_FlushQueue(void);
/* Clipboard get/set */
/* Copy clipboard to buffer of size n */
void IN_GetClipboardText(char *out, size_t n);
/* Copy text to clipboard */
int IN_SetClipboardText(const char *s);
#endif

View file

@ -2428,3 +2428,9 @@ IN_GetClipboardText(char *out, size_t n)
SDL_free(s);
}
int
IN_SetClipboardText(const char *s)
{
return SDL_SetClipboardText(s);
}

View file

@ -2426,3 +2426,9 @@ IN_GetClipboardText(char *out, size_t n)
SDL_free(s);
}
int
IN_SetClipboardText(const char *s)
{
return SDL_SetClipboardText(s);
}