From 254aa472e823a41a7ca979ff82d318badfac04f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 3 Sep 2017 19:46:26 +0000 Subject: [PATCH] [SETUPLIB][USETUP] Make the GENERIC_LIST store the items display text in UNICODE (and not in ANSI). Only convert to ANSI when needed (e.g. in the display code for usetup). The 1st-stage GUI setup will however use the UNICODE strings directly. svn path=/branches/setup_improvements/; revision=75753 --- base/setup/lib/settings.c | 14 +++++++------- base/setup/lib/utils/genlist.c | 9 +++++---- base/setup/lib/utils/genlist.h | 6 +++--- base/setup/lib/utils/osdetect.c | 4 +--- base/setup/usetup/genlist.c | 22 ++++++++++++++++------ base/setup/usetup/genlist.h | 3 +++ base/setup/usetup/usetup.c | 13 +++++++++---- 7 files changed, 44 insertions(+), 27 deletions(-) diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c index bf9a8049299..4e27d0300f2 100644 --- a/base/setup/lib/settings.c +++ b/base/setup/lib/settings.c @@ -323,7 +323,7 @@ typedef UCHAR (NTAPI *PPROCESS_ENTRY_ROUTINE)( IN PWCHAR KeyName, IN PWCHAR KeyValue, - IN PCHAR DisplayText, + OUT PWCHAR DisplayText, IN SIZE_T DisplayTextSize, OUT PVOID* UserData, OUT PBOOLEAN Current, @@ -344,7 +344,7 @@ AddEntriesFromInfSection( PVOID UserData; BOOLEAN Current; UCHAR RetVal; - CHAR DisplayText[128]; + WCHAR DisplayText[128]; if (!SetupFindFirstLineW(InfFile, SectionName, NULL, pContext)) return -1; @@ -404,7 +404,7 @@ NTAPI DefaultProcessEntry( IN PWCHAR KeyName, IN PWCHAR KeyValue, - IN PCHAR DisplayText, + OUT PWCHAR DisplayText, IN SIZE_T DisplayTextSize, OUT PVOID* UserData, OUT PBOOLEAN Current, @@ -422,7 +422,7 @@ DefaultProcessEntry( } wcscpy((PWCHAR)*UserData, KeyName); - sprintf(DisplayText, "%S", KeyValue); + wcscpy(DisplayText, KeyValue); *Current = (CompareKey ? !_wcsicmp(KeyName, CompareKey) : FALSE); @@ -739,7 +739,7 @@ CreateDisplayDriverList( } #if 0 - AppendGenericListEntry(List, "Other display driver", NULL, TRUE); + AppendGenericListEntry(List, L"Other display driver", NULL, TRUE); #endif return List; @@ -1086,7 +1086,7 @@ NTAPI ProcessLangEntry( IN PWCHAR KeyName, IN PWCHAR KeyValue, - IN PCHAR DisplayText, + OUT PWCHAR DisplayText, IN SIZE_T DisplayTextSize, OUT PVOID* UserData, OUT PBOOLEAN Current, @@ -1110,7 +1110,7 @@ ProcessLangEntry( } wcscpy((PWCHAR)*UserData, KeyName); - sprintf(DisplayText, "%S", KeyValue); + wcscpy(DisplayText, KeyValue); *Current = FALSE; diff --git a/base/setup/lib/utils/genlist.c b/base/setup/lib/utils/genlist.c index 1795895a78c..919b5243ccf 100644 --- a/base/setup/lib/utils/genlist.c +++ b/base/setup/lib/utils/genlist.c @@ -65,7 +65,7 @@ DestroyGenericList( BOOLEAN AppendGenericListEntry( IN OUT PGENERIC_LIST List, - IN PCHAR Text, + IN PCWSTR Text, IN PVOID UserData, IN BOOLEAN Current) { @@ -73,11 +73,12 @@ AppendGenericListEntry( Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap, 0, - sizeof(GENERIC_LIST_ENTRY) + strlen(Text)); + sizeof(GENERIC_LIST_ENTRY) + + (wcslen(Text) + 1) * sizeof(WCHAR)); if (Entry == NULL) return FALSE; - strcpy (Entry->Text, Text); + wcscpy(Entry->Text, Text); Entry->List = List; Entry->UserData = UserData; @@ -138,7 +139,7 @@ GetListEntryUserData( return Entry->UserData; } -LPCSTR +PCWSTR GetListEntryText( IN PGENERIC_LIST_ENTRY Entry) { diff --git a/base/setup/lib/utils/genlist.h b/base/setup/lib/utils/genlist.h index 56210891c1f..ca8696d9570 100644 --- a/base/setup/lib/utils/genlist.h +++ b/base/setup/lib/utils/genlist.h @@ -12,7 +12,7 @@ typedef struct _GENERIC_LIST_ENTRY LIST_ENTRY Entry; struct _GENERIC_LIST* List; PVOID UserData; - CHAR Text[1]; // FIXME: UI stuff + WCHAR Text[1]; // FIXME: UI stuff } GENERIC_LIST_ENTRY, *PGENERIC_LIST_ENTRY; @@ -38,7 +38,7 @@ DestroyGenericList( BOOLEAN AppendGenericListEntry( IN OUT PGENERIC_LIST List, - IN PCHAR Text, + IN PCWSTR Text, IN PVOID UserData, IN BOOLEAN Current); @@ -63,7 +63,7 @@ PVOID GetListEntryUserData( IN PGENERIC_LIST_ENTRY Entry); -LPCSTR +PCWSTR GetListEntryText( IN PGENERIC_LIST_ENTRY Entry); diff --git a/base/setup/lib/utils/osdetect.c b/base/setup/lib/utils/osdetect.c index a82b04c291f..fdfd5ba02ae 100644 --- a/base/setup/lib/utils/osdetect.c +++ b/base/setup/lib/utils/osdetect.c @@ -575,7 +575,6 @@ AddNTOSInstallation( { PNTOS_INSTALLATION NtOsInstall; SIZE_T ArcPathLength, NtPathLength; - CHAR InstallNameA[MAX_PATH]; /* Is there already any installation with these settings? */ NtOsInstall = FindExistingNTOSInstall(List, SystemRootArcPath, SystemRootNtPath); @@ -623,8 +622,7 @@ AddNTOSInstallation( InstallationName); // Having the GENERIC_LIST storing the display item string plainly sucks... - RtlStringCchPrintfA(InstallNameA, ARRAYSIZE(InstallNameA), "%S", InstallationName); - AppendGenericListEntry(List, InstallNameA, NtOsInstall, FALSE); + AppendGenericListEntry(List, InstallationName, NtOsInstall, FALSE); return NtOsInstall; } diff --git a/base/setup/usetup/genlist.c b/base/setup/usetup/genlist.c index 773dd1b14b6..d0b7a638750 100644 --- a/base/setup/usetup/genlist.c +++ b/base/setup/usetup/genlist.c @@ -47,6 +47,8 @@ InitGenericListUi( ListUi->Right = 0; ListUi->Bottom = 0; ListUi->Redraw = TRUE; + + ListUi->CurrentItemText[0] = ANSI_NULL; } static @@ -157,6 +159,8 @@ DrawListEntries( break; ListUi->LastShown = Entry; + sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text); + FillConsoleOutputAttribute(StdOutput, (List->CurrentEntry == ListEntry) ? FOREGROUND_BLUE | BACKGROUND_WHITE : @@ -173,8 +177,8 @@ DrawListEntries( coPos.X++; WriteConsoleOutputCharacterA(StdOutput, - ListEntry->Text, - min(strlen(ListEntry->Text), (SIZE_T)Width - 2), + ListUi->CurrentItemText, + min(strlen(ListUi->CurrentItemText), (SIZE_T)Width - 2), coPos, &Written); coPos.X--; @@ -414,7 +418,7 @@ ScrollPageUpGenericList( for (i = ListUi->Bottom - 1; i > ListUi->Top + 1; i--) { - ScrollUpGenericList(ListUi); + ScrollUpGenericList(ListUi); } /* Update user interface */ @@ -489,13 +493,17 @@ GenericListKeyPress( ListUi->Redraw = FALSE; - if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar) && + sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text); + + if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar) && (List->CurrentEntry->Entry.Flink != &List->ListHead)) { ScrollDownGenericList(ListUi); ListEntry = List->CurrentEntry; - if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar)) + sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text); + + if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar)) goto End; } @@ -506,7 +514,9 @@ GenericListKeyPress( for (;;) { - if ((strlen(ListEntry->Text) > 0) && (tolower(ListEntry->Text[0]) == AsciiChar)) + sprintf(ListUi->CurrentItemText, "%S", ListEntry->Text); + + if ((strlen(ListUi->CurrentItemText) > 0) && (tolower(ListUi->CurrentItemText[0]) == AsciiChar)) { Flag = TRUE; break; diff --git a/base/setup/usetup/genlist.h b/base/setup/usetup/genlist.h index 0799a63ef78..5e85800fd63 100644 --- a/base/setup/usetup/genlist.h +++ b/base/setup/usetup/genlist.h @@ -40,6 +40,9 @@ typedef struct _GENERIC_LIST_UI SHORT Right; SHORT Bottom; BOOL Redraw; + + CHAR CurrentItemText[256]; + } GENERIC_LIST_UI, *PGENERIC_LIST_UI; VOID diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index a5764589ef4..9106d0dcab7 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -1093,6 +1093,7 @@ static PAGE_NUMBER DeviceSettingsPage(PINPUT_RECORD Ir) { static ULONG Line = 16; + CHAR CurrentItemText[256]; /* Initialize the computer settings list */ if (ComputerList == NULL) @@ -1147,10 +1148,14 @@ DeviceSettingsPage(PINPUT_RECORD Ir) MUIDisplayPage(DEVICE_SETTINGS_PAGE); - CONSOLE_SetTextXY(25, 11, GetListEntryText(GetCurrentListEntry(ComputerList))); - CONSOLE_SetTextXY(25, 12, GetListEntryText(GetCurrentListEntry(DisplayList))); - CONSOLE_SetTextXY(25, 13, GetListEntryText(GetCurrentListEntry(KeyboardList))); - CONSOLE_SetTextXY(25, 14, GetListEntryText(GetCurrentListEntry(LayoutList))); + sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(ComputerList))); + CONSOLE_SetTextXY(25, 11, CurrentItemText); + sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(DisplayList))); + CONSOLE_SetTextXY(25, 12, CurrentItemText); + sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(KeyboardList))); + CONSOLE_SetTextXY(25, 13, CurrentItemText); + sprintf(CurrentItemText, "%S", GetListEntryText(GetCurrentListEntry(LayoutList))); + CONSOLE_SetTextXY(25, 14, CurrentItemText); CONSOLE_InvertTextXY(24, Line, 48, 1);