summaryrefslogtreecommitdiffstats
path: root/lib/readline.c
Commit message (Collapse)AuthorAgeFilesLines
* readline: Complete strings containing whitespaces correctlySascha Hauer2022-10-271-1/+6
| | | | | | | | | | | Completion strings containing whitespaces have to end up as a single argv[] argument, thus the whitespaces have to be escaped. Fix this. Ideally the whitespaces should only be escaped when we are outside of double or single quotes, but our completion currently doesn't trigger at all when invokes inside quotes, so we can ignore this case for now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: add SPDX-License-Identifier for files without explicit licenseAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: poller: replace explicit calls to poller_call() with resched()Ahmad Fatoum2021-03-171-2/+2
| | | | | | | | | | | We won't replace pollers with bthreads completely over night. To make migration easier, replace explicit calls to poller_call with a new resched() function. This can be made to call bthread_reschedule() in future and eventually replaced with bthread_reschedule() once pollers are removed. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: Switch to workqueuesSascha Hauer2020-08-131-5/+1
| | | | | | | This switches running barebox commands in ratp to a context where it's safe to do so: In a work queue. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: make ctrl-u to work like linux consoleDU HUANPENG2019-10-181-0/+8
| | | | | | | | | currtly, the ctrl-u discards the whole line, in most linux boxes, ctrl-u just erase characters before cursor to the begginning of the line. this patch make ctrl-u to do this. Signed-off-by: DU HUANPENG <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: add ctrl-u (unix-line-discard)Robert Karszniewicz2019-02-051-0/+1
| | | | | Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: allow building without full console supportAleksander Morgado2018-03-011-1/+1
| | | | | | | | | | | | | Make CONFIG_RATP a selectable config option, so that the user can enable RATP support without explicitly needing to enable the full console support over RATP (e.g. only for RATP FS or built-in command support). The full console can still be explicitly enabled with CONFIG_CONSOLE_RATP. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ratp: move barebox-specific command to ratp_bb.hAleksander Morgado2018-01-301-2/+2
| | | | | | | | | The ratp_run_command() is really an implementation detail of the barebox ratp 'command' operation support. Move it to the barebox specific header and rename it with the correct prefix. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ratp'Sascha Hauer2016-02-081-0/+8
|\
| * barebox remote controlSascha Hauer2016-01-181-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability to control barebox over serial lines. The regular console is designed for human input and is unsuitable for controlling barebox from scripts since characters can be lost on both ends, the data stream contains escape sequences and the prompt cannot be easily matched upon. This approach is based on the RATP protocol. RATP packages start with a binary 0x01 which does not occur in normal console data. Whenever a 0x01 character is detected in the console barebox goes into RATP mode. The RATP packets contain a simple structure with a command/respone type and data for that type. Currently defined types are: BB_RATP_TYPE_COMMAND (host->barebox): Execute a command in the shell BB_RATP_TYPE_COMMAND_RETURN (barebox->host) Sends return value of the command back to the host, also means barebox is ready for the next command BB_RATP_TYPE_CONSOLEMSG (barebox->host) Console message from barebox Planned but not yet implemented are: BB_RATP_TYPE_PING (host->barebox) BB_RATP_TYPE_PONG (barebox->host) For testing purposes BB_RATP_TYPE_GETENV (host->barebox) BB_RATP_TYPE_GETENV_RETURN (barebox->host) Get values of environment variables Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* | readline: Fix potential buffer overflow in command historySascha Hauer2016-01-081-1/+2
| | | | | | | | | | | | | | Cursor up copies the last line into the buffer without checking if it fits into the current buffer. Fix this using safe_strncpy. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | readline: Fix potential buffer overflowSascha Hauer2016-01-081-1/+1
|/ | | | | | | cread_add_char doesn't take the trailing '\0' into account, so adding it at the end of readline can overflow the buffer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib: readline support ctrl-l to clear screenDu Huanpeng2015-11-171-0/+8
| | | | | | | | maybe it is easier to press ctrl-l to clear the screen than type 'clear' command. Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: Fix history prev when history is emptySascha Hauer2014-09-011-1/+5
| | | | | | | | | | | | | | | | We cannot use list_entry() on an empty list. Without history we have to return an empty line. This fixes a crash when the cursor up button is pressed and no command has been entered previously. Broken since: commit ada160a34a1ec8421d5bb7b9dd746294668a5130 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Tue Jul 29 11:54:26 2014 +0200 readline: reimplement history functions Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Teresa Gamez <t.gamez@phytec.de>
* readline: reimplement history functionsSascha Hauer2014-07-291-68/+54
| | | | | | | | | | | | | | This reimplements the history functions in readline. - Use regular lists instead of homegrown list implementation - Allocate history strings dynamically instead of copying strings to fixed buffers without checking the size - saves us an initcall - slightly smaller - no longer add duplicates to the history - when moving past the last history entry print an empty line Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* input: Add BB_ prefix to KEY_ definesSascha Hauer2014-02-171-13/+13
| | | | | | | Our KEY_ defines conflict with the standard Linux KEY_ defines, so add a BB_ prefix to them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: remove unused variableSascha Hauer2013-11-121-2/+1
| | | | | | 'rc' is never set to anything else than 0, so drop it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: fix the 'new blank line at EOF' typoAntony Pavlov2012-10-291-1/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: add ctrl-w handling (cut-the-last-word)Antony Pavlov2012-10-291-0/+10
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: move backspace key handling to the DO_BACKSPACE macroAntony Pavlov2012-10-291-10/+13
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* lib/readline.c: fix unused-but-set-variable gcc warningAntony Pavlov2011-07-041-2/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Silence few warnings.Krzysztof Halasa2010-12-211-2/+2
| | | | | Signed-off-by: Krzysztof HaƂasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: sparse fixesSascha Hauer2010-10-211-3/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Remove unnecessary casts in key definesSascha Hauer2009-12-181-3/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: Allow only ascii and printable charactersSascha Hauer2009-09-291-2/+4
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readline: Fix wrong screen reprinting. Try:Sascha Hauer2008-03-021-3/+3
| | | | abcde<BACKSPACE><HOME><DEL>
* readline: Fix a bug when tab completion is used in the middleSascha Hauer2008-03-021-4/+12
| | | | of the line.
* implement TAB completionSascha Hauer2008-03-011-0/+23
|
* implement delete key in readlinesascha2007-10-161-0/+12
|
* declare lots of functions staticSascha Hauer2007-09-281-5/+3
|
* - putc is now putchar for better standard conformitySascha Hauer2007-09-211-2/+2
| | | | - make printf return int
* svn_rev_643Sascha Hauer2007-07-051-0/+302
structure cleanup