Experimental "paste" support for text fields.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1827 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
4dc40e7784
commit
afa22ae0ac
@ -120,9 +120,11 @@ byte Native_filesel(byte load)
|
|||||||
// Check if cancel
|
// Check if cancel
|
||||||
return CommDlgExtendedError();
|
return CommDlgExtendedError();
|
||||||
}
|
}
|
||||||
#else ifndef(__linux__) // This makes no sense on X11-oriented platform. Nothing is really native there.
|
#else
|
||||||
#warning "EXPERIMENTAL function for native fileselector not available for this platform!"
|
#ifndef(__linux__) // This makes no sense on X11-oriented platform. Nothing is really native there.
|
||||||
return 255; // fail !
|
#warning "EXPERIMENTAL function for native fileselector not available for this platform!"
|
||||||
|
#endif
|
||||||
|
return 255; // fail !
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1298,7 +1300,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context)
|
|||||||
|
|
||||||
Reset_quicksearch();
|
Reset_quicksearch();
|
||||||
|
|
||||||
// if (Native_filesel(load) != 0); // TODO : handle this
|
//if (Native_filesel(load) != 0); // TODO : handle this
|
||||||
|
|
||||||
if (context->Type == CONTEXT_MAIN_IMAGE)
|
if (context->Type == CONTEXT_MAIN_IMAGE)
|
||||||
window_shortcut = load?(0x100+BUTTON_LOAD):(0x100+BUTTON_SAVE);
|
window_shortcut = load?(0x100+BUTTON_LOAD):(0x100+BUTTON_SAVE);
|
||||||
|
|||||||
@ -41,6 +41,11 @@
|
|||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <SDL_syswm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Virtual keyboard is mandatory on these platforms:
|
// Virtual keyboard is mandatory on these platforms:
|
||||||
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
#if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__)
|
||||||
#ifndef VIRT_KEY
|
#ifndef VIRT_KEY
|
||||||
@ -143,9 +148,45 @@ void Init_virtual_keyboard(word y_pos, word keyboard_width, word keyboard_height
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Inspired from http://www.libsdl.org/projects/scrap/
|
||||||
|
// TODO X11 and others
|
||||||
|
char* getClipboard()
|
||||||
|
{
|
||||||
|
char* dst = NULL;
|
||||||
|
#ifdef __WIN32__
|
||||||
|
SDL_SysWMinfo info;
|
||||||
|
HWND SDL_Window;
|
||||||
|
|
||||||
|
SDL_VERSION(&info.version);
|
||||||
|
|
||||||
|
if ( SDL_GetWMInfo(&info) )
|
||||||
|
{
|
||||||
|
SDL_Window = info.window;
|
||||||
|
|
||||||
|
if ( IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(SDL_Window) )
|
||||||
|
{
|
||||||
|
HANDLE hMem;
|
||||||
|
char *src;
|
||||||
|
|
||||||
|
hMem = GetClipboardData(CF_TEXT);
|
||||||
|
if ( hMem != NULL )
|
||||||
|
{
|
||||||
|
src = (char *)GlobalLock(hMem);
|
||||||
|
dst = strdup(src);
|
||||||
|
GlobalUnlock(hMem);
|
||||||
|
}
|
||||||
|
CloseClipboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Enhanced super scanf deluxe pro plus giga mieux :-) *
|
* Enhanced super scanf deluxe pro plus giga mieux :-) *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
|
byte Readline(word x_pos,word y_pos,char * str,byte visible_size,byte input_type)
|
||||||
// Paramètres:
|
// Paramètres:
|
||||||
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
|
// x_pos, y_pos : Coordonnées de la saisie dans la fenêtre
|
||||||
@ -410,9 +451,23 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz
|
|||||||
input_key=Key_ANSI;
|
input_key=Key_ANSI;
|
||||||
if (Mouse_K)
|
if (Mouse_K)
|
||||||
input_key=SDLK_RETURN;
|
input_key=SDLK_RETURN;
|
||||||
|
|
||||||
|
// Handle paste request on CTRL+v
|
||||||
|
if ((Key & MOD_CTRL) && ((Key & 0xFFF) == 'v'))
|
||||||
|
{
|
||||||
|
char* data = getClipboard();
|
||||||
|
if (data == NULL) continue; // No clipboard data
|
||||||
|
// TODO Insert it at the cursor position, not at the end
|
||||||
|
// TODO Update cursor position
|
||||||
|
// TODO This doesn't respect the "allowed chars" restriction
|
||||||
|
strncat(str, data, max_size - size);
|
||||||
|
free(data);
|
||||||
|
goto affichage;
|
||||||
|
}
|
||||||
} while(input_key==0);
|
} while(input_key==0);
|
||||||
}
|
}
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
|
|
||||||
switch (input_key)
|
switch (input_key)
|
||||||
{
|
{
|
||||||
case SDLK_DELETE : // Suppr.
|
case SDLK_DELETE : // Suppr.
|
||||||
@ -529,6 +584,7 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz
|
|||||||
// On regarde si la touche est autorisée
|
// On regarde si la touche est autorisée
|
||||||
if ( Valid_character(input_key))
|
if ( Valid_character(input_key))
|
||||||
is_authorized=1;
|
is_authorized=1;
|
||||||
|
break;
|
||||||
case INPUT_TYPE_HEXA:
|
case INPUT_TYPE_HEXA:
|
||||||
if ( (input_key>='0') && (input_key<='9') )
|
if ( (input_key>='0') && (input_key<='9') )
|
||||||
is_authorized=1;
|
is_authorized=1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user