Rev 4217 | Rev 4224 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4217 | Rev 4223 | ||
---|---|---|---|
Line 257... | Line 257... | ||
257 | /* Backspace */ |
257 | /* Backspace */ |
258 | if (position == 0) |
258 | if (position == 0) |
259 | continue; |
259 | continue; |
260 | 260 | ||
261 | if (wstr_remove(current, position - 1)) { |
261 | if (wstr_remove(current, position - 1)) { |
262 | putchar('\b'); |
- | |
263 | printf("%ls", current + position); |
- | |
264 | position--; |
262 | position--; |
- | 263 | putchar('\b'); |
|
- | 264 | printf("%ls ", current + position); |
|
265 | print_cc('\b', wstr_length(current) - position); |
265 | print_cc('\b', wstr_length(current) - position + 1); |
266 | continue; |
266 | continue; |
267 | } |
267 | } |
268 | } |
268 | } |
269 | 269 | ||
270 | if (ch == '\t') { |
270 | if (ch == '\t') { |
Line 331... | Line 331... | ||
331 | 331 | ||
332 | print_cc('\b', wstr_length(current) - position); |
332 | print_cc('\b', wstr_length(current) - position); |
333 | continue; |
333 | continue; |
334 | } |
334 | } |
335 | 335 | ||
336 | if (ch == 0x1b) { |
336 | if (ch == U_LEFT_ARROW) { |
- | 337 | /* Left */ |
|
- | 338 | if (position > 0) { |
|
- | 339 | putchar('\b'); |
|
- | 340 | position--; |
|
- | 341 | } |
|
- | 342 | continue; |
|
- | 343 | } |
|
- | 344 | ||
- | 345 | if (ch == U_RIGHT_ARROW) { |
|
- | 346 | /* Right */ |
|
- | 347 | if (position < wstr_length(current)) { |
|
- | 348 | putchar(current[position]); |
|
- | 349 | position++; |
|
- | 350 | } |
|
- | 351 | continue; |
|
- | 352 | } |
|
- | 353 | ||
- | 354 | if ((ch == U_UP_ARROW) || (ch == U_DOWN_ARROW)) { |
|
337 | /* Special command */ |
355 | /* Up, down */ |
338 | wchar_t mod = _getc(indev); |
356 | print_cc('\b', position); |
339 | wchar_t ch = _getc(indev); |
357 | print_cc(' ', wstr_length(current)); |
- | 358 | print_cc('\b', wstr_length(current)); |
|
340 | 359 | ||
- | 360 | if (ch == U_UP_ARROW) { |
|
- | 361 | /* Up */ |
|
- | 362 | if (history_pos == 0) |
|
- | 363 | history_pos = KCONSOLE_HISTORY - 1; |
|
- | 364 | else |
|
- | 365 | history_pos--; |
|
- | 366 | } else { |
|
- | 367 | /* Down */ |
|
- | 368 | history_pos++; |
|
- | 369 | history_pos = history_pos % KCONSOLE_HISTORY; |
|
- | 370 | } |
|
- | 371 | current = history[history_pos]; |
|
- | 372 | printf("%ls", current); |
|
- | 373 | position = wstr_length(current); |
|
- | 374 | continue; |
|
- | 375 | } |
|
- | 376 | ||
- | 377 | if (ch == U_HOME_ARROW) { |
|
- | 378 | /* Home */ |
|
- | 379 | print_cc('\b', position); |
|
- | 380 | position = 0; |
|
- | 381 | continue; |
|
- | 382 | } |
|
- | 383 | ||
- | 384 | if (ch == U_END_ARROW) { |
|
- | 385 | /* End */ |
|
- | 386 | printf("%ls", current + position); |
|
- | 387 | position = wstr_length(current); |
|
- | 388 | continue; |
|
- | 389 | } |
|
- | 390 | ||
- | 391 | if (ch == U_DELETE) { |
|
- | 392 | /* Delete */ |
|
341 | if ((mod != 0x5b) && (mod != 0x4f)) |
393 | if (position == wstr_length(current)) |
342 | continue; |
394 | continue; |
343 | 395 | ||
344 | if ((ch == 0x33) && (_getc(indev) == 0x7e)) { |
- | |
345 | /* Delete */ |
- | |
346 | if (position == wstr_length(current)) |
- | |
347 | continue; |
- | |
348 | - | ||
349 | if (wstr_remove(current, position)) { |
396 | if (wstr_remove(current, position)) { |
350 | putchar('\b'); |
- | |
351 | printf("%ls", current + position); |
397 | printf("%ls ", current + position); |
352 | position--; |
- | |
353 | print_cc('\b', wstr_length(current) - position); |
398 | print_cc('\b', wstr_length(current) - position + 1); |
354 | } |
- | |
355 | } else if (ch == 0x48) { |
- | |
356 | /* Home */ |
- | |
357 | print_cc('\b', position); |
- | |
358 | position = 0; |
- | |
359 | } else if (ch == 0x46) { |
- | |
360 | /* End */ |
- | |
361 | printf("%ls", current + position); |
- | |
362 | position = wstr_length(current); |
- | |
363 | } else if (ch == 0x44) { |
- | |
364 | /* Left */ |
- | |
365 | if (position > 0) { |
- | |
366 | putchar('\b'); |
- | |
367 | position--; |
- | |
368 | } |
- | |
369 | } else if (ch == 0x43) { |
- | |
370 | /* Right */ |
- | |
371 | if (position < wstr_length(current)) { |
- | |
372 | putchar(current[position]); |
- | |
373 | position++; |
- | |
374 | } |
- | |
375 | } else if ((ch == 0x41) || (ch == 0x42)) { |
- | |
376 | /* Up, down */ |
- | |
377 | print_cc('\b', position); |
- | |
378 | print_cc(' ', wstr_length(current)); |
- | |
379 | print_cc('\b', wstr_length(current)); |
- | |
380 | - | ||
381 | if (ch == 0x41) { |
- | |
382 | /* Up */ |
- | |
383 | if (history_pos == 0) |
- | |
384 | history_pos = KCONSOLE_HISTORY - 1; |
- | |
385 | else |
- | |
386 | history_pos--; |
- | |
387 | } else { |
- | |
388 | /* Down */ |
- | |
389 | history_pos++; |
- | |
390 | history_pos = history_pos % KCONSOLE_HISTORY; |
- | |
391 | } |
- | |
392 | current = history[history_pos]; |
- | |
393 | printf("%ls", current); |
- | |
394 | position = wstr_length(current); |
- | |
395 | } |
399 | } |
396 | continue; |
400 | continue; |
397 | } |
401 | } |
398 | 402 | ||
399 | if (wstr_linsert(current, ch, position, MAX_CMDLINE)) { |
403 | if (wstr_linsert(current, ch, position, MAX_CMDLINE)) { |