From patchwork Sun Jul 5 21:04:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 7522 Received: (qmail 66021 invoked by alias); 5 Jul 2015 21:04:21 -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 65958 invoked by uid 89); 5 Jul 2015 21:04:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 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-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 05 Jul 2015 21:04:18 +0000 Received: by qkbp125 with SMTP id p125so105818313qkb.2 for ; Sun, 05 Jul 2015 14:04:16 -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:in-reply-to :references; bh=uiJ87GW3EOYlCFrxKHh4LoMmCSlISnLXZjyUlb5pN/A=; b=PCmATb5ZH9jM1vkS442jGNnq7k2RE8qrzev+fpHhb7coMb6ws/BpCC4m7Jg2+93vJb pO41tUAl/43dWokg8ExpxZEOPMS4/2n4/Pe/WXu86DU/NsLgWck5na86mgUlmGLVzFUt AcuusnKANTDcrG1I/tO6ukVNXuwBLXZ6vXCpvi7/Zn+Q9DXk/ZqwOE7j2KbpduF0OhZH q3JmDS/tONn3rRw5+FTedjlcJRx5BBbSqTV9hU4N6C4V45YiNbUIlJM2oekCW0wepsDj HQQFyBzlNHHf0oll2fNHlKfHYYGxVRgiDk2lG78N+VGKr9F2m7oZDXdUUB+agYatVtLz xJmw== X-Gm-Message-State: ALoCoQmtajZcb0LuLJxsV4Rlb0gQTb8uSQj89LmZgtVFZeEe8iiQ8gyWJ0zXxZtj1xN0oOT1aeVV X-Received: by 10.140.131.81 with SMTP id 78mr40915507qhd.70.1436130255974; Sun, 05 Jul 2015 14:04:15 -0700 (PDT) Received: from localhost.localdomain (ool-4353acd8.dyn.optonline.net. [67.83.172.216]) by mx.google.com with ESMTPSA id 131sm8181073qhf.14.2015.07.05.14.04.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Jul 2015 14:04:15 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH 4/5] tui: make updating of start_line in tui_puts more consistent Date: Sun, 5 Jul 2015 17:04:00 -0400 Message-Id: <1436130241-21443-4-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1436130241-21443-1-git-send-email-patrick@parcs.ath.cx> References: <1436130177-21362-1-git-send-email-patrick@parcs.ath.cx> <1436130241-21443-1-git-send-email-patrick@parcs.ath.cx> The command window's start_line field is used by tui_redisplay_readline to figure out on which window line to start redrawing the (possibly multi-line) command line. It differs from cur_line only when the length of the line being outputted is longer than the width of the window. In this case, start_line will not equal to cur_line. Instead, start_line will be equal to cur_line - N where N is the number of times the current line was wrapped around the width of the command window. start_line takes into consideration whether line wrapping has occurred, and cur_line does not. 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 properly update start_line. It must only be updated if a newline is emitted, or if ncurses scrolls the command window (thus shifting all the line numbers). gdb/ChangeLog: * tui/tui-io.c (tui_puts): Fix the updating of start_line. --- gdb/tui/tui-io.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 5b9ca20..9302391 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,14 +188,23 @@ 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; } getyx (w, TUI_CMD_WIN->detail.command_info.cur_line, TUI_CMD_WIN->detail.command_info.curch); - TUI_CMD_WIN->detail.command_info.start_line - = TUI_CMD_WIN->detail.command_info.cur_line; } /* Readline callback.