Added MORE command.
[reactos.git] / rosapps / cmd / screen.c
1 /*
2 * SCREEN.C - screen internal command.
3 *
4 * clone from 4nt msgbox command
5 *
6 * 30 Aug 1999
7 * started - Dr.F <dfaustus@freemail.it>
8 *
9 *
10 */
11
12 #include "config.h"
13
14 #ifdef INCLUDE_CMD_SCREEN
15
16 #include <tchar.h>
17 #include <windows.h>
18 #include <stdlib.h>
19 #include <ctype.h>
20
21 #include "cmd.h"
22
23
24 INT CommandScreen (LPTSTR cmd, LPTSTR param)
25 {
26 SHORT x,y;
27 BOOL bSkipText = FALSE;
28
29 if (_tcsncmp (param, _T("/?"), 2) == 0)
30 {
31 ConOutPuts(_T(
32 "move cursor and optionally print text\n"
33 "\n"
34 "SCREEN row col [text]\n"
35 "\n"
36 " row row to wich move the cursor\n"
37 " col column to wich move the cursor"));
38 return 0;
39 }
40
41 //get row
42 while(_istspace(*param))
43 param++;
44
45 if(!(*param))
46 {
47 error_req_param_missing ();
48 return 1;
49 }
50
51 y = atoi(param);
52 if (y<0 || y>(maxy-1))
53 {
54 ConOutPrintf("invalid value for row");
55 return 1;
56 }
57
58 //get col
59 if(!(param = _tcschr(param,_T(' '))))
60 {
61 error_req_param_missing ();
62 return 1;
63 }
64
65 while(_istspace(*param))
66 param++;
67
68 if(!(*param))
69 {
70 error_req_param_missing ();
71 return 1;
72 }
73
74 x = atoi(param);
75 if (x<0 || x>(maxx-1))
76 {
77 ConErrPuts(_T("invalid value for col"));
78 return 1;
79 }
80
81 //get text
82 if(!(param = _tcschr(param,_T(' '))))
83 {
84 bSkipText = TRUE;
85 }
86 else
87 {
88 while(_istspace(*param))
89 param++;
90
91 if(!(*param))
92 {
93 bSkipText = TRUE;
94 }
95 }
96
97 bIgnoreEcho = TRUE;
98
99 if(bSkipText)
100 x=0;
101
102
103 SetCursorXY(x,y);
104
105 if(!(bSkipText))
106 ConOutPuts(param);
107
108 return 0;
109 }
110
111 #endif /* INCLUDE_CMD_SCREEN */