summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/settings.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/settings.cc')
-rw-r--r--Build/source/utils/asymptote/settings.cc84
1 files changed, 50 insertions, 34 deletions
diff --git a/Build/source/utils/asymptote/settings.cc b/Build/source/utils/asymptote/settings.cc
index 9f478da8f25..213a0a89c67 100644
--- a/Build/source/utils/asymptote/settings.cc
+++ b/Build/source/utils/asymptote/settings.cc
@@ -69,9 +69,6 @@ namespace settings {
using camp::pair;
-string asyInstallDir;
-string defaultXasy="xasy";
-
#ifdef HAVE_LIBGL
const bool haveglut=true;
#else
@@ -81,7 +78,7 @@ const bool haveglut=false;
#ifndef __CYGWIN__
bool msdos=false;
-const char *HOME="HOME";
+string HOME="HOME";
const char pathSeparator=':';
string defaultPSViewer="gv";
#ifdef __APPLE__
@@ -100,7 +97,7 @@ const string dirsep="/";
#else
bool msdos=true;
-const char *HOME="USERPROFILE";
+string HOME="USERPROFILE";
const char pathSeparator=';';
string defaultPSViewer="gsview32.exe";
string defaultPDFViewer="AcroRd32.exe";
@@ -174,7 +171,6 @@ void queryRegistry()
docdir=getEntry("Microsoft/Windows/CurrentVersion/App Paths/Asymptote/Path");
if(!systemDir.empty()) // An empty systemDir indicates a TeXLive build
systemDir=docdir;
- defaultXasy=asyInstallDir+"\\"+defaultXasy;
}
#endif
@@ -950,11 +946,13 @@ void initSettings() {
// LEFT: rotate
// SHIFT LEFT: zoom
// CTRL LEFT: shift
+// ALT LEFT: pan
- array *leftbutton=new array(3);
+ array *leftbutton=new array(4);
(*leftbutton)[0]=string("rotate");
(*leftbutton)[1]=string("zoom");
(*leftbutton)[2]=string("shift");
+ (*leftbutton)[3]=string("pan");
// MIDDLE: menu
@@ -967,7 +965,7 @@ void initSettings() {
// ALT RIGHT: rotateZ
array *rightbutton=new array(4);
- (*rightbutton)[0]=string("zoom/menu");
+ (*rightbutton)[0]=string("zoom");
(*rightbutton)[1]=string("rotateX");
(*rightbutton)[2]=string("rotateY");
(*rightbutton)[3]=string("rotateZ");
@@ -1174,7 +1172,6 @@ void initSettings() {
addOption(new envSetting("display", defaultDisplay));
addOption(new envSetting("animate", "animate"));
addOption(new envSetting("python", defaultPython));
- addOption(new envSetting("xasy", defaultXasy));
addOption(new envSetting("papertype", "letter"));
addOption(new envSetting("dir", ""));
addOption(new envSetting("sysdir", systemDir));
@@ -1220,8 +1217,41 @@ string outname() {
return name.empty() ? "out" : name;
}
+string lookup(const string& symbol)
+{
+ string s;
+ iopipestream pipe(("kpsewhich --var-value="+symbol).c_str());
+ pipe >> s;
+// Workaround broken header file on i386-solaris with g++ 3.4.3.
+#ifdef erase
+#undef erase
+#endif
+ size_t n=s.find('\r');
+ if(n != string::npos)
+ s.erase(n,1);
+ n=s.find('\n');
+ if(n != string::npos)
+ s.erase(n,1);
+ return s;
+}
+
void initDir() {
- initdir=Getenv(HOME,msdos)+"/."+suffix;
+ if(getSetting<string>("sysdir").empty()) {
+ string s=lookup("SELFAUTOPARENT");
+ if(s.size() > 1) {
+ docdir=s+dirsep+"share"+dirsep+"doc"+dirsep+"asymptote";
+ Setting("sysdir")=s+dirsep+"texmf"+dirsep+"asymptote";
+ s=lookup("TEXMFCONFIG");
+ if(s.size() > 1)
+ initdir=s+dirsep+"asymptote";
+ }
+ }
+
+ if(initdir.empty())
+ initdir=Getenv(HOME.c_str(),msdos)+dirsep+"."+suffix;
+
+ if(verbose > 1)
+ cerr << "Using configuration directory " << initdir << endl;
mkdir(initdir.c_str(),0777);
}
@@ -1239,24 +1269,6 @@ void setPath() {
}
searchPath.push_back(initdir);
string sysdir=getSetting<string>("sysdir");
- if(sysdir == "") {
- iopipestream pipe("kpsewhich --var-value=SELFAUTOPARENT");
- pipe >> sysdir;
-// Workaround broken header file on i386-solaris with g++ 3.4.3.
-#ifdef erase
-#undef erase
-#endif
- size_t n=sysdir.find('\r');
- if(n != string::npos)
- sysdir.erase(n,1);
- n=sysdir.find('\n');
- if(n != string::npos)
- sysdir.erase(n,1);
- if(sysdir.size() > 1) {
- sysdir.append(dirsep+"texmf"+dirsep+"asymptote");
- Setting("sysdir")=sysdir;
- }
- }
if(sysdir != "")
searchPath.push_back(sysdir);
}
@@ -1264,7 +1276,7 @@ void setPath() {
void SetPageDimensions() {
string paperType=getSetting<string>("papertype");
- if(paperType == "" &&
+ if(paperType.empty() &&
getSetting<double>("paperwidth") != 0.0 &&
getSetting<double>("paperheight") != 0.0) return;
@@ -1307,7 +1319,7 @@ string nativeformat() {
string defaultformat() {
string format=getSetting<string>("outformat");
- return (format == "") ? nativeformat() : format;
+ return (format.empty()) ? nativeformat() : format;
}
// Begin TeX put command.
@@ -1436,16 +1448,18 @@ void setOptions(int argc, char *argv[])
cout.precision(DBL_DIG);
- // Make configuration and history directory
- initDir();
-
// Build settings module.
initSettings();
- // Read command-line options initially to obtain CONFIG and DIR.
+ // Read command-line options initially to obtain config, dir, sysdir, verbose.
getOptions(argc,argv);
+ // Make configuration and history directory
+ initDir();
+
Int Verbose=verbose;
+ string sysdir=getSetting<string>("sysdir");
+
resetOptions();
// Read user configuration file.
@@ -1463,6 +1477,8 @@ void setOptions(int argc, char *argv[])
// Read command-line options again to override configuration file defaults.
getOptions(argc,argv);
+ Setting("sysdir")=sysdir;
+
#ifdef USEGC
if(verbose == 0 && !getSetting<bool>("debug")) GC_set_warn_proc(no_GCwarn);
#endif