From patchwork Fri Sep 19 20:14:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 375 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313036; bh=pwGVARoM1LmKilZX7Sj6k5f5jQylW0Z+YlCgPW7MQO4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=bu5kXW2OUqGb/S9cLoXESDkHBKzCSolfu3oc9TBU3ND5DTILuRmKTfrFuxbAj+omE ZRf8IOEM9EdVJqhxKHbCKWTZV8JGTdOoefRr9n422WZqH4491iPgRbxWy+5g9UKR7Q YbITf1PaZGSqIdhqaDwxCR3CbcZJu2IB3F4KdPEW/HD/RbwzUsFIUYf/W4TTIWq6NS ymK2nmGoPzlvAzqABBGfML57KtU+YMpfXeVMwrObttPPBlac7oOzwhmm+KOcrTgcXB tJUXgG/atLZsYMydYTPkjwsktIpWllp6SLDWcuYRfirzqk/xHR8w5fjhdqxAyaTwr1 i+0o5WUskaRog== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D811567C8C for ; Fri, 19 Sep 2025 14:17:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BriK3xeayx1O for ; Fri, 19 Sep 2025 14:17:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313034; bh=pwGVARoM1LmKilZX7Sj6k5f5jQylW0Z+YlCgPW7MQO4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XlyszUXcXzHmTTfxd5dn9Jbv6/Ni7q0bL9IEdrAqZVGuApgnfE8QE67jsq8vjgQwX YtTG3ywEwisZREkRcLpFrvzRD3jhdBtRAgRuOwQpSVNFK5mCfbA/xoclJoVSlfUxiL VibwaUmkU0mX6p8DXvOhuuvzMBGKqlNWI+6fZXTDuJN4l098/RMebWXM2l0VuKXcoI jrChUWqHjP+h5tsaE223GwwKPD1mUJXTT4FhB3YpCDLVa4kTPhYeLFL5liuQXMFxkC TKo5kvhKhiETz8xaHEmp7NDOY2hqk4JqDRWtxZG+W7fF1e3ToxB8VQLU7zeSjCcgAB tASt75nTtzasQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA96067C81 for ; Fri, 19 Sep 2025 14:17:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313032; bh=LGrdsajODZhUXJkQmuLq1c0AnDiODYqBM5zhNndwT/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/TC4X30Xedj4DNpXjGpIc0DuTH6Ojev6QAOOGAmJsOI9/ZaehQB5r+GL3FijhKiy uS9xFZRkqH+KYYTFIYZSH6B84P+3Cie5lleg8W4YEyr1SAtLCcjhXV8pEx3B6Dz9kB +qlf6zUZwYWlyFiZlEk6zlQbCqgSCMC1thJEbZgmZs+QYL6uMuKz3husmX+SiURrDi 3HvrT6AegqnUiG6RG3LXRVfSx6VTvK428759ZE66T5UZj+BrDME9ZFQSFk2H+xKOFg ce2EQg2txW85YyCI7LO/W8eIgCVXvaVEQIsvpTnZyWiXOFQeo9vdKA/OrLMr0kc60z 35M/AxhDL+FVQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1ABDF67A99; Fri, 19 Sep 2025 14:17:12 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 4QJr8viukK8o; Fri, 19 Sep 2025 14:17:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313031; bh=pkmgTo/evbBv0kqOnAkFoqLPnCzpi8bC6gdMFBB14GM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dSGKfipzoYdIWAXF0LxdbI8AmpaZHHUcYpRZsSKgxb5kDW9t0IJEXFHUT0bE+rcHh EPaLJfRkqAe+trzNpoGunytoUImuBEc0neXNjK5b53WvbDwo2VUCnUEwlMmCQNoWsc Y/i2RkYHHJlya/8g0P0uYlYFrocik4DcG0iybzlfJRju4eibIlwx3F/jjVGRDnM9d3 EsOhuzHrRizyl4Y1uQ4jbJB/x5Vc6jZzlwjhcv4VCCaRTBys23xm/OnwiID63af7og YIWRy60iZAEH/WA+++GJIVscvZLfay305aNVuzm2G9Clz6X3y1pFRrl/yEVXfaYLqO utIcjQm3Nm1wA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7ACF267C06; Fri, 19 Sep 2025 14:17:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:40 -0600 Message-ID: <20250919201507.4024144-34-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250919201507.4024144-1-sjg@u-boot.org> References: <20250919201507.4024144-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JBPPSMBUZJLAJJP2IPVTHG4HMTTBXT4G X-Message-ID-Hash: JBPPSMBUZJLAJJP2IPVTHG4HMTTBXT4G X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 33/42] video: Support a cursor in multi-line text List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass For expo, lineedit only supports a single line. For the CLI, the text can extend across multiple lines. Add support for this in the normal console, calculating the x and y offset of the cursor position based on the display width and font size. The truetype console already works, since it has had this tracking for a while. Signed-off-by: Simon Glass --- drivers/video/console_normal.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 5ef1cb1c68f..8f936191dd8 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -88,7 +88,7 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev) struct console_simple_priv *priv = dev_get_priv(dev); struct video_fontdata *fontdata = priv->fontdata; struct vidconsole_cursor *curs = &vc_priv->curs; - int x, y, index; + int x, y, index, xspace, xpos; /* for now, this is not used outside expo */ if (!IS_ENABLED(CONFIG_EXPO)) @@ -97,7 +97,30 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev) x = VID_TO_PIXEL(vc_priv->xmark_frac); y = vc_priv->ymark; index = vc_priv->cli_index; - x += index * fontdata->width; + + /* rounded up character position in this line */ + xpos = (x + vc_priv->x_charsize - 1) / vc_priv->x_charsize; + + /* number of characters which can fit on this (first) line */ + xspace = vc_priv->cols - xpos; + + if (!curs->indent && index > xspace) { + /* move to the next line */ + y += vc_priv->y_charsize; + index -= xspace; + + /* figure out the available space in subsequent lines */ + if (!curs->indent) { + xspace = vc_priv->cols; + x = 0; + } + + /* calculate the line based on that */ + y += index / xspace; + x += (index % xspace) * fontdata->width; + } else { + x += index * fontdata->width; + } /* place the cursor 1 pixel before the start of the next char */ if (x > 0) @@ -107,7 +130,7 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev) curs->x = x; curs->y = y; curs->height = vc_priv->y_charsize; - curs->index = index; + curs->index = vc_priv->cli_index; return 0; }