BAS: Add support for color command
This commit is contained in:
parent
7dc7e40796
commit
2d8f159dd5
@ -79,6 +79,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <nuttx/ascii.h>
|
#include <nuttx/ascii.h>
|
||||||
|
#include <nuttx/vt100.h>
|
||||||
|
|
||||||
#include "vt100.h"
|
#include "vt100.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
@ -102,6 +103,14 @@ static int g_used;
|
|||||||
static const int g_open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
|
static const int g_open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
|
||||||
static char g_errmsgbuf[80];
|
static char g_errmsgbuf[80];
|
||||||
|
|
||||||
|
#ifdef CONFIG_INTERPREPTER_BAS_VT100
|
||||||
|
static const uint8_t g_vt100_colormap[8] =
|
||||||
|
{
|
||||||
|
VT100_BLACK, VT100_BLUE, VT100_GREEN, VT100_CYAN,
|
||||||
|
VT100_RED, VT100_MAGENTA, VT100_YELLOW, VT100_WHITE
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -411,18 +420,28 @@ static int locate(int chn, int line, int column)
|
|||||||
static int colour(int chn, int foreground, int background)
|
static int colour(int chn, int foreground, int background)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_INTERPREPTER_BAS_VT100
|
#ifdef CONFIG_INTERPREPTER_BAS_VT100
|
||||||
/* REVISIT: Use VT100 commands to color */
|
if (foreground >= 0)
|
||||||
#warning Missing Logic
|
{
|
||||||
#endif
|
vt100_foreground_color(chn, foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (background >= 0)
|
||||||
|
{
|
||||||
|
vt100_background_color(chn, background);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
FS_errmsg = _("Set color operation no implemented");
|
FS_errmsg = _("Set color operation no implemented");
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int resetcolour(int chn)
|
static int resetcolour(int chn)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_INTERPREPTER_BAS_VT100
|
#ifdef CONFIG_INTERPREPTER_BAS_VT100
|
||||||
/* REVISIT: Use VT100 commands to reset color */
|
vt100_foreground_color(chn, VT100_DEFAULT);
|
||||||
#warning Missing Logic
|
vt100_background_color(chn, VT100_DEFAULT);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "fs.h"
|
||||||
#include "bas.h"
|
#include "bas.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -75,7 +75,9 @@ static const char g_reverseoff[] = VT100_REVERSEOFF;
|
|||||||
static const char g_blinkoff[] = VT100_BLINKOFF;
|
static const char g_blinkoff[] = VT100_BLINKOFF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char g_fmtcursorpos[] = VT100_FMT_CURSORPOS;
|
static const char g_fmt_cursorpos[] = VT100_FMT_CURSORPOS;
|
||||||
|
static const char g_fmt_forecolor[] = VT100_FMT_FORE_COLOR;
|
||||||
|
static const char g_fmt_backcolor[] = VT100_FMT_BACK_COLOR;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -235,7 +237,7 @@ void vt100_setcursor(int chn, uint16_t row, uint16_t column)
|
|||||||
|
|
||||||
/* Format the cursor position command. The origin is (1,1). */
|
/* Format the cursor position command. The origin is (1,1). */
|
||||||
|
|
||||||
len = snprintf(buffer, 16, g_fmtcursorpos, row + 1, column + 1);
|
len = snprintf(buffer, 16, g_fmt_cursorpos, row + 1, column + 1);
|
||||||
|
|
||||||
/* Send the VT100 CURSORPOS command */
|
/* Send the VT100 CURSORPOS command */
|
||||||
|
|
||||||
@ -317,3 +319,49 @@ void vt100_scrolldown(int chn, uint16_t nlines)
|
|||||||
vt100_write(chn, g_revindex, sizeof(g_revindex));
|
vt100_write(chn, g_revindex, sizeof(g_revindex));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: vt100_foreground_color
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the foreground color
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void vt100_foreground_color(int chn, uint8_t color)
|
||||||
|
{
|
||||||
|
char buffer[16];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Format the foreground color command. */
|
||||||
|
|
||||||
|
DEBUGASSERT(color < 10);
|
||||||
|
len = snprintf(buffer, 16, g_fmt_forecolor, color);
|
||||||
|
|
||||||
|
/* Send the VT100 foreground color command */
|
||||||
|
|
||||||
|
vt100_write(chn, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: vt100_background_color
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the background color
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void vt100_background_color(int chn, uint8_t color)
|
||||||
|
{
|
||||||
|
char buffer[16];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Format the background color command. */
|
||||||
|
|
||||||
|
DEBUGASSERT(color < 10);
|
||||||
|
len = snprintf(buffer, 16, g_fmt_backcolor, color);
|
||||||
|
|
||||||
|
/* Send the VT100 background color command */
|
||||||
|
|
||||||
|
vt100_write(chn, buffer, len);
|
||||||
|
}
|
||||||
|
@ -209,6 +209,26 @@ void vt100_scrollup(int chn, uint16_t nlines);
|
|||||||
void vt100_scrolldown(int chn, uint16_t nlines);
|
void vt100_scrolldown(int chn, uint16_t nlines);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: vt100_foreground_color
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the foreground color
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void vt100_foreground_color(int chn, uint8_t color);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: vt100_background_color
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the background color
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void vt100_background_color(int chn, uint8_t color);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user