mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-16 09:51:56 +00:00
Merge pull request #44 from nickeb96/master
Added $SDCV_HISTFILE to set history file
This commit is contained in:
@@ -89,9 +89,12 @@ If set, sdcv uses this variable as the data directory, this means that sdcv
|
|||||||
searches dictionaries in $\fBSTARDICT_DATA_DIR\fR\\dic
|
searches dictionaries in $\fBSTARDICT_DATA_DIR\fR\\dic
|
||||||
.TP 20
|
.TP 20
|
||||||
.B SDCV_HISTSIZE
|
.B SDCV_HISTSIZE
|
||||||
If set, sdcv writes in $(HOME)/.sdcv_history the last $(SDCV_HISTSIZE) words,
|
If set, sdcv writes in $(HOME)/.sdcv_history (or $(SDCV_HISTFILE)) the last $(SDCV_HISTSIZE) words,
|
||||||
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(HOME)/.sdcv_history.
|
which you look up using sdcv. If it is not set, then the last 2000 words are saved in $(HOME)/.sdcv_history.
|
||||||
.TP 20
|
.TP 20
|
||||||
|
.B SDCV_HISTFILE
|
||||||
|
If set, sdcv writes it's history to $(SDCV_HISTFILE). If it is not set, then the default $(HOME)/.sdcv_history path will be used.
|
||||||
|
.TP 20
|
||||||
.B SDCV_PAGER
|
.B SDCV_PAGER
|
||||||
If SDCV_PAGER is set, its value is used as the name of the program
|
If SDCV_PAGER is set, its value is used as the name of the program
|
||||||
to use to display the dictionary article.
|
to use to display the dictionary article.
|
||||||
|
|||||||
@@ -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,13 +80,13 @@ public:
|
|||||||
{
|
{
|
||||||
rl_readline_name = "sdcv";
|
rl_readline_name = "sdcv";
|
||||||
using_history();
|
using_history();
|
||||||
const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
const std::string histname = get_hist_file_path();
|
||||||
read_history(histname.c_str());
|
read_history(histname.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
~real_readline()
|
~real_readline()
|
||||||
{
|
{
|
||||||
const std::string histname = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
const std::string histname = get_hist_file_path();
|
||||||
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