From patchwork Fri Sep 19 20:14:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 364 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=1758313003; bh=hLV/GnZWPwDyFBf9mGkx8wmRamTwk+DnctcPqrE6FDk=; 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=RNU9QO7CEcah0VaWU7h6ubsJ/wxBZu53n+7QGREQgJTw/6fEwWOSfexJsl3ytvEdG /mDeq6xyuJkobIex1VekQdt2eIckOlrQqm96hnNa7ezuIGAi+pEGunxc8F8Dd5n6Kv 8R7SqexS3xwZF9zUWj5H4eTWAE8xBlfn5y2P9pVeDUhQnMtgriJyDan8dAhv80xLgF Yv7UfgQFVFVyMYvyHmBLMXAdqSWUWq15qTpNMJk+hTwjI8rDXVGVDCCxKlZZXRbPHF dgRo1SHOmlIdnO1xupH3Tba+Yt4s3HKQSppxAGOzAtuW6KL57k8X96EJ8hmPw84ij1 ni3hzyo5ouuzA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E653F67C20 for ; Fri, 19 Sep 2025 14:16:43 -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 mB01ktYmrsz2 for ; Fri, 19 Sep 2025 14:16:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313003; bh=hLV/GnZWPwDyFBf9mGkx8wmRamTwk+DnctcPqrE6FDk=; 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=RNU9QO7CEcah0VaWU7h6ubsJ/wxBZu53n+7QGREQgJTw/6fEwWOSfexJsl3ytvEdG /mDeq6xyuJkobIex1VekQdt2eIckOlrQqm96hnNa7ezuIGAi+pEGunxc8F8Dd5n6Kv 8R7SqexS3xwZF9zUWj5H4eTWAE8xBlfn5y2P9pVeDUhQnMtgriJyDan8dAhv80xLgF Yv7UfgQFVFVyMYvyHmBLMXAdqSWUWq15qTpNMJk+hTwjI8rDXVGVDCCxKlZZXRbPHF dgRo1SHOmlIdnO1xupH3Tba+Yt4s3HKQSppxAGOzAtuW6KL57k8X96EJ8hmPw84ij1 ni3hzyo5ouuzA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D412667B55 for ; Fri, 19 Sep 2025 14:16:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313001; bh=1qgzHuGewrVKWAKqJlgLqCmLIPwTAhY9g3/jKtOGDn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Icd6eYYLmk2mc6ClPUmHWTkU3nSWmNu456VA7CQ0GhrfqwThD1IhTPKYquwAilDft Dd0W+zQ+oGrWaPcx8yzMAj0ZataGLv6WkLPDvELzJd3a156MDuIJCUFKKSrj9OIu6J p1kL8LWNtdVjsJDvZfDncJpabS0b7h+PZVgvU2qfOUo4ffKJWSaRMsm9nGPun1JAFE S8mRb7D0zIgPHY0rna1WBS2bjZzWl6E3IiJd+UT/BX2ZgKsVtyrINi3o5KNAx5VDV9 BbJoPhHMq6BbRelbxku5I0SK7nhWA76Zzo/GJ3Ffm9QjAdhLM4jWe15CM4elo9Xh33 h/QpWUV1Vtv3A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BAA3A67BFC; Fri, 19 Sep 2025 14:16:41 -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 tKT2_TbhpIVx; Fri, 19 Sep 2025 14:16:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312994; bh=lB9pGGI+K7JVLC4Eqc48aqRoMa0qL6T8N4rDs/MCJRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I+xKsuT8MLRZ+XECzZBSEhNOEGx56JXrRKcZQQQaDPxqvUaFxxKPgME6O1EeBDJx8 82Gf8rF5mcAR625Jg4QVME4WKqLLd3fJPVcyAuc6ZHVFVUxvyuHyDWVhGhGRlpDDVN UnP06Q+Z7dbfSJcg+i/oZAv8/PJrOKDuHFmI3HMGkeN9yJG4KVxeka5umhAQ5xZGhd 6qGSL+URJaQGKBIrisuxKvB9VYVGChiPN0TeCrlmT6AhYRa2Pzeu3Z9QtDfTvZ08n2 kHsMfqpRoS9xqX6q/rK54ClmFga73GHndTgm1xGBbjEqbGksAzFAbcTZ9cMoGLkXE7 fflhl/3CHUXpg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 9E38A67A99; Fri, 19 Sep 2025 14:16:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:29 -0600 Message-ID: <20250919201507.4024144-23-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: JLM7BKZJCVSLEMA63TAPEGRVRNBN3TTZ X-Message-ID-Hash: JLM7BKZJCVSLEMA63TAPEGRVRNBN3TTZ 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 22/42] video: Track the current CLI index 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 Keep track of the current character index in the current CLI entry. This corresponds to the cursor position and is numbered from zero. Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 4 ++++ include/video_console.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 479793bc227..830e3ca306e 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -79,6 +79,9 @@ static int vidconsole_back(struct udevice *dev) if (priv->ycur < 0) priv->ycur = 0; } + assert(priv->cli_index); + cli_index_adjust(priv, -1); + return video_sync(dev->parent, false); } @@ -455,6 +458,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) priv->last_ch = ch; if (priv->xcur_frac >= priv->xsize_frac) vidconsole_newline(dev); + cli_index_adjust(priv, 1); return 0; } diff --git a/include/video_console.h b/include/video_console.h index d86cac42110..5074880c674 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -70,6 +70,7 @@ struct vidconsole_cursor { * @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units * @last_ch: Last character written to the text console on this line + * @cli_index: Character index into the CLI text (0=start) * @escape: TRUE if currently accumulating an ANSI escape sequence * @escape_len: Length of accumulated escape sequence so far * @col_saved: Saved X position, in fractional units (VID_TO_POS(x)) @@ -91,6 +92,7 @@ struct vidconsole_priv { int xsize_frac; int xstart_frac; int last_ch; + int cli_index; /* * ANSI escape sequences are accumulated character by character, * starting after the ESC char (0x1b) until the entire sequence @@ -474,6 +476,12 @@ static inline int vidconsole_set_cursor_visible(struct udevice *dev, } #endif /* CONFIG_CURSOR */ +static inline void cli_index_adjust(struct vidconsole_priv *priv, int by) +{ + if (CONFIG_IS_ENABLED(CURSOR)) + priv->cli_index += by; +} + /** * vidconsole_push_colour() - Temporarily change the font colour *