Rev 7787 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7787 | Rev 8827 | ||
---|---|---|---|
Line 1... | Line -... | ||
1 | /// =========================================================== |
- | |
2 | - | ||
3 | void command_history_add() |
1 | void command_history_add() { |
4 | { |
- | |
5 | - | ||
6 | int i; |
2 | int i; |
Line 7... | Line 3... | ||
7 | 3 | ||
Line 8... | Line 4... | ||
8 | if ('\0' == CMD[0]) return; |
4 | if ('\0' == CMD[0]) return; |
Line 21... | Line 17... | ||
21 | if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM-1) |
17 | if (CMD_HISTORY_NUM_REAL < CMD_HISTORY_NUM-1) |
22 | CMD_HISTORY_NUM_REAL++; |
18 | CMD_HISTORY_NUM_REAL++; |
Line 23... | Line 19... | ||
23 | 19 | ||
24 | } |
- | |
- | 20 | } |
|
Line 25... | Line 21... | ||
25 | // ============================================================ |
21 | |
26 | 22 | ||
27 | char * insert_string( char s1[], unsigned int pos, const char s2[] ) |
23 | char * insert_string( char s1[], unsigned int pos, const char s2[] ) |
28 | { |
24 | { |
Line 46... | Line 42... | ||
46 | 42 | ||
Line 47... | Line 43... | ||
47 | return s1; |
43 | return s1; |
48 | } |
44 | } |
Line 49... | Line -... | ||
49 | - | ||
- | 45 | ||
Line 50... | Line 46... | ||
50 | /// =========================================================== |
46 | |
51 | 47 | ||
52 | void command_get() |
48 | void command_get() |
Line 61... | Line 57... | ||
61 | int clipNum; // number of clipboard slots |
57 | int clipNum; // number of clipboard slots |
62 | char* clipBuf; // clipboard buffer |
58 | char* clipBuf; // clipboard buffer |
63 | char clipCopy[255+12]; |
59 | char clipCopy[255+12]; |
Line 64... | Line 60... | ||
64 | 60 | ||
65 | for (;;) |
- | |
66 | { |
61 | for (;;) { |
67 | key = getch(); |
62 | key = getch(); |
68 | if ( 0 != (key & 0xff) ) |
- | |
69 | { |
63 | if ( 0 != (key & 0xff) ) { |
70 | key &= 0xff; |
64 | key &= 0xff; |
71 | switch (key) |
- | |
72 | { |
65 | switch (key) { |
73 | case 27: // ESC |
66 | case 27: // ESC |
74 | for (i = cmdPos; i < cmdLen; i++) |
67 | for (i = cmdPos; i < cmdLen; i++) |
75 | printf(" "); |
68 | printf(" "); |
76 | for (i = cmdLen; i > 0; i--) |
69 | for (i = cmdLen; i > 0; i--) |
Line 111... | Line 104... | ||
111 | break; |
104 | break; |
112 | 105 | ||
Line 113... | Line 106... | ||
113 | 106 | ||
114 | case 22: // Ctrl+V |
107 | case 22: // Ctrl+V |
115 | clipNum = kol_clip_num(); |
108 | clipNum = _ksys_clip_num(); |
116 | if (clipNum > 0) |
109 | if (clipNum > 0) |
117 | { |
110 | { |
118 | clipBuf = kol_clip_get(clipNum-1); |
111 | clipBuf = _ksys_clip_get(clipNum-1); |
119 | // printf("Length: %d, Type: %d, Encoding: %d\n", (int) *clipBuf, (int)*(clipBuf+4), (int)*(clipBuf+8)); |
112 | // printf("Length: %d, Type: %d, Encoding: %d\n", (int) *clipBuf, (int)*(clipBuf+4), (int)*(clipBuf+8)); |
120 | if ( (int) *clipBuf > 0 ) // is clipboard empty? |
113 | if ( (int) *clipBuf > 0 ) // is clipboard empty? |
121 | { |
114 | { |
122 | if ((int)*(clipBuf+4)==0) // text? |
115 | if ((int)*(clipBuf+4)==0) // text? |
Line 153... | Line 146... | ||
153 | 146 | ||
Line 154... | Line 147... | ||
154 | for (i = 0; i <= cmdLen; i++) |
147 | for (i = 0; i <= cmdLen; i++) |
155 | *(clipCopy+12+i) = CMD[i]; |
148 | *(clipCopy+12+i) = CMD[i]; |
Line 156... | Line 149... | ||
156 | 149 | ||
Line 157... | Line 150... | ||
157 | kol_clip_set(12+cmdLen, clipCopy); |
150 | _ksys_clip_set(12+cmdLen, clipCopy); |
158 | 151 | ||
Line 159... | Line 152... | ||
159 | } |
152 | } |
160 | break; |
153 | break; |
161 | 154 | ||
162 | 155 | ||
163 | default: |
156 | default: |
164 | if (cmdLen < 255) |
157 | if (cmdLen < 255) |
165 | { |
158 | { |
166 | if ( kol_key_control() & 0x40 ) // ¥á«¨ ¢ª«îçñ CapsLock |
159 | if ( kol_key_control() & 0x40 ) // � ������ CapsLock |
Line 167... | Line 160... | ||
167 | if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // ¥á«¨ ¦ âë è¨äâë |
160 | if ( (kol_key_control() & 1) || (kol_key_control() & 2)) // � ������ ���� |
Line 296... | Line 289... | ||
296 | 289 | ||
297 | case 0: // console window closed |
290 | case 0: // console window closed |
Line -... | Line 291... | ||
- | 291 | cmd_exit(NULL); |
|
- | 292 | ||
298 | cmd_exit(NULL); |
293 | } // switch end |
Line 299... | Line 294... | ||
299 | 294 | } // if end |
|
300 | } |
- | |
Line 301... | Line -... | ||
301 | - | ||
Line 302... | Line -... | ||
302 | } |
- | |
Line 303... | Line 295... | ||
303 | } |
295 | } // for end |
304 | 296 | ||
305 | } |
297 | } |
306 | 298 | ||
Line 351... | Line 343... | ||
351 | return i+1; |
343 | return i+1; |
352 | } |
344 | } |
353 | } |
345 | } |
354 | 346 | ||
Line 355... | Line -... | ||
355 | /// =========================================================== |
- | |
- | 347 | ||
Line 356... | Line 348... | ||
356 | 348 | ||
Line 357... | Line -... | ||
357 | typedef int (*handler1_t)(char* arg); |
- | |
- | 349 | typedef int (*handler1_t)(char* arg); |
|
Line 358... | Line 350... | ||
358 | 350 | ||
359 | /// =========================================================== |
351 | |
360 | 352 | ||
361 | void command_execute() |
353 | void command_execute() |
Line 374... | Line 366... | ||
374 | 366 | ||
Line 375... | Line 367... | ||
375 | strcpy(args, CMD+arg); |
367 | strcpy(args, CMD+arg); |
376 | trim(args); |
368 | trim(args); |
Line 377... | Line 369... | ||
377 | 369 | ||
378 | for (i = 0; i < NUM_OF_CMD; i++) |
- | |
379 | { |
370 | for (i = 0; i < NUM_OF_CMD; i++) { |
380 | if (!strcmp(cmd, COMMANDS[i].name)) |
- | |
381 | { |
371 | if (!strcmp(cmd, COMMANDS[i].name)) { |
382 | result = ((handler1_t)COMMANDS[i].handler)(args); |
372 | result = ((handler1_t)COMMANDS[i].handler)(args); |
383 | if (result == FALSE) |
- | |
384 | { |
- | |
385 | #if LANG_ENG |
373 | if (result == FALSE) { |
386 | printf(" Error!\n\r"); |
- | |
387 | #elif LANG_RUS |
- | |
388 | printf(" 訡ª !\n\r"); |
- | |
389 | #endif |
374 | printf(UNKNOWN_CMD_ERROR); |
390 | } |
375 | } |
391 | return; |
376 | return; |
392 | } |
377 | } |
Line 393... | Line -... | ||
393 | } |
- | |
394 | 378 | } |
|
395 | - | ||
396 | if ( -1 != alias_search(CMD) ) |
379 | |
397 | { |
380 | if ( -1 != alias_search(CMD) ) { |
398 | strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD)); |
381 | strcpy(CMD, ALIASES+64*1024+256*alias_search(CMD)); |
399 | command_execute(); |
382 | command_execute(); |
Line 400... | Line 383... | ||
400 | return; |
383 | return; |
Line 401... | Line 384... | ||
401 | } |
384 | } |
402 | - | ||
403 | executable_run(cmd, args); |
- | |
404 | - |