[SACDRV]: Switch !SAC back to VT-UTF8 and remove the previous hacks.

[SACDRV]: We need VTUTF8ChannelOEcho. Implement VTUTF8ChannelAnsiDispatch in anticipation.

svn path=/trunk/; revision=59829
This commit is contained in:
Alex Ionescu 2013-08-26 07:16:10 +00:00
parent aa7497361a
commit 30f0e5cc98
3 changed files with 147 additions and 11 deletions

View file

@ -169,7 +169,7 @@ ConMgrInitialize(VOID)
/* Setup the attributes for the raw SAC channel */
RtlZeroMemory(&SacChannelAttributes, sizeof(SacChannelAttributes));
SacChannelAttributes.ChannelType = Raw; /* FIXME: Should be VtUtf8 */
SacChannelAttributes.ChannelType = VtUtf8;
/* Get the right name for it */
pcwch = GetMessage(SAC_CHANNEL_NAME);
@ -725,7 +725,7 @@ DoLineParsing:
/* Read every character in the channel, and strip whitespace */
ChannelIRead(CurrentChannel,
ReadBuffer,
sizeof(CHAR), /* FIXME: Should be sizeof(ReadBuffer) */
sizeof(ReadBuffer),
&ReadBufferSize);
} while ((ReadBufferSize) &&
((ReadBuffer[0] == ' ') || (ReadBuffer[0] == '\t')));
@ -740,7 +740,7 @@ DoLineParsing:
/* Read each character -- there should be max 80 */
ChannelIRead(CurrentChannel,
ReadBuffer,
sizeof(CHAR), /* FIXME: Should be sizeof(ReadBuffer) */
sizeof(ReadBuffer),
&ReadBufferSize);
ASSERT(i < SAC_VTUTF8_COL_WIDTH);
InputBuffer[i++] = ReadBuffer[0];

View file

@ -11,6 +11,7 @@
#include <ntifs.h>
#include <intrin.h>
#include <wchar.h>
#include <stdio.h>
#include <ndk/obtypes.h>
#include <ndk/exfuncs.h>
#include <ndk/rtlfuncs.h>
@ -211,7 +212,7 @@ typedef struct _SAC_MESSAGE_ENTRY
} SAC_MESSAGE_ENTRY, *PSAC_MESSAGE_ENTRY;
//
// These are the VT-100/220/ANSI Escape Codes supported by SAC
// These are the VT-100/220/ANSI Escape Codes supported by SAC as input
//
typedef enum _SAC_ANSI_COMMANDS
{
@ -241,6 +242,25 @@ typedef enum _SAC_ANSI_COMMANDS
SacSetColorsAndAttributes
} SAC_ANSI_COMMANDS;
//
// These are the VT-100/220/ANSI Escape Codes send by SAC as output
//
typedef enum _SAC_ANSI_DISPATCH
{
SacAnsiClearScreen,
SacAnsiClearEndOfScreen,
SacAnsiClearEndOfLine,
SacAnsiSetColors,
SacAnsiSetPosition,
SacAnsiClearAttributes,
SacAnsiSetInverseAttribute,
SacAnsiClearInverseAttribute,
SacAnsiSetBlinkAttribute,
SacAnsiClearBlinkAttribute,
SacAnsiSetBoldAttribute,
SacAnsiClearBoldAttribute
} SAC_ANSI_DISPATCH;
//
// SAC supports 3 different channel output types
//

View file

