completion in readline

This commit is contained in:
Vitor Santos Costa 2017-08-27 22:20:38 +01:00
parent 2add5f2971
commit ec3995dd82
3 changed files with 4 additions and 28 deletions

View File

@ -106,7 +106,7 @@ include(CheckVariableExists)
check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP)
check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT)
check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT)
check_function_exists( rl_filename_completion_function HAVE_RL_FILENAME_COMPLETION_FUNCTION)
check_symbol_exists( rl_filename_completion_function stdio.h;readline/readline.h HAVE_RL_FILENAME_COMPLETION_FUNCTION)
check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE )
check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE )
check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL )

View File

@ -51,9 +51,9 @@ you don't. */
#cmakedefine HAVE_RL_CLEAR_PENDING_INPUT ${HAVE_RL_CLEAR_PENDING_INPUT}
#endif
/* Define to 1 if the system has the type `rl_completion_func_t'). */
#ifndef HAVE_RL_COMPLETION_FUNC_T
#cmakedefine HAVE_RL_COMPLETION_FUNC_T ${HAVE_RL_COMPLETION_FUNC_T}
/* Define to 1 if the system has the type `rl_completion_entry_function'). */
#ifndef HAVE_RL_COMPLETION_ENTRY_FUNCTION
#cmakedefine HAVE_RL_COMPLETION_ENTRY_FUNCTION ${HAVE_RL_COMPLETION_ENTRY_FUNCTION}
#endif
/* Define to 1 if the system has the type `rl_completion_func_t'. */

View File

@ -273,24 +273,6 @@ bool Yap_ReadlineOps(StreamDesc *s) {
return false;
}
static int prolog_complete(int ignore, int key) {
if (rl_point > 0 && rl_line_buffer[rl_point - 1] != ' ') {
#if HAVE_DECL_RL_CATCH_SIGNALS /* actually version >= 1.2, or true readline \
*/
rl_begin_undo_group();
rl_complete(ignore, key);
if (rl_point > 0 && rl_line_buffer[rl_point - 1] == ' ') {
rl_delete_text(rl_point - 1, rl_point);
rl_point -= 1;
rl_delete(-1, key);
}
rl_end_undo_group();
#endif
} else
rl_complete(ignore, key);
return 0;
}
bool Yap_InitReadline(Term enable) {
// don't call readline within emacs
@ -320,12 +302,6 @@ bool Yap_InitReadline(Term enable) {
}
rl_readline_name = "YAP Prolog";
rl_attempted_completion_function = prolog_completion;
#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
rl_add_defun("prolog-complete", prolog_complete, '\t');
#else
rl_add_defun("prolog-complete", (void *)prolog_complete, '\t');
#endif
// does not work
// rl_prep_terminal(1);
if (GLOBAL_Flags)
setBooleanGlobalPrologFlag(READLINE_FLAG, true);