diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-12-04 11:50:19 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-12-04 11:50:19 +0000 |
commit | a34065606d81607214158d396161cffe2e2d828a (patch) | |
tree | f793adc16b7c57ffd0236402d0bb38e9b78ec8ec | |
parent | 82cbb1bd4133035fb37a753c15dfaa57e34db87f (diff) | |
download | syslinux-a34065606d81607214158d396161cffe2e2d828a.tar.gz syslinux-a34065606d81607214158d396161cffe2e2d828a.tar.xz syslinux-a34065606d81607214158d396161cffe2e2d828a.zip |
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 <matt.fleming@intel.com>
-rw-r--r-- | com32/elflink/ldlinux/cli.c | 12 |
1 files 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); |