summaryrefslogtreecommitdiff
path: root/common/cli_readline.c
AgeCommit message (Collapse)Author
2023-03-28cli: Correct handling of invalid escape sequences in cread_line()Simon Glass
The second call to cli_ch_process() is in the wrong place, meaning that the one of the characters of an invalid escape sequence is swallowed instead of being returned. Fix the bug and add a test to cover this. This behaviour matches that of the code before cli_getch() was introduced. This was verified on the commit before b08e9d4b66 i.e.: 7d850f85aad ("sandbox: Enable mmc command and legacy images") Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-01-16cli: Move readline character-processing to a state machineSimon Glass
The current cread_line() function is very long. It handles the escape processing inline. The menu command does similar processing but at the character level, so there is some duplication. Split the character processing into a new function cli_ch_process() which processes individual characters and returns the resulting input character, taking account of escape sequences. It requires the caller to set up and maintain its state. Update cread_line() to use this new function. The only intended functional change is that an invalid escape sequence does not add invalid/control characters into the input buffer, but instead discards these. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-21Revert "cli_readline: Only insert printable chars"Pali Rohár
This reverts commit d2e64d29c44dee6d455f7705dd1cf1af8674ad9a. This commit broke support for pound sign (£) and euro sign (€) keys on Nokia N900 keypad. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-18cyclic: Use schedule() instead of WATCHDOG_RESET()Stefan Roese
Globally replace all occurances of WATCHDOG_RESET() with schedule(), which handles the HW_WATCHDOG functionality and the cyclic infrastructure. Signed-off-by: Stefan Roese <sr@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Tom Rini <trini@konsulko.com> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
2022-09-15cli: Reduce size of readline buffers in SPLSean Anderson
Normally, readline is not used int SPL. However, it may be useful to enable the Freescale DDR interactive mode in SPL, while U-Boot is still executing from SRAM. The default settings for readline result in a large buffer being allocated. Reduce the size of the maximum input line, and the number of lines of scrollback when building for SPL. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-07-18cli: support bracketed pasteHeinrich Schuchardt
Some consoles use CSI 200~ and CSI 201~ to bracket inserts. This leads U-Boot to misinterpret the inserted string. Ignore these escape sequences. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-01-16cli_readline: Only insert printable charsSteve Bennett
There should be no need to insert non-printable characters and this prevents line editing getting confused. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-10-22common: rename getc() to getchar()Heinrich Schuchardt
The sandbox is built with the SDL2 library with invokes the X11 library which in turn calls getc(). But getc() in glibc is defined as int getc(FILE *) This does not match our definition. int getc(void) The sandbox crashes when called with parameter -l. Rename our library symbol getc() to getchar(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-05-18command: Remove the cmd_tbl_t typedefSimon Glass
We should not use typedefs in U-Boot. They cannot be used as forward declarations which means that header files must include the full header to access them. Drop the typedef and rename the struct to remove the _s suffix which is now not useful. This requires quite a few header-file additions. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-12-02common: Move get_ticks() function out of common.hSimon Glass
This function belongs in time.h so move it over and add a comment. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-12-02Drop CONFIG_SHOW_ACTIVITYSimon Glass
This feature is not enabled by any board. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-10cli: handle getch errorPatrick Delaunay
Handle getch error (when getch return 0x0) to avoid display issue in the console. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2016-08-20common: cli_readline: Improve command line editingJames Byrne
This improves the cread_line() function so that it will correctly process the 'Home', 'End', 'Delete' and arrow key escape sequences produced by various terminal emulators. This makes command line editing a more pleasant experience. The previous code only supported the cursor keys and the 'Home' key, and only for certain terminal emulator configurations. This adds support for the 'End and 'Delete' keys, and recognises a wider range of escape sequences. For example, the left arrow key can be 'ESC O D' instead of 'ESC [ D', and the 'Home' key can be 'ESC [ H', 'ESC O H', 'ESC 1 ~' or 'ESC 7 ~', depending on what terminal emulator you use and how it is configured. Signed-off-by: James Byrne <james.byrne@origamienergy.com> Changes for v2 - Explicitly initialize variable to avoid spurious compiler warning. Changes for v3 - Remove unnecessary setting of 'act' to ESC_REJECT (now its default value).
2015-08-12spl, common, serial: build SPL without serial supportHeiko Schocher
This patch enables building SPL without CONFIG_SPL_SERIAL_SUPPORT support. Signed-off-by: Heiko Schocher <hs@denx.de> [trini: Ensure we build arch/arm/imx-common on mx28] Signed-off-by: Tom Rini <trini@konsulko.com>
2014-05-29Move bootretry code into bootretry.c and clean upSimon Glass
This code is only used by one board, so it seems a shame to clutter up the readline code with it. Move it into its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Add cli_ prefix to readline functionsSimon Glass
This makes it clear where the code resides. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-29Split out simple parser and readline into separate filesSimon Glass
It doesn't make sense to have the simple parser and the readline code all in main. Split them out into separate files. Signed-off-by: Simon Glass <sjg@chromium.org>