| 1019 | } |
| 1020 | |
| 1021 | static bool readline_simple(std::string & line, bool multiline_input) { |
| 1022 | #if defined(_WIN32) |
| 1023 | std::wstring wline; |
| 1024 | if (!std::getline(std::wcin, wline)) { |
| 1025 | // Input stream is bad or EOF received |
| 1026 | line.clear(); |
| 1027 | GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0); |
| 1028 | return false; |
| 1029 | } |
| 1030 | |
| 1031 | int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wline[0], (int)wline.size(), NULL, 0, NULL, NULL); |
| 1032 | line.resize(size_needed); |
| 1033 | WideCharToMultiByte(CP_UTF8, 0, &wline[0], (int)wline.size(), &line[0], size_needed, NULL, NULL); |
| 1034 | #else |
| 1035 | if (!std::getline(std::cin, line)) { |
| 1036 | // Input stream is bad or EOF received |
| 1037 | line.clear(); |
| 1038 | return false; |
| 1039 | } |
| 1040 | #endif |
| 1041 | if (!line.empty()) { |
| 1042 | char last = line.back(); |
| 1043 | if (last == '/') { // Always return control on '/' symbol |
| 1044 | line.pop_back(); |
| 1045 | return false; |
| 1046 | } |
| 1047 | if (last == '\\') { // '\\' changes the default action |
| 1048 | line.pop_back(); |
| 1049 | multiline_input = !multiline_input; |
| 1050 | } |
| 1051 | } |
| 1052 | line += '\n'; |
| 1053 | |
| 1054 | // By default, continue input if multiline_input is set |
| 1055 | return multiline_input; |
| 1056 | } |
| 1057 | |
| 1058 | bool readline(std::string & line, bool multiline_input) { |
| 1059 | if (simple_io) { |