From 5f43b6c815fbcd6b6f705a0c1a721624c9591805 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 20 Jan 2014 19:32:30 -0600 Subject: [PATCH] VI: Display origin for VT100 is (1,1), not (0,0) --- system/vi/.gitignore | 11 +++++++++++ system/vi/vi.c | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 system/vi/.gitignore diff --git a/system/vi/.gitignore b/system/vi/.gitignore new file mode 100644 index 000000000..83bd7b811 --- /dev/null +++ b/system/vi/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.obj diff --git a/system/vi/vi.c b/system/vi/vi.c index ab2669cee..83dbbb3b6 100644 --- a/system/vi/vi.c +++ b/system/vi/vi.c @@ -572,9 +572,9 @@ static void vi_setcursor(FAR struct vi_s *vi, uint16_t row, uint16_t column) vivdbg("row=%d column=%d\n", row, column); - /* Format the cursor position command */ + /* Format the cursor position command. The origin is (1,1). */ - len = snprintf(buffer, 16, g_fmtcursorpos, row, column); + len = snprintf(buffer, 16, g_fmtcursorpos, row + 1, column + 1); /* Send the VT100 CURSORPOS command */ @@ -1557,7 +1557,7 @@ static void vi_showtext(FAR struct vi_s *vi) /* If there was not enough text to fill the display, clear the * remaining lines (except for any possible error line at the - & bottom of the display). + * bottom of the display). */ for (; row < endrow; row++) @@ -1676,7 +1676,7 @@ static off_t vi_cursorleft(FAR struct vi_s *vi, off_t curpos, int ncolumns) vivdbg("curpos=%ld ncolumns=%d\n", curpos, ncolumns); - for (remaining = ncolumns < 1 ? 1 : ncolumns; + for (remaining = (ncolumns < 1 ? 1 : ncolumns); curpos > 0 && remaining > 0 && vi->text[curpos] != '\n'; curpos--, remaining--); @@ -1699,7 +1699,7 @@ static off_t vi_cursorright(FAR struct vi_s *vi, off_t curpos, int ncolumns) vivdbg("curpos=%ld ncolumns=%d\n", curpos, ncolumns); - for (remaining = ncolumns < 1 ? 1 : ncolumns; + for (remaining = (ncolumns < 1 ? 1 : ncolumns); curpos < vi->textsize && remaining > 0 && vi->text[curpos] != '\n'; curpos++, remaining--);