From patchwork Fri Sep 19 20:14:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 365 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=1758313006; bh=7VDSXlMgpFBhKG08yyJn/Ljrl/MunRulXadCID8lA3Y=; 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=aG1mEGmFnvm06Cbjk/YWH5/pLfcTZ+Rq2DQa+HfCVKM4wHTewrxsNBm2hrkyY9aQs VTYRaJKZKAQDkUmaTgWx5NSuCT1wydgk1XCxvT8iVKTyV0JAu2iP6vN/gf7ecdJgIu 8hljXVSvfXYM71sni+MxSU8OuIKHsF4blM8cZdbOultcMnXe60yf8EoOEhtfibS1gM kVfCkItfAMbDJGn/Iqc5XdiOLcVRCtMQwFekBU1UKyj3AmLNxrN66NSYk30JYLX3Q5 czAdrMdSgwMZSc06RrA58MaJ5pusP5KRATVKbMUyF5Ynx4dpk2UUsGR7S3kBlyToyH QVVo3KOruosVg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3368967B55 for ; Fri, 19 Sep 2025 14:16:46 -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 j8qERqVzyUqN for ; Fri, 19 Sep 2025 14:16:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313004; bh=7VDSXlMgpFBhKG08yyJn/Ljrl/MunRulXadCID8lA3Y=; 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=PWCYphveK4f0eSY9cZ0ZicmVvz6+1JYp+8UzAzLxbk0BQfi7cmivC15i8iF8FOBdn 8XWdlTBV04PrtS6fHrP/g531rXcooc5H5uofsB7knT1DyhGRx9T8BcDemhGwfZa5T7 rsndzzcHRs0xfaLiSK7Nf9pRM8SwS8SdCb7BJ91lQYl6328OvyWBIBUdj6GHW4uGkf LJ+BQAl/+54tNw7ZWJEi9M+bpYa3vvFc8ZWGIjXL+SNpVigIdXgYEm/p5Gv/E1aF3M oxdy72oFnm71z/iYnLgNVsQK2LfmeTVPfP4Im29Afv7nYm5nzUhAsWvTJVi7WuAlrN uS6Q89ka4//aw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A2C6767C20 for ; Fri, 19 Sep 2025 14:16:44 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313001; bh=E/VkZakmY+NPBRqFPsBay9ccPtLFNiECtdqjHbVRCnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UHHTMO/DmdFaFv/J90eGWSdU/cugss9Z6id7rCDlMohCRKK8uBQP9syk62z97DS+z /E/Qf2rrCemtuB/lbj4nA9HTtD0jwXskrpziDczrBwuSnZJmYLFQ0oTcIQ1z6/3DQe WNgX21wmjo6ylw/0aOYzKxE5WLFCBc+x9g76hi1zikgoWgfcsXV46WGn7hz/Ljxkmh NVMMvVDv9229eenEvg9ISl3J4TGtLUSLY/L/FCLajGOPGIYBjRSeZWrKiXA+QK+scU CLxkD6iDm4D2lwJzU5ONDERrDvL02MEFBHmk/RnIE6gaxu7yGV4T0yH/rcOXYjxxaX Z3gPw5M4dzI9w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C566F67A99; 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 tdVNxQdEcDKr; 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=1758312999; bh=GEM+PUyP9c88OyYjuvVx2LizPx/94nupYkVubxInvtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hn7cSzLaPX3dd/h8vlzRivj9kZNDJpvJ2bU1bCiL+EZP5kJqraJGDzMIGsEHvZB01 ozH1y7yT8H3IAB/aXRJ6mnTHyQavoFOACuGpClUAkKSLbI5iwwRwUoHpEmWkvvdyCp 7DebsYYsWRMSvlS4o0KBoj9QvvrpZp0C2cYqNukwj8VDRWYAogHoru0fZYjuFdpqC4 /IvUSrXfKMQt1w8TTIhzAFJkPMp53s7AuOl8yHVYYhUKxlQNruYgo/xZPSLhkCJjvr 3Xh5ruSZj9qz69bDXihNarvflxMnmdn0Yz1yp/oNAJ8OGIjK3LH7ptDaI5PlicKrOa +fM/oPdpHMTCA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4851067B3B; Fri, 19 Sep 2025 14:16:39 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:30 -0600 Message-ID: <20250919201507.4024144-24-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: LQB2SDNSLOATGKDEFTZQUIOALQMQ7M6B X-Message-ID-Hash: LQB2SDNSLOATGKDEFTZQUIOALQMQ7M6B 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 23/42] video: Provide a way to indicate the start of CLI entry 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 Add a new mark_start() method for the console, which indicates that the CLI prompt has been written to the display and any following characters will be user input. There are two cases to consider, tracked by an indent flag in struct vidconsole_cursor: - normal CLI entry where new lines start at the left of the console - expo entry where new lines start at the same position as the previous line (indent=true) Record this position in the uclass info, so it is available to console drivers. Signed-off-by: Simon Glass --- common/cli_readline.c | 5 ++++ drivers/video/vidconsole-uclass.c | 39 +++++++++++++++++++++++++++ include/video_console.h | 44 +++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/common/cli_readline.c b/common/cli_readline.c index 2326e4b4f37..dc27a962e9d 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -676,6 +677,8 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, if (prompt) puts(prompt); + /* tell the vidconsole the cursor is at its start position */ + vidconsole_readline_start(false); rc = cread_line(prompt, p, &len, timeout); rc = rc < 0 ? rc : len; @@ -686,5 +689,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, pager_set_bypass(gd_pager(), old_bypass); pager_reset(gd_pager()); + vidconsole_readline_end(); + return rc; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 830e3ca306e..0a7cf5ad81a 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -761,6 +761,25 @@ int vidconsole_set_cursor_visible(struct udevice *dev, bool visible, } #endif /* CONFIG_CURSOR */ +int vidconsole_mark_start(struct udevice *dev) +{ + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + struct vidconsole_ops *ops = vidconsole_get_ops(dev); + + priv->xmark_frac = priv->xcur_frac; + priv->ymark = priv->ycur; + priv->cli_index = 0; + if (ops->mark_start) { + int ret; + + ret = ops->mark_start(dev); + if (ret != -ENOSYS) + return ret; + } + + return 0; +} + void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg, enum colour_idx bg, struct vidconsole_colour *old) { @@ -884,3 +903,23 @@ void vidconsole_set_bitmap_font(struct udevice *dev, void vidconsole_idle(struct udevice *dev) { } + +#ifdef CONFIG_CURSOR +void vidconsole_readline_start(bool indent) +{ + struct uclass *uc; + struct udevice *dev; + + uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + + priv->curs.indent = indent; + vidconsole_mark_start(dev); + } +} + +void vidconsole_readline_end(void) +{ + /* TODO: mark the end */ +} +#endif /* CURSOR */ diff --git a/include/video_console.h b/include/video_console.h index 5074880c674..c5450f70c4d 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -30,6 +30,7 @@ enum { * vertical bar of width VIDCONSOLE_CURSOR_WIDTH shown in the foreground colour. * * @visible: cursor is currently visible + * @indent: indent subsequent lines to the same position as the first line * @x: cursor left X position in pixels * @y: cursor top Y position in pixels * @height: height of cursor in pixels @@ -37,6 +38,7 @@ enum { */ struct vidconsole_cursor { bool visible; + bool indent; /* filled in by get_cursor_info(): */ uint x; @@ -70,6 +72,8 @@ 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 + * @xmark_frac: X position of start of CLI text entry, in fractional units + * @ymark: Y position of start of CLI text * @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 @@ -92,6 +96,8 @@ struct vidconsole_priv { int xsize_frac; int xstart_frac; int last_ch; + int xmark_frac; + int ymark; int cli_index; /* * ANSI escape sequences are accumulated character by character, @@ -345,6 +351,17 @@ struct vidconsole_ops { */ int (*get_cursor_info)(struct udevice *dev, bool visible, uint x, uint y, uint index); + + /** + * mark_start() - Mark the current position as the state of CLI entry + * + * This indicates that a new CLI entry is starting, so the user will be + * entering characters from this point. The console can use this to set + * the beginning point for the cursor. + * + * @dev: Console device to use + */ + int (*mark_start)(struct udevice *dev); }; /* Get a pointer to the driver operations for a video console device */ @@ -461,6 +478,24 @@ int vidconsole_show_cursor(struct udevice *dev, uint x, uint y, uint index); */ int vidconsole_set_cursor_visible(struct udevice *dev, bool visible, uint x, uint y, uint index); + +/** + * vidconsole_readline_start() - Enable cursor for all video consoles + * + * Called at the start of command line input to show cursors on all + * active video consoles + * + * @indent: indent subsequent lines to the same position as the first line + */ +void vidconsole_readline_start(bool indent); + +/** + * vidconsole_readline_end() - Disable cursor for all video consoles + * + * Called at the end of command line input to hide cursors on all + * active video consoles + */ +void vidconsole_readline_end(void); #else static inline int vidconsole_show_cursor(struct udevice *dev, uint x, uint y, uint index) @@ -474,6 +509,15 @@ static inline int vidconsole_set_cursor_visible(struct udevice *dev, { return 0; } + +static inline void vidconsole_readline_start(bool indent) +{ +} + +static inline void vidconsole_readline_end(void) +{ +} + #endif /* CONFIG_CURSOR */ static inline void cli_index_adjust(struct vidconsole_priv *priv, int by)