From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 5D5B33858D35 for ; Thu, 29 Jun 2023 17:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D5B33858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id 4CEE41003898E for ; Thu, 29 Jun 2023 17:32:52 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id EvVkqLIPXLmMcEvVkqHEdT; Thu, 29 Jun 2023 17:32:52 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=GtGHRm5C c=1 sm=1 tr=0 ts=649dc044 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=of4jigFt-DYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=tTLXf_SQsSrnMxIS_GgA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=BNxgF2RcOu/VTWAAmfFsZIyUNtZGpqXth2RpSWBKqT4=; b=AGh1s9CJwLEqHHDFDAgpzm/mYQ DuUXHcsScz/cDjwR2YpBgS5ah5QrLu8zmmImqj6PU7Iz/55lERbOLQGGTkN1SAQDQMGy76ifX9HZ/ qr6QgrB0gEK0lxncVVtkQZroq; Received: from 71-211-136-248.hlrn.qwest.net ([71.211.136.248]:37684 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qEvVj-0000jm-3D; Thu, 29 Jun 2023 11:32:52 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Update TUI window title when changed Date: Thu, 29 Jun 2023 11:32:42 -0600 Message-ID: <20230629173242.151691-1-tom@tromey.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.136.248 X-Source-L: No X-Exim-ID: 1qEvVj-0000jm-3D X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-136-248.hlrn.qwest.net (localhost.localdomain) [71.211.136.248]:37684 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I wrote a TUI window in Python, and I noticed that setting its title did not result in a refresh, so the new title did not appear. This patch corrects this problem. --- gdb/python/py-tui.c | 2 +- gdb/testsuite/gdb.python/tui-window.exp | 4 ++++ gdb/testsuite/gdb.python/tui-window.py | 5 +++++ gdb/tui/tui-data.c | 11 +++++++++++ gdb/tui/tui-data.h | 4 ++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c index 84a435ead68..c52b04f9a51 100644 --- a/gdb/python/py-tui.c +++ b/gdb/python/py-tui.c @@ -531,7 +531,7 @@ gdbpy_tui_set_title (PyObject *self, PyObject *newvalue, void *closure) if (value == nullptr) return -1; - win->window->title = value.get (); + win->window->set_title (value.get ()); return 0; } diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp index 9b5d17c35d4..defc8c68b25 100644 --- a/gdb/testsuite/gdb.python/tui-window.exp +++ b/gdb/testsuite/gdb.python/tui-window.exp @@ -54,6 +54,10 @@ Term::check_contents "error message after trying to delete title" \ Term::check_contents "title is unchanged" \ "This Is The Title" +Term::command "python change_window_title ()" +Term::check_contents "test new title" \ + "New Title" + Term::resize 51 51 # Remember that a resize request actually does two resizes... Term::check_contents "Window was updated" "Test: 2" diff --git a/gdb/testsuite/gdb.python/tui-window.py b/gdb/testsuite/gdb.python/tui-window.py index 401cb5197ff..dc72cc4c0f7 100644 --- a/gdb/testsuite/gdb.python/tui-window.py +++ b/gdb/testsuite/gdb.python/tui-window.py @@ -53,4 +53,9 @@ def failwin(win): raise RuntimeError("Whoops") +# Change the title of the window. +def change_window_title(): + the_window.win.title = "New Title" + + gdb.register_window_type("fail", failwin) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 0daed32b6e6..abd2ec2b5fd 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -152,6 +152,17 @@ tui_prev_win (struct tui_win_info *cur_win) return *iter; } +/* See tui-data.h. */ + +void +tui_win_info::set_title (const char *new_title) +{ + if (title != new_title) + { + title = new_title; + check_and_display_highlight_if_needed (); + } +} void tui_win_info::rerender () diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index c92e85c9da1..030ce2a5438 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -146,6 +146,10 @@ struct tui_win_info void check_and_display_highlight_if_needed (); + /* A helper function to change the title and then redraw the + surrounding box, if needed. */ + void set_title (const char *new_title); + /* Window handle. */ std::unique_ptr handle; /* Window width. */ -- 2.41.0