/**
* Handle ANSI CUP (cursor position)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params[0] Row (1 is top)
* @v params[1] Column (1 is left)
*/
-static void bios_handle_cup ( unsigned int count __unused, int params[] ) {
+static void bios_handle_cup ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused, int params[] ) {
int cx = ( params[1] - 1 );
int cy = ( params[0] - 1 );
/**
* Handle ANSI ED (erase in page)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params[0] Region to erase
*/
-static void bios_handle_ed ( unsigned int count __unused,
+static void bios_handle_ed ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused,
int params[] __unused ) {
/* We assume that we always clear the whole screen */
assert ( params[0] == ANSIESC_ED_ALL );
/**
* Handle ANSI SGR (set graphics rendition)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params List of graphic rendition aspects
*/
-static void bios_handle_sgr ( unsigned int count, int params[] ) {
+static void bios_handle_sgr ( struct ansiesc_context *ctx __unused,
+ unsigned int count, int params[] ) {
static const uint8_t bios_attr_fcols[10] = {
ATTR_FCOL_BLACK, ATTR_FCOL_RED, ATTR_FCOL_GREEN,
ATTR_FCOL_YELLOW, ATTR_FCOL_BLUE, ATTR_FCOL_MAGENTA,
/**
* Call ANSI escape sequence handler
*
- * @v handlers List of escape sequence handlers
+ * @v ctx ANSI escape sequence context
* @v function Control function identifier
* @v count Parameter count
* @v params Parameter list
*/
-static void ansiesc_call_handler ( struct ansiesc_handler *handlers,
+static void ansiesc_call_handler ( struct ansiesc_context *ctx,
unsigned int function, int count,
int params[] ) {
+ struct ansiesc_handler *handlers = ctx->handlers;
struct ansiesc_handler *handler;
for ( handler = handlers ; handler->function ; handler++ ) {
if ( handler->function == function ) {
- handler->handle ( count, params );
+ handler->handle ( ctx, count, params );
break;
}
}
* sequences we are prepared to accept as valid.
*/
int ansiesc_process ( struct ansiesc_context *ctx, int c ) {
+
if ( ctx->count == 0 ) {
if ( c == ESC ) {
/* First byte of CSI : begin escape sequence */
ctx->count = 0;
ctx->function <<= 8;
ctx->function |= c;
- ansiesc_call_handler ( ctx->handlers, ctx->function,
+ ansiesc_call_handler ( ctx, ctx->function,
count, ctx->params );
}
return -1;
FILE_LICENCE ( GPL2_OR_LATER );
+struct ansiesc_context;
+
/** A handler for an escape sequence */
struct ansiesc_handler {
/** The control function identifier
unsigned int function;
/** Handle escape sequence
*
+ * @v ctx ANSI escape context
* @v count Parameter count
* @v params Parameter list
*
* omitted". Consequently, the parameter list will always
* contain at least one item.
*/
- void ( * handle ) ( unsigned int count, int params[] );
+ void ( * handle ) ( struct ansiesc_context *ctx, unsigned int count,
+ int params[] );
};
/** Maximum number of parameters within a single escape sequence */
/**
* Handle ANSI CUP (cursor position)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params[0] Row (1 is top)
* @v params[1] Column (1 is left)
*/
-static void efi_handle_cup ( unsigned int count __unused, int params[] ) {
+static void efi_handle_cup ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused, int params[] ) {
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
int cx = ( params[1] - 1 );
int cy = ( params[0] - 1 );
/**
* Handle ANSI ED (erase in page)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params[0] Region to erase
*/
-static void efi_handle_ed ( unsigned int count __unused,
- int params[] __unused ) {
+static void efi_handle_ed ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused,
+ int params[] __unused ) {
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
/* We assume that we always clear the whole screen */
/**
* Handle ANSI SGR (set graphics rendition)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params List of graphic rendition aspects
*/
-static void efi_handle_sgr ( unsigned int count, int params[] ) {
+static void efi_handle_sgr ( struct ansiesc_context *ctx __unused,
+ unsigned int count, int params[] ) {
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *conout = efi_systab->ConOut;
static const uint8_t efi_attr_fcols[10] = {
ATTR_FCOL_BLACK, ATTR_FCOL_RED, ATTR_FCOL_GREEN,
/**
* Handle ANSI set encrypted syslog priority (private sequence)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params List of graphic rendition aspects
*/
-static void syslogs_handle_priority ( unsigned int count __unused,
+static void syslogs_handle_priority ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused,
int params[] ) {
if ( params[0] >= 0 ) {
syslogs_severity = params[0];
/**
* Handle ANSI set syslog priority (private sequence)
*
+ * @v ctx ANSI escape sequence context
* @v count Parameter count
* @v params List of graphic rendition aspects
*/
-static void syslog_handle_priority ( unsigned int count __unused,
+static void syslog_handle_priority ( struct ansiesc_context *ctx __unused,
+ unsigned int count __unused,
int params[] ) {
if ( params[0] >= 0 ) {
syslog_severity = params[0];