mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
Moved history file path code to helper function
This commit is contained in:
@@ -62,6 +62,16 @@ public:
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
std::string get_hist_file_path()
|
||||||
|
{
|
||||||
|
const gchar *hist_file_str = g_getenv("SDCV_HISTFILE");
|
||||||
|
|
||||||
|
if (hist_file_str != nullptr)
|
||||||
|
return std::string(hist_file_str);
|
||||||
|
else
|
||||||
|
return std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||||
|
}
|
||||||
|
|
||||||
class real_readline : public IReadLine
|
class real_readline : public IReadLine
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -70,15 +80,13 @@ public:
|
|||||||
{
|
{
|
||||||
rl_readline_name = "sdcv";
|
rl_readline_name = "sdcv";
|
||||||
using_history();
|
using_history();
|
||||||
const gchar *hist_file_str = g_getenv("SDCV_HISTFILE");
|
const std::string histname = get_hist_file_path();
|
||||||
const std::string histname = hist_file_str ? std::string(hist_file_str) : (std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history");
|
|
||||||
read_history(histname.c_str());
|
read_history(histname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
~real_readline()
|
~real_readline()
|
||||||
{
|
{
|
||||||
const gchar *hist_file_str = g_getenv("SDCV_HISTFILE");
|
const std::string histname = get_hist_file_path();
|
||||||
const std::string histname = hist_file_str ? std::string(hist_file_str) : (std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history");
|
|
||||||
write_history(histname.c_str());
|
write_history(histname.c_str());
|
||||||
const gchar *hist_size_str = g_getenv("SDCV_HISTSIZE");
|
const gchar *hist_size_str = g_getenv("SDCV_HISTSIZE");
|
||||||
int hist_size;
|
int hist_size;
|
||||||
|
|||||||
Reference in New Issue
Block a user