X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=subsys%2Fsystem%2Fusetup%2Fconsole.c;h=912f8be1e01dd2c2888101a891774a5676736f11;hp=1655d4c5c9f07e80bc7ca8315355cda7b6ea2232;hb=03af8776dc14167b078911b0c7c5327d1bcdd128;hpb=f4077c1bf64ef89d74a8d4822d2d7aada3ba9927 diff --git a/subsys/system/usetup/console.c b/subsys/system/usetup/console.c index 1655d4c..912f8be 100644 --- a/subsys/system/usetup/console.c +++ b/subsys/system/usetup/console.c @@ -367,6 +367,57 @@ WriteConsoleOutputCharacters(LPCSTR lpCharacter, NTSTATUS +WriteConsoleOutputCharactersW(LPCWSTR lpCharacter, + ULONG nLength, + COORD dwWriteCoord) +{ + IO_STATUS_BLOCK IoStatusBlock; + PCHAR Buffer; + COORD *pCoord; + PCHAR pText; + NTSTATUS Status; + ULONG i; + + Buffer = RtlAllocateHeap(ProcessHeap, + 0, + nLength + sizeof(COORD)); + pCoord = (COORD *)Buffer; + pText = (PCHAR)(pCoord + 1); + + *pCoord = dwWriteCoord; + + /* FIXME: use real unicode->oem conversion */ + for (i = 0; i < nLength; i++) + pText[i] = (CHAR)lpCharacter[i]; + pText[i] = 0; + + Status = NtDeviceIoControlFile(StdOutput, + NULL, + NULL, + NULL, + &IoStatusBlock, + IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER, + NULL, + 0, + Buffer, + nLength + sizeof(COORD)); + if (Status == STATUS_PENDING) + { + NtWaitForSingleObject(StdOutput, + FALSE, + NULL); + Status = IoStatusBlock.Status; + } + + RtlFreeHeap(ProcessHeap, + 0, + Buffer); + + return(Status); +} + + +NTSTATUS WriteConsoleOutputAttributes(CONST USHORT *lpAttribute, ULONG nLength, COORD dwWriteCoord, @@ -892,7 +943,7 @@ SetTextXY(SHORT x, SHORT y, PCHAR Text) VOID -SetInputTextXY(SHORT x, SHORT y, SHORT len, PCHAR Text) +SetInputTextXY(SHORT x, SHORT y, SHORT len, PWCHAR Text) { COORD coPos; ULONG Length; @@ -901,16 +952,20 @@ SetInputTextXY(SHORT x, SHORT y, SHORT len, PCHAR Text) coPos.X = x; coPos.Y = y; - Length = strlen(Text); + Length = wcslen(Text); + if (Length > len - 1) + { + Length = len - 1; + } FillConsoleOutputAttribute(0x70, len, coPos, &Written); - WriteConsoleOutputCharacters(Text, - Length, - coPos); + WriteConsoleOutputCharactersW(Text, + Length, + coPos); coPos.X += Length; FillConsoleOutputCharacter('_', @@ -1000,7 +1055,7 @@ SetHighlightedTextXY(SHORT x, SHORT y, PCHAR Text) VOID -PrintTextXY(SHORT x, SHORT y, char* fmt,...) +PrintTextXY(SHORT x, SHORT y, char* fmt, ...) { char buffer[512]; va_list ap; @@ -1018,4 +1073,43 @@ PrintTextXY(SHORT x, SHORT y, char* fmt,...) coPos); } + +VOID +PrintTextXYN(SHORT x, SHORT y, SHORT len, char* fmt, ...) +{ + char buffer[512]; + va_list ap; + COORD coPos; + ULONG Length; + ULONG Written; + + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + va_end(ap); + + coPos.X = x; + coPos.Y = y; + + Length = strlen(buffer); + if (Length > len - 1) + { + Length = len - 1; + } + + WriteConsoleOutputCharacters(buffer, + Length, + coPos); + + coPos.X += Length; + + if (len > Length) + { + FillConsoleOutputCharacter(' ', + len - Length, + coPos, + &Written); + } +} + + /* EOF */