mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-30 12:00:39 +00:00
- Changed I_GetFromClipboard() to return an FString.
SVN r1414 (trunk)
This commit is contained in:
parent
be165578ea
commit
025e36ee41
8 changed files with 32 additions and 27 deletions
|
@ -1,4 +1,5 @@
|
||||||
February 7, 2009
|
February 7, 2009
|
||||||
|
- Changed I_GetFromClipboard() to return an FString.
|
||||||
- Added GTK+-based clipboard support for Linux.
|
- Added GTK+-based clipboard support for Linux.
|
||||||
- Fixed: Most Linux filesystems do not fill in d_type for scandir(), so we
|
- Fixed: Most Linux filesystems do not fill in d_type for scandir(), so we
|
||||||
cannot rely on it to detect directories.
|
cannot rely on it to detect directories.
|
||||||
|
|
|
@ -1739,13 +1739,14 @@ static bool C_HandleKey (event_t *ev, BYTE *buffer, int len)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // paste from clipboard
|
{ // paste from clipboard
|
||||||
char *clip = I_GetFromClipboard ();
|
FString clip = I_GetFromClipboard ();
|
||||||
if (clip != NULL)
|
if (clip.IsNotEmpty())
|
||||||
{
|
{
|
||||||
strtok (clip, "\r\n\b");
|
// Only paste the first line.
|
||||||
int cliplen = (int)strlen (clip);
|
long brk = clip.IndexOfAny("\r\n\b");
|
||||||
|
int cliplen = brk >= 0 ? brk : clip.Len();
|
||||||
|
|
||||||
cliplen = MIN(len, cliplen);
|
// Make sure there's room for the whole thing.
|
||||||
if (buffer[0] + cliplen > len)
|
if (buffer[0] + cliplen > len)
|
||||||
{
|
{
|
||||||
cliplen = len - buffer[0];
|
cliplen = len - buffer[0];
|
||||||
|
@ -1764,7 +1765,6 @@ static bool C_HandleKey (event_t *ev, BYTE *buffer, int len)
|
||||||
makestartposgood ();
|
makestartposgood ();
|
||||||
HistPos = NULL;
|
HistPos = NULL;
|
||||||
}
|
}
|
||||||
delete[] clip;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,16 +150,19 @@ bool CT_Responder (event_t *ev)
|
||||||
}
|
}
|
||||||
else if (ev->data1 == 'V' && (ev->data3 & GKM_CTRL))
|
else if (ev->data1 == 'V' && (ev->data3 & GKM_CTRL))
|
||||||
{
|
{
|
||||||
char *clip = I_GetFromClipboard ();
|
FString clip = I_GetFromClipboard ();
|
||||||
if (clip != NULL)
|
if (clip.IsNotEmpty())
|
||||||
{
|
{
|
||||||
char *clip_p = clip;
|
// Only paste the first line.
|
||||||
strtok (clip, "\n\r\b");
|
const char *clip_p = clip;
|
||||||
while (*clip_p)
|
while (*clip_p)
|
||||||
{
|
{
|
||||||
|
if (*clip_p == '\n' || *clip_p == '\r' || *clip_p == '\b')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
CT_AddChar (*clip_p++);
|
CT_AddChar (*clip_p++);
|
||||||
}
|
}
|
||||||
delete[] clip;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,7 +646,7 @@ void M_ScreenShot (const char *filename)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int dirlen;
|
size_t dirlen;
|
||||||
autoname = Args->CheckValue("-shotdir");
|
autoname = Args->CheckValue("-shotdir");
|
||||||
if (autoname == NULL)
|
if (autoname == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define __I_INPUT_H__
|
#define __I_INPUT_H__
|
||||||
|
|
||||||
void I_PutInClipboard (const char *str);
|
void I_PutInClipboard (const char *str);
|
||||||
char *I_GetFromClipboard ();
|
FString I_GetFromClipboard ();
|
||||||
|
|
||||||
struct GUIDName
|
struct GUIDName
|
||||||
{
|
{
|
||||||
|
|
|
@ -596,7 +596,7 @@ void I_PutInClipboard (const char *str)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *I_GetFromClipboard ()
|
FString I_GetFromClipboard ()
|
||||||
{
|
{
|
||||||
#ifndef NO_GTK
|
#ifndef NO_GTK
|
||||||
if (GtkAvailable)
|
if (GtkAvailable)
|
||||||
|
@ -607,12 +607,12 @@ char *I_GetFromClipboard ()
|
||||||
gchar *text = gtk_clipboard_wait_for_text(clipboard);
|
gchar *text = gtk_clipboard_wait_for_text(clipboard);
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
char *copy = copystring(text);
|
FString copy(text);
|
||||||
g_free(text);
|
g_free(text);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2024,15 +2024,15 @@ void I_PutInClipboard (const char *str)
|
||||||
CloseClipboard ();
|
CloseClipboard ();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *I_GetFromClipboard ()
|
FString I_GetFromClipboard ()
|
||||||
{
|
{
|
||||||
char *retstr = NULL;
|
FString retstr;
|
||||||
HGLOBAL cliphandle;
|
HGLOBAL cliphandle;
|
||||||
char *clipstr;
|
char *clipstr;
|
||||||
char *nlstr;
|
char *nlstr;
|
||||||
|
|
||||||
if (!IsClipboardFormatAvailable (CF_TEXT) || !OpenClipboard (Window))
|
if (!IsClipboardFormatAvailable (CF_TEXT) || !OpenClipboard (Window))
|
||||||
return NULL;
|
return retstr;
|
||||||
|
|
||||||
cliphandle = GetClipboardData (CF_TEXT);
|
cliphandle = GetClipboardData (CF_TEXT);
|
||||||
if (cliphandle != NULL)
|
if (cliphandle != NULL)
|
||||||
|
@ -2040,15 +2040,16 @@ char *I_GetFromClipboard ()
|
||||||
clipstr = (char *)GlobalLock (cliphandle);
|
clipstr = (char *)GlobalLock (cliphandle);
|
||||||
if (clipstr != NULL)
|
if (clipstr != NULL)
|
||||||
{
|
{
|
||||||
retstr = copystring (clipstr);
|
// Convert CR-LF pairs to just LF while copying to the FString
|
||||||
GlobalUnlock (clipstr);
|
for (nlstr = clipstr; *nlstr != '\0'; ++nlstr)
|
||||||
nlstr = retstr;
|
|
||||||
|
|
||||||
// Convert CR-LF pairs to just LF
|
|
||||||
while ( (nlstr = strstr (retstr, "\r\n")) )
|
|
||||||
{
|
{
|
||||||
memmove (nlstr, nlstr + 1, strlen (nlstr) - 1);
|
if (nlstr[0] == '\r' && nlstr[1] == '\n')
|
||||||
|
{
|
||||||
|
nlstr++;
|
||||||
|
}
|
||||||
|
retstr += *nlstr;
|
||||||
}
|
}
|
||||||
|
GlobalUnlock (clipstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
bool I_InitInput (void *hwnd);
|
bool I_InitInput (void *hwnd);
|
||||||
void I_ShutdownInput ();
|
void I_ShutdownInput ();
|
||||||
void I_PutInClipboard (const char *str);
|
void I_PutInClipboard (const char *str);
|
||||||
char *I_GetFromClipboard ();
|
FString I_GetFromClipboard ();
|
||||||
|
|
||||||
void I_GetEvent ();
|
void I_GetEvent ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue