| 654 | } |
| 655 | |
| 656 | static void move_cursor(int delta) { |
| 657 | if (delta == 0) return; |
| 658 | #if defined(_WIN32) |
| 659 | if (hConsole != NULL) { |
| 660 | CONSOLE_SCREEN_BUFFER_INFO bufferInfo; |
| 661 | GetConsoleScreenBufferInfo(hConsole, &bufferInfo); |
| 662 | COORD newCursorPosition = bufferInfo.dwCursorPosition; |
| 663 | int width = bufferInfo.dwSize.X; |
| 664 | int newX = newCursorPosition.X + delta; |
| 665 | int newY = newCursorPosition.Y; |
| 666 | |
| 667 | while (newX >= width) { |
| 668 | newX -= width; |
| 669 | newY++; |
| 670 | } |
| 671 | while (newX < 0) { |
| 672 | newX += width; |
| 673 | newY--; |
| 674 | } |
| 675 | |
| 676 | newCursorPosition.X = newX; |
| 677 | newCursorPosition.Y = newY; |
| 678 | SetConsoleCursorPosition(hConsole, newCursorPosition); |
| 679 | } |
| 680 | #else |
| 681 | if (delta < 0) { |
| 682 | for (int i = 0; i < -delta; i++) fprintf(out, "\b"); |
| 683 | } else { |
| 684 | for (int i = 0; i < delta; i++) fprintf(out, "\033[C"); |
| 685 | } |
| 686 | #endif |
| 687 | } |
| 688 | |
| 689 | struct history_t { |
| 690 | std::vector<std::string> entries; |
no outgoing calls
no test coverage detected