From a34065606d81607214158d396161cffe2e2d828a Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Tue, 4 Dec 2012 11:50:19 +0000 Subject: CLI: Don't always start the CLI at column 0 If we print files with no newline then it looks better if the CLI prompt is printed immediately after the file content, rather than erasing the line and printing prompt at column 0. This mainly affects files with one line of text and no newline character. Signed-off-by: Matt Fleming --- com32/elflink/ldlinux/cli.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c index 472eb2f7..b94c6835 100644 --- a/com32/elflink/ldlinux/cli.c +++ b/com32/elflink/ldlinux/cli.c @@ -123,7 +123,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , { char cmdline[MAX_CMDLINE_LEN] = { }; int key, len, prev_len, cursor; - int redraw = 1; /* We enter with the menu already drawn */ + int redraw = 0; int x, y; bool done = false; const char *ret; @@ -142,6 +142,13 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , prev_len = 0; x = y = 0; + /* + * Before we start messing with the x,y coordinates print 'input' + * so that it follows whatever text has been written to the screen + * previously. + */ + eprintf("%s ", input); + while (!done) { if (redraw > 1) { /* Clear and redraw whole screen */ @@ -151,6 +158,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , if (pDraw_Menu) (*pDraw_Menu) (-1, top, 1); prev_len = 0; + eprintf("\033[2J\033[H"); // printf("\033[0m\033[2J\033[H"); } @@ -161,8 +169,6 @@ const char *edit_cmdline(const char *input, int top /*, int width */ , /* Redraw the command line */ eprintf("\033[?7l\033[?25l"); - if (y) - eprintf("\033[%dA", y); eprintf("\033[1G%s ", input); x = strlen(input); -- cgit v1.2.1