@ -65,14 +65,130 @@ VTUTF8ChannelScanForNumber(IN PWCHAR String,
NTSTATUS
NTAPI
VTUTF8ChannelAnsiDispatch(
IN NTSTATUS Status,
IN ULONG AnsiCode,
IN PWCHAR Data,
IN ULONG Length
)
VTUTF8ChannelAnsiDispatch(IN PSAC_CHANNEL Channel,
IN SAC_ANSI_DISPATCH AnsiCode,
IN INT* Data,
IN ULONG Length)
{
return STATUS_NOT_IMPLEMENTED;
NTSTATUS Status = STATUS_SUCCESS;
PCHAR LocalBuffer = NULL;
INT l;
CHECK_PARAMETER1(Channel);
/* Check which ANSI sequence we should output */
switch (AnsiCode)
{
/* Send the [2J (Clear Screen and Reset Cursor) */
case SacAnsiClearScreen:
LocalBuffer = "\x1B[2J";
break;
/* Send the [0J (Clear From Position Till End Of Screen) */
case SacAnsiClearEndOfScreen:
LocalBuffer = "\x1B[0J";
break;
/* Send the [0K (Clear from Position Till End Of Line) */
case SacAnsiClearEndOfLine:
LocalBuffer = "\x1B[0K";
break;
/* Send a combination of two [#m attribute changes */
case SacAnsiSetColors:
/* Allocate a small local buffer for it */
LocalBuffer = SacAllocatePool(SAC_VTUTF8_COL_WIDTH, GLOBAL_BLOCK_TAG);
CHECK_ALLOCATION(LocalBuffer);
/* Caller should have sent two colors as two integers */
if (!(Data) || (Length != 8))
{
Status = STATUS_INVALID_PARAMETER;
break;
}
/* Create the escape sequence string */
l = sprintf(LocalBuffer, "\x1B[%dm\x1B[%dm", Data[1], Data[0]);
ASSERT((l + 1)*sizeof(UCHAR) < SAC_VTUTF8_COL_WIDTH);
ASSERT(LocalBuffer);
break;
/* Send the [#;#H (Cursor Positio) sequence */
case SacAnsiSetPosition:
/* Allocate a small local buffer for it */
LocalBuffer = SacAllocatePool(SAC_VTUTF8_COL_WIDTH, GLOBAL_BLOCK_TAG);
CHECK_ALLOCATION(LocalBuffer);
/* Caller should have sent the position as two integers */
if (!(Data) || (Length != 8))
{
Status = STATUS_INVALID_PARAMETER;
break;
}
/* Create the escape sequence string */
l = sprintf(LocalBuffer, "\x1B[%d;%dH", Data[1] + 1, Data[0] + 1);
ASSERT((l + 1)*sizeof(UCHAR) < SAC_VTUTF8_COL_WIDTH);
ASSERT(LocalBuffer);
break;
/* Send the [0m sequence (Set Attribute 0) */
case SacAnsiClearAttributes:
LocalBuffer = "\x1B[0m";
break;
/* Send the [7m sequence (Set Attribute 7) */
case SacAnsiSetInverseAttribute:
LocalBuffer = "\x1B[7m";
break;
/* Send the [27m sequence (Set Attribute 27) */
case SacAnsiClearInverseAttribute:
LocalBuffer = "\x1B[27m";
break;
/* Send the [5m sequence (Set Attribute 5) */
case SacAnsiSetBlinkAttribute:
LocalBuffer = "\x1B[5m";
break;
/* Send the [25m sequence (Set Attribute 25) */
case SacAnsiClearBlinkAttribute:
LocalBuffer = "\x1B[25m";
break;
/* Send the [1m sequence (Set Attribute 1) */
case SacAnsiSetBoldAttribute:
LocalBuffer = "\x1B[1m";
break;
/* Send the [22m sequence (Set Attribute 22) */
case SacAnsiClearBoldAttribute:
LocalBuffer = "\x1B[22m";
break;
/* We don't recognize it */
default:
Status = STATUS_INVALID_PARAMETER;
break;
}
/* Did everything work above? */
if (NT_SUCCESS(Status))
{
/* Go write out the sequence */
Status = ConMgrWriteData(Channel, LocalBuffer, strlen(LocalBuffer));
if (NT_SUCCESS(Status))
{
/* Now flush it */
Status = ConMgrFlushData(Channel);
}
}
/* Free the temporary buffer, if any, and return the status */
if (LocalBuffer) SacFreePool(LocalBuffer);
return Status;
}
NTSTATUS