limit history
This commit is contained in:
parent
6a076bc8ac
commit
943900865e
@ -251,16 +251,6 @@ void Yap_ReadlineFlush(int sno) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Yap_ReadlinePrompt(StreamDesc *s) {
|
|
||||||
if (s->status & Tty_Stream_f) {
|
|
||||||
s->stream_getc = ReadlineGetc;
|
|
||||||
if (GLOBAL_Stream[0].status & Tty_Stream_f &&
|
|
||||||
s->name == GLOBAL_Stream[0].name)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Yap_ReadlineOps(StreamDesc *s) {
|
bool Yap_ReadlineOps(StreamDesc *s) {
|
||||||
if (s->status & Tty_Stream_f) {
|
if (s->status & Tty_Stream_f) {
|
||||||
if (GLOBAL_Stream[0].status & (Input_Stream_f | Tty_Stream_f) &&
|
if (GLOBAL_Stream[0].status & (Input_Stream_f | Tty_Stream_f) &&
|
||||||
@ -294,9 +284,11 @@ static int prolog_complete(int ignore, int key) {
|
|||||||
bool Yap_InitReadline(Term enable) {
|
bool Yap_InitReadline(Term enable) {
|
||||||
// don't call readline within emacs
|
// don't call readline within emacs
|
||||||
if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) ||
|
if (!(GLOBAL_Stream[StdInStream].status & Tty_Stream_f) ||
|
||||||
getenv("INSIDE_EMACS") ||
|
getenv("INSIDE_EMACS") || enable != TermTrue) {
|
||||||
enable != TermTrue)
|
if (GLOBAL_Flags)
|
||||||
|
setBooleanGlobalPrologFlag(READLINE_FLAG, false);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
GLOBAL_Stream[StdInStream].u.irl.buf = NULL;
|
GLOBAL_Stream[StdInStream].u.irl.buf = NULL;
|
||||||
GLOBAL_Stream[StdInStream].u.irl.ptr = NULL;
|
GLOBAL_Stream[StdInStream].u.irl.ptr = NULL;
|
||||||
GLOBAL_Stream[StdInStream].status |= Readline_Stream_f;
|
GLOBAL_Stream[StdInStream].status |= Readline_Stream_f;
|
||||||
@ -315,13 +307,15 @@ bool Yap_InitReadline(Term enable) {
|
|||||||
}
|
}
|
||||||
rl_readline_name = "YAP Prolog";
|
rl_readline_name = "YAP Prolog";
|
||||||
rl_attempted_completion_function = prolog_completion;
|
rl_attempted_completion_function = prolog_completion;
|
||||||
#ifdef HAVE_RL_COMPLETION_FUNC_T
|
#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
|
||||||
rl_add_defun("prolog-complete", prolog_complete, '\t');
|
rl_add_defun("prolog-complete", prolog_complete, '\t');
|
||||||
#else
|
#else
|
||||||
rl_add_defun("prolog-complete", (void *)prolog_complete, '\t');
|
rl_add_defun("prolog-complete", (void *)prolog_complete, '\t');
|
||||||
#endif
|
#endif
|
||||||
// does not work
|
// does not work
|
||||||
// rl_prep_terminal(1);
|
// rl_prep_terminal(1);
|
||||||
|
if (GLOBAL_Flags)
|
||||||
|
setBooleanGlobalPrologFlag(READLINE_FLAG, true);
|
||||||
return Yap_ReadlineOps(GLOBAL_Stream + StdInStream);
|
return Yap_ReadlineOps(GLOBAL_Stream + StdInStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,8 +327,9 @@ static bool getLine(int inp) {
|
|||||||
|
|
||||||
/* window of vulnerability opened */
|
/* window of vulnerability opened */
|
||||||
LOCAL_PrologMode |= ConsoleGetcMode;
|
LOCAL_PrologMode |= ConsoleGetcMode;
|
||||||
if (LOCAL_newline) { // no output so far
|
if (Yap_DoPrompt(s)) { // no output so far
|
||||||
myrl_line = (unsigned char *)readline(LOCAL_Prompt);
|
myrl_line = (unsigned char *)readline(LOCAL_Prompt);
|
||||||
|
s->stream_getc = ReadlineGetc;
|
||||||
} else {
|
} else {
|
||||||
myrl_line = (unsigned char *)readline(NULL);
|
myrl_line = (unsigned char *)readline(NULL);
|
||||||
}
|
}
|
||||||
@ -477,5 +472,6 @@ void Yap_InitReadlinePreds(void) {}
|
|||||||
void Yap_CloseReadline(void) {
|
void Yap_CloseReadline(void) {
|
||||||
#if USE_READLINE
|
#if USE_READLINE
|
||||||
write_history(history_file);
|
write_history(history_file);
|
||||||
|
history_truncate_file(history_file, 300);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user