Returns true when the line is complete cppcheck-suppress unusedFunction
| 460 | // Returns true when the line is complete |
| 461 | // cppcheck-suppress unusedFunction |
| 462 | bool Lineedit::step(int c) { |
| 463 | // Regardless of editing mode, ^L turns off editing/echoing |
| 464 | if (c == CTRL('l')) { |
| 465 | editing = false; |
| 466 | return false; |
| 467 | } |
| 468 | |
| 469 | if (!editing) { |
| 470 | if (c < ' ') { |
| 471 | if (c == '\r' || c == '\n') { |
| 472 | return true; |
| 473 | } |
| 474 | needs_reecho = true; |
| 475 | editing = true; |
| 476 | // continue to editing code below |
| 477 | } else { |
| 478 | addchar(c, false); |
| 479 | return false; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if (needs_reecho) { |
| 484 | needs_reecho = false; |
| 485 | echo_line(); |
| 486 | } |
| 487 | |
| 488 | // If we are running on Windows, key() returns the SPECIAL_* values |
| 489 | // for non-ASCII movement keys. Under a terminal emulator, such keys |
| 490 | // generate escape sequences that we parse herein and convert to |
| 491 | // those SPECIAL_* values. |
| 492 | |
| 493 | // Expecting [ as second character of escape sequence |
| 494 | if (escaping == 1) { |
| 495 | if (c >= 'A' && c <= 'Z') { |
| 496 | c += 'a' - 'A'; |
| 497 | } |
| 498 | switch (c) { |
| 499 | case '[': |
| 500 | escaping = 2; |
| 501 | return false; |
| 502 | case 'f': |
| 503 | forward_word(); |
| 504 | break; |
| 505 | case 'b': |
| 506 | backward_word(); |
| 507 | break; |
| 508 | } |
| 509 | escaping = 0; |
| 510 | return false; |
| 511 | } |
| 512 | |
| 513 | // Expecting third character of escape sequence |
| 514 | if (escaping == 2) { |
| 515 | escaping = 0; |
| 516 | switch (c) { |
| 517 | // In these 3 cases we have to get one more byte, typically ~ |
| 518 | case '2': |
| 519 | escaping = SPECIAL_HOME; |
no outgoing calls
no test coverage detected