add:添加~输出为实际路径。
This commit is contained in:
parent
5e05691227
commit
16633d9d9a
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user