summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-01-21 08:02:38 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-01-21 08:02:38 -0600
commita34994e624fafe9b74411868519504e452246004 (patch)
tree2ca4a8c2bef7263d0cc3eb56c28f6a7a7858e4de
parent79b9a868c2e195afb30e234c8eb779a0b85150ce (diff)
downloadnuttx-a34994e624fafe9b74411868519504e452246004.tar.gz
nuttx-a34994e624fafe9b74411868519504e452246004.tar.bz2
nuttx-a34994e624fafe9b74411868519504e452246004.zip
VI: Turn off cursor when updating screen; eliminate some warnings
-rw-r--r--apps/system/vi/vi.c79
-rw-r--r--nuttx/include/nuttx/vt100.h11
2 files changed, 80 insertions, 10 deletions
diff --git a/apps/system/vi/vi.c b/apps/system/vi/vi.c
index c36067455..d580f57c6 100644
--- a/apps/system/vi/vi.c
+++ b/apps/system/vi/vi.c
@@ -240,19 +240,27 @@ static void vi_write(FAR struct vi_s *vi, FAR const char *buffer,
size_t buflen);
static void vi_putch(FAR struct vi_s *vi, char ch);
static char vi_getch(FAR struct vi_s *vi);
+#if 0 /* Not used */
static void vi_blinkon(FAR struct vi_s *vi);
+#endif
static void vi_attriboff(FAR struct vi_s *vi);
static void vi_boldon(FAR struct vi_s *vi);
static void vi_attriboff(FAR struct vi_s *vi);
static void vi_reverseon(FAR struct vi_s *vi);
static void vi_attriboff(FAR struct vi_s *vi);
+static void vi_cursoron(FAR struct vi_s *vi);
+static void vi_cursoroff(FAR struct vi_s *vi);
+#if 0 /* Not used */
static void vi_cursorhome(FAR struct vi_s *vi);
+#endif
static void vi_setcursor(FAR struct vi_s *vi, uint16_t row,
uint16_t column);
static void vi_clrtoeol(FAR struct vi_s *vi);
+#if 0 /* Not used */
static void vi_clrscreen(FAR struct vi_s *vi);
+#endif
-/* Error dispaly */
+/* Error display */
static void vi_error(FAR struct vi_s *vi, FAR const char *fmt, ...);
@@ -340,15 +348,27 @@ static void vi_showusage(FAR struct vi_s *vi, FAR const char *progname,
/* VT100 escape sequences */
+static const char g_cursoron[] = VT100_CURSORON;
+static const char g_cursoroff[] = VT100_CURSOROFF;
+#if 0 /* Not used */
static const char g_cursorhome[] = VT100_CURSORHOME;
+#endif
static const char g_erasetoeol[] = VT100_CLEAREOL;
+#if 0 /* Not used */
static const char g_clrscreen[] = VT100_CLEARSCREEN;
+#endif
static const char g_index[] = VT100_INDEX;
static const char g_revindex[] = VT100_REVINDEX;
static const char g_attriboff[] = VT100_MODESOFF;
static const char g_boldon[] = VT100_BOLD;
static const char g_reverseon[] = VT100_REVERSE;
+#if 0 /* Not used */
static const char g_blinkon[] = VT100_BLINK;
+static const char g_boldoff[] = VT100_BOLDOFF;
+static const char g_reverseoff[] = VT100_REVERSEOFF;
+static const char g_blinkoff[] = VT100_BLINKOFF;
+#endif
+
static const char g_fmtcursorpos[] = VT100_FMT_CURSORPOS;
/* Error format strings */
@@ -492,12 +512,14 @@ static char vi_getch(FAR struct vi_s *vi)
*
****************************************************************************/
+#if 0 /* Not used */
static void vi_blinkon(FAR struct vi_s *vi)
{
/* Send the VT100 BLINKON command */
vi_write(vi, g_blinkon, sizeof(g_blinkon));
}
+#endif
/****************************************************************************
* Name: vi_boldon
@@ -545,6 +567,36 @@ static void vi_attriboff(FAR struct vi_s *vi)
}
/****************************************************************************
+ * Name: vi_cursoron
+ *
+ * Description:
+ * Turn on the cursor
+ *
+ ****************************************************************************/
+
+static void vi_cursoron(FAR struct vi_s *vi)
+{
+ /* Send the VT100 CURSORON command */
+
+ vi_write(vi, g_cursoron, sizeof(g_cursoron));
+}
+
+/****************************************************************************
+ * Name: vi_cursoroff
+ *
+ * Description:
+ * Turn off the cursor
+ *
+ ****************************************************************************/
+
+static void vi_cursoroff(FAR struct vi_s *vi)
+{
+ /* Send the VT100 CURSOROFF command */
+
+ vi_write(vi, g_cursoroff, sizeof(g_cursoroff));
+}
+
+/****************************************************************************
* Name: vi_cursorhome
*
* Description:
@@ -552,12 +604,14 @@ static void vi_attriboff(FAR struct vi_s *vi)
*
****************************************************************************/
+#if 0 /* Not used */
static void vi_cursorhome(FAR struct vi_s *vi)
{
/* Send the VT100 CURSORHOME command */
vi_write(vi, g_cursorhome, sizeof(g_cursorhome));
}
+#endif
/****************************************************************************
* Name: vi_setcursor
@@ -607,12 +661,14 @@ static void vi_clrtoeol(FAR struct vi_s *vi)
*
****************************************************************************/
+#if 0 /* Not used */
static void vi_clrscreen(FAR struct vi_s *vi)
{
/* Send the VT100 CLRSCREEN command */
vi_write(vi, g_clrscreen, sizeof(g_clrscreen));
}
+#endif
/****************************************************************************
* Name: vi_scrollup
@@ -1472,9 +1528,12 @@ static void vi_showtext(FAR struct vi_s *vi)
endrow--;
}
- /* Make sure that all character attributes are disabled. */
+ /* Make sure that all character attributes are disabled; Turn off the
+ * cursor during the update.
+ */
vi_attriboff(vi);
+ vi_cursoroff(vi);
/* Write each line to the display, handling horizontal scrolling and
* tab expansion.
@@ -1572,6 +1631,10 @@ static void vi_showtext(FAR struct vi_s *vi)
vi_setcursor(vi, row, 0);
vi_clrtoeol(vi);
}
+
+ /* Turn the cursor back on */
+
+ vi_cursoron(vi);
}
/****************************************************************************
@@ -2035,10 +2098,6 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
}
break;
- case KEY_CMDMODE_REDRAW: /* Redraws the screen */
- case KEY_CMDMODE_REDRAW2: /* Redraws the screen, removing deleted lines */
- break; /* Not implemented */
-
case KEY_CMDMODE_DEL: /* Delete N characters at the cursor */
case ASCII_DEL:
{
@@ -2085,9 +2144,6 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
}
break;
- case KEY_CMDMODE_MARK: /* Place a mark beginning at the current cursor position */
- break; /* Not implemented */
-
case KEY_CMDMODE_REPLACECH: /* Replace character(s) under cursor */
{
vi_setmode(vi, SUBMODE_REPLACECH, vi->value);
@@ -2173,6 +2229,11 @@ static void vi_cmd_mode(FAR struct vi_s *vi)
}
break;
+ /* Uimplemented and invalid commands */
+
+ case KEY_CMDMODE_REDRAW: /* Redraws the screen */
+ case KEY_CMDMODE_REDRAW2: /* Redraws the screen, removing deleted lines */
+ case KEY_CMDMODE_MARK: /* Place a mark beginning at the current cursor position */
default:
{
VI_BEL(vi);
diff --git a/nuttx/include/nuttx/vt100.h b/nuttx/include/nuttx/vt100.h
index 4ee3a73b3..b74b9b7a2 100644
--- a/nuttx/include/nuttx/vt100.h
+++ b/nuttx/include/nuttx/vt100.h
@@ -86,16 +86,25 @@
#define VT100_SETSS3 {ASCII_ESC, 'O'} /* Set single shift 3 */
#define VT100_MODESOFF {ASCII_ESC, '[', 'm'} /* Turn off character attributes */
-#define VT100_MODESOFF_ {ASCII_ESC, '[', '0', 'm'} /* Turn off character attributes */
+#define VT100_MODESOFF2 {ASCII_ESC, '[', '0', 'm'} /* Turn off character attributes */
#define VT100_BOLD {ASCII_ESC, '[', '1', 'm'} /* Turn bold mode on */
#define VT100_LOWINT {ASCII_ESC, '[', '2', 'm'} /* Turn low intensity mode on */
#define VT100_UNDERLINE {ASCII_ESC, '[', '4', 'm'} /* Turn underline mode on */
#define VT100_BLINK {ASCII_ESC, '[', '5', 'm'} /* Turn blinking mode on */
#define VT100_REVERSE {ASCII_ESC, '[', '7', 'm'} /* Turn reverse video on */
#define VT100_INVISIBLE {ASCII_ESC, '[', '8', 'm'} /* Turn invisible text mode on */
+#define VT100_BOLDOFF {ASCII_ESC, '[', '2', '2', 'm'} /* Turn bold off */
+#define VT100_UNDERLINEOFF {ASCII_ESC, '[', '2', '4', 'm'} /* Turn underline off */
+#define VT100_BLINKOFF {ASCII_ESC, '[', '2', '5', 'm'} /* Turn blink off */
+#define VT100_REVERSEOFF {ASCII_ESC, '[', '2', '7', 'm'} /* Turn reverse video off */
#define VT100_SETWIN(t,b) {ASCII_ESC, '[', (t), ';', (b), 'r'} /* Set top and bottom line#s of a window */
+#define VT100_CURSOROFF {ASCII_ESC, '[', '?', '2', '5', 'l'} /* Cursor OFF */
+#define VT100_CURSORON {ASCII_ESC, '[', '?', '2', '5', 'h'} /* Cursor ON */
+#define VT100_CURSOROFF2 {ASCII_ESC, '[', '?', '5', '0', 'l'} /* Cursor OFF */
+#define VT100_CURSORON2 {ASCII_ESC, '[', '?', '5', '0', 'h'} /* Cursor ON */
+
#define VT100_CURSORUP(n) {ASCII_ESC, '[', (n), 'A'} /* Move cursor up n lines */
#define VT100_CURSORDN(n) {ASCII_ESC, '[', (n), 'B'} /* Move cursor down n lines */
#define VT100_CURSORRT(n) {ASCII_ESC, '[', (n), 'C'} /* Move cursor right n lines */