From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4489 invoked by alias); 30 Dec 2014 19:15:54 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 4357 invoked by uid 89); 30 Dec 2014 19:15:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: nm13-vm4.bullet.mail.ir2.yahoo.com Received: from nm13-vm4.bullet.mail.ir2.yahoo.com (HELO nm13-vm4.bullet.mail.ir2.yahoo.com) (212.82.96.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 30 Dec 2014 19:15:39 +0000 Received: from [212.82.98.51] by nm13.bullet.mail.ir2.yahoo.com with NNFMP; 30 Dec 2014 19:15:36 -0000 Received: from [212.82.98.70] by tm4.bullet.mail.ir2.yahoo.com with NNFMP; 30 Dec 2014 19:15:36 -0000 Received: from [127.0.0.1] by omp1007.mail.ir2.yahoo.com with NNFMP; 30 Dec 2014 19:15:36 -0000 Received: by 217.12.9.14; Tue, 30 Dec 2014 19:15:35 +0000 Date: Tue, 30 Dec 2014 19:15:00 -0000 From: Hannes Domani Reply-To: Hannes Domani To: "gdb@sourceware.org" Message-ID: <2166009.2872410.1419966905934.JavaMail.yahoo@jws11122.mail.ir2.yahoo.com> In-Reply-To: References: Subject: Re: building gdb with TUI support on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00061.txt.bz2 Ofir Cohen schrieb am 16:28 Montag, 29.Dezember 2014: > Hi Hannes, > Thanks again for the reply =]. > > > You are aware that with the arrow keys in TUI mode you move in the source > window, and not in the history? > > Yes, ofc, I'm therefore moving the window focus from source to the > interpreter's CLI window (Ctrl+x, o), > and only then issue the arrow up/down/left/right commands. > Unfortunately, it doesn't work, I have to get out of TUI mode (Ctrl+x, > a), to make the arrow keys respond. > > On Linux, when you do the above mentioned steps, it works flawlessly. > > A shallow investigation, debugging of gdb with gdb, showed that > wgetch() function (deep in the call-stack, invoked indirectly by > stdin_event_handler), is blocking and doesn't return when the > arrow-keys are issued. > > When gdb is not in TUI mode, however, getch() is called instead, > returns promptly and issues > the associated dispatch handler. I figured out the problem here. When the CLI get the focus, the keypad is disabled. This means wgetch() should return special keys as escape sequences (like getch() does), and not as a single value (e.g. KEY_LEFT). pdcurses instead ignores special keys completely if keypad is disabled. I've made the following changes to recreate this behavior for some keys: --- a/pdcurses/getch.c 2008-07-13 18:08:18.000000000 +0200 +++ b/pdcurses/getch.c 2014-12-30 16:46:45.604498500 +0100 @@ -2,6 +2,11 @@ #include +#ifdef _WIN32 +#include +extern HANDLE pdc_con_in; +#endif + RCSID("$Id: getch.c,v 1.72 2008/07/13 16:08:18 wmcbrine Exp $") /*man-start************************************************************** @@ -238,7 +243,55 @@ /* filter special keys if not in keypad mode */ if (!win->_use_keypad) + { +#ifdef _WIN32 + char backhalf = 0; + switch (key) + { + case KEY_UP: + backhalf = 'H'; + break; + case KEY_DOWN: + backhalf = 'P'; + break; + case KEY_LEFT: + backhalf = 'K'; + break; + case KEY_RIGHT: + backhalf = 'M'; + break; + case KEY_HOME: + backhalf = 'G'; + break; + case KEY_END: + backhalf = 'O'; + break; + case KEY_DC: + backhalf = 'S'; + break; + case KEY_IC: + backhalf = 'R'; + break; + } + if (backhalf) + { + INPUT_RECORD ir; + ir.EventType = KEY_EVENT; + ir.Event.KeyEvent.bKeyDown = TRUE; + ir.Event.KeyEvent.dwControlKeyState = 0; + ir.Event.KeyEvent.uChar.UnicodeChar = backhalf; + ir.Event.KeyEvent.wRepeatCount = 1; + ir.Event.KeyEvent.wVirtualKeyCode = backhalf; + ir.Event.KeyEvent.wVirtualScanCode = + MapVirtualKey(backhalf, MAPVK_VK_TO_VSC); + DWORD written; + WriteConsoleInput(pdc_con_in, &ir, 1, &written); + return 0xe0; + } +#endif + key = -1; + } /* filter mouse events; translate mouse clicks in the slk area to function keys */