From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id TwCKK6pu1WLonxUAWB0awg (envelope-from ) for ; Mon, 18 Jul 2022 10:31:06 -0400 Received: by simark.ca (Postfix, from userid 112) id A13B71E5EA; Mon, 18 Jul 2022 10:31:06 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=KwvxlqTv; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 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 B1E121E21F for ; Mon, 18 Jul 2022 10:31:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 51B9A385354A for ; Mon, 18 Jul 2022 14:31:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51B9A385354A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1658154662; bh=jUtPBiIrd+z8CiEFPGJfKbwGJNg/RiruOLCOevLD9jM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KwvxlqTvBQqr7yVEMksqMkds/pp0LgbHgzv+8cC00fmgajPuz0e8Amfb6YH7Wu0SJ dVf4Emf3R0NFT4A41hQJkTzq+Ia8p1OtStEJ1hUXadV9pGn4CFzHS3xbmltlSxDh/N V6GajtOVVMCRhWVykp38STcrpI13bbXBGzfCIOHQ= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1458A385840F for ; Mon, 18 Jul 2022 14:30:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1458A385840F Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-13-twoYnA8qOem5YgXr3vvNFQ-1; Mon, 18 Jul 2022 10:30:40 -0400 X-MC-Unique: twoYnA8qOem5YgXr3vvNFQ-1 Received: by mail-wr1-f69.google.com with SMTP id l11-20020adfbd8b000000b0021d754b84c5so2057098wrh.17 for ; Mon, 18 Jul 2022 07:30:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=jUtPBiIrd+z8CiEFPGJfKbwGJNg/RiruOLCOevLD9jM=; b=Gpo2/cDy8ABaRbmCEhtVdg7PprixYSWoUEdIbnYG+V+cmbS58TXHLf5JJNo2pHLA7h xf1+LEOYBmJ/HM0XL8OtZbXVOG6H3itka44X9q6e8mP6J0C2tKurZxyoW1x3KuW8WT2z YLqWrt9j/wxHGxs+shHSuvkKEIXmevoTcqdyUmRK+zxdovrn03JEOXS2GmQ2hlEmfkMu FVZgiOHg/v2DAT1YmROW+Ua9Xs14NiCrgB8DleTSxb9HxECbnY8Md1VAAusgcZAp7jxd NvxLdyGKrpJeRn/tjvE5xCPbnXV7tL/VOIqKVvb001cPXKO8E68FDoF0TR6lWrDcWDPU dkzg== X-Gm-Message-State: AJIora/ZJsNXChGFfUKeyZFUMGWXX3/8ftnzXdA/ELlZcd0TG49cef7o 8khpuXrNSZZIEnBChAITwPhYjuJMPcGOxRcPIHymTLCji/OIsF2iV95/wIzPHKC6U6gzaL3E3RO Sa8AC44uiChaYwxxrUdMRqg== X-Received: by 2002:a7b:ce8f:0:b0:3a3:150c:d8ff with SMTP id q15-20020a7bce8f000000b003a3150cd8ffmr9471804wmj.152.1658154638687; Mon, 18 Jul 2022 07:30:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v0nftbdsrtAscHKNTqwvclFk1duRPqC5xNJg2wwzmMypNdZaiHHSf+cEf6u3GWAnpsCoNvQA== X-Received: by 2002:a7b:ce8f:0:b0:3a3:150c:d8ff with SMTP id q15-20020a7bce8f000000b003a3150cd8ffmr9471778wmj.152.1658154638209; Mon, 18 Jul 2022 07:30:38 -0700 (PDT) Received: from localhost (15.72.115.87.dyn.plus.net. [87.115.72.15]) by smtp.gmail.com with ESMTPSA id h13-20020a5d6e0d000000b0021b9e360523sm10926485wrz.8.2022.07.18.07.30.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 07:30:37 -0700 (PDT) To: Andrei Pikas , tom@tromey.com Subject: Re: [PATCH v3] Add style tui-current-line command to colorize TUI current line. In-Reply-To: <20220715224949.164691-1-gdb@mail.api.win> References: <87tu7imafv.fsf@tromey.com> <20220715224949.164691-1-gdb@mail.api.win> Date: Mon, 18 Jul 2022 15:30:36 +0100 Message-ID: <87r12iqyr7.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: Andrei Pikas , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Andrei Pikas writes: > Adds the ability to customize the colors of the current line of code in TUI. > This may be desirable when code highlighting is enabled. Because higlighted > keywords in dark blue color are indistinguishable from a black background > (which is the default inverse color for a white terminal). > Here is a screenshot of old and new behavior > https://drive.google.com/file/d/1BbgNwpFa0DvKX0K9UAd48dEgtn8aChXP/view > --- > gdb/NEWS | 4 ++++ > gdb/cli/cli-style.c | 36 ++++++++++++++++++++++++++++++++++++ > gdb/cli/cli-style.h | 3 +++ > gdb/doc/gdb.texinfo | 3 +++ > gdb/tui/tui-io.c | 44 ++++++++++++++++++++++++++++++++++++++++---- > gdb/tui/tui-win.c | 1 + > 6 files changed, 87 insertions(+), 4 deletions(-) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 1178a37017e..03c8f53738d 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -41,6 +41,10 @@ > > * New commands > > +set style tui-current-line foreground COLOR > +set style tui-current-line background COLOR > + Control the styling of the currently executing line of code. > + > maintenance set ignore-prologue-end-flag on|off > maintenance show ignore-prologue-end-flag > This setting, which is off by default, controls whether GDB ignores the > diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c > index 3fd85f4aa86..64312809385 100644 > --- a/gdb/cli/cli-style.c > +++ b/gdb/cli/cli-style.c > @@ -54,6 +54,28 @@ static const char * const cli_colors[] = { > "magenta", > "cyan", > "white", > + "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", > + "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", > + "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", > + "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", > + "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", > + "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", > + "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", > + "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", > + "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", > + "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", > + "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", > + "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", > + "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", > + "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", > + "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", > + "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", > + "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", > + "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", > + "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", > + "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", > + "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", > + "253", "254", "255", As I said in another mail, I think this change needs spinning out into its own patch. > nullptr > }; > > @@ -101,6 +123,11 @@ cli_style_option tui_active_border_style ("tui-active-border", > > /* See cli-style.h. */ > > +cli_style_option tui_current_line_style ("tui-current-line", > + ui_file_style::NONE); Continuation lines like this should be indented initially with TABS, and the alignment should be like: cli_style_option tui_current_line_style ("tui-current-line", ui_file_style::NONE); See tui_active_border_style for an example. Thanks, Andrew > + > +/* See cli-style.h. */ > + > cli_style_option metadata_style ("metadata", ui_file_style::DIM); > > /* See cli-style.h. */ > @@ -446,6 +473,15 @@ TUI window that does have the focus."), > &style_show_list, > true); > > + tui_current_line_style.add_setshow_commands (no_class, _("\ > +TUI current line display styling.\n\ > +Configure TUI current line colors\n\ > +The \"tui-current-line\" style is used when GDB displays the current line of \ > +code."), > + &style_set_list, > + &style_show_list, > + true); > + > version_style.add_setshow_commands (no_class, _("\ > Version string display styling.\n\ > Configure colors used to display the GDB version string."), > diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h > index f69df47098c..745e530c6a9 100644 > --- a/gdb/cli/cli-style.h > +++ b/gdb/cli/cli-style.h > @@ -122,6 +122,9 @@ extern cli_style_option tui_border_style; > /* The border style of a TUI window that does have the focus. */ > extern cli_style_option tui_active_border_style; > > +/* The style of a reverse mode for current line in TUI window. */ > +extern cli_style_option tui_current_line_style; > + > /* The style to use for the GDB version string. */ > extern cli_style_option version_style; > > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index 7a4e337d15b..d3a45087217 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -26642,6 +26642,9 @@ general styling to @value{GDBN}. @xref{TUI Configuration}. > Control the styling of the active TUI border; that is, the TUI window > that has the focus. > > +@item tui-current-line > +Control the styling of the currently executing line of code. > + > @end table > > @node Numbers > diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c > index 22c234a0dc2..4517cc7124a 100644 > --- a/gdb/tui/tui-io.c > +++ b/gdb/tui/tui-io.c > @@ -35,6 +35,7 @@ > #include "tui/tui-out.h" > #include "ui-out.h" > #include "cli-out.h" > +#include "cli/cli-style.h" > #include > #include > #ifdef __MINGW32__ > @@ -351,6 +352,22 @@ tui_apply_style (WINDOW *w, ui_file_style style) > last_style = style; > } > > +/* Reads style which have been set by command "set style tui-current-line" into > + STYLE and returns true. > + Returns false and leaves STYLE untouched if tui-current-line style > + isn't set. */ > + > +static bool > +get_custom_current_line_style (ui_file_style *style) > +{ > + ui_file_style current_line_style = tui_current_line_style.style (); > + if (current_line_style.is_default ()) > + return false; > + > + *style = current_line_style; > + return true; > +} > + > /* Apply an ANSI escape sequence from BUF to W. BUF must start with > the ESC character. If BUF does not start with an ANSI escape, > return 0. Otherwise, apply the sequence if it is recognized, or > @@ -392,10 +409,12 @@ apply_ansi_escape (WINDOW *w, const char *buf) > ui_file_style::color fg = style.get_foreground (); > style.set_fg (bg); > style.set_bg (fg); > - } > > - /* Enable A_REVERSE. */ > - style.set_reverse (true); > + /* Enable A_REVERSE. */ > + style.set_reverse (true); > + } > + else if (!get_custom_current_line_style (&style)) > + style.set_reverse (true); > } > > tui_apply_style (w, style); > @@ -410,17 +429,19 @@ tui_set_reverse_mode (WINDOW *w, bool reverse) > ui_file_style style = last_style; > > reverse_mode_p = reverse; > - style.set_reverse (reverse); > > if (reverse) > { > reverse_save_bg = style.get_background (); > reverse_save_fg = style.get_foreground (); > + if (!get_custom_current_line_style (&style)) > + style.set_reverse (reverse); > } > else > { > style.set_bg (reverse_save_bg); > style.set_fg (reverse_save_fg); > + style.set_reverse (reverse); > } > > tui_apply_style (w, style); > @@ -448,6 +469,9 @@ tui_puts (const char *string, WINDOW *w) > if (w == nullptr) > w = TUI_CMD_WIN->handle.get (); > > + attr_t w_attrs = 0; > + short w_pair = 0; > + > while (true) > { > const char *next = strpbrk (string, "\n\1\2\033\t"); > @@ -472,6 +496,13 @@ tui_puts (const char *string, WINDOW *w) > break; > > case '\n': > + if (wattr_get (w, &w_attrs, &w_pair, nullptr) == OK) > + /* Apply current style till the end of line. */ > + wchgat (w, -1, w_attrs, w_pair, nullptr); > + do_tui_putc (w, c); > + ++next; > + break; > + > case '\t': > do_tui_putc (w, c); > ++next; > @@ -497,6 +528,11 @@ tui_puts (const char *string, WINDOW *w) > string = next; > } > > + if (wattr_get (w, &w_attrs, &w_pair, nullptr) == OK) > + /* Apply current style till the end of line. */ > + wchgat (w, -1, w_attrs, w_pair, nullptr); > + > + > if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) > update_cmdwin_start_line (); > } > diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c > index 31b6606636a..d03b12984ad 100644 > --- a/gdb/tui/tui-win.c > +++ b/gdb/tui/tui-win.c > @@ -1197,4 +1197,5 @@ the line numbers and uses less horizontal space."), > > tui_border_style.changed.attach (tui_rehighlight_all, "tui-win"); > tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win"); > + tui_current_line_style.changed.attach (tui_refresh_all_win, "tui-win"); > } > -- > 2.34.1