mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-05 22:04:57 +00:00
(svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
This commit is contained in:
parent
78b02129c1
commit
7693c58e28
42
console.c
42
console.c
@ -7,7 +7,11 @@
|
||||
#include "variables.h"
|
||||
#include "hal.h"
|
||||
#include <stdarg.h>
|
||||
#include "console.h"
|
||||
#include "console.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// ** main console ** //
|
||||
static bool _iconsole_inited;
|
||||
@ -46,9 +50,34 @@ static const WindowDesc _iconsole_window_desc = {
|
||||
|
||||
/* *************** */
|
||||
/* end of header */
|
||||
/* *************** */
|
||||
/* *************** */
|
||||
|
||||
static void IConsoleAppendClipboard()
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (IsClipboardFormatAvailable(CF_TEXT)) {
|
||||
byte * data;
|
||||
HGLOBAL cbuf;
|
||||
int i;
|
||||
|
||||
OpenClipboard(NULL);
|
||||
cbuf = GetClipboardData(CF_TEXT);
|
||||
data = (byte *) GlobalLock(cbuf);
|
||||
|
||||
i=0;
|
||||
while (IS_INT_INSIDE(data[i], 32, 256)) {
|
||||
_iconsole_cmdline[_iconsole_cmdpos]=data[i];
|
||||
i++;
|
||||
_iconsole_cmdpos++;
|
||||
}
|
||||
|
||||
GlobalUnlock(cbuf);
|
||||
CloseClipboard();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void IConsoleClearCommand()
|
||||
static void IConsoleClearCommand()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<255; i++) _iconsole_cmdline[i]=0;
|
||||
@ -103,7 +132,12 @@ static void IConsoleWndProc(Window *w, WindowEvent *e)
|
||||
break;
|
||||
|
||||
case WE_KEYPRESS:
|
||||
e->keypress.cont=false;
|
||||
e->keypress.cont=false;
|
||||
if (e->keypress.keycode == (WKC_CTRL | 'V'))
|
||||
{
|
||||
IConsoleAppendClipboard();
|
||||
SetWindowDirty(w);
|
||||
} else
|
||||
if (e->keypress.keycode == (WKC_UP))
|
||||
{
|
||||
IConsoleCmdBufferNavigate(+1);
|
||||
|
Loading…
Reference in New Issue
Block a user