From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12434 invoked by alias); 30 Dec 2014 20:10:52 -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 12349 invoked by uid 89); 30 Dec 2014 20:10:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f170.google.com Received: from mail-wi0-f170.google.com (HELO mail-wi0-f170.google.com) (209.85.212.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 30 Dec 2014 20:10:49 +0000 Received: by mail-wi0-f170.google.com with SMTP id bs8so26099395wib.5 for ; Tue, 30 Dec 2014 12:10:46 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.194.61.18 with SMTP id l18mr125235612wjr.42.1419970246365; Tue, 30 Dec 2014 12:10:46 -0800 (PST) Received: by 10.194.165.106 with HTTP; Tue, 30 Dec 2014 12:10:46 -0800 (PST) In-Reply-To: <2166009.2872410.1419966905934.JavaMail.yahoo@jws11122.mail.ir2.yahoo.com> References: <2166009.2872410.1419966905934.JavaMail.yahoo@jws11122.mail.ir2.yahoo.com> Date: Tue, 30 Dec 2014 20:10:00 -0000 Message-ID: Subject: Re: building gdb with TUI support on Windows From: Ofir Cohen To: Hannes Domani Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg00062.txt.bz2 Hi Hannes, Holy smokes, just tested and it works ;-) Thanks a lot for sharing this useful patch. Sorry for the ignorance, but what does this keypad mode mean and what is its role? Moreover, is this default behavior intended? (as both PDCurses and true libncurses fail, each in its own (unique?) way). Bonus question: in your opinion, is screen clear possible on Windows? (CTRL+L) Thanks a lot again, you've just made my debugging experience way more fun and productive! - Ofir Cohen On 30 December 2014 at 21:15, Hannes Domani wrote: > 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 */