MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / move_cursor

Function move_cursor

subprojects/llama.cpp/common/console.cpp:656–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers 7

delete_at_cursorFunction · 0.85
clear_current_lineFunction · 0.85
move_to_line_startFunction · 0.85
move_to_line_endFunction · 0.85
move_word_leftFunction · 0.85
move_word_rightFunction · 0.85
readline_advancedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected