Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EdnH2-0005NA-Nv for qemu-devel@nongnu.org; Sun, 20 Nov 2005 06:22:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EdnGz-0005M6-6f for qemu-devel@nongnu.org; Sun, 20 Nov 2005 06:22:19 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EdnGv-0005Lw-Tt for qemu-devel@nongnu.org; Sun, 20 Nov 2005 06:22:15 -0500 Received: from [69.17.117.28] (helo=mail26.sea5.speakeasy.net) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1EdnGv-0002Ow-Oa for qemu-devel@nongnu.org; Sun, 20 Nov 2005 06:22:14 -0500 Received: from dsl027-178-085.sfo1.dsl.speakeasy.net (HELO firebird) ([216.27.178.85]) (envelope-sender ) by mail26.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 20 Nov 2005 11:22:11 -0000 Date: Sun, 20 Nov 2005 03:25:56 -0800 From: art yerkes Message-Id: <20051120032556.2a72d9fc.ayerkes@speakeasy.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Sun__20_Nov_2005_03_25_56_-0800_IeFfdYZzFb/40acI" Subject: [Qemu-devel] Patch: Ctrl+Ins to copy console on windows Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --Multipart=_Sun__20_Nov_2005_03_25_56_-0800_IeFfdYZzFb/40acI Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit This is a small patch to enable copying the current console to the clipboard with Ctrl+Ins. A line break is added after the last nonblank character of each copied line. -- Here's a simple experiment. Stand on a train track between two locomotives which are pushing on you with equal force in opposite directions. You will exhibit no net motion. None the less, you may soon begin to notice that something important is happening. -- Robert Stirniman --Multipart=_Sun__20_Nov_2005_03_25_56_-0800_IeFfdYZzFb/40acI Content-Type: text/x-patch; name="qemu-copy-console.diff" Content-Disposition: attachment; filename="qemu-copy-console.diff" Content-Transfer-Encoding: 7bit Index: sdl.c =================================================================== RCS file: /cvsroot/qemu/qemu/sdl.c,v retrieving revision 1.23 diff -u -r1.23 sdl.c --- sdl.c 30 Oct 2005 23:19:10 -0000 1.23 +++ sdl.c 20 Nov 2005 11:17:22 -0000 @@ -378,6 +378,7 @@ case SDLK_END: keysym = QEMU_KEY_CTRL_END; break; case SDLK_PAGEUP: keysym = QEMU_KEY_CTRL_PAGEUP; break; case SDLK_PAGEDOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break; + case SDLK_INSERT: keysym = QEMU_KEY_CTRL_INS; break; default: break; } } else { Index: vl.h =================================================================== RCS file: /cvsroot/qemu/qemu/vl.h,v retrieving revision 1.91 diff -u -r1.91 vl.h --- vl.h 15 Nov 2005 22:16:05 -0000 1.91 +++ vl.h 20 Nov 2005 11:17:23 -0000 @@ -37,6 +37,9 @@ #include #include #include +#ifdef _WIN32 +#include +#endif #include "audio/audio.h" #ifndef O_LARGEFILE @@ -189,6 +192,7 @@ #define QEMU_KEY_CTRL_END 0xe405 #define QEMU_KEY_CTRL_PAGEUP 0xe406 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 +#define QEMU_KEY_CTRL_INS 0xe408 void kbd_put_keysym(int keysym); Index: console.c =================================================================== RCS file: /cvsroot/qemu/qemu/console.c,v retrieving revision 1.3 diff -u -r1.3 console.c --- console.c 9 Oct 2004 17:32:58 -0000 1.3 +++ console.c 20 Nov 2005 11:17:23 -0000 @@ -406,6 +406,67 @@ console_show_cursor(s, 1); } +static void console_copy() +{ +#ifdef _WIN32 + TextConsole *s; + int i, j, copytotal = 0, lastline = 0, row; + char *copydest; + HGLOBAL clipbuf; + + s = active_console; + + // Count characters + for( i = 0; i < s->total_height; i++ ) { + row = 0; + for( j = 0; j < s->width; j++ ) { + char ch = s->cells[i * s->width + j].ch; + if( isprint(ch) && !isspace(ch) ) + row = j; + } + if( row != 0 ) + lastline = i; + copytotal += row + strlen("\r\n"); + } + + // Create the clip buffer + if( !OpenClipboard( NULL ) ) return; + + EmptyClipboard(); + clipbuf = GlobalAlloc(GMEM_DDESHARE, copytotal+1); + + if( !clipbuf ) return; + + copydest = (char *)GlobalLock(clipbuf); + + // Copy the actual text + for( i = 0; i < lastline+1; i++ ) { + row = 0; + for( j = 0; j < s->width; j++ ) { + char ch = s->cells[i * s->width + j].ch; + if( isprint(ch) && !isspace(ch) ) + row = j; + } + for( j = 0; j < row; j++ ) { + char ch = s->cells[i * s->width + j].ch; + if( isprint(ch) && !isspace(ch) ) + *copydest++ = ch; + else + *copydest++ = ' '; + } + *copydest++ = '\r'; + *copydest++ = '\n'; + } + + *copydest++ = 0; + + // Now set the clipboard + GlobalUnlock(clipbuf); + SetClipboardData(CF_TEXT,clipbuf); + CloseClipboard(); +#endif +} + static void console_scroll(int ydelta) { TextConsole *s; @@ -641,6 +702,9 @@ case QEMU_KEY_CTRL_PAGEDOWN: console_scroll(10); break; + case QEMU_KEY_CTRL_INS: + console_copy(); + break; default: if (s->fd_read) { /* convert the QEMU keysym to VT100 key string */ --Multipart=_Sun__20_Nov_2005_03_25_56_-0800_IeFfdYZzFb/40acI--