From be5c2edd10cc0c5c1b938fc03bc7e7c35801a0bd Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 1 Oct 2023 19:13:11 -0600 Subject: cli: Convert cread_line() to use a struct for the main vars We want to reuse the editing code elsewhere. As a first step, move the common variables into a struct. This will allow us to eventually put the contents of the inner loop in a function, so it can be called from elsewhere. Signed-off-by: Simon Glass --- include/cli.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/cli.h') diff --git a/include/cli.h b/include/cli.h index ac09c80c784..1bc1ab8035c 100644 --- a/include/cli.h +++ b/include/cli.h @@ -8,6 +8,7 @@ #define __CLI_H #include +#include /** * struct cli_ch_state - state information for reading cmdline characters @@ -24,6 +25,19 @@ struct cli_ch_state { bool emitting; }; +/** + * struct cli_line_state - state of the line editor + * + * @num: Current cursor position, where 0 is the start + * @eol_num: Number of characters in the buffer + * @insert: true if in 'insert' mode + */ +struct cli_line_state { + uint num; + uint eol_num; + bool insert; +}; + /** * Go into the command loop * -- cgit v1.2.3