summaryrefslogtreecommitdiff
path: root/graphics/asymptote/runhistory.in
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-08-07 03:02:55 +0000
committerNorbert Preining <norbert@preining.info>2020-08-07 03:02:55 +0000
commit3710c23789342d9d88783cbe9ad23eb5263a7c33 (patch)
tree1c40b2bfb9f6b652f7877ad0991f5d6b44391154 /graphics/asymptote/runhistory.in
parentd99fea72e367e8d4d2809b43b3b0206b1bb526b8 (diff)
CTAN sync 202008070302
Diffstat (limited to 'graphics/asymptote/runhistory.in')
-rw-r--r--graphics/asymptote/runhistory.in44
1 files changed, 25 insertions, 19 deletions
diff --git a/graphics/asymptote/runhistory.in b/graphics/asymptote/runhistory.in
index ddf60e22f6..fce3ccadfd 100644
--- a/graphics/asymptote/runhistory.in
+++ b/graphics/asymptote/runhistory.in
@@ -30,7 +30,7 @@ struct historyState {
bool store;
HISTORY_STATE state;
};
-
+
typedef mem::map<CONST string, historyState> historyMap_t;
historyMap_t historyMap;
static HISTORY_STATE history_save;
@@ -47,7 +47,7 @@ void store_history(HISTORY_STATE *dest)
}
}
-stringarray* get_history(Int n)
+stringarray* get_history(Int n)
{
int N=intcast(n);
if(N <= 0) N=history_length;
@@ -58,14 +58,18 @@ stringarray* get_history(Int n)
HIST_ENTRY *last=history_get(offset+i);
string s=last ? last->line : "";
(*a)[i]=s;
- }
+ }
return a;
}
-string historyfilename(const string &name)
+string historyfilename(const string &name)
{
return historyname+"_"+name;
}
+
+namespace camp {
+bool allowRender=true;
+}
#endif
namespace run {
@@ -81,7 +85,7 @@ void cleanup()
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
store_history(&history_save);
int nlines=intcast(getSetting<Int>("historylines"));
- for(historyMap_t::iterator h=historyMap.begin(); h != historyMap.end();
+ for(historyMap_t::iterator h=historyMap.begin(); h != historyMap.end();
++h) {
history_set_history_state(&h->second.state);
if(h->second.store) {
@@ -94,7 +98,7 @@ void cleanup()
#endif
#ifdef HAVE_LIBGSL
trans::GSLrngFree();
-#endif
+#endif
}
}
@@ -106,9 +110,9 @@ stringarray* history(string name, Int n=1)
{
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
bool newhistory=historyMap.find(name) == historyMap.end();
-
+
string filename;
-
+
if(newhistory) {
filename=historyfilename(name);
std::ifstream exists(filename.c_str());
@@ -118,15 +122,15 @@ stringarray* history(string name, Int n=1)
store_history(&history_save);
HISTORY_STATE& history=historyMap[name].state;
history_set_history_state(&history);
-
+
if(newhistory)
read_history(filename.c_str());
array *a=get_history(n);
-
+
store_history(&history);
history_set_history_state(&history_save);
-
+
return a;
#else
unused(&n);
@@ -154,7 +158,7 @@ string readline(string prompt=emptystring, string name=emptystring,
return emptystring;
#if defined(HAVE_LIBREADLINE) && defined(HAVE_LIBCURSES)
interact::init_readline(tabcompletion);
-
+
store_history(&history_save);
bool newhistory=historyMap.find(name) == historyMap.end();
historyState& h=historyMap[name];
@@ -163,7 +167,7 @@ string readline(string prompt=emptystring, string name=emptystring,
if(newhistory)
read_history(historyfilename(name).c_str());
-
+
static char *line=NULL;
/* Return the memory to the free pool
if the buffer has already been allocated. */
@@ -171,12 +175,14 @@ string readline(string prompt=emptystring, string name=emptystring,
free(line);
line=NULL;
}
-
+
/* Get a line from the user. */
+ allowRender=false;
line=readline(prompt.c_str());
-
+ allowRender=true;
+
if(!line) cout << endl;
-
+
history_set_history_state(&history_save);
return line ? string(line) : emptystring;
@@ -203,7 +209,7 @@ void saveline(string name, string value, bool store=true)
if(newhistory)
read_history(historyfilename(name).c_str());
-
+
if(value != "") {
add_history(value.c_str());
if(store) {
@@ -211,10 +217,10 @@ void saveline(string name, string value, bool store=true)
hout << value << endl;
}
}
-
+
store_history(&history);
history_set_history_state(&history_save);
#else
unused(&store);
-#endif
+#endif
}