https://git.reactos.org/?p=reactos.git;a=commitdiff;h=254aa472e823a41a7ca979...
commit 254aa472e823a41a7ca979ff82d318badfac04f8 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Sep 3 19:46:26 2017 +0000 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Sun Oct 28 00:30:54 2018 +0200
[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 bf9a804929..4e27d0300f 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 1795895a78..919b5243cc 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 56210891c1..ca8696d957 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 a82b04c291..fdfd5ba02a 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 773dd1b14b..d0b7a63875 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 0799a63ef7..5e85800fd6 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 a5764589ef..9106d0dcab 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);