Revision: 18925
http://vice-emu.svn.sourceforge.net/vice-emu/?rev=18925&view=rev
Author: strik
Date: 2008-06-27 15:33:42 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
2008-06-28 Spiro Trikaliotis <spi...@gm...>
* src/arch/win32/ui.c: Added paste function to paste from
clipboard to the VICE keyboard buffer. It is selected either via
menu (Edit/Paste), or via right-click on the VICE window.
* src/arch/win32/resmenu.txt, src/arch/win32/rescbm2.rc,
src/arch/win32/resplus4.rc, src/arch/win32/resmenu.txt,
src/arch/win32/resvic20.rc, src/arch/win32/resc128.rc,
src/arch/win32/resc64.rc, src/arch/win32/respet.rc: Added
IDM_EDIT_CUT, IDM_EDIT_COPY and IDM_EDIT_PASTE.
Modified Paths:
--------------
trunk/vice/src/ChangeLog
trunk/vice/src/arch/win32/resc128.rc
trunk/vice/src/arch/win32/resc64.rc
trunk/vice/src/arch/win32/rescbm2.rc
trunk/vice/src/arch/win32/resmenu.txt
trunk/vice/src/arch/win32/respet.rc
trunk/vice/src/arch/win32/resplus4.rc
trunk/vice/src/arch/win32/resvic20.rc
trunk/vice/src/arch/win32/ui.c
Modified: trunk/vice/src/ChangeLog
===================================================================
--- trunk/vice/src/ChangeLog 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/ChangeLog 2008-06-27 22:33:42 UTC (rev 18925)
@@ -1,3 +1,15 @@
+2008-06-28 Spiro Trikaliotis <spi...@gm...>
+
+ * arch/win32/ui.c: Added paste function to paste from clipboard
+ to the VICE keyboard buffer. It is selected either via menu
+ (Edit/Paste), or via right-click on the VICE window.
+
+ * arch/win32/resmenu.txt, arch/win32/rescbm2.rc,
+ arch/win32/resplus4.rc, arch/win32/resmenu.txt,
+ arch/win32/resvic20.rc, arch/win32/resc128.rc,
+ arch/win32/resc64.rc, arch/win32/respet.rc: Added IDM_EDIT_CUT,
+ IDM_EDIT_COPY and IDM_EDIT_PASTE.
+
2008-06-27 Spiro Trikaliotis <spi...@gm...>
* autostart.c: Incorporated patch from iAN Coog: 1. Add colon
Modified: trunk/vice/src/arch/win32/resc128.rc
===================================================================
--- trunk/vice/src/arch/win32/resc128.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/resc128.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -127,6 +127,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/resc64.rc
===================================================================
--- trunk/vice/src/arch/win32/resc64.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/resc64.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -127,6 +127,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/rescbm2.rc
===================================================================
--- trunk/vice/src/arch/win32/rescbm2.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/rescbm2.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -96,6 +96,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/resmenu.txt
===================================================================
--- trunk/vice/src/arch/win32/resmenu.txt 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/resmenu.txt 2008-06-27 22:33:42 UTC (rev 18925)
@@ -59,6 +59,9 @@
IDM_EXIT
IDM_ABOUT
IDM_PAUSE
+IDM_EDIT_CUT
+IDM_EDIT_COPY
+IDM_EDIT_PASTE
IDM_SINGLE_FRAME_ADVANCE
IDM_AUTOSTART
IDM_RESET_HARD
Modified: trunk/vice/src/arch/win32/respet.rc
===================================================================
--- trunk/vice/src/arch/win32/respet.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/respet.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -94,6 +94,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/resplus4.rc
===================================================================
--- trunk/vice/src/arch/win32/resplus4.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/resplus4.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -106,6 +106,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/resvic20.rc
===================================================================
--- trunk/vice/src/arch/win32/resvic20.rc 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/resvic20.rc 2008-06-27 22:33:42 UTC (rev 18925)
@@ -104,6 +104,12 @@
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_EXIT
END
+ POPUP "&Edit"
+ BEGIN
+ MENUITEM "Cu&t", IDM_EDIT_CUT
+ MENUITEM "&Copy", IDM_EDIT_COPY
+ MENUITEM "&Paste", IDM_EDIT_PASTE
+ END
POPUP "Sna&pshot"
BEGIN
MENUITEM "Load snapshot &image...", IDM_SNAPSHOT_LOAD
Modified: trunk/vice/src/arch/win32/ui.c
===================================================================
--- trunk/vice/src/arch/win32/ui.c 2008-06-27 21:15:29 UTC (rev 18924)
+++ trunk/vice/src/arch/win32/ui.c 2008-06-27 22:33:42 UTC (rev 18925)
@@ -40,6 +40,7 @@
#include "attach.h"
#include "autostart.h"
#include "archdep.h"
+#include "charset.h"
#include "debug.h"
#include "drive.h"
#include "drivecpu.h"
@@ -49,6 +50,7 @@
#include "interrupt.h"
#include "intl.h"
#include "kbd.h"
+#include "kbdbuf.h"
#include "lib.h"
#include "log.h"
#include "machine.h"
@@ -980,6 +982,76 @@
/* ------------------------------------------------------------------------ */
+static void ui_paste_clipboard_text(HWND window)
+{
+ HANDLE hdata;
+ BOOL clipboard_is_open = FALSE;
+ char * text = NULL;
+ char * text_in_petscii = NULL;
+
+ do {
+ DWORD size;
+
+ if ( ! OpenClipboard(window) ) {
+ break;
+ }
+
+ clipboard_is_open = TRUE;
+
+ hdata = GetClipboardData(CF_TEXT);
+
+ if ( ! hdata ) {
+ break;
+ }
+
+ text = GlobalLock(hdata);
+
+ if (text == NULL) {
+ break;
+ }
+
+ size = GlobalSize(hdata);
+
+ if (size < 1) {
+ break;
+ }
+
+ /*
+ * Allocate memmory for the string to convert in petscii.
+ * Note: As we are not sure if the original text is null-terminated,
+ * do *not* use lib_stralloc()!
+ */
+ text_in_petscii = lib_malloc(size + 1);
+
+ if (text_in_petscii == NULL) {
+ break;
+ }
+
+ memcpy(text_in_petscii, text, size);
+ text_in_petscii[size] = 0;
+
+ charset_petconvstring(text_in_petscii, 0);
+
+ kbdbuf_feed(text_in_petscii);
+
+ } while (0);
+
+ if (text_in_petscii) {
+ lib_free(text_in_petscii);
+ }
+
+ if (text) {
+ GlobalUnlock(text);
+ }
+
+ if (clipboard_is_open) {
+ CloseClipboard();
+ }
+}
+
+
+/* ------------------------------------------------------------------------ */
+
/* FIXME: tmp hack. */
int syscolorchanged, displaychanged, querynewpalette, palettechanged;
@@ -1030,6 +1102,20 @@
}
}
+static void handle_wm_initmenupopup(HMENU menu)
+{
+ /* not implemented yet: */
+
+ EnableMenuItem(menu, IDM_EDIT_CUT, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(menu, IDM_EDIT_COPY, MF_BYCOMMAND | MF_GRAYED);
+
+ /* enable PASTE iff the clipboard contains "our" format: */
+
+ EnableMenuItem(menu, IDM_EDIT_PASTE,
+ MF_BYCOMMAND
+ | ( IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED));
+}
+
static void handle_wm_command(WPARAM wparam, LPARAM lparam, HWND hwnd)
{
/* Handle machine specific commands first. */
@@ -1045,6 +1131,9 @@
case IDM_EXIT:
PostMessage(hwnd, WM_CLOSE, wparam, lparam);
break;
+ case IDM_EDIT_PASTE:
+ ui_paste_clipboard_text(hwnd);
+ break;
case IDM_ABOUT:
case IDM_HELP:
case IDM_CONTRIBUTORS:
@@ -1393,6 +1482,9 @@
This message seems to be a good candidate for the remote desktop. */
ui_redraw_all_windows();
return 0;
+ case WM_INITMENUPOPUP:
+ handle_wm_initmenupopup((HMENU)wparam);
+ break;
case WM_COMMAND:
handle_wm_command(wparam, lparam, window);
return 0;
@@ -1482,6 +1574,9 @@
case WM_NCLBUTTONDOWN:
vsync_suspend_speed_eval();
break;
+ case WM_RBUTTONDOWN:
+ ui_paste_clipboard_text(window);
+ break;
case WM_NOTIFY:
statusbar_notify(window, window_index, wparam, lparam);
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|