From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from qproxy2-pub.mail.unifiedlayer.com (qproxy2-pub.mail.unifiedlayer.com [69.89.16.161]) by sourceware.org (Postfix) with ESMTPS id 1A0413858431 for ; Tue, 30 May 2023 17:03:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A0413858431 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by qproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id C9C618028A5C for ; Tue, 30 May 2023 17:03:34 +0000 (UTC) Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id BBD9A1004938B for ; Tue, 30 May 2023 17:03:04 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 42kSqeapHpMQl42kSqndco; Tue, 30 May 2023 17:03:04 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=XKv19StE c=1 sm=1 tr=0 ts=64762c48 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=P0xRbXHiH_UA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=nb3LwfCI8pomSnjbp6oA:9 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=Tk86Ux1arNY+LzY0WX5KP0fQXqK7eHRT1MGYZKn/HD0=; b=SwRniEe0mJMZYXAPPtK4kKJ/uk zoJ/2PJuFdAeHUBH4fSopcRvMqj2/lyFvdv3uAruz46PmwPxd4nICDN7FmV9DSA76K8AwXsMLUpBF zGVZTBvzQmFCz1imFqMop7C96; Received: from 71-211-130-244.hlrn.qwest.net ([71.211.130.244]:54236 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q42kS-0001VI-DB; Tue, 30 May 2023 11:03:04 -0600 From: Tom Tromey To: Tom de Vries via Gdb-patches Cc: Tom de Vries , Tom Tromey Subject: Re: [PATCH] [gdb/tui] Handle unicode chars in prompt References: <20230526132512.29496-1-tdevries@suse.de> <0c1512d8-0912-044d-6c12-ec93de068b87@suse.de> X-Attribution: Tom Date: Tue, 30 May 2023 11:03:03 -0600 In-Reply-To: <0c1512d8-0912-044d-6c12-ec93de068b87@suse.de> (Tom de Vries via Gdb-patches's message of "Fri, 26 May 2023 17:44:29 +0200") Message-ID: <875y89wy48.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (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: 71.211.130.244 X-Source-L: No X-Exim-ID: 1q42kS-0001VI-DB X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-130-244.hlrn.qwest.net (murgatroyd) [71.211.130.244]:54236 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3020.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >> In TUI, the prompt is written out by tui_puts_internal, which outputs one byte >> at a time using waddch, which apparantly breaks multi-byte char support. >> Fix this by detecting multi-byte chars in tui_puts_internal, and >> printing them using >> waddnstr. > FWIW, I just came across this commit, which seems relevant: Tom> Note that tui_puts_internal remains. It is needed to handle computing Tom> the start line of the readline prompt, which is difficult to do Tom> properly in the case where redisplaying can also cause the command Tom> window to scroll. This might be possible to implement by reverting to Tom> single "character" output, by using mbsrtowcs for its side effects to Tom> find character boundaries in the input. I have not attempted this. Tom> ... I no longer remember what made this difficult. I wonder if it's possible to simply emit as many characters as possible in a single call, and then use getyx to figure out the length of the prompt after it has been fully displayed. If the prompt wraps or if it takes multiple lines, offhand it seems fine to just pick whatever the final column happens to be. Using wchar functions in gdb is a pain; at least in the past, gdb_wchar.h was written to support systems that don't support these at all (DJGPP - not sure if that host even builds any more). Some characters may take multiple columns (see 'wcwidth'). I'd hope that the display-and-getyx approach would avoid having to have gdb understand this; though I suppose gdb's pager probably already gets this wrong. Tom