Subversion Repositories Kolibri OS

Rev

Rev 2174 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1665 Nasarus 1
 
2
3
 
4
{
5
for (;CMD_POS;CMD_POS--)
6
	printf("%c %c", 8, 8);
7
CMD[0]='\0';
8
}
9
10
 
11
12
 
13
{
14
15
 
16
	(0 != strcmp( CMD_HISTORY[1], CMD)) &&
17
	(0 != strcmp( CMD_HISTORY[2], CMD)) &&
18
	(0 != strcmp( CMD_HISTORY[3], CMD)) &&
19
	(0 != strcmp( CMD_HISTORY[4], CMD)) )
20
21
 
22
	strcpy(CMD_HISTORY[4], CMD_HISTORY[3]);
23
	strcpy(CMD_HISTORY[3], CMD_HISTORY[2]);
24
	strcpy(CMD_HISTORY[2], CMD_HISTORY[1]);
25
	strcpy(CMD_HISTORY[1], CMD_HISTORY[0]);
26
27
 
28
	}
29
30
 
31
32
 
33
34
 
35
{
36
unsigned key;
37
//unsigned pos = 0;
38
int hist;
39
40
 
41
CMD_NUM = 0;
42
43
 
44
	{
45
	key = getch();
46
	if ( 0 != (key & 0xff) )
47
		{
48
		key &= 0xff;
49
		switch (key)
50
			{
51
			case 27: // ESC
52
				command_clear();
53
				break;
54
55
 
56
				CMD[CMD_POS] = '\0';
57
				printf("\n\r");
58
59
 
60
				return;
61
62
 
63
				if (CMD_POS > 0)
64
					{
65
					printf ("%c %c", 8, 8);
66
					CMD_POS--;
67
					}
68
				break;
69
70
 
71
				break;
72
73
 
74
				if (CMD_POS < 255)
75
					{
76
					CMD[CMD_POS] = key;
77
					CMD_POS++;
78
					printf("%c", key);
79
					}
80
					break;
81
			};
82
		}
83
	else	// обработка расширенных клавиш
84
		{
85
		key = (key>>8)&0xff;
86
//		printf ("%d\n\r", key);
87
88
 
89
			{
90
91
 
92
				for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
93
					{
94
					command_clear();
95
96
 
97
						CMD_NUM++;
98
					else
99
						CMD_NUM = 0;
100
101
 
102
					strcpy(CMD, CMD_HISTORY[CMD_NUM]);
103
					if ((CMD_POS = strlen(CMD)) != 0)
104
						break;
105
					}
106
107
 
108
109
 
110
				for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
111
					{
112
					command_clear();
113
114
 
115
						CMD_NUM--;
116
					else
117
						CMD_NUM = CMD_HISTORY_NUM-1;
118
119
 
120
					strcpy(CMD, CMD_HISTORY[CMD_NUM]);
121
					if ((CMD_POS = strlen(CMD)) != 0)
122
						break;
123
					}
124
				break;
125
126
 
127
				cmd_exit(NULL);
128
129
 
130
		}
131
132
 
133
}
134
135
 
136
 
137
 
138
139
 
140
{
141
unsigned i;
142
for (i=0;;i++)
143
	{
144
	cmd[i] = CMD[i];
145
	if (0 == cmd[i])
146
		{
147
		i = -2;
148
		break;
149
		}
150
	if ( iswhite(cmd[i]) )
151
		{
152
		cmd[i] = '\0';
153
		break;
154
		}
155
	}
156
return i+1;
157
}
158
159
 
160
161
 
162
163
 
164
165
 
166
{
167
char cmd[256];
168
char args[256];
169
unsigned arg;
170
int i;
171
172
 
173
arg = command_get_cmd(cmd);
174
175
 
176
	return;
177
178
 
179
trim(args);
180
181
 
182
	{
183
	if (!strcmp(cmd, COMMANDS[i].name))
184
		{
185
		((handler1_t)COMMANDS[i].handler)(args);
186
		return;
187
		}
188
	}
189
190
 
191
 
192
	{
193
	strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD));
194
	command_execute();
195
	return;
196
	}
197
198
 
199
200
 
201
202
 
203