From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.150.24]) by sourceware.org (Postfix) with ESMTPS id 51250385B831 for ; Sun, 5 Apr 2020 20:41:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 51250385B831 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 939A236E0 for ; Sun, 5 Apr 2020 15:41:34 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id LC5GjJSzNSl8qLC5GjoH6J; Sun, 05 Apr 2020 15:41:34 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1z3mHe0x876uqUqe9CQC3Ms5Is4LIfC0UR0/WtXAXKo=; b=v8ukB07dUAR2t0nDN6qkPCRSvF fK7HSyr+vC7UEmS3NCDKWGD2WPPcROajZZbOJGdWDoD0cc9y01yFGpazw39NLIWS2A9fuTWMeDcFN JYzhtEIHjN8dTmOIQK4DlDr/g; Received: from 174-16-110-145.hlrn.qwest.net ([174.16.110.145]:33442 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jLC5G-002Qdt-2e; Sun, 05 Apr 2020 14:41:34 -0600 From: Tom Tromey To: Tom Tromey Cc: vaag--- via Gdb-patches Subject: Re: [patch v2] Fix cyrillic symbols show in tui References: <20200331091638.1087-1-vaag@ispras.ru> <87o8sccw5l.fsf@tromey.com> <875zed9am0.fsf@tromey.com> X-Attribution: Tom Date: Sun, 05 Apr 2020 14:41:33 -0600 In-Reply-To: <875zed9am0.fsf@tromey.com> (Tom Tromey's message of "Sun, 05 Apr 2020 10:10:47 -0600") Message-ID: <871rp18y2q.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 174.16.110.145 X-Source-L: No X-Exim-ID: 1jLC5G-002Qdt-2e X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 174-16-110-145.hlrn.qwest.net (bapiya) [174.16.110.145]:33442 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Apr 2020 20:41:37 -0000 >>>>> "Tom" == Tom Tromey writes: Tom> 1. Use waddnstr or mvaddnstr to limit how many characters are emitted. Tom> To do this, I suppose that do_tui_putc would have to be reimplemented Tom> (to fix the \t hack), and also tui_puts_internal would have to be Tom> changed so that it does not emit a single character at a time. Tom> Instead, tui_puts_internal would be changed to emit strings of Tom> characters (limited to the remaining horizontal space), then check Tom> the column to see where the cursor ended up. Maybe we don't need the do_tui_putc change. I'm not totally sure yet. Could you try this? Tom diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index b5ee2a2b6b6..92a10420a5c 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -438,42 +438,90 @@ tui_write (const char *buf, size_t length) static void tui_puts_internal (WINDOW *w, const char *string, int *height) { - char c; int prev_col = 0; bool saw_nl = false; + /* Once we run off the end of the window, we keep processing escape + sequences, but otherwise suppress output. */ + bool suppressing = false; + int max_col = getmaxx (w); - while ((c = *string++) != 0) + while (true) { - if (c == '\n') - saw_nl = true; + const char *next = strpbrk (string, "\n\1\2\033\t"); - if (c == '\1' || c == '\2') + /* Print the plain text prefix, stopping at the window + boundary. */ + size_t n_chars = next == nullptr ? strlen (string) : next - string; + if (!suppressing && n_chars > 0) { - /* Ignore these, they are readline escape-marking - sequences. */ - } - else - { - if (c == '\033') + int col = getcurx (w); + waddnstr (w, string, std::min (n_chars, (size_t) (max_col - col))); + if (getcurx (w) == 0) { - size_t bytes_read = apply_ansi_escape (w, string - 1); - if (bytes_read > 0) - { - string = string + bytes_read - 1; - continue; - } + /* We wrapped. */ + suppressing = true; } - do_tui_putc (w, c); + } - if (height != nullptr) + if (height != nullptr) + { + int col = getcurx (w); + if (col <= prev_col) + ++*height; + prev_col = col; + } + + /* We finished. */ + if (next == nullptr) + break; + + switch (*next) + { + case '\1': + case '\2': + /* Ignore these, they are readline escape-marking + sequences. */ + ++next; + break; + + case '\n': + saw_nl = true; + if (suppressing) { - int col = getcurx (w); - if (col <= prev_col) - ++*height; - prev_col = col; + /* The cursor is already on the next line and there's + nothing to do. */ + suppressing = false; } + else + do_tui_putc (w, '\n'); + ++next; + break; + + case '\t': + do_tui_putc (w, '\t'); + ++next; + break; + + case '\033': + { + size_t bytes_read = apply_ansi_escape (w, next); + if (bytes_read > 0) + next += bytes_read; + else + { + /* Just drop the escape. */ + ++next; + } + } + break; + + default: + gdb_assert_not_reached ("missing case in tui_puts_internal"); } + + string = next; } + if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) update_cmdwin_start_line (); if (saw_nl) diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index b5ba59e2f7a..d2bdd9ed1f2 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -39,6 +39,7 @@ #include "tui/tui-source.h" #include "tui/tui-disasm.h" #include "gdb_curses.h" +#include "safe-ctype.h" /* Function to display the "main" routine. */ void @@ -131,7 +132,7 @@ tui_copy_source_line (const char **ptr, int line_no, int first_col, { /* Nothing. */ } - else if (c < 040 && c != '\t') + else if (ISCNTRL (c) && c != '\t') { result.push_back ('^'); result.push_back (c + 0100);