From patchwork Sat Jan 10 03:49: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: 4605 Received: (qmail 23171 invoked by alias); 10 Jan 2015 03:49:38 -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 23151 invoked by uid 89); 10 Jan 2015 03:49:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-qg0-f48.google.com Received: from mail-qg0-f48.google.com (HELO mail-qg0-f48.google.com) (209.85.192.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 10 Jan 2015 03:49:35 +0000 Received: by mail-qg0-f48.google.com with SMTP id j5so11803478qga.7 for ; Fri, 09 Jan 2015 19:49:33 -0800 (PST) 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=Ft3xBIc8VPiYS6HRusDHwnKhyWd4nOwqBaK5U2DslS0=; b=dlMBk1K1Zv2uiJgHA7gaaIkuU9HVbrFAN6KZ9QXCw/tOwgKaWr5G8N+ryPRvL17nMr 740IgGxVtpfyr/eTiscHqze4WUb5/706Q6NgZPYSu7Wx8rwIsn5vZQJ8E3scDYOv+JfY UenJVRB/aUWb7nT/kfnNvw6/L9h8Hhlx3KVh0/iB3RMPGHuuksCHWnJYb+u9ipy/enQe 7BuLDzow0mfLwvbzoD9wE3MYi7QRSZ6zdGjrrWGbPPahlTQcVMUqRGMFXn6Uz9u5wRck 5mbljZJXgl4GgcEsPCEgEg8k124WJqeRhgcHG660uwwNthhn/Swj0QAurv3Ml5EhILZ0 /grw== X-Gm-Message-State: ALoCoQkwm1JzcxDReBTLkRiA02nGv5BHH3cyDBd6g1ViToe6lfN4lpOHTnvXOp8b1tRDirtrzUiy X-Received: by 10.224.121.79 with SMTP id g15mr22297321qar.68.1420861773064; Fri, 09 Jan 2015 19:49:33 -0800 (PST) Received: from localhost.localdomain (ool-4353ac94.dyn.optonline.net. [67.83.172.148]) by mx.google.com with ESMTPSA id y8sm8815554qat.29.2015.01.09.19.49.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Jan 2015 19:49:32 -0800 (PST) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH] Fix truncation of TUI command history Date: Fri, 9 Jan 2015 22:49:19 -0500 Message-Id: <1420861759-10700-2-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1420861759-10700-1-git-send-email-patrick@parcs.ath.cx> References: <1420861759-10700-1-git-send-email-patrick@parcs.ath.cx> If we submit a command while the prompt cursor is somewhere other than at the end of the command line, the command line gets truncated as the command window gets shifted one line up. This happens because we fail to properly move the cursor to the end of the command line before transmitting the newline to ncurses. We need to move the cursor because when ncurses outputs a newline it truncates any text that appears past the end of the cursor. The fix is generic enough to work properly even in multi-line secondary prompts like the quit prompt. gdb/ChangeLog: * tui/tui-io.c (tui_getc): Move cursor to the end of the command line before printing a newline. --- gdb/tui/tui-io.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 73dbcfc..94c3ec2 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -708,9 +708,15 @@ tui_getc (FILE *fp) } else { - wmove (w, TUI_CMD_WIN->detail.command_info.cur_line, - TUI_CMD_WIN->detail.command_info.curch); - waddch (w, ch); + /* Move cursor to the end of the command line before emitting the + newline. */ + int px = TUI_CMD_WIN->detail.command_info.curch; + int py = TUI_CMD_WIN->detail.command_info.cur_line; + px += rl_end - rl_point; + py += px / TUI_CMD_WIN->generic.width; + px %= TUI_CMD_WIN->generic.width; + wmove (w, py, px); + waddch (w, ch); } }