| 456 | } |
| 457 | |
| 458 | static bool readline_simple(std::string & line, bool multiline_input) { |
| 459 | #if defined(_WIN32) |
| 460 | std::wstring wline; |
| 461 | if (!std::getline(std::wcin, wline)) { |
| 462 | // Input stream is bad or EOF received |
| 463 | line.clear(); |
| 464 | GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); |
| 465 | return false; |
| 466 | } |
| 467 | |
| 468 | int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wline[0], (int)wline.size(), NULL, 0, NULL, NULL); |
| 469 | line.resize(size_needed); |
| 470 | WideCharToMultiByte(CP_UTF8, 0, &wline[0], (int)wline.size(), &line[0], size_needed, NULL, NULL); |
| 471 | #else |
| 472 | if (!std::getline(std::cin, line)) { |
| 473 | // Input stream is bad or EOF received |
| 474 | line.clear(); |
| 475 | return false; |
| 476 | } |
| 477 | #endif |
| 478 | if (!line.empty()) { |
| 479 | char last = line.back(); |
| 480 | if (last == '/') { // Always return control on '/' symbol |
| 481 | line.pop_back(); |
| 482 | return false; |
| 483 | } |
| 484 | if (last == '\\') { // '\\' changes the default action |
| 485 | line.pop_back(); |
| 486 | multiline_input = !multiline_input; |
| 487 | } |
| 488 | } |
| 489 | line += '\n'; |
| 490 | |
| 491 | // By default, continue input if multiline_input is set |
| 492 | return multiline_input; |
| 493 | } |
| 494 | |
| 495 | bool readline(std::string & line, bool multiline_input) { |
| 496 | set_display(user_input); |