diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-03 22:35:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-03 22:35:09 +0000 |
commit | f6bb2b5974c9dc15a4530842100d30fe1981b973 (patch) | |
tree | 62ef95efa54d91b6eafb6df99f330dc136f77f29 /Build/source/utils/asymptote/interact.cc | |
parent | 24dbc0b1802756862bedad6a4088f50aad68b51b (diff) |
asy 2.63 sources
git-svn-id: svn://tug.org/texlive/trunk@54034 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/interact.cc')
-rw-r--r-- | Build/source/utils/asymptote/interact.cc | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/Build/source/utils/asymptote/interact.cc b/Build/source/utils/asymptote/interact.cc index c49f50d2b91..84d6b00ce76 100644 --- a/Build/source/utils/asymptote/interact.cc +++ b/Build/source/utils/asymptote/interact.cc @@ -18,9 +18,19 @@ #include "interact.h" #include "runhistory.h" -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#ifdef HAVE_LIBCURSES +#ifdef HAVE_LIBREADLINE #include <readline/readline.h> #include <readline/history.h> +#else +#ifdef HAVE_LIBEDIT +#ifdef HAVE_EDITLINE_READLINE_H +#include <editline/readline.h> +#else +#include <readline/readline.h> +#endif +#endif +#endif #endif #include "util.h" @@ -50,7 +60,7 @@ char *call_completer(const char *text, int state) { return currentCompleter ? (*currentCompleter)(text, state) : 0; } -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) void init_completion() { rl_completion_entry_function=call_completer; @@ -111,7 +121,7 @@ void pre_readline() if(!fin) fin=fdopen(fd,"r"); Readline=readpipeline; } else { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) if(tty) { Readline=readline; } else @@ -120,13 +130,20 @@ void pre_readline() } } +void init_readline(bool tabcompletion) +{ +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) + rl_bind_key('\t',tabcompletion ? rl_complete : rl_insert); +#endif +} + void init_interactive() { if(getSetting<bool>("xasy")) tty=false; -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) if(tty) { init_completion(); - run::init_readline(getSetting<bool>("tabcompletion")); + interact::init_readline(getSetting<bool>("tabcompletion")); read_history(historyname.c_str()); } #endif @@ -161,7 +178,7 @@ string simpleline(string prompt) { } void addToHistory(string line) { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) // Only add it if it has something other than newlines. if(tty && line.find_first_not_of('\n') != string::npos) { add_history(line.c_str()); @@ -170,7 +187,7 @@ void addToHistory(string line) { } string getLastHistoryLine() { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) if(tty && history_length > 0) { HIST_ENTRY *entry=history_list()[history_length-1]; if(!entry) { @@ -185,7 +202,7 @@ string getLastHistoryLine() { } void setLastHistoryLine(string line) { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) if(tty) { if (history_length > 0) { HIST_ENTRY *entry=remove_history(history_length-1); @@ -194,7 +211,7 @@ void setLastHistoryLine(string line) { em.compiler(); em << "cannot modify last history line"; } else { - free(entry->line); + free((char *) entry->line); free(entry); } } @@ -204,14 +221,14 @@ void setLastHistoryLine(string line) { } void deleteLastLine() { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) if(tty) { HIST_ENTRY *entry=remove_history(history_length-1); if(!entry) { em.compiler(); em << "cannot delete last history line"; } else { - free(entry->line); + free((char *) entry->line); free(entry); } } @@ -219,7 +236,7 @@ void deleteLastLine() { } void cleanup_interactive() { -#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES) +#if defined(HAVE_READLINE) && defined(HAVE_LIBCURSES) // Write the history file. if(tty) { stifle_history(intcast(getSetting<Int>("historylines"))); |