Revision: 18930
http://vice-emu.svn.sourceforge.net/vice-emu/?rev=18930&view=rev
Author: strik
Date: 2008-06-29 12:34:50 -0700 (Sun, 29 Jun 2008)
Log Message:
-----------
2008-06-29 Spiro Trikaliotis <spi...@gm...>
* src/arch/win32/ui.c: Add copy to clipboard for the text
screen. All emulators which support the monitor "screen"
command are supported, that is: x64, xplus4, xvic, x128 in
VIC-II mode. xcbm2 and xpet are not supported, as their base
video addresses are not given with mem_get_screen_parameter().
New functions read_screen_output(), ui_copy_clipboard().
Modified Paths:
--------------
trunk/vice/src/ChangeLog
trunk/vice/src/arch/win32/ui.c
Modified: trunk/vice/src/ChangeLog
===================================================================
--- trunk/vice/src/ChangeLog 2008-06-28 14:51:02 UTC (rev 18929)
+++ trunk/vice/src/ChangeLog 2008-06-29 19:34:50 UTC (rev 18930)
@@ -1,3 +1,12 @@
+2008-06-29 Spiro Trikaliotis <spi...@gm...>
+
+ * arch/win32/ui.c: Add copy to clipboard for the text screen.
+ All emulators which support the monitor "screen" command are
+ supported, that is: x64, xplus4, xvic, x128 in VIC-II mode.
+ xcbm2 and xpet are not supported, as their base video addresses
+ are not given with mem_get_screen_parameter(). New functions
+ read_screen_output(), ui_copy_clipboard().
+
2008-06-28 Spiro Trikaliotis <spi...@gm...>
* src/arch/win32/rescbm2.rc, src/arch/win32/resplus4.rc,
Modified: trunk/vice/src/arch/win32/ui.c
===================================================================
--- trunk/vice/src/arch/win32/ui.c 2008-06-28 14:51:02 UTC (rev 18929)
+++ trunk/vice/src/arch/win32/ui.c 2008-06-29 19:34:50 UTC (rev 18930)
@@ -28,6 +28,7 @@
#include "vice.h"
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
@@ -982,6 +983,112 @@
/* ------------------------------------------------------------------------ */
+static char * read_screen_output(void)
+{
+ char * outputbuffer = NULL;
+
+ do {
+ WORD base;
+ BYTE allrows, allcols;
+ unsigned int row, col;
+ unsigned int size;
+ char * p;
+
+ mem_get_screen_parameter(&base, &allrows, &allcols);
+
+ size = allrows * (allcols + 2) + 1;
+
+ outputbuffer = lib_malloc(size);
+ if (outputbuffer == NULL) {
+ break;
+ }
+
+ p = outputbuffer;
+
+ for (row = 0; row < allrows; row++) {
+ char * last_non_whitespace = p - 1;
+
+ for (col = 0; col < allcols; col++) {
+ BYTE data;
+
+ data = mem_bank_peek(0, base++, NULL);
+ data = charset_p_toascii(charset_screencode_to_petcii(data), 1);
+
+ if (data != ' ') {
+ last_non_whitespace = p;
+ }
+ *p++ = data;
+ }
+
+ /* trim the line if there are only whitespace at the end */
+
+ if (last_non_whitespace < p) {
+ p = last_non_whitespace + 1;
+ }
+
+ /* add a CR/LF */
+
+ *p++ = '\r';
+ *p++ = '\n';
+ }
+
+ *p = 0;
+
+ assert(p < outputbuffer + size);
+
+ } while (0);
+
+ return outputbuffer;
+}
+
+static void ui_copy_clipboard(HWND window)
+{
+ BOOL clipboard_is_open = FALSE;
+ char * text;
+ HGLOBAL globaltext = NULL;
+
+ do {
+ char * p;
+
+ if ( ! OpenClipboard(window) ) {
+ break;
+ }
+ clipboard_is_open = TRUE;
+
+ if ( ! EmptyClipboard() ) {
+ break;
+ }
+
+ text = read_screen_output();
+ if (text == NULL) {
+ break;
+ }
+
+ globaltext = GlobalAlloc(GMEM_DDESHARE, strlen(text) + 1);
+ if (globaltext == NULL) {
+ break;
+ }
+
+ p = GlobalLock(globaltext);
+ strcpy(p, text);
+
+ SetClipboardData(CF_TEXT, globaltext);
+
+ } while (0);
+
+ if (globaltext) {
+ GlobalUnlock(globaltext);
+ }
+
+ if (text) {
+ lib_free(text);
+ }
+
+ if (clipboard_is_open) {
+ CloseClipboard();
+ }
+}
+
static void ui_paste_clipboard_text(HWND window)
{
HANDLE hdata;
@@ -1104,10 +1211,6 @@
static void handle_wm_initmenupopup(HMENU menu)
{
- /* not implemented yet: */
-
- EnableMenuItem(menu, IDM_EDIT_COPY, MF_BYCOMMAND | MF_GRAYED);
-
/* enable PASTE iff the clipboard contains "our" format: */
EnableMenuItem(menu, IDM_EDIT_PASTE,
@@ -1130,6 +1233,9 @@
case IDM_EXIT:
PostMessage(hwnd, WM_CLOSE, wparam, lparam);
break;
+ case IDM_EDIT_COPY:
+ ui_copy_clipboard(hwnd);
+ break;
case IDM_EDIT_PASTE:
ui_paste_clipboard_text(hwnd);
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|