fix:尝试处理win下回车后可能导致的残留光标显示问题。

This commit is contained in:
taynpg 2025-01-21 13:03:26 +08:00
parent 27241c505b
commit fcd61b381a

View File

@ -501,6 +501,14 @@ char* fc_readline()
std::chrono::time_point<std::chrono::high_resolution_clock> p1, p2; std::chrono::time_point<std::chrono::high_resolution_clock> p1, p2;
p1 = std::chrono::high_resolution_clock::now(); p1 = std::chrono::high_resolution_clock::now();
#if defined(OS_WINDOWS)
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(hConsole, &cursorInfo);
cursorInfo.bVisible = TRUE;
SetConsoleCursorInfo(hConsole, &cursorInfo);
#endif
while (1) { while (1) {
word.clear(); word.clear();
clear_line(); clear_line();
@ -540,6 +548,13 @@ char* fc_readline()
switch (ch) { switch (ch) {
case ENTER: case ENTER:
#if defined(OS_WINDOWS)
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(hConsole, &cursorInfo);
cursorInfo.bVisible = FALSE;
SetConsoleCursorInfo(hConsole, &cursorInfo);
#endif
append_his(main_buf); append_his(main_buf);
return main_buf; return main_buf;
#if defined(OS_WINDOWS) #if defined(OS_WINDOWS)