From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Mon, 11 Sep 2017 13:50:21 +0200 Subject: [U-Boot] [PATCH] dm: video: Add basic ANSI escape sequence support In-Reply-To: References: <20170907202816.18765-1-robdclark@gmail.com> Message-ID: <20170911135021.4a51dcb2@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Mon, 11 Sep 2017 05:42:01 -0400 Rob Clark wrote: > On Mon, Sep 11, 2017 at 2:18 AM, Simon Glass wrote: > > On 7 September 2017 at 14:28, Rob Clark wrote: > >> Really just the subset that is needed by efi_console. Perhaps more wi= ll > >> be added later, for example color support would be useful to implement > >> efi_cout_set_attribute(). > >> > >> Signed-off-by: Rob Clark > >> --- > >> drivers/video/vidconsole-uclass.c | 112 +++++++++++++++++++++++++++++= +++++++++ > >> drivers/video/video-uclass.c | 4 +- > >> include/video.h | 7 +++ > >> include/video_console.h | 11 ++++ > >> 4 files changed, 131 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidcons= ole-uclass.c > >> index e081d5a0ee..7998b4cf5f 100644 > >> --- a/drivers/video/vidconsole-uclass.c > >> +++ b/drivers/video/vidconsole-uclass.c > >> @@ -9,6 +9,7 @@ > >> */ > >> > >> #include > >> +#include > >> #include > >> #include > >> #include > >> @@ -107,12 +108,123 @@ static void vidconsole_newline(struct udevice *= dev) > >> video_sync(dev->parent); > >> } > >> > >> +/* > >> + * Parse a number from string that ends in a non-numeric character.. > >> + * sscanf() would be nice. This is just enough for parsing ANSI esca= pe > >> + * sequences. > >> + */ > >> +static char *parsenum(char *s, int *num) > > > > Can you use simple_strtoul() or similar? >=20 > Possibly, but I'm not sure it is a good idea.. I don't think escape > sequences are meant to be encoded with hex or octal number strings. > From a quick look, I don't see any escape code terminated with 'x', so > maybe it would end up working ok.. but something like ESC[0x1234m > should be an escape sequence terminated with x followed by normal > chars 1234m and strtoul would get that wrong.. >=20 stroul(s, NULL, 10) will only parse decimal numbers and stop at non-decimal digits. Lothar Wa=C3=9Fmann