[USETUP] Loop over MUI entries of the same ID 2553/head
authorGeorge Bișoc <george.bisoc@reactos.org>
Tue, 28 Apr 2020 11:08:55 +0000 (13:08 +0200)
committerGeorge Bișoc <george.bisoc@reactos.org>
Wed, 5 May 2021 17:30:53 +0000 (19:30 +0200)
MUI entries can have the same ID pointed by TextID member of MUI_ENTRY structure. For this matter, altering a certain entry such as deleting a portion of text with MUIClearStyledText() only removes that portion of text when the given ID argument and the retrieved ID match.

However, MUIClearStyledText() only removes the first instance of text in the console leaving other entries with the same ID as is. Therefore we must ensure that we also iterate over other entries with the same ID as well. Besides the aforementioned function, do the same with MUIClearText(), MUISetText() and MUISetStyledText() too.

base/setup/usetup/mui.c

index d16caaa..d1e6599 100644 (file)
@@ -325,6 +325,7 @@ MUIClearText(
     IN INT TextID)
 {
     const MUI_ENTRY * entry;
+    ULONG Index = 0;
 
     /* Get the MUI entry */
     entry = MUIGetEntry(Page, TextID);
@@ -332,11 +333,25 @@ MUIClearText(
     if (!entry)
         return;
 
-    /* Remove the text by using CONSOLE_ClearTextXY() */
-    CONSOLE_ClearTextXY(
-        entry->X,
-        entry->Y,
-        (ULONG)strlen(entry->Buffer));
+    /* Ensure that the text string given by the text ID and page is not NULL */
+    while (entry[Index].Buffer != NULL)
+    {
+        /* If text ID is not correct, skip the entry */
+        if (entry[Index].TextID != TextID)
+        {
+            Index++;
+            continue;
+        }
+
+        /* Remove the text by using CONSOLE_ClearTextXY() */
+        CONSOLE_ClearTextXY(
+            entry[Index].X,
+            entry[Index].Y,
+            (ULONG)strlen(entry[Index].Buffer));
+
+        /* Increment the index and loop over next entires with the same ID */
+        Index++;
+    }
 }
 
 /**
@@ -366,6 +381,7 @@ MUIClearStyledText(
     IN INT Flags)
 {
     const MUI_ENTRY * entry;
+    ULONG Index = 0;
 
     /* Get the MUI entry */
     entry = MUIGetEntry(Page, TextID);
@@ -373,12 +389,26 @@ MUIClearStyledText(
     if (!entry)
         return;
 
-    /* Now, begin removing the text by calling CONSOLE_ClearStyledText() */
-    CONSOLE_ClearStyledText(
-        entry->X,
-        entry->Y,
-        Flags,
-        (ULONG)strlen(entry->Buffer));
+    /* Ensure that the text string given by the text ID and page is not NULL */
+    while (entry[Index].Buffer != NULL)
+    {
+        /* If text ID is not correct, skip the entry */
+        if (entry[Index].TextID != TextID)
+        {
+            Index++;
+            continue;
+        }
+
+        /* Now, begin removing the text by calling CONSOLE_ClearStyledText() */
+        CONSOLE_ClearStyledText(
+            entry[Index].X,
+            entry[Index].Y,
+            Flags,
+            (ULONG)strlen(entry[Index].Buffer));
+
+        /* Increment the index and loop over next entires with the same ID */
+        Index++;
+    }
 }
 
 /**
@@ -403,6 +433,7 @@ MUISetText(
     IN INT TextID)
 {
     const MUI_ENTRY * entry;
+    ULONG Index = 0;
 
     /* Get the MUI entry */
     entry = MUIGetEntry(Page, TextID);
@@ -410,8 +441,22 @@ MUISetText(
     if (!entry)
         return;
 
-    /* Print the text to the console output by calling CONSOLE_SetTextXY() */
-    CONSOLE_SetTextXY(entry->X, entry->Y, entry->Buffer);
+    /* Ensure that the text string given by the text ID and page is not NULL */
+    while (entry[Index].Buffer != NULL)
+    {
+        /* If text ID is not correct, skip the entry */
+        if (entry[Index].TextID != TextID)
+        {
+            Index++;
+            continue;
+        }
+
+        /* Print the text to the console output by calling CONSOLE_SetTextXY() */
+        CONSOLE_SetTextXY(entry[Index].X, entry[Index].Y, entry[Index].Buffer);
+
+        /* Increment the index and loop over next entires with the same ID */
+        Index++;
+    }
 }
 
 /**
@@ -441,6 +486,7 @@ MUISetStyledText(
     IN INT Flags)
 {
     const MUI_ENTRY * entry;
+    ULONG Index = 0;
 
     /* Get the MUI entry */
     entry = MUIGetEntry(Page, TextID);
@@ -448,8 +494,22 @@ MUISetStyledText(
     if (!entry)
         return;
 
-    /* Print the text to the console output by calling CONSOLE_SetStyledText() */
-    CONSOLE_SetStyledText(entry->X, entry->Y, Flags, entry->Buffer);
+    /* Ensure that the text string given by the text ID and page is not NULL */
+    while (entry[Index].Buffer != NULL)
+    {
+        /* If text ID is not correct, skip the entry */
+        if (entry[Index].TextID != TextID)
+        {
+            Index++;
+            continue;
+        }
+
+        /* Print the text to the console output by calling CONSOLE_SetStyledText() */
+        CONSOLE_SetStyledText(entry[Index].X, entry[Index].Y, Flags, entry[Index].Buffer);
+
+        /* Increment the index and loop over next entires with the same ID */
+        Index++;
+    }
 }
 
 VOID