From patchwork Fri Apr 24 00:53:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 6415 Received: (qmail 119352 invoked by alias); 24 Apr 2015 00:53:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 119070 invoked by uid 89); 24 Apr 2015 00:53:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_05, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-vn0-f43.google.com Received: from mail-vn0-f43.google.com (HELO mail-vn0-f43.google.com) (209.85.216.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 24 Apr 2015 00:53:53 +0000 Received: by vnbg1 with SMTP id g1so2881701vnb.2 for ; Thu, 23 Apr 2015 17:53:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TFhlgQw3xO2RaQJ9psAm1c40Ybmj3kmebJl+hz37IYU=; b=VxZcWHS5i5ryk99MyF9u/ztB/eIojcDMZaruLFC9Vgr6Q4+HUw+Hy97tuuh03DQrl8 iOQTdscmrLA0Bo1wTHnxiUCR/S4q88rCoUm4XuSh4TGhC+w+nOmZU5dyDO7dYGqYL1/P 7pmlGvudcvzhbFdgW3MnbRuuhpkERwqit+ATWJwEhOE8aFUnuznOdABQeiQCUH1+Ypxk 7fPrhv6Gl636jLg1uFFnz3Ri9OuK0HF4LRtDXE46XlwkkMjlzjzjeIkaPqMonrwx25fm Mvccs5oNUgSls1yJ8TKd0rvvZotQAICkYWCC1Dvo78cSX5SDSlUF3wVlnS1QgwR9toFV n7ZQ== X-Gm-Message-State: ALoCoQnDfyYjEp9/T4IhKEU0Iw+6Vxhn/JLwg2XZcclnvA6O+PSzUTBp5Gaon2hqzFvc1mLgIgGe X-Received: by 10.52.236.134 with SMTP id uu6mr6120307vdc.45.1429836831490; Thu, 23 Apr 2015 17:53:51 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by mx.google.com with ESMTPSA id r7sm3450884vdw.23.2015.04.23.17.53.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Apr 2015 17:53:50 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH 1/3] Introduce function for directly updating GDB's screen dimensions Date: Thu, 23 Apr 2015 20:53:19 -0400 Message-Id: <1429836801-14218-1-git-send-email-patrick@parcs.ath.cx> ... to replace the roundabout pattern of execute_command ("set width %d"); execute_command ("set height %d"); for doing the same thing. gdb/ChangeLog * utils.h (set_screen_width_and_height): Declare. * utils.c (set_screen_width_and_height): Define. * tui/tui-win.c (tui_update_gdb_sizes): Use it. --- gdb/tui/tui-win.c | 21 +++++++++++++-------- gdb/utils.c | 12 ++++++++++++ gdb/utils.h | 2 ++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 3cf38fc..6830977 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -465,15 +465,20 @@ bold-standout use extra bright or bold with standout mode"), void tui_update_gdb_sizes (void) { - char cmd[50]; + int width, height; - /* Set to TUI command window dimension or use readline values. */ - xsnprintf (cmd, sizeof (cmd), "set width %d", - tui_active ? TUI_CMD_WIN->generic.width : tui_term_width()); - execute_command (cmd, 0); - xsnprintf (cmd, sizeof (cmd), "set height %d", - tui_active ? TUI_CMD_WIN->generic.height : tui_term_height()); - execute_command (cmd, 0); + if (tui_active) + { + width = TUI_CMD_WIN->generic.width; + height = TUI_CMD_WIN->generic.height; + } + else + { + width = tui_term_width (); + height = tui_term_height (); + } + + set_screen_width_and_height (width, height); } diff --git a/gdb/utils.c b/gdb/utils.c index a9350d9..ec2fd87 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1795,6 +1795,18 @@ set_height_command (char *args, int from_tty, struct cmd_list_element *c) set_screen_size (); } +/* Set the screen dimensions to WIDTH and HEIGHT. */ + +void +set_screen_width_and_height (int width, int height) +{ + lines_per_page = height; + chars_per_line = width; + + set_screen_size (); + set_width (); +} + /* Wait, so the user can read what's on the screen. Prompt the user to continue by pressing RETURN. */ diff --git a/gdb/utils.h b/gdb/utils.h index b8e1aff..9c1af78 100644 --- a/gdb/utils.h +++ b/gdb/utils.h @@ -174,6 +174,8 @@ extern struct ui_file *gdb_stdtarg; extern struct ui_file *gdb_stdtargerr; extern struct ui_file *gdb_stdtargin; +extern void set_screen_width_and_height (int width, int height); + /* More generic printf like operations. Filtered versions may return non-locally on error. */