summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorsignde <signde@openttd.org>2004-09-17 06:06:47 +0000
committersignde <signde@openttd.org>2004-09-17 06:06:47 +0000
commit7693c58e280148334754b00fb4142930cc7f65ea (patch)
tree356415f8865c3d51465c5f3b950e1dee26f72668 /console.c
parent78b02129c171f7b15a1f658f75b45feef06a1181 (diff)
downloadopenttd-7693c58e280148334754b00fb4142930cc7f65ea.tar.xz
(svn r279) -Feature: [WIN32] Console now allows to paste data from the clipboard [ctrl + v]
Diffstat (limited to 'console.c')
-rw-r--r--console.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/console.c b/console.c
index 06d59059a..d867bdf3b 100644
--- a/console.c
+++ b/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);