From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 40145384A033 for ; Mon, 15 Jun 2020 20:45:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 40145384A033 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-698bLLEVN9mtuUAXqAQJ_A-1; Mon, 15 Jun 2020 16:45:42 -0400 X-MC-Unique: 698bLLEVN9mtuUAXqAQJ_A-1 Received: by mail-wr1-f69.google.com with SMTP id p9so7511744wrx.10 for ; Mon, 15 Jun 2020 13:45:42 -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:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=NTXAPmu9zJ8OufER510X+aTDvnrI6HIfkCKevE8KoFQ=; b=MKtHYitlEmr6rOUnkNXztzjSL5XRUS//jpqZxTbnvy2SNYmbvWuYCRhc6keLADpUjE zUjaTyaqp6ywIhoQYs0qgjl9nhqffnAc0CtI5xQuMgMZ9+jK24+NB8lDIxMZHzu4W505 zdIbzfzranjdxZRloXgoEBrHf+cswkQrP0giYCF7x0R36REoivb0GWgWI50zkc8P7bOq b53//OHXG1qEVOBi72mqxaNjNEpV//tXSO4QPB09ItMR1UrPR1CKLSVyplIkVy9lNqjr bCJhrWAfYJAD5oGFvx0agJ8+GlHRIXokKqc4210qGy7qiuesu0eLU3Tgo/Y/nOLmAOih 6ERg== X-Gm-Message-State: AOAM532b+6iBjXZ7bj5wygaHV1XJPkMIS0EayuvXy9zwf3Kogmabp6lj 6yGpssJm1KziyFQ53HMTtA9bcMPL725FCnwHOPPXPmB8oZuHxiTHDkAoe4t5/2H5GY8O28Wip15 b/YJwTYJH2BRIe+7h1m+kWQ== X-Received: by 2002:a5d:4a8a:: with SMTP id o10mr30175300wrq.222.1592253941553; Mon, 15 Jun 2020 13:45:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDBnT80J5XDxtTkvhITN6CaKILse+Rl19QhUuh/VKolSveBx3NxVxE2Ed1z+oIbXeHFxY3Ew== X-Received: by 2002:a5d:4a8a:: with SMTP id o10mr30175288wrq.222.1592253941317; Mon, 15 Jun 2020 13:45:41 -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 t8sm25570927wro.56.2020.06.15.13.45.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Jun 2020 13:45:40 -0700 (PDT) Subject: Re: TUI enhancement suggestion. To: Tom Tromey , Pedro Alves via Gdb-patches 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> From: Pedro Alves Message-ID: <00ed105b-6fe6-f554-f1d8-7f361695687e@redhat.com> Date: Mon, 15 Jun 2020 21:45:39 +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: <87366whyvk.fsf@tromey.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------D43BD31392BBB0820389120B" 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: Mon, 15 Jun 2020 20:45:50 -0000 This is a multi-part message in MIME format. --------------D43BD31392BBB0820389120B Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 6/15/20 9:12 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves via Gdb-patches writes: > > Pedro> Try the attached patch, and do "set tui current-line-highlight reverse-mono". > > Maybe the new mode ought to be the default. Yeah. I'm not sure what is the mode that people prefer the most, but that would be fine with me. > > Pedro> +static void > Pedro> +set_tui_current_line_highlight_mode (const char *ignore, int from_tty, > Pedro> + struct cmd_list_element *c) > Pedro> +{ > Pedro> + if (TUI_SRC_WIN != nullptr) > Pedro> + TUI_SRC_WIN->refill (); > Pedro> +} > > Possibly this should update the assembly window as well. Indeed. Here's an updated patch. I wonder whether some option under "set style" would be more appropriate here. Typing "set tui current-line-highlight reverse-mono" is a bit of a "mouthful". Like, (gdb) set style tui-current-line on|off I see that we already have "set style tui-active-border" and "set style tui-border" in there. Thanks, Pedro Alves --------------D43BD31392BBB0820389120B Content-Type: text/x-patch; name="0001-set-tui-current-line-highlight-mode-reverse-styled-r.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-set-tui-current-line-highlight-mode-reverse-styled-r.pa"; filename*1="tch" >From 162a6ff7256b88faae70988fd490f22371f3298e Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 15 Jun 2020 19:35:10 +0100 Subject: [PATCH] set tui current-line-highlight-mode reverse-styled|reverse-mono --- gdb/tui/tui-io.c | 11 +++++++++- gdb/tui/tui-win.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/tui/tui-win.h | 14 +++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index e7a8ac77bce..36b6ae81c45 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -365,6 +365,10 @@ apply_ansi_escape (WINDOW *w, const char *buf) if (reverse_mode_p) { + current_line_highlight_mode mode = get_current_line_highlight_mode (); + if (mode == current_line_highlight_mode::reverse_mono) + 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 +411,15 @@ 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 (); + + current_line_highlight_mode mode = get_current_line_highlight_mode (); + if (mode == current_line_highlight_mode::reverse_mono) + style = {}; } else { @@ -420,6 +427,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..426a59194a1 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -108,6 +108,16 @@ static const char *const tui_border_mode_enums[] = { NULL }; +static const char *highlight_mode_reverse_styled = "reverse-styled"; +static const char *highlight_mode_reverse_mono = "reverse-mono"; + +/* Possible values for tui-current-line-highlight variable. */ +static const char *const tui_current_line_highlight_mode_enums[] = { + highlight_mode_reverse_styled, + highlight_mode_reverse_mono, + NULL +}; + struct tui_translate { const char *name; @@ -218,6 +228,44 @@ show_tui_border_kind (struct ui_file *file, value); } +/* Implementation of the "set/show tui current-line-highlight" commands. */ + +static const char *tui_current_line_highlight_mode + = highlight_mode_reverse_styled; + +static void +show_tui_current_line_highlight_mode (struct ui_file *file, + int from_tty, + struct cmd_list_element *c, + const char *value) +{ + fprintf_filtered (file, _("\ +The mode to use for the current source highlight is \"%s\".\n"), + value); +} + +static void +set_tui_current_line_highlight_mode (const char *ignore, int from_tty, + struct cmd_list_element *c) +{ + if (TUI_SRC_WIN != nullptr) + TUI_SRC_WIN->refill (); + if (TUI_DISASM_WIN != nullptr) + TUI_DISASM_WIN->refill (); +} + +/* See tui-win.h. */ + +current_line_highlight_mode +get_current_line_highlight_mode () +{ + for (int i = 0; i < ARRAY_SIZE (tui_current_line_highlight_mode_enums); i++) + if (tui_current_line_highlight_mode + == tui_current_line_highlight_mode_enums[i]) + return (current_line_highlight_mode) i; + + gdb_assert_not_reached ("unknown mode"); +} /* Tui internal configuration variables. These variables are updated by tui_update_variables to reflect the tui configuration @@ -1120,6 +1168,18 @@ the line numbers and uses less horizontal space."), tui_set_compact_source, tui_show_compact_source, &tui_setlist, &tui_showlist); + add_setshow_enum_cmd ("current-line-highlight-mode", no_class, + tui_current_line_highlight_mode_enums, + &tui_current_line_highlight_mode, _("\ +Set the mode to use for the current line highlight."), _("\ +Show the mode to use for the current line highlight."), _("\ +This variable controls the mode to use for the current line indicator:\n\ + reverse-styled use reverse video for the background, and style the text\n\ + reverse-mono use reverse video for the background, don't style the text"), + set_tui_current_line_highlight_mode, + show_tui_current_line_highlight_mode, + &tui_setlist, &tui_showlist); + 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..ae67b42273b 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -57,4 +57,18 @@ struct cmd_list_element **tui_get_cmd_list (void); /* Whether compact source display should be used. */ extern bool compact_source; +enum current_line_highlight_mode +{ + /* Reverse video, and if source styling is enabled, display the + foreground text with style enabled. */ + reverse_styled, + + /* Reverse video, and display foreground text in background color, + with source styling disabled. */ + reverse_mono, +}; + +/* Get the current line highlight mode. */ +current_line_highlight_mode get_current_line_highlight_mode (); + #endif /* TUI_TUI_WIN_H */ base-commit: 669203174311c5be76744a879563c697cd479853 -- 2.14.5 --------------D43BD31392BBB0820389120B--