try:尝试修正Linux下偶发光标位置不正确问题。

This commit is contained in:
taynpg 2025-02-08 08:24:04 +08:00
parent 909c68cf6e
commit 58fa3dbb09
3 changed files with 9 additions and 7 deletions

View File

@ -12,7 +12,6 @@ endif()
if(DEFINED IOS_ISH)
message(STATUS "filecomplete USE IOS_ISH")
add_definitions(-DIOS_ISH)
add_definitions(-DMFLUSH_STDOUT)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows")

View File

@ -531,13 +531,19 @@ char* fc_readline()
cur_pos += 1;
}
}
#endif
#if defined(OS_UNIX)
fflush(stdout);
#endif
set_cursor_x(cur_pos + 1);
#if defined(OS_UNIX)
fflush(stdout);
#endif
};
while (1) {
refresh_show();
refresh_show();
need_predic = true;
// Read character from console
@ -748,8 +754,5 @@ void color_print(const char* text, const COLOR_TYPE color)
}
// Resets the text to default color
printf("\033[0m");
#if defined(MFLUSH_STDOUT)
fflush(stdout);
#endif
#endif
}

View File

@ -3,13 +3,13 @@
#include <string>
#include <thread>
static int cnt = 5;
static int cnt = 500;
// 测试光标位置
void delay_auto_show()
{
while (--cnt) {
std::this_thread::sleep_for(std::chrono::seconds(10));
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "IMCOMMING..............." << std::endl;
}
}