diff options
author | sascha <sascha@nomad.localdomain> | 2007-10-16 22:35:42 +0200 |
---|---|---|
committer | sascha <sascha@nomad.localdomain> | 2007-10-16 22:35:42 +0200 |
commit | 288c97b89ca9c9a38dfd108495c6a1e83e21306a (patch) | |
tree | a1c60057760caaa29aa8ff672f2cf2a05ac97597 /commands | |
parent | a09b455fcefed0eac9670345e172da3224bb7f96 (diff) | |
download | barebox-288c97b89ca9c9a38dfd108495c6a1e83e21306a.tar.gz barebox-288c97b89ca9c9a38dfd108495c6a1e83e21306a.tar.xz |
editor: Do not use ansi code for screen scrolling by default.
Add an aliases 'sedit' which does this.
Diffstat (limited to 'commands')
-rw-r--r-- | commands/edit.c | 53 |
1 files changed, 37 insertions, 16 deletions
diff --git a/commands/edit.c b/commands/edit.c index fd9afba8a4..0795d88abc 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -118,28 +118,41 @@ static void refresh_line(struct line *line, int ypos) pos(cursx, cursy); } +/* + * Most sane terminal programs can do ansi screen scrolling. + * Unfortunately one of the most popular programs cannot: + * minicom. + * Grmpf! + */ +static int smartscroll = 0; + static void refresh(int full) { int i; struct line *l = scrline; if (!full) { - if (scrline->next == lastscrline) { - printf("%c[1T", 27); - refresh_line(scrline, 0); - pos(0, screenheight); - printf("%*s", screenwidth, ""); - return; - } + if (smartscroll) { + if (scrline->next == lastscrline) { + printf("%c[1T", 27); + refresh_line(scrline, 0); + pos(0, screenheight); + printf("%*s", screenwidth, ""); + return; + } - if (scrline->prev == lastscrline) { - printf("%c[1S", 27); - for (i = 0; i < screenheight - 1; i++) { - l = l->next; - if (!l) - return; + if (scrline->prev == lastscrline) { + printf("%c[1S", 27); + for (i = 0; i < screenheight - 1; i++) { + l = l->next; + if (!l) + return; + } + refresh_line(l, screenheight - 1); + return; } - refresh_line(l, screenheight - 1); + } else { + refresh(1); return; } } @@ -385,6 +398,9 @@ static int do_edit(cmd_tbl_t * cmdtp, int argc, char *argv[]) return 1; } + if (*argv[0] == 's') + smartscroll = 1; + buffer = NULL; if(edit_read_file(argv[1])) return 1; @@ -530,16 +546,21 @@ out: return 0; } +static char *edit_aliases[] = { "sedit", NULL}; + static __maybe_unused char cmd_edit_help[] = -"Usage: edit <file>\n" +"Usage: (s)edit <file>\n" "This is a very small editor. Its only features are moving the cursor with\n" "the usual keys and typing characters.\n" "<ctrl-c> quits the editor without saving,\n" -"<ctrl-d> quits the editor with saving the current file.\n"; +"<ctrl-d> quits the editor with saving the current file.\n" +"\n" +"If called as sedit the editor uses ansi codes to scroll the screen.\n"; U_BOOT_CMD_START(edit) .maxargs = 2, .cmd = do_edit, + .aliases = edit_aliases, .usage = "edit a file", U_BOOT_CMD_HELP(cmd_edit_help) U_BOOT_CMD_END |