From patchwork Wed Aug 26 01:06:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 8444 Received: (qmail 91432 invoked by alias); 26 Aug 2015 01:06:22 -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 91418 invoked by uid 89); 26 Aug 2015 01:06:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, COMPENSATION, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mail-qg0-f41.google.com Received: from mail-qg0-f41.google.com (HELO mail-qg0-f41.google.com) (209.85.192.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 26 Aug 2015 01:06:21 +0000 Received: by qgeb6 with SMTP id b6so117646810qge.3 for ; Tue, 25 Aug 2015 18:06:19 -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=3H2nngaaY1ehMcuopS4C/wcwBH182eZCjnENC8ByuLc=; b=mefdH1aw12ze2anFJbUYU/kUMA/sEmH3z/eIQ2hiPhnXxidgZelZ2C82sY7eFGyRZh J+wbH//z0sTesC6KfV2KXg74YsvBaR1ppvhbyt1rNMoLQX02w9oLraO83+iUUzf0fHtz w3QGwgIuNcRs5D34WHfGQMxkeoaY3ULS/QGGMp2UYZJb5kSFkFYh9sIzKl/sj1kRWdAu 1wgAcCelAkvCFYppX70RkhPeT5ykEPWGMJ4Ng1AbaUwwpelU/UPv/7eqpyYZ7SnMXidr NuX021PuTg6AgO8GVmT4q3cOGo0NHORqIwsmca8KUBI/XWSzMaGJZxZprm04ojYa+X0c nZoA== X-Gm-Message-State: ALoCoQnQLXvlDpN05dF3KfdzsVeX+A0EZ1ZrhjqTjmWO51j86zuvDqECe0oFy+tVR8eIEutYCWHF X-Received: by 10.140.132.71 with SMTP id 68mr76008520qhe.64.1440551179226; Tue, 25 Aug 2015 18:06:19 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by smtp.gmail.com with ESMTPSA id f9sm7504787qhe.7.2015.08.25.18.06.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Aug 2015 18:06:18 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH 1/2] tui: make updating of start_line in tui_puts more consistent Date: Tue, 25 Aug 2015 21:06:12 -0400 Message-Id: <1440551173-18266-1-git-send-email-patrick@parcs.ath.cx> The command window's start_line field is used by the function tui_redisplay_readline to figure out on which window line to start redrawing the (possibly multi-line) command line. It differs from the Y coordinate of the window cursor only when the length of the line being outputted is longer than the width of the window. The function tui_puts however currently does not respect this property of start_line. After a call to tui_puts, start_line will always be equal to cur_line even when the outputted line may have wrapped a few times. This patch makes tui_puts update start_line in a way that's consistent with how tui_redisplay_readline does it. This patch also explicitly documents this property of start_line. gdb/ChangeLog: * tui/tui-data.h (tui_command_info): Add comment documenting the field start_line. * tui/tui-io.c (tui_puts): Fix the updating of start_line. --- gdb/tui/tui-data.h | 5 +++++ gdb/tui/tui-io.c | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index df1fe6c..2f9030a 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -265,6 +265,11 @@ struct tui_source_info struct tui_command_info { + /* The line number (i.e. the Y coordinate of the command window) that + contains the start of the latest line being outputted. START_LINE differs + from the Y coordinate of the window cursor only when the current line is + longer than the width of the window, i.e. only when the current line has + wrapped to the next line one or more times. */ int start_line; }; diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index c7a092f..311c96c 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -168,7 +168,12 @@ tui_puts (const char *string) } else if (tui_skip_line != 1) { + int prev_line, prev_col; + tui_skip_line = -1; + + getyx (w, prev_line, prev_col); + /* Expand TABs, since ncurses on MS-Windows doesn't. */ if (c == '\t') { @@ -183,11 +188,21 @@ tui_puts (const char *string) } else waddch (w, c); + + if (c == '\n') + TUI_CMD_WIN->detail.command_info.start_line = getcury (w); + else if (getcurx (w) <= prev_col && getcury (w) == prev_line) + { + /* If the cursor is on the last line of the command window and the + added character caused the line to wrap, then we have to adjust + start_line to compensate for the scrolling up of each line that + the line wrapping caused. */ + TUI_CMD_WIN->detail.command_info.start_line--; + } } else if (c == '\n') tui_skip_line = -1; } - TUI_CMD_WIN->detail.command_info.start_line = getcury (w); } /* Readline callback.