add:添加~输出为实际路径。

This commit is contained in:
taynpg 2025-02-25 00:54:00 -08:00
parent 5e05691227
commit 16633d9d9a
2 changed files with 29 additions and 0 deletions

View File

@ -97,6 +97,7 @@ static std::mutex mut;
static std::string header{};
static size_t header_len{};
static size_t unix_signal{};
static bool need_turn{true};
void trans2buf(char* buffer);
void clear_line();
@ -136,6 +137,16 @@ static std::string home_path{};
// #endif
// }
void fc_turn_on()
{
need_turn = true;
}
void fc_turn_off()
{
need_turn = false;
}
std::string get_home()
{
#if defined(_WIN32)
@ -648,6 +659,14 @@ char* fc_readline()
str_predict.clear();
refresh_show();
append_his(main_buf);
if (need_turn) {
std::string rep(main_buf);
if (rep.find("~") == 0) {
rep = get_home() + rep.substr(1, rep.size() - 1);
std::memset(main_buf, 0x0, buf_size);
std::snprintf(main_buf, buf_size, "%s", rep.c_str());
}
}
return main_buf;
case CTRL_C: {
free(main_buf);

View File

@ -68,6 +68,16 @@ void fc_unlock_print(void);
*/
void fc_free(char* str);
/**
* @brief ~
*/
void fc_turn_on();
/**
* @brief
*/
void fc_turn_off();
#ifdef __cplusplus
}
#endif