From patchwork Wed Dec 11 23:21:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36746 Received: (qmail 13608 invoked by alias); 11 Dec 2019 23:21:33 -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 13488 invoked by uid 89); 11 Dec 2019 23:21:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=Term X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Dec 2019 23:21:29 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id DA00A2048C; Wed, 11 Dec 2019 18:21:27 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 9DEAB20391; Wed, 11 Dec 2019 18:21:09 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 8620A20AF6; Wed, 11 Dec 2019 18:21:09 -0500 (EST) X-Gerrit-PatchSet: 5 Date: Wed, 11 Dec 2019 18:21:06 -0500 From: "Sourceware to Gerrit sync (Code Review)" To: Tom Tromey , Andrew Burgess , gdb-patches@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [pushed] Re-apply the current layout when resizing X-Gerrit-Change-Id: I3dc6c02a753d495d9ab5e8213d550a147198ce6f X-Gerrit-Change-Number: 369 X-Gerrit-ChangeURL: X-Gerrit-Commit: 3d97994549706f8f65fe9726b1fec1f0d643f822 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, andrew.burgess@embecosm.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191211232109.8620A20AF6@gnutoolchain-gerrit.osci.io> The original change was created by Tom Tromey. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/369 ...................................................................... Re-apply the current layout when resizing The TUI has separate code for each possible layout to handle the case where the terminal window is resized. With the new layout code, this can all be replaced with a call to tui_apply_current_layout, which simply re-applies the current layout. This results in some small differences in behavior when resizing, so some tests are updated. gdb/ChangeLog 2019-12-11 Tom Tromey * tui/tui-win.c (tui_resize_all): Remove code, call tui_apply_current_layout. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey * gdb.tui/resize.exp: Update. * gdb.tui/empty.exp (layouts): Update. Change-Id: I3dc6c02a753d495d9ab5e8213d550a147198ce6f --- M gdb/ChangeLog M gdb/testsuite/ChangeLog M gdb/testsuite/gdb.tui/empty.exp M gdb/testsuite/gdb.tui/resize.exp M gdb/tui/tui-win.c 5 files changed, 19 insertions(+), 111 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4c98df3..22cebfb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2019-12-11 Tom Tromey + * tui/tui-win.c (tui_resize_all): Remove code, call + tui_apply_current_layout. + +2019-12-11 Tom Tromey + * tui/tui-layout.h (tui_apply_current_layout): Declare. * tui/tui-layout.c (standard_layouts, applied_layout): New globals. diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9b7a81e..cf3fcb7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2019-12-11 Tom Tromey + * gdb.tui/resize.exp: Update. + * gdb.tui/empty.exp (layouts): Update. + +2019-12-11 Tom Tromey + * gdb.tui/regs.exp: Update. * gdb.tui/empty.exp (layouts): Update. * gdb.tui/basic.exp: Update. diff --git a/gdb/testsuite/gdb.tui/empty.exp b/gdb/testsuite/gdb.tui/empty.exp index 861f564..d0d8270 100644 --- a/gdb/testsuite/gdb.tui/empty.exp +++ b/gdb/testsuite/gdb.tui/empty.exp @@ -32,28 +32,28 @@ # 4. List of boxes in 90x40 mode # 5. List of test name and text for the empty window set layouts { - {src src {{0 0 80 15}} {{0 0 90 23}} + {src src {{0 0 80 15}} {{0 0 90 26}} {{"no source" "No Source Available"}}} - {regs src-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}} + {regs src-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 13} {0 12 90 13}} { {"no source" "No Source Available"} {"no regs" "Register Values Unavailable"} }} - {asm asm {{0 0 80 15}} {{0 0 90 23}} + {asm asm {{0 0 80 13}} {{0 0 90 26}} { {"no asm" "No Assembly Available"} }} - {regs asm-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}} + {regs asm-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 13} {0 12 90 13}} { {"no asm" "No Assembly Available"} {"no regs" "Register Values Unavailable"} }} - {split split {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}} + {split split {{0 0 80 6} {0 5 80 8}} {{0 0 90 13} {0 12 90 13}} { {"no source" "No Source Available"} {"no asm" "No Assembly Available"} }} - {regs split-regs {{0 0 80 7} {0 6 80 9}} {{0 0 90 12} {0 11 90 14}} + {regs split-regs {{0 0 80 6} {0 5 80 8}} {{0 0 90 13} {0 12 90 13}} { {"no asm" "No Assembly Available"} {"no regs" "Register Values Unavailable"} diff --git a/gdb/testsuite/gdb.tui/resize.exp b/gdb/testsuite/gdb.tui/resize.exp index 3b885e1..c530279 100644 --- a/gdb/testsuite/gdb.tui/resize.exp +++ b/gdb/testsuite/gdb.tui/resize.exp @@ -37,4 +37,4 @@ Term::check_contents "source at startup" ">|21 *return 0" Term::resize 40 90 -Term::check_box "source box after resize" 0 0 90 23 +Term::check_box "source box after resize" 0 0 90 26 diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 4339b7e..199f3ba 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -536,13 +536,7 @@ height_diff = screenheight - tui_term_height (); if (height_diff || width_diff) { - enum tui_layout_type cur_layout = tui_current_layout (); struct tui_win_info *win_with_focus = tui_win_with_focus (); - struct tui_win_info *first_win; - struct tui_win_info *second_win; - tui_source_window_base *src_win; - struct tui_locator_window *locator = tui_locator_win_info_ptr (); - int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; #ifdef HAVE_RESIZE_TERM resize_term (screenheight, screenwidth); @@ -553,108 +547,12 @@ tui_update_gdb_sizes (); tui_set_term_height_to (screenheight); tui_set_term_width_to (screenwidth); - if (cur_layout == SRC_DISASSEM_COMMAND - || cur_layout == SRC_DATA_COMMAND - || cur_layout == DISASSEM_DATA_COMMAND) - num_wins_displayed++; - split_diff = height_diff / num_wins_displayed; - cmd_split_diff = split_diff; - if (height_diff % num_wins_displayed) - { - if (height_diff < 0) - cmd_split_diff--; - else - cmd_split_diff++; - } - /* Now adjust each window. */ + /* erase + clearok are used instead of a straightforward clear as AIX 5.3 does not define clear. */ erase (); clearok (curscr, TRUE); - switch (cur_layout) - { - case SRC_COMMAND: - case DISASSEM_COMMAND: - src_win = *(tui_source_windows ().begin ()); - /* Check for invalid heights. */ - if (height_diff == 0) - new_height = src_win->height; - else if ((src_win->height + split_diff) >= - (screenheight - MIN_CMD_WIN_HEIGHT - 1)) - new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1; - else if ((src_win->height + split_diff) <= 0) - new_height = MIN_WIN_HEIGHT; - else - new_height = src_win->height + split_diff; - - src_win->resize (new_height, screenwidth, 0, 0); - - locator->resize (1, screenwidth, 0, new_height); - - new_height = screenheight - (new_height + 1); - TUI_CMD_WIN->resize (new_height, screenwidth, - 0, locator->y + 1); - break; - default: - if (cur_layout == SRC_DISASSEM_COMMAND) - { - src_win = TUI_SRC_WIN; - first_win = src_win; - second_win = TUI_DISASM_WIN; - } - else - { - first_win = TUI_DATA_WIN; - src_win = *(tui_source_windows ().begin ()); - second_win = src_win; - } - /* Change the first window's height/width. */ - /* Check for invalid heights. */ - if (height_diff == 0) - new_height = first_win->height; - else if ((first_win->height + - second_win->height + (split_diff * 2)) >= - (screenheight - MIN_CMD_WIN_HEIGHT - 1)) - new_height = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2; - else if ((first_win->height + split_diff) <= 0) - new_height = MIN_WIN_HEIGHT; - else - new_height = first_win->height + split_diff; - - first_win->resize (new_height, screenwidth, 0, 0); - - /* Change the second window's height/width. */ - /* Check for invalid heights. */ - if (height_diff == 0) - new_height = second_win->height; - else if ((first_win->height + - second_win->height + (split_diff * 2)) >= - (screenheight - MIN_CMD_WIN_HEIGHT - 1)) - { - new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1; - if (new_height % 2) - new_height = (new_height / 2) + 1; - else - new_height /= 2; - } - else if ((second_win->height + split_diff) <= 0) - new_height = MIN_WIN_HEIGHT; - else - new_height = second_win->height + split_diff; - - second_win->resize (new_height, screenwidth, - 0, first_win->height - 1); - - locator->resize (1, screenwidth, - 0, second_win->y + new_height); - - /* Change the command window's height/width. */ - new_height = screenheight - (locator->y + 1); - TUI_CMD_WIN->resize (new_height, screenwidth, - 0, locator->y + 1); - break; - } - + tui_apply_current_layout (); tui_delete_invisible_windows (); /* Turn keypad back on, unless focus is in the command window. */