[PATCH v2 00/36] expo: Support editing lines of text
Simon Glass
sjg at chromium.org
Mon Oct 2 03:13:04 CEST 2023
So far expo only supports menus. These are quite flexible for various
kinds of settings, but cannot deal with free-form input, such as a
serial number or a machine name.
This series adds support for a textline object, which is a single line
of text. It has a maximum length and its value is stored within the expo
structure.
U-Boot already has a command-line editor which provides most of the
features needed by expo. But the code runs in its own loop and only
returns when the line is finished. This is not suitable for expo, which
must handle a keypress at a time, returning to its caller after each
one.
In order to use the CLI code, some significant refactoring is included
here. This mostly involves moving the internal loop of the CLI to a
separate function and recording its state in a struct, just as was done
for single keypresses some time back. A minor addition is support for
Ctrl-W to delete a word, since strangely this is currently only present
in the simple version.
The video-console system provides most of the features needed by
testline, but a few things are missing. This series provides:
- primitive cursor support so the user can see where he is typing
- saving and restoring of the text-entry context, so that expo can allow
the user to continue where he left off, including deleting previously
entered characters correctly (for Truetype)
- obtaining the nominal width of a string of n characters, so that a
suitable width can be chosen for the textline object
Note that no support is provided for clearing the cursor. This was
addressed in a previous series[1] which could perhaps be rebased. For
this implementation, the cursor is therefore not enabled for the normal
command line, only for expo.
Reading and writing textline objects is supported for FDT and
environment, but not for CMOS RAM, since it would likely use too much
RAM to store a string.
In terms of code size, the overall size increase is 180 bytes for
Thumb02 boards, 160 of whcih is the addition of Ctrl-W to delete a word.
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=280178&state=*
Changes in v2:
- Drop blank line at end of help
- Drop trailing ;
- Correct variable declaration in switch() to make clang happy
Simon Glass (36):
cli: Move simple readline into a function
cli: Add a command to show cmdline history
cli: Drop some #ifdefs in cli_readline
cli: Drop #ifdefs for CONFIG_AUTO_COMPLETE in cli_readline
cli: Implement delete-word in cread_line()
cli: Use unsigned int instead of unsigned long
cli: Convert cread_line() to use a struct for the main vars
cli: Unindent some code in cread_line()
cli: Create a function to process characters
cli: Terminate the string in cread_line_process_ch()
cli: Allow history to be disabled
cli: Allow command completion to be disabled
cli: Add a function to set up a new cread
video: Allow obtaining the nominal size of a string size
video: Allow saving and restoring text-entry state
video: Export vidconsole_entry_start()
video: Support showing a cursor
expo: Add better error reporting
expo: Fix up comments for get_cur_menuitem_text() et al
expo: Use switch statements more for object types
expo: Correct some swallowed errors in scene
expo: Correct the logic for duplicate-ID detection
expo: Allow highlighting other scene-object types
expo: Add a function to write a property to a devicetree
expo: Make calculation of an object bounding box generic
expo: Allow rendering the background of any object
expo: Add some scene fields needed for text entry
expo: Add basic support for textline objects
expo: Support opening a textline
expo: Plumb in textlines to a scene
video: Mark truetype_measure() static
expo: Support handling any key in cedit
expo: Plumb in textline to cedit
expo: Support building an expo with a textline
expo: Update tests to include textline
expo: Update documentation to include textline
arch/sandbox/dts/cedit.dtsi | 8 +
boot/Makefile | 3 +-
boot/cedit.c | 198 ++++++++---
boot/expo_build.c | 102 +++++-
boot/scene.c | 237 +++++++++++--
boot/scene_internal.h | 128 ++++++-
boot/scene_menu.c | 68 +---
boot/scene_textline.c | 229 +++++++++++++
cmd/Kconfig | 7 +
cmd/Makefile | 1 +
cmd/history.c | 23 ++
common/cli_readline.c | 498 ++++++++++++++++------------
doc/develop/cedit.rst | 3 +-
doc/develop/expo.rst | 48 ++-
doc/usage/cmd/history.rst | 67 ++++
doc/usage/index.rst | 1 +
drivers/video/console_core.c | 31 ++
drivers/video/console_normal.c | 29 ++
drivers/video/console_truetype.c | 191 ++++++++++-
drivers/video/vidconsole-uclass.c | 71 +++-
drivers/video/vidconsole_internal.h | 24 ++
include/cli.h | 51 +++
include/command.h | 6 +
include/expo.h | 60 +++-
include/menu.h | 7 +-
include/test/cedit-test.h | 5 +-
include/video_console.h | 123 +++++++
test/boot/cedit.c | 30 +-
test/boot/expo.c | 2 +-
test/boot/files/expo_ids.h | 3 +
test/boot/files/expo_layout.dts | 8 +
test/cmd/Makefile | 1 +
test/cmd/history.c | 49 +++
33 files changed, 1935 insertions(+), 377 deletions(-)
create mode 100644 boot/scene_textline.c
create mode 100644 cmd/history.c
create mode 100644 doc/usage/cmd/history.rst
create mode 100644 test/cmd/history.c
--
2.42.0.582.g8ccd20d70d-goog
More information about the U-Boot
mailing list