From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id pVgwFnICxmAsFAAAWB0awg (envelope-from ) for ; Sun, 13 Jun 2021 09:04:50 -0400 Received: by simark.ca (Postfix, from userid 112) id 402671F163; Sun, 13 Jun 2021 09:04:50 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B02881E01F for ; Sun, 13 Jun 2021 09:04:47 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2161D386FC09 for ; Sun, 13 Jun 2021 13:04:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2161D386FC09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1623589487; bh=KXGrmjLF0KTpGxmimpb2oRaoCv5ytLcEKd+zLLZrStI=; h=Date:To:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=am0iykFSDiiPzEFKat00TBYJ9ASrtGITS5BhXhb+yhOw3KNjQVsZ/GgDXmN2BTEJ/ Ual2HsN1APsE4992UvGwQSdK59Mn5LgdNwo/xGMEunhXBoVakqVNzjxqEU3BeV3m7m UUc8FnHisQU6yLk5vmnU5bsPlFoLhcpNq5lUK54E= Received: from sonic309-24.consmr.mail.ir2.yahoo.com (sonic309-24.consmr.mail.ir2.yahoo.com [77.238.179.82]) by sourceware.org (Postfix) with ESMTPS id 208693848000 for ; Sun, 13 Jun 2021 13:04:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 208693848000 X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1623589463; bh=8JqRolidrvyP4G0V1qmRNPzwOfnD7kqGdpglzrckdQa=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=dfLyhbyyI0isDV5pv7CtmqTigNYOoRb8nl3Dqpt3OAg52ko+GgcFFhnBk6MQ10/jbvDMT8WKQtSi7dskUdCxt8ibTDZKofcZqtIKfK1KNEoY67oTYGRP+L1AZaoQMrIMbtFT2JM5i935PMdGOBa509zSDWiYdtI8on03CdnKn1r2fN9ScwYRvKvOy3PE0XDFZFTrF8uMyWf4oGKf5ujUpbqFP755jOT6JAENJIIvfiotcWE4yeJo70lyrEdLqVuypVieCeyBXV3NbJk6UkfdJWhCfaVyJniFoCCOcPF+aHRXJ3J86d43Udd2Gkj2jb3e6vjGUPwpkIUqkIZ8fu/hJA== X-YMail-OSG: yEw6TNwVM1nfBjPLNODNhMcXuS9fzrq3hqWzeM5ASY90km9uVoOn.pEDhNw2.Ci qC1awqplcisytq.jD41arYPVVL3mViTWpuUGvhQ5J5KpH4IQOv_NeLi2OxX7nI92.iTLCAZLC2qg PhHaJlYcsSBRCCC4pRyujoAK69Ac.24wKMZsbO20V.XVRmlg.Ph3tLIMuk3m5Gq7qO5UaE3vHFfW TAMBULQk_92WmZq14BM4HeH9t1Kd4ek1ogRAp3ZruOjYfuI2TvfBPcaP1wIzniPxPOQqwTv2CY86 aUOOubKA3CjXQ1l657iBVx2m55sCgPWC_FOvKDH2soTRsl0Me0L8Ca5IT1wIhgXMRnwYVlbqQoGP KS2qtZCvX6aA_Jrh8_hrygbrQzNN1GgOfIacXiZU9.sHkQCe6icDwgglltl9aj8nbJcG4bbiJKvV iyQ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mShRTByUT94ed7LsQNyPOdW6jmsIyhxa3FsSQsvcEle_iPv967h4OqWD9oyFjjX7_Hl.3o NWtHwipJ93JeWoIownMw- X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Sun, 13 Jun 2021 13:04:23 +0000 Date: Sun, 13 Jun 2021 13:04:07 +0000 (UTC) To: Hannes Domani via Gdb-patches , Tom Tromey , Pedro Alves Message-ID: <1500249367.9517443.1623589447782@mail.yahoo.com> In-Reply-To: <455337ea-65c3-42b5-0ec0-3c85b85ba054@palves.net> References: <20210603151453.15248-1-ssbssa.ref@yahoo.de> <20210603151453.15248-1-ssbssa@yahoo.de> <87r1hhoi03.fsf@tromey.com> <1760297979.5212997.1622816480782@mail.yahoo.com> <0936428e-80c4-c192-cdfd-817ff9bcfab0@palves.net> <877dj9o4ch.fsf@tromey.com> <3facd73a-bfea-d46c-85a7-101ea893998f@palves.net> <8cfc78b7-ecdc-b435-5c1f-f027c8704f9e@palves.net> <1231900744.5510610.1622904017896@mail.yahoo.com> <87wnr1h80t.fsf@tromey.com> <287323544.8784317.1623409369460@mail.yahoo.com> <1761936332.9225994.1623501145444@mail.yahoo.com> <6afbe909-91d6-af32-d496-ca112dcfb43a@palves.net> <455337ea-65c3-42b5-0ec0-3c85b85ba054@palves.net> Subject: Re: [PATCH v2] Make the TUI command window support the mouse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.18368 YMailNorrin X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Hannes Domani via Gdb-patches Reply-To: Hannes Domani Cc: Joel Brobecker Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Am Sonntag, 13. Juni 2021, 04:46:15 MESZ hat Pedro Alves Folgendes geschrieben: > On 2021-06-12 7:08 p.m., Pedro Alves wrote: > > On 2021-06-12 1:32 p.m., Hannes Domani wrote: > > >> On the other hand, if keypad was enabled, couldn't we just forward rea= dline > >> the escape sequences for the arrow keys instead? > > > > Yeah, to be honest I think that is likely a better approach and worth i= t of a > > try -- my only concern is whether the escape sequences are standard eno= ugh > > across terminals?=C2=A0 Maybe it's all covered by ANSI and it's all we = need to care > > about?=C2=A0 I thought of the other approach because that let's us not = care about > > specific sequences, other than the mouse sequence, which seemed pretty = much > > standard from looking around.=C2=A0 Also, it was run to write.=C2=A0 :-= ) > > > > Alright, I gave that approach a go.=C2=A0 Below's a patch implementing th= at.=C2=A0 It > works quite nicely here.=C2=A0 I tried it on konsole, xterm and rxvt.=C2= =A0 Among those, > rxvt uses different escape sequences for ctrl-up/ctrl-down/ctrl-left/ctrl= -right, > but it doesn't really matter -- I found that readline binds actions to > different variants of escape sequences, so if we pick sequences readline = always binds, > it should always work.=C2=A0 See readline.c:bind_arrow_keys_internal. > Despite that, for the standard ncurses keys below KEY_MAX, it's easier > to use the corresponding lowercase key_foo variable, which I believe is > filled in from termcap so should also always work, as readline also > binds the key sequences termcap returns. > > Overall, I'm pleased with this approach.=C2=A0 See commit log for more, p= articularly > the extra improvement we get. > > From: Pedro Alves > Date: 2021-06-05 19:11:09 +0100 > > Make the TUI command window support the mouse > > Currently, when the focus is on the command window, we disable the > keypad.=C2=A0 This means that when the command window has the focus, keys > such as up/down/home/end etc. are not processed by ncurses, and their > escape sequences go straight to readline. > > A side effect of disabling keypad mode is that wgetch no longer > processes mouse escape sequences, with the end result being the mouse > doesn't work, and worse, the raw mouse escape sequences are printed on > the terminal. > > This commit makes the TUI command window support the mouse as well, by > always enabling the keypad, and then to avoid losing support for > up/down browsing the command history, home/end/left/right moving the > cursor position, etc., we forward those keys as raw escape sequences > to readline. > > Note that the patch makes it so that CTLC-L is already passed to > readline even if the command window does not have the focus.=C2=A0 It was > simpler to implement that way, and it just seems correct to me.=C2=A0 I > don't know of a reason we shouldn't do that. > > The patch improves the TUI behavior in a related way.=C2=A0 Now we can pa= ss > keys to readline irrespective of which window has focus.=C2=A0 First, we > try to dispatch the key to a window, via tui_displatch_ctrl_char.=C2=A0 I= f > the key is dispatched, then we don't pass it to readline.=C2=A0 E.g., > pressing "up" when you have the source window in focus results in > scrolling the source window, and nothing else.=C2=A0 If however, you pres= s > ctrl-del instead, that results in killing the next word in the command > window, no matter which window has focus.=C2=A0 Before, it would only wor= k > if you had the command window in focus.=C2=A0 Similarly, > ctrl-left/ctrl-right to move between words, etc. > > Similarly, the previous spot where we handled mouse events was > incorrect.=C2=A0 It was never reached if the window with focus can't > scroll, which is the case for the command window.=C2=A0 Mouse scrolling > affects the window under the mouse cursor, not the window in focus. > We now always try to dispatch mouse events. This is great, thank you for doing this. I just tried it, and I had just one problem, see below. > gdb/ChangeLog: > yyyy-mm-dd=C2=A0 Pedro Alves=C2=A0 > >=C2=A0=C2=A0=C2=A0=C2=A0 * tui/tui-io.c (tui_dispatch_mouse_event): New, f= actored out from >=C2=A0=C2=A0=C2=A0=C2=A0 ... >=C2=A0=C2=A0=C2=A0=C2=A0 (tui_dispatch_ctrl_char): ... this.=C2=A0 Move CT= RL-L handling to >=C2=A0=C2=A0=C2=A0=C2=A0 tui_getc_1. >=C2=A0=C2=A0=C2=A0=C2=A0 (cur_seq, start_sequence): New. >=C2=A0=C2=A0=C2=A0=C2=A0 (tui_getc_1): Pass key escape sequences for ncurs= es control keys >=C2=A0=C2=A0=C2=A0=C2=A0 to readline.=C2=A0 Handle mouse and ctrl-l here. >=C2=A0=C2=A0=C2=A0=C2=A0 (tui_resize_all): Disable/reenable the keypad if = the command >=C2=A0=C2=A0=C2=A0=C2=A0 window has the focus too. >=C2=A0=C2=A0=C2=A0=C2=A0 * tui/tui-win.c (tui_set_focus_command): Don't ch= ange keypad >=C2=A0=C2=A0=C2=A0=C2=A0 setting. >=C2=A0=C2=A0=C2=A0=C2=A0 * tui/tui.c (tui_rl_other_window): Don't change k= eypad setting. > > Change-Id: Ie0a7d849943cfb47f4a6589e1c73341563740fa9 > > --- > > gdb/tui/tui-io.c=C2=A0 |=C2=A0 195 ++++++++++++++++++++++++++++++++++++++= ++++----------- > gdb/tui/tui-win.c |=C2=A0 12 +-- > gdb/tui/tui.c=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0 5 - > 3 files changed, 160 insertions(+), 52 deletions(-) > > diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c > index 7df0e2f1bd3..4da6f2bab11 100644 > --- a/gdb/tui/tui-io.c > +++ b/gdb/tui/tui-io.c > @@ -946,6 +946,38 @@ tui_initialize_io (void) > #endif > } > > +/* Dispatch the correct tui function based upon the mouse event.=C2=A0 *= / > + > +static void > +tui_dispatch_mouse_event () > +{ > +=C2=A0 MEVENT mev; > +=C2=A0 if (getmouse (&mev) !=3D OK) > +=C2=A0=C2=A0=C2=A0 return; > + > +=C2=A0 for (tui_win_info *wi : all_tui_windows ()) > +=C2=A0=C2=A0=C2=A0 if (mev.x > wi->x && mev.x < wi->x + wi->width - 1 > +=C2=A0=C2=A0=C2=A0 && mev.y > wi->y && mev.y < wi->y + wi->height - 1) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0 if ((mev.bstate & BUTTON1_CLICKED) !=3D 0 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 || (mev.bstate & BUTTON2_CLIC= KED) !=3D 0 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 || (mev.bstate & BUTTON3_CLIC= KED) !=3D 0) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int button =3D (mev.bstate & = BUTTON1_CLICKED) !=3D 0 ? 1 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ((mev.bstate & BUTTON2_CLICKED) !=3D 0 ? 2 > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : 3); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->click (mev.x - wi->x - 1,= mev.y - wi->y - 1, button); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > +#ifdef BUTTON5_PRESSED > +=C2=A0=C2=A0=C2=A0 else if ((mev.bstate & BUTTON4_PRESSED) !=3D 0) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->backward_scroll (3); > +=C2=A0=C2=A0=C2=A0 else if ((mev.bstate & BUTTON5_PRESSED) !=3D 0) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->forward_scroll (3); > +#endif > +=C2=A0=C2=A0=C2=A0 break; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > +} > + > /* Dispatch the correct tui function based upon the control >=C2=A0=C2=A0=C2=A0=C2=A0 character.=C2=A0 */ > static unsigned int > @@ -953,10 +985,6 @@ tui_dispatch_ctrl_char (unsigned int ch) > { >=C2=A0=C2=A0 struct tui_win_info *win_info =3D tui_win_with_focus (); > > -=C2=A0 /* Handle the CTRL-L refresh for each window.=C2=A0 */ > -=C2=A0 if (ch =3D=3D '\f') > -=C2=A0=C2=A0=C2=A0 tui_refresh_all_win (); > - >=C2=A0=C2=A0 /* If no window has the focus, or if the focus window can't s= croll, >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 just pass the character through.=C2= =A0 */ >=C2=A0=C2=A0 if (win_info =3D=3D NULL || !win_info->can_scroll ()) > @@ -984,39 +1012,6 @@ tui_dispatch_ctrl_char (unsigned int ch) >=C2=A0=C2=A0=C2=A0=C2=A0 case KEY_LEFT: >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 win_info->right_scroll (1); >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > -#ifdef NCURSES_MOUSE_VERSION > -=C2=A0=C2=A0=C2=A0 case KEY_MOUSE: > -=C2=A0=C2=A0=C2=A0 { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 MEVENT mev; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (getmouse (&mev) !=3D OK) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > - > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (tui_win_info *wi : all_tui_windows (= )) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (mev.x > wi->x && mev.x < = wi->x + wi->width - 1 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 && mev.y > wi->y && mev.y < w= i->y + wi->height - 1) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if ((mev.bstate & BUTTON1_CLI= CKED) !=3D 0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 || (m= ev.bstate & BUTTON2_CLICKED) !=3D 0 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 || (m= ev.bstate & BUTTON3_CLICKED) !=3D 0) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int b= utton =3D (mev.bstate & BUTTON1_CLICKED) !=3D 0 ? 1 > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 :=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((mev.bstate & BUTTON2_C= LICKED) !=3D 0 ? 2 > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 : 3); > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->c= lick (mev.x - wi->x - 1, mev.y - wi->y - 1, button); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > -#ifdef BUTTON5_PRESSED > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if ((mev.bstate & BUTTON= 4_PRESSED) !=3D 0) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->backward_scro= ll (3); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if ((mev.bstate & BUTTON= 5_PRESSED) !=3D 0) > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wi->forward_scrol= l (3); > -#endif > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > -=C2=A0=C2=A0=C2=A0 } > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; > -#endif > -=C2=A0=C2=A0=C2=A0 case '\f': > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >=C2=A0=C2=A0=C2=A0=C2=A0 default: >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* We didn't recognize the character = as a control character, so pass it >=C2=A0=C2=A0=C2=A0=C2=A0 through.=C2=A0 */ > @@ -1067,6 +1062,24 @@ tui_inject_newline_into_command_window () >=C2=A0=C2=A0=C2=A0=C2=A0 } > } > > +/* If we're passing an escape sequence to readline, this points to a > +=C2=A0 string holding the remaining characters of the sequence to pass. > +=C2=A0 We advance the pointer one character at a time until '\0' is > +=C2=A0 reached.=C2=A0 */ > +static const char *cur_seq =3D nullptr; > + > +/* Set CUR_SEQ to point at the current sequence to pass to readline, > +=C2=A0 setup to call the input handler again so we complete the sequence > +=C2=A0 shortly, and return the first character to start the sequence.=C2= =A0 */ > + > +static int > +start_sequence (const char *seq) > +{ > +=C2=A0 call_stdin_event_handler_again_p =3D 1; > +=C2=A0 cur_seq =3D seq + 1; > +=C2=A0 return seq[0]; > +} > + > /* Main worker for tui_getc.=C2=A0 Get a character from the command windo= w. >=C2=A0=C2=A0=C2=A0=C2=A0 This is called from the readline package, but wra= pped in a >=C2=A0=C2=A0=C2=A0=C2=A0 try/catch by tui_getc.=C2=A0 */ > @@ -1084,11 +1097,115 @@ tui_getc_1 (FILE *fp) >=C2=A0=C2=A0 tui_readline_output (0, 0); > #endif > > -=C2=A0 ch =3D gdb_wgetch (w); > +=C2=A0 /* We enable keypad mode so that ncurses's wgetch processes mouse > +=C2=A0=C2=A0=C2=A0 escape sequences.=C2=A0 In keypad mode, wgetch also p= rocesses the > +=C2=A0=C2=A0=C2=A0 escape sequences for keys such as up/down etc. and re= turns KEY_UP > +=C2=A0=C2=A0=C2=A0 / KEY_DOWN etc.=C2=A0 When we have the focus on the c= ommand window > +=C2=A0=C2=A0=C2=A0 though, we want to pass the raw up/down etc. escape c= odes to > +=C2=A0=C2=A0=C2=A0 readline so readline understands them.=C2=A0 */ > +=C2=A0 if (cur_seq !=3D nullptr) > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ch =3D *cur_seq++; > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* If we've reached the end of the string= , we're done with the > +=C2=A0=C2=A0=C2=A0 sequence.=C2=A0 Otherwise, setup to get back here aga= in for > +=C2=A0=C2=A0=C2=A0 another character.=C2=A0 */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (*cur_seq =3D=3D '\0') > +=C2=A0=C2=A0=C2=A0 cur_seq =3D nullptr; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else > +=C2=A0=C2=A0=C2=A0 call_stdin_event_handler_again_p =3D 1; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ch; > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0 else > +=C2=A0=C2=A0=C2=A0 ch =3D gdb_wgetch (w); > >=C2=A0=C2=A0 /* Handle prev/next/up/down here.=C2=A0 */ >=C2=A0=C2=A0 ch =3D tui_dispatch_ctrl_char (ch); > - > + > +#ifdef NCURSES_MOUSE_VERSION > +=C2=A0 if (ch =3D=3D KEY_MOUSE) > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_dispatch_mouse_event (); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; > +=C2=A0=C2=A0=C2=A0 } > +#endif > + > +=C2=A0 /* Translate ncurses keys back to escape sequences so that readli= ne > +=C2=A0=C2=A0=C2=A0 can understand them.=C2=A0 We do this irrespective of= what is the > +=C2=A0=C2=A0=C2=A0 focus window.=C2=A0 If e.g., we're focused on a non-c= ommand window, > +=C2=A0=C2=A0=C2=A0 then the up/down keys will already have been filtered= by > +=C2=A0=C2=A0=C2=A0 tui_dispatch_ctrl_char.=C2=A0 Keys that haven't been = intercepted will > +=C2=A0=C2=A0=C2=A0 be passed down to readline.=C2=A0 */ > +=C2=A0 if (current_ui->command_editing) > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* For the standard keys, we can find the= m efficiently in the > +=C2=A0=C2=A0=C2=A0 key_xxx macros, defined by ncurses.=C2=A0 We could al= so hardcode > +=C2=A0=C2=A0=C2=A0 sequences readline understands, and/or use rl_get_ter= mcap. > +=C2=A0=C2=A0=C2=A0 See readline/readline.c:bind_arrow_keys_internal for > +=C2=A0=C2=A0=C2=A0 hardcoded sequences.=C2=A0 */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 switch (ch) > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0 case KEY_NPAGE: /* page down */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_npage); > +=C2=A0=C2=A0=C2=A0 case KEY_PPAGE: /* page up */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_ppage); > +=C2=A0=C2=A0=C2=A0 case KEY_DOWN: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_down); > +=C2=A0=C2=A0=C2=A0 case KEY_UP: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_up); > +=C2=A0=C2=A0=C2=A0 case KEY_RIGHT: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_right); > +=C2=A0=C2=A0=C2=A0 case KEY_LEFT: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_left); > +=C2=A0=C2=A0=C2=A0 case KEY_HOME: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_home); > +=C2=A0=C2=A0=C2=A0 case KEY_END: > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_end); > +=C2=A0=C2=A0=C2=A0 case KEY_DC: /* del */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_dc); > +=C2=A0=C2=A0=C2=A0 case KEY_IC: /* ins */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence (key_ic); > +=C2=A0=C2=A0=C2=A0 } PDcurses doesn't have these key_npage/key_ppage/key_down/... variables, so I had to use the hardcoded sequences as you described. This is working for the arrow keys and home/end, and for del I used '\004' instead, but I didn't see any for page up/down and ins. I'm not sure if it's even a problem for page up/down, they seem to not be u= sed by readline, but I couldn't make ins work. And rl_get_termcap returned for everything except "le" NULL, but I assume that's just how it is on Windows. > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Keycodes above KEY_MAX are not garante= ed to be stable. > +=C2=A0=C2=A0=C2=A0 Compare keyname instead.=C2=A0 */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ch >=3D KEY_MAX) > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auto name =3D gdb::string_view (keyname (= ch)); > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* ctrl-arrow keys */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (name =3D=3D "kLFT5") /* ctrl-left */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5D"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kRIT5") /* ctrl-rig= ht */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5C"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kUP5") /* ctrl-up *= / > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5A"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kDN5") /* ctrl-down= */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5B"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kHOM5") /* ctrl-hom= e */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5H"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kEND5") /* ctrl-end= */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;5F"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kIC5") /* ctrl-ins = */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 2;5~"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kDC5") /* ctrl-del = */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 3;5~"); > + > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* alt-arrow keys */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kLFT3") /* alt-left= */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;3D"); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 else if (name =3D=3D "kRIT3") /* alt-righ= t */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return start_sequence ("\033[= 1;3C"); > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 } > + > +=C2=A0 /* Handle the CTRL-L refresh for each window.=C2=A0 */ > +=C2=A0 if (ch =3D=3D '\f') > +=C2=A0=C2=A0=C2=A0 { > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_refresh_all_win (); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ch; > +=C2=A0=C2=A0=C2=A0 } > + >=C2=A0=C2=A0 if (ch =3D=3D KEY_BACKSPACE) >=C2=A0=C2=A0=C2=A0=C2=A0 return '\b'; > > diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c > index 4e75a66a00e..a51e7b9f6da 100644 > --- a/gdb/tui/tui-win.c > +++ b/gdb/tui/tui-win.c > @@ -498,14 +498,11 @@ tui_resize_all (void) >=C2=A0=C2=A0 height_diff =3D screenheight - tui_term_height (); >=C2=A0=C2=A0 if (height_diff || width_diff) >=C2=A0=C2=A0=C2=A0=C2=A0 { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct tui_win_info *win_with_focus =3D t= ui_win_with_focus (); > - > #ifdef HAVE_RESIZE_TERM >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 resize_term (screenheight, screenwidt= h); > #endif=C2=A0=C2=A0=C2=A0 =C2=A0 >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Turn keypad off while we resize.= =C2=A0 */ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (win_with_focus !=3D TUI_CMD_WIN) > -=C2=A0=C2=A0=C2=A0 keypad (TUI_CMD_WIN->handle.get (), FALSE); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 keypad (TUI_CMD_WIN->handle.get (), FALSE= ); >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_update_gdb_sizes (); >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_set_term_height_to (screenheight)= ; >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_set_term_width_to (screenwidth); > @@ -515,10 +512,8 @@ tui_resize_all (void) >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 erase (); >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 clearok (curscr, TRUE); >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_apply_current_layout (); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Turn keypad back on, unless focus is i= n the command > -=C2=A0=C2=A0=C2=A0 window.=C2=A0 */ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (win_with_focus !=3D TUI_CMD_WIN) > -=C2=A0=C2=A0=C2=A0 keypad (TUI_CMD_WIN->handle.get (), TRUE); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Turn keypad back on.=C2=A0 */ > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 keypad (TUI_CMD_WIN->handle.get (), TRUE)= ; >=C2=A0=C2=A0=C2=A0=C2=A0 } > } > > @@ -703,7 +698,6 @@ tui_set_focus_command (const char *arg, int from_tty) >=C2=A0=C2=A0=C2=A0=C2=A0 error (_("Window \"%s\" is not visible"), arg); > >=C2=A0=C2=A0 tui_set_win_focus_to (win_info); > -=C2=A0 keypad (TUI_CMD_WIN->handle.get (), win_info !=3D TUI_CMD_WIN); >=C2=A0=C2=A0 printf_filtered (_("Focus set to %s window.\n"), >=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_win_with_= focus ()->name ()); > } > diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c > index 529fc62c9ac..5f0c87c05e1 100644 > --- a/gdb/tui/tui.c > +++ b/gdb/tui/tui.c > @@ -179,10 +179,7 @@ tui_rl_other_window (int count, int key) > >=C2=A0=C2=A0 win_info =3D tui_next_win (tui_win_with_focus ()); >=C2=A0=C2=A0 if (win_info) > -=C2=A0=C2=A0=C2=A0 { > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tui_set_win_focus_to (win_info); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 keypad (TUI_CMD_WIN->handle.get (), win_i= nfo !=3D TUI_CMD_WIN); > -=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 tui_set_win_focus_to (win_info); >=C2=A0=C2=A0 return 0; > > } Hannes