From patchwork Sun Jul 5 21:03:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 7521 Received: (qmail 65645 invoked by alias); 5 Jul 2015 21:04:18 -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 65516 invoked by uid 89); 5 Jul 2015 21:04:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, 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:17 +0000 Received: by qkbp125 with SMTP id p125so105818074qkb.2 for ; Sun, 05 Jul 2015 14:04:14 -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=cUtfKfvakIyO9askeW6yST/o39F2sJ5+s3XHFEQgMFU=; b=E7JsAjVLATr9VjPTmPW74lmvOvYwiJEUdPjF/LwfsKaqYXJ5lhoDdPJwrtUHG9d0ci iW15gSOINyRXjyhNqnmeeR9FS1zdZ/fhwsU9Bie2nUEpO9UjhF8r5K8qukiPnBcHHfld VB4Q/xEzT/waGvKAYHLRNwTQ8ao6CMHCeUiJAn34XAYogGM9j7/sqG5xNCe7GnPrPqIO b3MV2ZoKvd3gCliipZRa1O1qJGSNK2Jbvr2i1dKgaih7WD7lJw6pO3rDq9fzB7M70Aby CKx6gXDek7hV3QZS9CwaR3Mmy4a/ZzZo7cY/Zunt3V6GCvZxs3Z1D5txW1xuFHiEmKsL +W8w== X-Gm-Message-State: ALoCoQloSzou/PHsNudg9+2pnBxga7+zkDxT1inNQ6qhBNue8VEm1y3XUTbihQlDTLNwk3qdCCDF X-Received: by 10.140.235.71 with SMTP id g68mr69031076qhc.41.1436130254784; Sun, 05 Jul 2015 14:04:14 -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.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Jul 2015 14:04:14 -0700 (PDT) From: Patrick Palka To: gdb-patches@sourceware.org Cc: Patrick Palka Subject: [PATCH 3/5] tui: simplify and fix up handling of start_line in tui_redisplay_readline Date: Sun, 5 Jul 2015 17:03:59 -0400 Message-Id: <1436130241-21443-3-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> This patch makes three small changes: The code guarded by the c == '\n' condition is dead code because whatever value start_line and curch get set to will be overwritten after the while-loop finishes anyway. So this patch removes this dead code. Besides that, the remaining two writes to start_line are combined into one write. Finally, if start_line ever falls below 0, which can happen if the command line is so long that it wraps along the height of the entire command window, just reset it to 0 so that we avoid passing an invalid y parameter to wmove() later, and emit a beep to "warn" the user that the command line is too long. gdb/ChangeLog: * tui/tui-io.c (tui_redisplay_readline): Simplify the updating of start_line. If start_line is negative, re-set it to 0 and emit a beep. --- gdb/tui/tui-io.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index ba42c18..5b9ca20 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -270,26 +270,33 @@ tui_redisplay_readline (void) { waddch (w, c); } - if (c == '\n') - { - getyx (w, TUI_CMD_WIN->detail.command_info.start_line, - TUI_CMD_WIN->detail.command_info.curch); - } getyx (w, line, col); if (col < prev_col) height++; prev_col = col; } + wclrtobot (w); - getyx (w, TUI_CMD_WIN->detail.command_info.start_line, - TUI_CMD_WIN->detail.command_info.curch); + + TUI_CMD_WIN->detail.command_info.start_line + = getcury (w) - (height - 1); + TUI_CMD_WIN->detail.command_info.curch + = getcurx (w); + + /* This can happen if the command line is so long that it wraps along the + height of the entire window. */ + if (TUI_CMD_WIN->detail.command_info.start_line < 0) + { + beep (); + TUI_CMD_WIN->detail.command_info.start_line = 0; + } + if (c_line >= 0) { wmove (w, c_line, c_pos); TUI_CMD_WIN->detail.command_info.cur_line = c_line; TUI_CMD_WIN->detail.command_info.curch = c_pos; } - TUI_CMD_WIN->detail.command_info.start_line -= height - 1; wrefresh (w); fflush(stdout);