[CMD]: Small refactoring:
[reactos.git] / reactos / base / shell / cmd / screen.c
index b45d9da..0304b52 100644 (file)
 
 #ifdef INCLUDE_CMD_SCREEN
 
-
-INT CommandScreen (LPTSTR param)
+INT CommandScreen(LPTSTR param)
 {
-    SHORT x,y;
+    SHORT x, y;
+    SHORT maxx, maxy;
     BOOL bSkipText = FALSE;
 
-    if (_tcsncmp (param, _T("/?"), 2) == 0)
+    if (_tcsncmp(param, _T("/?"), 2) == 0)
     {
         ConOutResPaging(TRUE,STRING_SCREEN_HELP);
         return 0;
@@ -29,72 +29,71 @@ INT CommandScreen (LPTSTR param)
 
     nErrorLevel = 0;
 
-    //get row
-    while(_istspace(*param))
+    /* Retrieve the screen dimensions */
+    GetScreenSize(&maxx, &maxy);
+
+    /* Get row */
+    while (_istspace(*param))
         param++;
 
-    if (!(*param))
+    if (!*param)
     {
-        error_req_param_missing ();
+        error_req_param_missing();
         return 1;
     }
 
     y = _ttoi(param);
-    if (y<0 || y>(maxy-1))
+    if (y < 0 || y > (maxy-1))
     {
         ConOutResPuts(STRING_SCREEN_ROW);
-
         return 1;
     }
 
-    //get col
-    if (!(param = _tcschr(param,_T(' '))))
+    /* Get column */
+    if (!(param = _tcschr(param, _T(' '))))
     {
-        error_req_param_missing ();
+        error_req_param_missing();
         return 1;
     }
 
-    while(_istspace(*param))
+    while (_istspace(*param))
         param++;
 
-    if (!(*param))
+    if (!*param)
     {
-        error_req_param_missing ();
+        error_req_param_missing();
         return 1;
     }
 
     x = _ttoi(param);
-    if (x<0 || x>(maxx-1))
+    if (x < 0 || x > (maxx-1))
     {
         ConErrResPuts(STRING_SCREEN_COL);
         return 1;
     }
 
-    //get text
-    if (!(param = _tcschr(param,_T(' '))))
+    /* Get text */
+    if (!(param = _tcschr(param, _T(' '))))
     {
         bSkipText = TRUE;
     }
     else
     {
-        while(_istspace(*param))
+        while (_istspace(*param))
             param++;
 
-        if (!(*param))
-        {
+        if (!*param)
             bSkipText = TRUE;
-        }
     }
 
     bIgnoreEcho = TRUE;
 
     if (bSkipText)
-        x=0;
-
+        x = 0;
 
-    SetCursorXY(x,y);
+    SetCursorXY(x, y);
 
-    if (!(bSkipText))
+    if (!bSkipText)
         ConOutPuts(param);
 
     return 0;