summaryrefslogtreecommitdiff
path: root/apps/interpreters
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-03 09:52:31 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-03 09:52:31 -0600
commit653f9821770e0c1f81c83a6eb16d767fb9a35745 (patch)
treee0496da3c401dc61132cf2f2fc68d51083b7870a /apps/interpreters
parent83acc8b8a304ea02e954b033c706767e0f28a02e (diff)
downloadnuttx-653f9821770e0c1f81c83a6eb16d767fb9a35745.tar.gz
nuttx-653f9821770e0c1f81c83a6eb16d767fb9a35745.tar.bz2
nuttx-653f9821770e0c1f81c83a6eb16d767fb9a35745.zip
BAS: Remove some code that I removed too aggressively
Diffstat (limited to 'apps/interpreters')
-rw-r--r--apps/interpreters/bas/fs.c44
1 files changed, 41 insertions, 3 deletions
diff --git a/apps/interpreters/bas/fs.c b/apps/interpreters/bas/fs.c
index 12958240a..6fd731c20 100644
--- a/apps/interpreters/bas/fs.c
+++ b/apps/interpreters/bas/fs.c
@@ -78,6 +78,8 @@
#include <time.h>
#include <unistd.h>
+#include <nuttx/ascii.h>
+
#include "fs.h"
/****************************************************************************
@@ -279,32 +281,68 @@ static int edit(int chn, int onl)
return -1;
}
+ /* Check for the backspace charactor */
+
+ if (ch == ASCII_BS)
+ {
+ if (f->inCapacity)
+ {
#ifdef CONFIG_INTERPREPTER_BAS_VT100
- /* REVISIT: Use VT100 commands to erase */
+ /* REVISIT: Use VT100 commands to erase: Move cursor back and erase to the end of the line */
#warning Missing Logic
#else
- if ((f->inCapacity + 1) < sizeof(f->inBuf))
+ /* Use backspace to erase */
+
+ if (f->inBuf[f->inCapacity - 1] >= '\0' &&
+ f->inBuf[f->inCapacity - 1] < ' ')
+ {
+ FS_putChars(chn, "\b\b \b\b");
+ }
+ else
+ {
+ FS_putChars(chn, "\b \b");
+ }
+#endif
+ --f->inCapacity;
+ }
+ }
+
+ /* Is there space for another character in the buffer? */
+
+ else if ((f->inCapacity + 1) < sizeof(f->inBuf))
{
+ /* Yes.. Was this a new line character? */
+
if (ch != '\n')
{
+ /* No.. was this an ASCII control character? */
+
if (ch >= '\0' && ch < ' ')
{
+ /* Yes.. Echo control characters as escape sequences */
+
FS_putChar(chn, '^');
FS_putChar(chn, ch ? (ch + 'a' - 1) : '@');
}
else
{
+ /* No.. Just echo the character */
+
FS_putChar(chn, ch);
}
}
+
+ /* Should we echo newline characters? */
+
else if (onl)
{
FS_putChar(chn, '\n');
}
+ /* Put the raw character into the buffer in any event */
+
f->inBuf[f->inCapacity++] = ch;
}
-#endif
}
while (ch != '\n');