mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +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
36
console.c
36
console.c
@ -9,6 +9,10 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// ** main console ** //
|
// ** main console ** //
|
||||||
static bool _iconsole_inited;
|
static bool _iconsole_inited;
|
||||||
static byte* _iconsole_buffer[80];
|
static byte* _iconsole_buffer[80];
|
||||||
@ -48,7 +52,32 @@ static const WindowDesc _iconsole_window_desc = {
|
|||||||
/* end of header */
|
/* end of header */
|
||||||
/* *************** */
|
/* *************** */
|
||||||
|
|
||||||
void IConsoleClearCommand()
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
static void IConsoleClearCommand()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<255; i++) _iconsole_cmdline[i]=0;
|
for (i=0; i<255; i++) _iconsole_cmdline[i]=0;
|
||||||
@ -104,6 +133,11 @@ static void IConsoleWndProc(Window *w, WindowEvent *e)
|
|||||||
|
|
||||||
case WE_KEYPRESS:
|
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))
|
if (e->keypress.keycode == (WKC_UP))
|
||||||
{
|
{
|
||||||
IConsoleCmdBufferNavigate(+1);
|
IConsoleCmdBufferNavigate(+1);
|
||||||
|
Loading…
Reference in New Issue
Block a user