Subversion Repositories Kolibri OS

Rev

Rev 2735 | Rev 3247 | Go to most recent revision | Details | Compare with Previous | 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)) &&
3245 Albom 20
        (0 != strcmp( CMD_HISTORY[5], CMD)) &&
21
        (0 != strcmp( CMD_HISTORY[6], CMD)) &&
22
        (0 != strcmp( CMD_HISTORY[7], CMD)) &&
23
        (0 != strcmp( CMD_HISTORY[8], CMD)) &&
24
	(0 != strcmp( CMD_HISTORY[9], CMD)) )
25
1665 Nasarus 26
 
27
        strcpy(CMD_HISTORY[9], CMD_HISTORY[8]);
3245 Albom 28
        strcpy(CMD_HISTORY[8], CMD_HISTORY[7]);
29
	strcpy(CMD_HISTORY[7], CMD_HISTORY[6]);
30
        strcpy(CMD_HISTORY[6], CMD_HISTORY[5]);
31
	strcpy(CMD_HISTORY[5], CMD_HISTORY[4]);
32
	strcpy(CMD_HISTORY[4], CMD_HISTORY[3]);
1665 Nasarus 33
	strcpy(CMD_HISTORY[3], CMD_HISTORY[2]);
34
	strcpy(CMD_HISTORY[2], CMD_HISTORY[1]);
35
	strcpy(CMD_HISTORY[1], CMD_HISTORY[0]);
36
37
 
38
2735 Albom 39
 
40
		CMD_HISTORY_NUM_REAL++;
41
42
 
1665 Nasarus 43
44
 
45
46
 
47
48
 
49
{
50
unsigned key;
51
//unsigned pos = 0;
52
int hist;
53
54
 
55
CMD_NUM = 0;
56
57
 
58
	{
59
	key = getch();
60
	if ( 0 != (key & 0xff) )
61
		{
62
		key &= 0xff;
63
		switch (key)
64
			{
65
			case 27: // ESC
66
				command_clear();
67
				break;
68
69
 
70
				CMD[CMD_POS] = '\0';
71
				printf("\n\r");
72
73
 
74
				return;
75
76
 
77
				if (CMD_POS > 0)
78
					{
79
					printf ("%c %c", 8, 8);
80
					CMD_POS--;
81
					}
82
				break;
83
84
 
85
				break;
86
87
 
88
				if (CMD_POS < 255)
89
					{
90
2174 Albom 91
 
92
						if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // если нажаты шифты
93
							key = tolower(key);
94
						else
95
							key = toupper(key);
96
97
 
1665 Nasarus 98
					CMD_POS++;
99
					printf("%c", key);
100
					}
101
					break;
102
			};
103
		}
104
	else	// обработка расширенных клавиш
105
		{
106
		key = (key>>8)&0xff;
107
//		printf ("%d\n\r", key);
108
109
 
110
			{
111
112
 
3245 Albom 113
				for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
1665 Nasarus 114
					{
115
					command_clear();
116
117
 
118
						CMD_NUM++;
119
					else
120
						CMD_NUM = 0;
121
122
 
123
					strcpy(CMD, CMD_HISTORY[CMD_NUM]);
124
					if ((CMD_POS = strlen(CMD)) != 0)
125
						break;
126
					}
127
128
 
129
130
 
3245 Albom 131
				for (hist = 0; hist < CMD_HISTORY_NUM; hist++)
1665 Nasarus 132
					{
133
					command_clear();
134
135
 
136
						CMD_NUM--;
137
					else
138
						CMD_NUM = CMD_HISTORY_NUM-1;
139
140
 
141
					strcpy(CMD, CMD_HISTORY[CMD_NUM]);
142
					if ((CMD_POS = strlen(CMD)) != 0)
143
						break;
144
					}
145
				break;
146
147
 
148
				cmd_exit(NULL);
149
150
 
151
		}
152
153
 
154
}
155
156
 
157
 
158
 
159
160
 
161
{
162
unsigned i, len;
3245 Albom 163
int quote = 0;
164
165
 
166
   quote = 1;
167
168
 
169
   {
170
   for (i=0;;i++)
171
       	{
172
	cmd[i] = CMD[i];
1665 Nasarus 173
	if (0 == cmd[i])
174
		{
175
		i = -2;
176
		break;
177
		}
178
	if ( iswhite(cmd[i]) )
179
		{
180
                cmd[i] = '\0';
3245 Albom 181
                break;
182
		}
183
	}
184
   return i+1;
185
   }
186
   else
187
   {
188
   len = 0;
189
   for (i=1;;i++)
190
       	{
191
	cmd[len] = CMD[i];
192
	if (0 == cmd[len])
193
		{
194
		len = -2;
195
		break;
1665 Nasarus 196
		}
197
	if ( cmd[len] == '"' )
3245 Albom 198
		{
199
                cmd[len] = '\0';
200
                break;
201
		}
202
        len++;
203
	}
1665 Nasarus 204
   trim(cmd);
3245 Albom 205
   return len+2;
206
   }
207
}
1665 Nasarus 208
209
 
210
211
 
212
213
 
214
215
 
216
{
217
char cmd[256];
218
char args[256];
219
unsigned arg;
220
int i;
221
222
 
223
arg = command_get_cmd(cmd);
224
225
 
226
	return;
227
228
 
229
trim(args);
230
231
 
232
	{
233
	if (!strcmp(cmd, COMMANDS[i].name))
234
		{
235
		((handler1_t)COMMANDS[i].handler)(args);
236
		return;
237
		}
238
	}
239
240
 
241
 
242
	{
243
	strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD));
244
	command_execute();
245
	return;
246
	}
247
248
 
249
250
 
251
252
 
253