shell: rework vt100 commands storage

VT100 commands are now stored as strings rather than character arrays.
This change will make it easier to create a unified macro for sending
all VT100 commands.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
This commit is contained in:
Jakub Rzeszutko 2021-09-20 14:18:08 +02:00 committed by Christopher Friedt
commit 0a50ebed01
4 changed files with 264 additions and 592 deletions

View file

@ -12,7 +12,6 @@ extern "C" {
#endif
enum shell_vt100_color {
SHELL_VT100_COLOR_DEFAULT,
SHELL_VT100_COLOR_BLACK,
SHELL_VT100_COLOR_RED,
SHELL_VT100_COLOR_GREEN,
@ -22,6 +21,8 @@ enum shell_vt100_color {
SHELL_VT100_COLOR_CYAN,
SHELL_VT100_COLOR_WHITE,
SHELL_VT100_COLOR_DEFAULT,
VT100_COLOR_END
};

View file

@ -7,22 +7,35 @@
#include <ctype.h>
#include "shell_ops.h"
#define CMD_CURSOR_LEN 8
void z_shell_op_cursor_vert_move(const struct shell *shell, int32_t delta)
{
if (delta != 0) {
z_shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'A' : 'B');
char dir = delta > 0 ? 'A' : 'B';
if (delta == 0) {
return;
}
if (delta < 0) {
delta = -delta;
}
Z_SHELL_VT100_CMD(shell, "\e[%d%c", delta, dir);
}
void z_shell_op_cursor_horiz_move(const struct shell *shell, int32_t delta)
{
if (delta != 0) {
z_shell_raw_fprintf(shell->fprintf_ctx, "\033[%d%c",
delta > 0 ? delta : -delta,
delta > 0 ? 'C' : 'D');
char dir = delta > 0 ? 'C' : 'D';
if (delta == 0) {
return;
}
if (delta < 0) {
delta = -delta;
}
Z_SHELL_VT100_CMD(shell, "\e[%d%c", delta, dir);
}
/* Function returns true if command length is equal to multiplicity of terminal
@ -285,8 +298,8 @@ static void char_replace(const struct shell *shell, char data)
void z_shell_op_char_insert(const struct shell *shell, char data)
{
if (shell->ctx->internal.flags.insert_mode &&
(shell->ctx->cmd_buff_len != shell->ctx->cmd_buff_pos)) {
if (z_flag_insert_mode_get(shell) &&
(shell->ctx->cmd_buff_len != shell->ctx->cmd_buff_pos)) {
char_replace(shell, data);
} else {
data_insert(shell, &data, 1);
@ -418,22 +431,33 @@ void z_shell_print_stream(const void *user_ctx, const char *data, size_t len)
static void vt100_bgcolor_set(const struct shell *shell,
enum shell_vt100_color bgcolor)
{
if (!IS_ENABLED(CONFIG_SHELL_VT100_COLORS)) {
return;
}
if (bgcolor >= VT100_COLOR_END) {
return;
}
if ((bgcolor == SHELL_NORMAL) ||
(shell->ctx->vt100_ctx.col.bgcol == bgcolor)) {
return;
}
/* -1 because default value is first in enum */
uint8_t cmd[] = SHELL_VT100_BGCOLOR(bgcolor - 1);
shell->ctx->vt100_ctx.col.bgcol = bgcolor;
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
Z_SHELL_VT100_CMD(shell, "\e[403%dm", bgcolor);
}
void z_shell_vt100_color_set(const struct shell *shell,
enum shell_vt100_color color)
{
if (!IS_ENABLED(CONFIG_SHELL_VT100_COLORS)) {
return;
}
if (color >= VT100_COLOR_END) {
return;
}
if (shell->ctx->vt100_ctx.col.col == color) {
return;
@ -442,20 +466,19 @@ void z_shell_vt100_color_set(const struct shell *shell,
shell->ctx->vt100_ctx.col.col = color;
if (color != SHELL_NORMAL) {
uint8_t cmd[] = SHELL_VT100_COLOR(color - 1);
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
Z_SHELL_VT100_CMD(shell, "\e[1;3%dm", color);
} else {
static const uint8_t cmd[] = SHELL_VT100_MODESOFF;
z_shell_raw_fprintf(shell->fprintf_ctx, "%s", cmd);
Z_SHELL_VT100_CMD(shell, SHELL_VT100_MODESOFF);
}
}
void z_shell_vt100_colors_restore(const struct shell *shell,
const struct shell_vt100_colors *color)
const struct shell_vt100_colors *color)
{
if (!IS_ENABLED(CONFIG_SHELL_VT100_COLORS)) {
return;
}
z_shell_vt100_color_set(shell, color->col);
vt100_bgcolor_set(shell, color->bgcol);
}
@ -464,7 +487,7 @@ void z_shell_vfprintf(const struct shell *shell, enum shell_vt100_color color,
const char *fmt, va_list args)
{
if (IS_ENABLED(CONFIG_SHELL_VT100_COLORS) &&
shell->ctx->internal.flags.use_colors &&
z_flag_use_colors_get(shell) &&
(color != shell->ctx->vt100_ctx.col.col)) {
struct shell_vt100_colors col;

View file

@ -25,14 +25,12 @@ static inline void z_shell_raw_fprintf(const struct shell_fprintf *const ctx,
va_end(args);
}
/* Macro to send VT100 commands. */
#define Z_SHELL_VT100_CMD(_shell_, _cmd_) \
/* Macro to send VT100 command. */
#define Z_SHELL_VT100_CMD(_shell_, ...) \
do { \
if (!IS_ENABLED(CONFIG_SHELL_VT100_COMMANDS)) \
break; \
\
static const char cmd[] = _cmd_; \
z_shell_raw_fprintf(_shell_->fprintf_ctx, "%s", cmd); \
z_shell_raw_fprintf(_shell_->fprintf_ctx, __VA_ARGS__); \
} while (0)
/* Function sends VT100 command to clear the screen from cursor position to

View file

@ -26,573 +26,223 @@
#define SHELL_VT100_ASCII_ALT_F (0x66)
#define SHELL_VT100_ASCII_ALT_R (0x72)
#define SHELL_VT100_SETNL \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', '0', 'h', '\0' \
} /* Set new line mode */
#define SHELL_VT100_SETAPPL \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '1', 'h', '\0' \
} /* Set cursor key to application */
#define SHELL_VT100_SETCOL_132 \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '3', 'h', '\0' \
} /* Set number of columns to 132 */
#define SHELL_VT100_SETSMOOTH \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '4', 'h', '\0' \
} /* Set smooth scrolling */
#define SHELL_VT100_SETREVSCRN \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '5', 'h', '\0' \
} /* Set reverse video on screen */
#define SHELL_VT100_SETORGREL \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '6', 'h', '\0' \
} /* Set origin to relative */
#define SHELL_VT100_SETWRAP_ON \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '7', 'h', '\0' \
} /* Set auto-wrap mode */
#define SHELL_VT100_SETWRAP_OFF \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '7', 'l', '\0' \
} /* Set auto-wrap mode */
#define SHELL_VT100_SETREP \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '8', 'h', '\0' \
} /* Set auto-repeat mode */
#define SHELL_VT100_SETINTER \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '9', 'h', '\0' \
} /* Set interlacing mode */
#define SHELL_VT100_SETLF \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', '0', 'l', '\0' \
} /* Set line feed mode */
#define SHELL_VT100_SETCURSOR \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '1', 'l', '\0' \
} /* Set cursor key to cursor */
#define SHELL_VT100_SETVT52 \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '2', 'l', '\0' \
} /* Set VT52 (versus ANSI) */
#define SHELL_VT100_SETCOL_80 \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '3', 'l', '\0' \
} /* Set number of columns to 80 */
#define SHELL_VT100_SETJUMP \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '4', 'l', '\0' \
} /* Set jump scrolling */
#define SHELL_VT100_SETNORMSCRN \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '5', 'l', '\0' \
} /* Set normal video on screen */
#define SHELL_VT100_SETORGABS \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '6', 'l', '\0' \
} /* Set origin to absolute */
#define SHELL_VT100_RESETWRAP \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '7', 'l', '\0' \
} /* Reset auto-wrap mode */
#define SHELL_VT100_RESETREP \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '8', 'l', '\0' \
} /* Reset auto-repeat mode */
#define SHELL_VT100_RESETINTER \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '9', 'l', '\0' \
} /* Reset interlacing mode */
#define SHELL_VT100_ALTKEYPAD \
{ \
SHELL_VT100_ASCII_ESC, '=', '\0' \
} /* Set alternate keypad mode */
#define SHELL_VT100_NUMKEYPAD \
{ \
SHELL_VT100_ASCII_ESC, '>', '\0' \
} /* Set numeric keypad mode */
#define SHELL_VT100_SETUKG0 \
{ \
SHELL_VT100_ASCII_ESC, '(', 'A', '\0' \
} /* Set United Kingdom G0 character set */
#define SHELL_VT100_SETUKG1 \
{ \
SHELL_VT100_ASCII_ESC, ')', 'A', '\0' \
} /* Set United Kingdom G1 character set */
#define SHELL_VT100_SETUSG0 \
{ \
SHELL_VT100_ASCII_ESC, '(', 'B', '\0' \
} /* Set United States G0 character set */
#define SHELL_VT100_SETUSG1 \
{ \
SHELL_VT100_ASCII_ESC, ')', 'B', '\0' \
} /* Set United States G1 character set */
#define SHELL_VT100_SETSPECG0 \
{ \
SHELL_VT100_ASCII_ESC, '(', '0', '\0' \
} /* Set G0 special chars. & line set */
#define SHELL_VT100_SETSPECG1 \
{ \
SHELL_VT100_ASCII_ESC, ')', '0', '\0' \
} /* Set G1 special chars. & line set */
#define SHELL_VT100_SETALTG0 \
{ \
SHELL_VT100_ASCII_ESC, '(', '1', '\0' \
} /* Set G0 alternate character ROM */
#define SHELL_VT100_SETALTG1 \
{ \
SHELL_VT100_ASCII_ESC, ')', '1', '\0' \
} /* Set G1 alternate character ROM */
#define SHELL_VT100_SETALTSPECG0 \
{ \
SHELL_VT100_ASCII_ESC, '(', '2', '\0' \
} /* Set G0 alt char ROM and spec. graphics */
#define SHELL_VT100_SETALTSPECG1 \
{ \
SHELL_VT100_ASCII_ESC, ')', '2', '\0' \
} /* Set G1 alt char ROM and spec. graphics */
#define SHELL_VT100_SETSS2 \
{ \
SHELL_VT100_ASCII_ESC, 'N', '\0' \
} /* Set single shift 2 */
#define SHELL_VT100_SETSS3 \
{ \
SHELL_VT100_ASCII_ESC, 'O', '\0' \
} /* Set single shift 3 */
#define SHELL_VT100_MODESOFF \
{ \
SHELL_VT100_ASCII_ESC, '[', 'm', '\0' \
} /* Turn off character attributes */
#define SHELL_VT100_MODESOFF_ \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'm', '\0' \
} /* Turn off character attributes */
#define SHELL_VT100_BOLD \
{ \
SHELL_VT100_ASCII_ESC, '[', '1', 'm', '\0' \
} /* Turn bold mode on */
#define SHELL_VT100_LOWINT \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', 'm', '\0' \
} /* Turn low intensity mode on */
#define SHELL_VT100_UNDERLINE \
{ \
SHELL_VT100_ASCII_ESC, '[', '4', 'm', '\0' \
} /* Turn underline mode on */
#define SHELL_VT100_BLINK \
{ \
SHELL_VT100_ASCII_ESC, '[', '5', 'm', '\0' \
} /* Turn blinking mode on */
#define SHELL_VT100_REVERSE \
{ \
SHELL_VT100_ASCII_ESC, '[', '7', 'm', '\0' \
} /* Turn reverse video on */
#define SHELL_VT100_INVISIBLE \
{ \
SHELL_VT100_ASCII_ESC, '[', '8', 'm', '\0' \
} /* Turn invisible text mode on */
#define SHELL_VT100_SETWIN(t, b) \
{ \
SHELL_VT100_ASCII_ESC, '[', (t), ';', (b), 'r', '\0' \
} /* Set top and bottom line#s of a window */
#define SHELL_VT100_CURSORUP(n) \
{ \
SHELL_VT100_ASCII_ESC, '[', (n), 'A', '\0' \
} /* Move cursor up n lines */
#define SHELL_VT100_CURSORDN(n) \
{ \
SHELL_VT100_ASCII_ESC, '[', (n), 'B', '\0' \
} /* Move cursor down n lines */
#define SHELL_VT100_CURSORRT(n) \
{ \
SHELL_VT100_ASCII_ESC, '[', (n), 'C', '\0' \
} /* Move cursor right n lines */
#define SHELL_VT100_CURSORLF(n) \
{ \
SHELL_VT100_ASCII_ESC, '[', (n), 'D', '\0' \
} /* Move cursor left n lines */
#define SHELL_VT100_CURSORHOME \
{ \
SHELL_VT100_ASCII_ESC, '[', 'H', '\0' \
} /* Move cursor to upper left corner */
#define SHELL_VT100_CURSORHOME_ \
{ \
SHELL_VT100_ASCII_ESC, '[', ';', 'H', '\0' \
} /* Move cursor to upper left corner */
#define SHELL_VT100_CURSORPOS(v, h) \
{ \
SHELL_VT100_ASCII_ESC, '[', (v), ';', (h), 'H', '\0' \
} /* Move cursor to screen location v,h */
#define SHELL_VT100_HVHOME \
{ \
SHELL_VT100_ASCII_ESC, '[', 'f', '\0' \
} /* Move cursor to upper left corner */
#define SHELL_VT100_HVHOME_ \
{ \
SHELL_VT100_ASCII_ESC, '[', ';', 'f', '\0' \
} /* Move cursor to upper left corner */
#define SHELL_VT100_HVPOS(v, h) \
{ \
SHELL_VT100_ASCII_ESC, '[', (v), ';', (h), 'f', '\0' \
} /* Move cursor to screen location v,h */
#define SHELL_VT100_INDEX \
{ \
SHELL_VT100_ASCII_ESC, 'D', '\0' \
} /* Move/scroll window up one line */
#define SHELL_VT100_REVINDEX \
{ \
SHELL_VT100_ASCII_ESC, 'M', '\0' \
} /* Move/scroll window down one line */
#define SHELL_VT100_NEXTLINE \
{ \
SHELL_VT100_ASCII_ESC, 'E', '\0' \
} /* Move to next line */
#define SHELL_VT100_SAVECURSOR \
{ \
SHELL_VT100_ASCII_ESC, '7', '\0' \
} /* Save cursor position and attributes */
#define SHELL_VT100_RESTORECURSOR \
{ \
SHELL_VT100_ASCII_ESC, '8', '\0' \
} /* Restore cursor position and attribute */
#define SHELL_VT100_TABSET \
{ \
SHELL_VT100_ASCII_ESC, 'H', '\0' \
} /* Set a tab at the current column */
#define SHELL_VT100_TABCLR \
{ \
SHELL_VT100_ASCII_ESC, '[', 'g', '\0' \
} /* Clear a tab at the current column */
#define SHELL_VT100_TABCLR_ \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'g', '\0' \
} /* Clear a tab at the current column */
#define SHELL_VT100_TABCLRALL \
{ \
SHELL_VT100_ASCII_ESC, '[', '3', 'g', '\0' \
} /* Clear all tabs */
#define SHELL_VT100_DHTOP \
{ \
SHELL_VT100_ASCII_ESC, '#', '3', '\0' \
} /* Double-height letters, top half */
#define SHELL_VT100_DHBOT \
{ \
SHELL_VT100_ASCII_ESC, '#', '4', '\0' \
} /* Double-height letters, bottom hal */
#define SHELL_VT100_SWSH \
{ \
SHELL_VT100_ASCII_ESC, '#', '5', '\0' \
} /* Single width, single height letters */
#define SHELL_VT100_DWSH \
{ \
SHELL_VT100_ASCII_ESC, '#', '6', '\0' \
} /* Double width, single height letters */
#define SHELL_VT100_CLEAREOL \
{ \
SHELL_VT100_ASCII_ESC, '[', 'K', '\0' \
} /* Clear line from cursor right */
#define SHELL_VT100_CLEAREOL_ \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'K', '\0' \
} /* Clear line from cursor right */
#define SHELL_VT100_CLEARBOL \
{ \
SHELL_VT100_ASCII_ESC, '[', '1', 'K', '\0' \
} /* Clear line from cursor left */
#define SHELL_VT100_CLEARLINE \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', 'K', '\0' \
} /* Clear entire line */
#define SHELL_VT100_CLEAREOS \
{ \
SHELL_VT100_ASCII_ESC, '[', 'J', '\0' \
} /* Clear screen from cursor down */
#define SHELL_VT100_CLEAREOS_ \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'J', '\0' \
} /* Clear screen from cursor down */
#define SHELL_VT100_CLEARBOS \
{ \
SHELL_VT100_ASCII_ESC, '[', '1', 'J', '\0' \
} /* Clear screen from cursor up */
#define SHELL_VT100_CLEARSCREEN \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', 'J', '\0' \
} /* Clear entire screen */
#define SHELL_VT100_DEVSTAT \
{ \
SHELL_VT100_ASCII_ESC, '5', 'n', '\0' \
} /* Device status report */
#define SHELL_VT100_TERMOK \
{ \
SHELL_VT100_ASCII_ESC, '0', 'n', '\0' \
} /* Response: terminal is OK */
#define SHELL_VT100_TERMNOK \
{ \
SHELL_VT100_ASCII_ESC, '3', 'n', '\0' \
} /* Response: terminal is not OK */
#define SHELL_VT100_GETCURSOR \
{ \
SHELL_VT100_ASCII_ESC, '[', '6', 'n', '\0' \
} /* Get cursor position */
#define SHELL_VT100_CURSORPOSAT \
{ \
SHELL_VT100_ASCII_ESC, (v), ';', (h), 'R', '\0' \
} /* Response: cursor is at v,h */
#define SHELL_VT100_IDENT \
{ \
SHELL_VT100_ASCII_ESC, '[', 'c', '\0' \
} /* Identify what terminal type */
#define SHELL_VT100_IDENT_ \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'c', '\0' \
} /* Identify what terminal type */
#define SHELL_VT100_GETTYPE \
{ \
SHELL_VT100_ASCII_ESC, '[', '?', '1', ';', (n), '0', 'c', '\0' \
} /* Response: terminal type code n */
#define SHELL_VT100_RESET \
{ \
SHELL_VT100_ASCII_ESC, 'c', '\0' \
} /*Reset terminal to initial state */
#define SHELL_VT100_ALIGN \
{ \
SHELL_VT100_ASCII_ESC, '#', '8', '\0' \
} /* Screen alignment display */
#define SHELL_VT100_TESTPU \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', ';', '1', 'y', '\0' \
} /* Confidence power up test */
#define SHELL_VT100_TESTLB \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', ';', '2', 'y', '\0' \
} /* Confidence loopback test */
#define SHELL_VT100_TESTPUREP \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', ';', '9', 'y', '\0' \
} /* Repeat power up test */
#define SHELL_VT100_TESTLBREP \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', ';', '1', '0', 'y', '\0' \
} /* Repeat loopback test */
#define SHELL_VT100_LEDSOFF \
{ \
SHELL_VT100_ASCII_ESC, '[', '0', 'q', '\0' \
} /* Turn off all four leds */
#define SHELL_VT100_LED1 \
{ \
SHELL_VT100_ASCII_ESC, '[', '1', 'q', '\0' \
} /* Turn on LED #1 */
#define SHELL_VT100_LED2 \
{ \
SHELL_VT100_ASCII_ESC, '[', '2', 'q', '\0' \
} /* Turn on LED #2 */
#define SHELL_VT100_LED3 \
{ \
SHELL_VT100_ASCII_ESC, '[', '3', 'q', '\0' \
} /* Turn on LED #3 */
#define SHELL_VT100_LED4 \
{ \
SHELL_VT100_ASCII_ESC, '[', '4', 'q', '\0' \
} /* Turn on LED #4 */
/* Set new line mode */
#define SHELL_VT100_SETNL "\e[20h\0"
/* Set cursor key to application */
#define SHELL_VT100_SETAPPL "\e[?1h\0"
/* Set number of columns to 132 */
#define SHELL_VT100_SETCOL_132 "\e[?3h\0"
/* Set smooth scrolling */
#define SHELL_VT100_SETSMOOTH "\e[?4h\0"
/* Set reverse video on screen */
#define SHELL_VT100_SETREVSCRN "\e[?5h\0"
/* Set origin to relative */
#define SHELL_VT100_SETORGREL "\e[?6h\0"
/* Set auto-wrap mode */
#define SHELL_VT100_SETWRAP_ON "\e[?7h\0"
/* Set auto-wrap mode */
#define SHELL_VT100_SETWRAP_OFF "\e[?7l\0"
/* Set auto-repeat mode */
#define SHELL_VT100_SETREP "\e[?8h\0"
/* Set interlacing mode */
#define SHELL_VT100_SETINTER "\e[?9h\0"
/* Set line feed mode */
#define SHELL_VT100_SETLF "\e[20l\0"
/* Set cursor key to cursor */
#define SHELL_VT100_SETCURSOR "\e[?1l\0"
/* Set VT52 (versus ANSI) */
#define SHELL_VT100_SETVT52 "\e[?2l\0"
/* Set number of columns to 80 */
#define SHELL_VT100_SETCOL_80 "\e[?3l\0"
/* Set jump scrolling */
#define SHELL_VT100_SETJUMP "\e[?4l\0"
/* Set normal video on screen */
#define SHELL_VT100_SETNORMSCRN "\e[?5l\0"
/* Set origin to absolute */
#define SHELL_VT100_SETORGABS "\e[?6l\0"
/* Reset auto-wrap mode */
#define SHELL_VT100_RESETWRAP "\e[?7l\0"
/* Reset auto-repeat mode */
#define SHELL_VT100_RESETREP "\e[?8l\0"
/* Reset interlacing mode */
#define SHELL_VT100_RESETINTER "\e[?9l\0"
/* Set alternate keypad mode */
#define SHELL_VT100_ALTKEYPAD "\e=\0"
/* Set numeric keypad mode */
#define SHELL_VT100_NUMKEYPAD "\e>\0"
/* Set United Kingdom G0 character set */
#define SHELL_VT100_SETUKG0 "\e(A\0"
/* Set United Kingdom G1 character set */
#define SHELL_VT100_SETUKG1 "\e)A\0"
/* Set United States G0 character set */
#define SHELL_VT100_SETUSG0 "\e(B\0"
/* Set United States G1 character set */
#define SHELL_VT100_SETUSG1 "\e)B\0"
/* Set G0 special chars. & line set */
#define SHELL_VT100_SETSPECG0 "\e(0\0"
/* Set G1 special chars. & line set */
#define SHELL_VT100_SETSPECG1 "\e)0\0"
/* Set G0 alternate character ROM */
#define SHELL_VT100_SETALTG0 "\e(1\0"
/* Set G1 alternate character ROM */
#define SHELL_VT100_SETALTG1 "\e)1\0"
/* Set G0 alt char ROM and spec. graphics */
#define SHELL_VT100_SETALTSPECG0 "\e(2\0"
/* Set G1 alt char ROM and spec. graphics */
#define SHELL_VT100_SETALTSPECG1 "\e)2\0"
/* Set single shift 2 */
#define SHELL_VT100_SETSS2 "\eN\0"
/* Set single shift 3 */
#define SHELL_VT100_SETSS3 "\eO\0"
/* Turn off character attributes */
#define SHELL_VT100_MODESOFF "\e[m\0"
/* Turn off character attributes */
#define SHELL_VT100_MODESOFF_ "\e[0m\0"
/* Turn bold mode on */
#define SHELL_VT100_BOLD "\e[1m\0"
/* Turn low intensity mode on */
#define SHELL_VT100_LOWINT "\e[2m\0"
/* Turn underline mode on */
#define SHELL_VT100_UNDERLINE "\e[4m\0"
/* Turn blinking mode on */
#define SHELL_VT100_BLINK "\e[5m\0"
/* Turn reverse video on */
#define SHELL_VT100_REVERSE "\e[7m\0"
/* Turn invisible text mode on */
#define SHELL_VT100_INVISIBLE "\e[8m\0"
/* Move cursor to upper left corner */
#define SHELL_VT100_CURSORHOME "\e[H\0"
/* Move cursor to upper left corner */
#define SHELL_VT100_CURSORHOME_ "\e[;H\0"
/* Move cursor to upper left corner */
#define SHELL_VT100_HVHOME "\e[f\0"
/* Move cursor to upper left corner */
#define SHELL_VT100_HVHOME_ "\e[;f\0"
/* Move/scroll window up one line */
#define SHELL_VT100_INDEX "\eD\0"
/* Move/scroll window down one line */
#define SHELL_VT100_REVINDEX "\eM\0"
/* Move to next line */
#define SHELL_VT100_NEXTLINE "\eE\0"
/* Save cursor position and attributes */
#define SHELL_VT100_SAVECURSOR "\e7\0"
/* Restore cursor position and attribute */
#define SHELL_VT100_RESTORECURSOR "\e8\0"
/* Set a tab at the current column */
#define SHELL_VT100_TABSET "\eH\0"
/* Clear a tab at the current column */
#define SHELL_VT100_TABCLR "\e[g\0"
/* Clear a tab at the current column */
#define SHELL_VT100_TABCLR_ "\e[0g\0"
/* Clear all tabs */
#define SHELL_VT100_TABCLRALL "\e[3g\0"
/* Double-height letters, top half */
#define SHELL_VT100_DHTOP "\e#3\0"
/* Double-height letters, bottom hal */
#define SHELL_VT100_DHBOT "\e#4\0"
/* Single width, single height letters */
#define SHELL_VT100_SWSH "\e#5\0"
/* Double width, single height letters */
#define SHELL_VT100_DWSH "\e#6\0"
/* Clear line from cursor right */
#define SHELL_VT100_CLEAREOL "\e[K\0"
/* Clear line from cursor right */
#define SHELL_VT100_CLEAREOL_ "\e[0K\0"
/* Clear line from cursor left */
#define SHELL_VT100_CLEARBOL "\e[1K\0"
/* Clear entire line */
#define SHELL_VT100_CLEARLINE "\e[2K\0"
/* Clear screen from cursor down */
#define SHELL_VT100_CLEAREOS "\e[J\0"
/* Clear screen from cursor down */
#define SHELL_VT100_CLEAREOS_ "\e[0J\0"
/* Clear screen from cursor up */
#define SHELL_VT100_CLEARBOS "\e[1J\0"
/* Clear entire screen */
#define SHELL_VT100_CLEARSCREEN "\e[2J\0"
/* Device status report */
#define SHELL_VT100_DEVSTAT "\e5n\0"
/* Response: terminal is OK */
#define SHELL_VT100_TERMOK "\e0n\0"
/* Response: terminal is OK */
#define SHELL_VT100_TERMNOK "\e3n\0"
/* Get cursor position */
#define SHELL_VT100_GETCURSOR "\e[6n\0"
/* Response: cursor is at v,h */
#define SHELL_VT100_CURSORPOSAT "\e, (v);', (h)R\0"
/* Identify what terminal type */
#define SHELL_VT100_IDENT "\e[c\0"
/* Identify what terminal type */
#define SHELL_VT100_IDENT_ "\e[0c\0"
/* Response: terminal type code n */
#define SHELL_VT100_GETTYPE "\e[?1;', (n)0c\0"
/*Reset terminal to initial state */
#define SHELL_VT100_RESET "\ec\0"
/* Screen alignment display */
#define SHELL_VT100_ALIGN "\e#8\0"
/* Confidence power up test */
#define SHELL_VT100_TESTPU "\e[2;1y\0"
/* Confidence loopback test */
#define SHELL_VT100_TESTLB "\e[2;2y\0"
/* Repeat power up test */
#define SHELL_VT100_TESTPUREP "\e[2;9y\0"
/* Repeat loopback test */
#define SHELL_VT100_TESTLBREP "\e[2;10y\0"
/* Turn off all four leds */
#define SHELL_VT100_LEDSOFF "\e[0q\0"
/* Turn on LED #1 */
#define SHELL_VT100_LED1 "\e[1q\0"
/* Turn on LED #2 */
#define SHELL_VT100_LED2 "\e[2q\0"
/* Turn on LED #3 */
#define SHELL_VT100_LED3 "\e[3q\0"
/* Turn on LED #4 */
#define SHELL_VT100_LED4 "\e[4q\0"
/* Function Keys */
#define SHELL_VT100_PF1 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'P', '\0' \
}
#define SHELL_VT100_PF2 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'Q', '\0' \
}
#define SHELL_VT100_PF3 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'R', '\0' \
}
#define SHELL_VT100_PF4 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'S', '\0' \
}
#define SHELL_VT100_PF1 "\eOP\0"
#define SHELL_VT100_PF2 "\eOQ\0"
#define SHELL_VT100_PF3 "\eOR\0"
#define SHELL_VT100_PF4 "\eOS\0"
/* Arrow keys */
#define SHELL_VT100_UP_RESET \
{ \
SHELL_VT100_ASCII_ESC, 'A', '\0' \
}
#define SHELL_VT100_UP_SET \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'A', '\0' \
}
#define SHELL_VT100_DOWN_RESET \
{ \
SHELL_VT100_ASCII_ESC, 'B', '\0' \
}
#define SHELL_VT100_DOWN_SET \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'B', '\0' \
}
#define SHELL_VT100_RIGHT_RESET \
{ \
SHELL_VT100_ASCII_ESC, 'C', '\0' \
}
#define SHELL_VT100_RIGHT_SET \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'C', '\0' \
}
#define SHELL_VT100_LEFT_RESET \
{ \
SHELL_VT100_ASCII_ESC, 'D', '\0' \
}
#define SHELL_VT100_LEFT_SET \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'D', '\0' \
}
#define SHELL_VT100_UP_RESET "\eA\0"
#define SHELL_VT100_UP_SET "\eOA\0"
#define SHELL_VT100_DOWN_RESET "\eB\0"
#define SHELL_VT100_DOWN_SET "\eOB\0"
#define SHELL_VT100_RIGHT_RESET "\eC\0"
#define SHELL_VT100_RIGHT_SET "\eOC\0"
#define SHELL_VT100_LEFT_RESET "\eD\0"
#define SHELL_VT100_LEFT_SET "\eOD\0"
/* Numeric Keypad Keys */
#define SHELL_VT100_NUMERIC_0 \
{ \
'0', '\0' \
}
#define SHELL_VT100_ALT_0 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'p', '\0' \
}
#define SHELL_VT100_NUMERIC_1 \
{ \
'1', '\0' \
}
#define SHELL_VT100_ALT_1 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'q', '\0' \
}
#define SHELL_VT100_NUMERIC_2 \
{ \
'2', '\0' \
}
#define SHELL_VT100_ALT_2 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'r', '\0' \
}
#define SHELL_VT100_NUMERIC_3 \
{ \
'3', '\0' \
}
#define SHELL_VT100_ALT_3 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 's', '\0' \
}
#define SHELL_VT100_NUMERIC_4 \
{ \
'4', '\0' \
}
#define SHELL_VT100_ALT_4 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 't', '\0' \
}
#define SHELL_VT100_NUMERIC_5 \
{ \
'5', '\0' \
}
#define SHELL_VT100_ALT_5 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'u', '\0' \
}
#define SHELL_VT100_NUMERIC_6 \
{ \
'6', '\0' \
}
#define SHELL_VT100_ALT_6 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'v', '\0' \
}
#define SHELL_VT100_NUMERIC_7 \
{ \
'7', '\0' \
}
#define SHELL_VT100_ALT_7 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'w', '\0' \
}
#define SHELL_VT100_NUMERIC_8 \
{ \
'8', '\0' \
}
#define SHELL_VT100_ALT_8 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'x', '\0' \
}
#define SHELL_VT100_NUMERIC_9 \
{ \
'9', '\0' \
}
#define SHELL_VT100_ALT_9 \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'y' \
}
#define SHELL_VT100_NUMERIC_MINUS \
{ \
'-', '\0' \
}
#define SHELL_VT100_ALT_MINUS \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'm', '\0' \
}
#define SHELL_VT100_NUMERIC_COMMA \
{ \
',', '\0' \
}
#define SHELL_VT100_ALT_COMMA \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'l', '\0' \
}
#define SHELL_VT100_NUMERIC_ENTER \
{ \
ASCII_CR \
}
#define SHELL_VT100_NUMERIC_PERIOD \
{ \
'.', '\0' \
}
#define SHELL_VT100_ALT_PERIOD \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'n', '\0' \
}
#define SHELL_VT100_ALT_ENTER \
{ \
SHELL_VT100_ASCII_ESC, 'O', 'M', '\0' \
}
#define SHELL_VT100_BGCOLOR(__col) \
{ \
SHELL_VT100_ASCII_ESC, '[', '4', '0' + (__col), 'm', '\0' \
}
#define SHELL_VT100_COLOR(__col) \
{ \
SHELL_VT100_ASCII_ESC, '[', '1', ';', '3', '0' + (__col), 'm', '\0' \
}
#define SHELL_VT100_NUMERIC_0 "0\0"
#define SHELL_VT100_ALT_0 "\eOp\0"
#define SHELL_VT100_NUMERIC_1 "1\0"
#define SHELL_VT100_ALT_1 "\eOq\0"
#define SHELL_VT100_NUMERIC_2 "2\0"
#define SHELL_VT100_ALT_2 "\eOr\0"
#define SHELL_VT100_NUMERIC_3 "3\0"
#define SHELL_VT100_ALT_3 "\eOs\0"
#define SHELL_VT100_NUMERIC_4 "4\0"
#define SHELL_VT100_ALT_4 "\eOt\0"
#define SHELL_VT100_NUMERIC_5 "5\0"
#define SHELL_VT100_ALT_5 "\eOu\0"
#define SHELL_VT100_NUMERIC_6 "6\0"
#define SHELL_VT100_ALT_6 "\eOv\0"
#define SHELL_VT100_NUMERIC_7 "7\0"
#define SHELL_VT100_ALT_7 "\eOw\0"
#define SHELL_VT100_NUMERIC_8 "8\0"
#define SHELL_VT100_ALT_8 "\eOx\0"
#define SHELL_VT100_NUMERIC_9 "9\0"
#define SHELL_VT100_ALT_9 "\eOy\0"
#define SHELL_VT100_NUMERIC_MINUS "-\0"
#define SHELL_VT100_ALT_MINUS "\eOm\0"
#define SHELL_VT100_NUMERIC_COMMA ",\0"
#define SHELL_VT100_ALT_COMMA "\eOl\0"
#define SHELL_VT100_NUMERIC_ENTER ASCII_CR
#define SHELL_VT100_NUMERIC_PERIOD ".\0"
#define SHELL_VT100_ALT_PERIOD "\eOn\0"
#define SHELL_VT100_ALT_ENTER "\eOM\0"
#endif /* SHELL_VT100_H__ */