From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id D495B388A83B for ; Tue, 16 Jun 2020 11:02:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D495B388A83B Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-8y0ksM5VMZmrTgQunxMz5g-1; Tue, 16 Jun 2020 07:02:34 -0400 X-MC-Unique: 8y0ksM5VMZmrTgQunxMz5g-1 Received: by mail-wm1-f69.google.com with SMTP id v24so1095370wmh.3 for ; Tue, 16 Jun 2020 04:02:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Vr83mDqpJP6mNr6QTKES4YgQtwmCD+koWhjcLlHkFMw=; b=nhzuYt8YU3aG1aNT8sf6XHL32UAiqUukEDFwI5O98c0P+qdkSXlXH1sQmxz+6I3+XU XrA7c+sv6PfWwBYLQAR4qWukpeF3UdeijlAz3rACyT+XsRfruU1H/f+qiJKBWsmzXmWg DE4xEKgDdb2XdeLadMSCU+VdVPpWIbx4ruTiKTw8CVlzsp3ptED2lEj2Blt4u6VesYD5 Yth2lnRq1XlyiQcxu+T8f4md0tfdGoG0PyO4r42ALrCukVRQ64nCpS+O+FDemNxs9bqd MAJEL0A8wQNdxpVsXwbQMPsgjzuh3VBnMVx/Kjkbmif+/++tG6OLl8wJ3FjgbCgVzEV4 QJWg== X-Gm-Message-State: AOAM532VLRsFcIiltG2P0VUrcw9AAt1S7eUJ4LIYans/XB2mDS1q+qCM HOcA+1nVLsP6qCRtagsHPjyBuxB9aCqWNTrMhW8RRUusVTs3kQtmzjESQhqF7A33aSpLwMSvc7g mHvbg/1S1OE2lt1FIInzpIQ== X-Received: by 2002:a1c:7d4c:: with SMTP id y73mr2580537wmc.188.1592305353075; Tue, 16 Jun 2020 04:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwONvJWM3ZreFkhLo55A0e11OYws0VWOhkKyCh9YpQxTLryaneU9GnrBgyJrp5zmD3RwBKsOQ== X-Received: by 2002:a1c:7d4c:: with SMTP id y73mr2580508wmc.188.1592305352819; Tue, 16 Jun 2020 04:02:32 -0700 (PDT) Received: from ?IPv6:2001:8a0:f922:c400:56ee:75ff:fe8d:232b? ([2001:8a0:f922:c400:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id b18sm27981098wrn.88.2020.06.16.04.02.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jun 2020 04:02:32 -0700 (PDT) Subject: [PATCH] Add "set style tui-current-position on|off" default to off To: Phi Debian References: <38b5d874-cdf2-50e7-dc76-aed3fee20334@redhat.com> <3011c306-2c6c-228f-07eb-95d3ff560942@redhat.com> <314644177.1902979.1592236099059@mail.yahoo.com> <07772538-b41f-49e2-43c9-c6cb8831050b@redhat.com> <87366whyvk.fsf@tromey.com> <00ed105b-6fe6-f554-f1d8-7f361695687e@redhat.com> Cc: Tom Tromey , Pedro Alves via Gdb-patches From: Pedro Alves Message-ID: <73b40c12-cbd2-336a-3258-96f5134843a3@redhat.com> Date: Tue, 16 Jun 2020 12:02:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 16 Jun 2020 11:02:41 -0000 On 6/16/20 4:38 AM, Phi Debian via Gdb-patches wrote: > Hi Pedro, > I like the "set tui current-line-highlight reverse-mono" of your patch, it > remove the underline need, the current line is well readable. > Great. Here's a more complete patch, now with documentation updated. The option is now named: "set style tui-current-position on|off" and the default is now off. >From 854948d86fca90e894813ee08e349fec95c4d2ba Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 15 Jun 2020 19:35:10 +0100 Subject: [PATCH] Add "set style tui-current-position on|off", default to off As discussed at: https://sourceware.org/pipermail/gdb-patches/2020-June/169519.html this patch disables source code highlighting for the text highlighted by the TUI's current position indicator, and adds a command to enable it back. gdb/ChangeLog: * NEWS: Document that the TUI no longer styles the source code highlighted by the current position indicator by default. Mention "set style tui-current-position". * cli/cli-style.c (style_set_list, style_show_list): Make extern. * gdbcmd.h (style_set_list, style_show_list): Declare. * tui/tui-io.c (apply_ansi_escape): Return early if styling the current position is disabled. (tui_set_reverse_mode): If reversing, and source styling for the current position is disabled, switch to default style, reversed. * tui/tui-win.c (style_tui_current_position) (show_style_tui_current_position, set_style_tui_current_position): New. (_initialize_tui_win): Install the "set/show style tui-current-position" commands. * tui/tui-win.h (style_tui_current_position): Declare. gdb/doc/ChangeLog: * gdb.texinfo (Output Styling): Document "set/show style tui-current-position". (TUI Overview): Document source code highlighting for the current position indicator and mention "set style tui-current-position off". --- gdb/doc/gdb.texinfo | 17 +++++++++++++++-- gdb/NEWS | 8 ++++++++ gdb/cli/cli-style.c | 4 ++-- gdb/gdbcmd.h | 4 ++++ gdb/tui/tui-io.c | 13 ++++++++++++- gdb/tui/tui-win.c | 37 +++++++++++++++++++++++++++++++++++++ gdb/tui/tui-win.h | 4 ++++ 7 files changed, 82 insertions(+), 5 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 59e3e75d18a..48d0ffd8524 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -25521,6 +25521,15 @@ default is @samp{on}. @item show style sources Show the current state of source code styling. + +@item set style tui-current-position @samp{on|off} +Enable or disable source code styling of the source code highlighted +by the TUI's current position indicator. The default is @samp{off}. +@xref{TUI, ,@value{GDBN} Text User Interface}. + +@item show style tui-current-position +Show whether the source code highlighted by the TUI's current position +indicator is styled. @end table Subcommands of @code{set style} control specific forms of styling. @@ -27721,8 +27730,12 @@ This window shows the processor registers. Registers are highlighted when their values change. @end table -The source and assembly windows show the current program position -by highlighting the current line and marking it with a @samp{>} marker. +The source and assembly windows show the current program position by +highlighting the current line and marking it with a @samp{>} marker. +By default, source code styling is disabled for the highlighted text, +but you can enable it with the @code{set style tui-current-position +on} command. @xref{Output Styling}. + Breakpoints are indicated with two markers. The first marker indicates the breakpoint type: diff --git a/gdb/NEWS b/gdb/NEWS index cebfd18f0c6..0c72b687cfe 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -54,6 +54,10 @@ * TUI windows can now be arranged horizontally. +* The TUI no longer styles the source code text highlighted by the + current position indicator by default. You can however re-enable + styling using the new "set style tui-current-position" command. + * The command history filename can now be set to the empty string either using 'set history filename' or by setting 'GDBHISTFILE=' in the environment. The effect of setting this filename to the empty @@ -79,6 +83,10 @@ tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]... Define a new TUI layout, specifying its name and the windows that will be displayed. +set style tui-current-position [on|off] + Whether to style the source code text highlighted by the TUI's + current position indicator. The default is off. + * New targets GNU/Linux/RISC-V (gdbserver) riscv*-*-linux* diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index a0c3cc51801..acbb58ea7bf 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -253,8 +253,8 @@ cli_style_option::add_setshow_commands (enum command_class theclass, &m_set_list, &m_show_list, (void *) this); } -static cmd_list_element *style_set_list; -static cmd_list_element *style_show_list; +cmd_list_element *style_set_list; +cmd_list_element *style_show_list; static void set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c) diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h index 4406094ea59..eed87d53847 100644 --- a/gdb/gdbcmd.h +++ b/gdb/gdbcmd.h @@ -128,6 +128,10 @@ extern struct cmd_list_element *setchecklist; extern struct cmd_list_element *showchecklist; +/* Chains containing all defined "set/show style" subcommands. */ +extern struct cmd_list_element *style_set_list; +extern struct cmd_list_element *style_show_list; + /* Chain containing all defined "save" subcommands. */ extern struct cmd_list_element *save_cmdlist; diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index e7a8ac77bce..0f1d90b66dc 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -365,6 +365,9 @@ apply_ansi_escape (WINDOW *w, const char *buf) if (reverse_mode_p) { + if (!style_tui_current_position) + return n_read; + /* We want to reverse _only_ the default foreground/background colors. If the foreground color is not the default (because the text was styled), we want to leave it as is. If e.g., @@ -407,12 +410,18 @@ 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 (!style_tui_current_position) + { + /* Switch to default style (reversed) while highlighting the + current position. */ + style = {}; + } } else { @@ -420,6 +429,8 @@ tui_set_reverse_mode (WINDOW *w, bool reverse) style.set_fg (reverse_save_fg); } + style.set_reverse (reverse); + tui_apply_style (w, style); } diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index a78837fe689..e9570a7924a 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -218,6 +218,30 @@ show_tui_border_kind (struct ui_file *file, value); } +/* Implementation of the "set/show style tui-current-position" commands. */ + +bool style_tui_current_position = false; + +static void +show_style_tui_current_position (ui_file *file, + int from_tty, + cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("\ +Styling the text highlighted by the TUI's current position indicator is %s.\n"), + value); +} + +static void +set_style_tui_current_position (const char *ignore, int from_tty, + cmd_list_element *c) +{ + if (TUI_SRC_WIN != nullptr) + TUI_SRC_WIN->refill (); + if (TUI_DISASM_WIN != nullptr) + TUI_DISASM_WIN->refill (); +} /* Tui internal configuration variables. These variables are updated by tui_update_variables to reflect the tui configuration @@ -1120,6 +1144,19 @@ the line numbers and uses less horizontal space."), tui_set_compact_source, tui_show_compact_source, &tui_setlist, &tui_showlist); + add_setshow_boolean_cmd ("tui-current-position", class_maintenance, + &style_tui_current_position, _("\ +Set whether to style text highlighted by the TUI's current position indicator."), + _("\ +Show whether to style text highlighted by the TUI's current position indicator."), + _("\ +When enabled, the source code text highlighted by the TUI's current position\n\ +indicator is styled."), + set_style_tui_current_position, + show_style_tui_current_position, + &style_set_list, + &style_show_list); + tui_border_style.changed.attach (tui_rehighlight_all); tui_active_border_style.changed.attach (tui_rehighlight_all); } diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index e3791846307..4def8dd670b 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -57,4 +57,8 @@ struct cmd_list_element **tui_get_cmd_list (void); /* Whether compact source display should be used. */ extern bool compact_source; +/* Whether to style the source code text highlighted by the TUI's + current position indicator. */ +extern bool style_tui_current_position; + #endif /* TUI_TUI_WIN_H */ base-commit: 669203174311c5be76744a879563c697cd479853 -- 2.14.5