Author: hbelusca
Date: Mon May  4 20:50:51 2015
New Revision: 67546

URL: http://svn.reactos.org/svn/reactos?rev=67546&view=rev
Log:
[USETUP]: Instead of defining a special function "DrawInputField" just to draw 
an input field for entering the partition size number, just use the already 
existing CONSOLE_SetInputTextXY function (and adapt the calling code because 
the string buffer for the SetInputTextXY function wants a unicode string). We 
now have a consistent input UI for usetup.
CORE-9453 #resolve #comment I committed a more elegant solution to this problem.

Modified:
    trunk/reactos/base/setup/usetup/interface/consup.h
    trunk/reactos/base/setup/usetup/interface/usetup.c

Modified: trunk/reactos/base/setup/usetup/interface/consup.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interface/consup.h?rev=67546&r1=67545&r2=67546&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/consup.h  [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/interface/consup.h  [iso-8859-1] Mon May  4 
20:50:51 2015
@@ -146,13 +146,6 @@
        IN LPCWSTR Text);
 
 VOID
-CONSOLE_SetInputTextXY(
-       IN SHORT x,
-       IN SHORT y,
-       IN SHORT len,
-       IN LPCWSTR Text);
-
-VOID
 CONSOLE_SetInvertedTextXY(
        IN SHORT x,
        IN SHORT y,

Modified: trunk/reactos/base/setup/usetup/interface/usetup.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interface/usetup.c?rev=67546&r1=67545&r2=67546&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/usetup.c  [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/interface/usetup.c  [iso-8859-1] Mon May  4 
20:50:51 2015
@@ -392,7 +392,7 @@
             Result = TRUE;
             break;
         }
-        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)   /* ENTER */
+        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)  /* ENTER */
         {
             Result = FALSE;
             break;
@@ -701,7 +701,7 @@
         else if ((Ir->Event.KeyEvent.uChar.AsciiChar > 0x60) && 
(Ir->Event.KeyEvent.uChar.AsciiChar < 0x7b))
         {
             /* a-z */
-            GenericListKeyPress (LanguageList, 
Ir->Event.KeyEvent.uChar.AsciiChar);
+            GenericListKeyPress(LanguageList, 
Ir->Event.KeyEvent.uChar.AsciiChar);
             RefreshPage = TRUE;
         }
 
@@ -1678,30 +1678,6 @@
 }
 
 
-static VOID
-DrawInputField(ULONG FieldLength,
-               SHORT Left,
-               SHORT Top,
-               PCHAR FieldContent)
-{
-    CHAR buf[100];
-    COORD coPos;
-    DWORD Written;
-
-    coPos.X = Left;
-    coPos.Y = Top;
-    memset(buf, '_', sizeof(buf));
-    buf[FieldLength - strlen(FieldContent)] = 0;
-    strcat(buf, FieldContent);
-
-    WriteConsoleOutputCharacterA(StdOutput,
-                                 buf,
-                                 strlen(buf),
-                                 coPos,
-                                 &Written);
-}
-
-
 #define PARTITION_SIZE_INPUT_FIELD_LENGTH 6
 /* Restriction for MaxSize: pow(10, PARTITION_SIZE_INPUT_FIELD_LENGTH)-1 */
 #define PARTITION_MAXSIZE 999999
@@ -1720,8 +1696,9 @@
     COORD coPos;
     DWORD Written;
     CHAR Buffer[100];
+    WCHAR PartitionSizeBuffer[100];
     ULONG Index;
-    CHAR ch;
+    WCHAR ch;
     SHORT iLeft;
     SHORT iTop;
 
@@ -1742,7 +1719,7 @@
 
     WriteConsoleOutputCharacterA(StdOutput,
                                  Buffer,
-                                 strlen (Buffer),
+                                 strlen(Buffer),
                                  coPos,
                                  &Written);
 
@@ -1751,16 +1728,16 @@
     coPos.Y = iTop;
     WriteConsoleOutputCharacterA(StdOutput,
                                  Buffer,
-                                 strlen (Buffer),
+                                 strlen(Buffer),
                                  coPos,
                                  &Written);
 
-    sprintf(Buffer, "%lu", MaxSize);
-    Index = strlen(Buffer);
-    DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
-                   iLeft,
-                   iTop,
-                   Buffer);
+    swprintf(PartitionSizeBuffer, L"%lu", MaxSize);
+    Index = wcslen(PartitionSizeBuffer);
+    CONSOLE_SetInputTextXY(iLeft,
+                           iTop,
+                           PARTITION_SIZE_INPUT_FIELD_LENGTH,
+                           PartitionSizeBuffer);
 
     while (TRUE)
     {
@@ -1772,52 +1749,53 @@
             if (Quit != NULL)
                 *Quit = TRUE;
 
-            Buffer[0] = 0;
+            PartitionSizeBuffer[0] = 0;
             break;
         }
-        else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN)       /* 
ENTER */
+        else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_RETURN)    /* ENTER */
         {
             break;
         }
-        else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)       /* 
ESCAPE */
+        else if (Ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)    /* ESCAPE 
*/
         {
             if (Cancel != NULL)
                 *Cancel = TRUE;
 
-            Buffer[0] = 0;
+            PartitionSizeBuffer[0] = 0;
             break;
         }
         else if ((Ir.Event.KeyEvent.wVirtualKeyCode == VK_BACK) &&  /* 
BACKSPACE */
                  (Index > 0))
         {
             Index--;
-            Buffer[Index] = 0;
-
-            DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
-                           iLeft,
-                           iTop,
-                           Buffer);
+            PartitionSizeBuffer[Index] = 0;
+
+            CONSOLE_SetInputTextXY(iLeft,
+                                   iTop,
+                                   PARTITION_SIZE_INPUT_FIELD_LENGTH,
+                                   PartitionSizeBuffer);
         }
         else if ((Ir.Event.KeyEvent.uChar.AsciiChar != 0x00) &&
                  (Index < PARTITION_SIZE_INPUT_FIELD_LENGTH))
         {
-            ch = Ir.Event.KeyEvent.uChar.AsciiChar;
-
-            if ((ch >= '0') && (ch <= '9'))
-            {
-                Buffer[Index] = ch;
+            ch = (WCHAR)Ir.Event.KeyEvent.uChar.AsciiChar;
+
+            if ((ch >= L'0') && (ch <= L'9'))
+            {
+                PartitionSizeBuffer[Index] = ch;
                 Index++;
-                Buffer[Index] = 0;
-
-                DrawInputField(PARTITION_SIZE_INPUT_FIELD_LENGTH,
-                               iLeft,
-                               iTop,
-                               Buffer);
-            }
-        }
-    }
-
-    strcpy(InputBuffer, Buffer);
+                PartitionSizeBuffer[Index] = 0;
+
+                CONSOLE_SetInputTextXY(iLeft,
+                                       iTop,
+                                       PARTITION_SIZE_INPUT_FIELD_LENGTH,
+                                       PartitionSizeBuffer);
+            }
+        }
+    }
+
+    /* Convert UNICODE --> ANSI the poor man's way */
+    sprintf(InputBuffer, "%S", PartitionSizeBuffer);
 }
 
 
@@ -3910,7 +3888,7 @@
 
             break;
         }
-        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)   /* ENTER */
+        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)    /* ENTER */
         {
             if (Line == 12)
             {
@@ -3958,7 +3936,7 @@
 
             break;
         }
-        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)   /* ENTER */
+        else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D)    /* ENTER */
         {
             if (DoesFileExist(L"\\Device\\Floppy0", L"\\") == FALSE)
             {


Reply via email to