[CMD]: Small refactoring:
[reactos.git] / reactos / base / shell / cmd / screen.c
1 /*
2 * SCREEN.C - screen internal command.
3 *
4 * clone from 4nt msgbox command
5 *
6 * 30 Aug 1999
7 * started - Paolo Pantaleo <paolopan@freemail.it>
8 *
9 * 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
10 * Remove all hardcoded strings in En.rc
11 *
12 */
13
14 #include "precomp.h"
15
16 #ifdef INCLUDE_CMD_SCREEN
17
18 INT CommandScreen(LPTSTR param)
19 {
20 SHORT x, y;
21 SHORT maxx, maxy;
22 BOOL bSkipText = FALSE;
23
24 if (_tcsncmp(param, _T("/?"), 2) == 0)
25 {
26 ConOutResPaging(TRUE,STRING_SCREEN_HELP);
27 return 0;
28 }
29
30 nErrorLevel = 0;
31
32 /* Retrieve the screen dimensions */
33 GetScreenSize(&maxx, &maxy);
34
35 /* Get row */
36 while (_istspace(*param))
37 param++;
38
39 if (!*param)
40 {
41 error_req_param_missing();
42 return 1;
43 }
44
45 y = _ttoi(param);
46 if (y < 0 || y > (maxy-1))
47 {
48 ConOutResPuts(STRING_SCREEN_ROW);
49 return 1;
50 }
51
52 /* Get column */
53 if (!(param = _tcschr(param, _T(' '))))
54 {
55 error_req_param_missing();
56 return 1;
57 }
58
59 while (_istspace(*param))
60 param++;
61
62 if (!*param)
63 {
64 error_req_param_missing();
65 return 1;
66 }
67
68 x = _ttoi(param);
69 if (x < 0 || x > (maxx-1))
70 {
71 ConErrResPuts(STRING_SCREEN_COL);
72 return 1;
73 }
74
75 /* Get text */
76 if (!(param = _tcschr(param, _T(' '))))
77 {
78 bSkipText = TRUE;
79 }
80 else
81 {
82 while (_istspace(*param))
83 param++;
84
85 if (!*param)
86 bSkipText = TRUE;
87 }
88
89 bIgnoreEcho = TRUE;
90
91 if (bSkipText)
92 x = 0;
93
94 SetCursorXY(x, y);
95
96 if (!bSkipText)
97 ConOutPuts(param);
98
99 return 0;
100 }
101
102 #endif /* INCLUDE_CMD_SCREEN */