aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/pybase.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-08-11 15:00:58 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-08-11 15:00:58 +0000
commit214bb7279f354adf1344376e26465046fc2581ce (patch)
tree0e0f32a27f274e4d6a09352146c7507472313dc5 /externals/grill/py/source/pybase.cpp
parente1be380510a42f13ce1fd55a29705aaf9e8c8da8 (diff)
oops, include libraries for editing the scripts
some optimizations and py reload fix open editor for module file on "edit" message (or click) open editor for script under OS X added cygwin support svn path=/trunk/; revision=3417
Diffstat (limited to 'externals/grill/py/source/pybase.cpp')
-rw-r--r--externals/grill/py/source/pybase.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/externals/grill/py/source/pybase.cpp b/externals/grill/py/source/pybase.cpp
index 69bead28..462cad62 100644
--- a/externals/grill/py/source/pybase.cpp
+++ b/externals/grill/py/source/pybase.cpp
@@ -200,14 +200,14 @@ pybase::pybase()
, detach(0)
, pymsg(false)
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
Py_INCREF(module_obj);
PyUnlock(state);
}
pybase::~pybase()
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
Py_XDECREF(module_obj);
PyUnlock(state);
}
@@ -355,7 +355,24 @@ void pybase::OpenEditor()
post("py/pyext - Couldn't launch editor");
}
}
-#elif FLEXT_OS == FLEXT_OS_LINUX
+#else
+ // thanks to Tim Blechmann
+
+ char *editor = getenv("EDITOR");
+
+ if(!editor || !strcmp(editor, "/usr/bin/nano") || !strcmp(editor, "/usr/bin/pico") || !strcmp(editor, "/usr/bin/vi")) {
+ // no environment variable or console text editor found ... use idle instead (should have come with Python)
+ editor = "idle";
+ }
+
+ pid_t child = fork();
+ if(!child) {
+ char cmd[80];
+ strcpy(cmd,editor);
+ strcat(cmd," ");
+ strcat(cmd,fname);
+ execl("/bin/sh", "sh", "-c", cmd, (char *) NULL);
+ }
#endif
}
@@ -539,7 +556,7 @@ void pybase::Respond(bool b)
void pybase::Reload()
{
- PyThreadState *state = PyLockSys();
+ PyThreadState *state = PyLock();
PyObject *reg = GetRegistry(REGNAME);
@@ -670,6 +687,7 @@ void pybase::exchandle()
{
#if 0
// want to use that, but exception keeps a reference to the object
+ // might be a Python bug!
PyErr_Print();
#else
// must use that instead... clear the exception
@@ -776,9 +794,3 @@ bool pybase::collect()
}
return true;
}
-
-/*
-PY_EXPORT PyThreadState *py_Lock(PyThreadState *st = NULL) { return pybase::PyLock(st?st:pybase::FindThreadState()); }
-PY_EXPORT PyThreadState *py_LockSys() { return pybase::PyLockSys(); }
-PY_EXPORT void py_Unlock(PyThreadState *st) { pybase::PyUnlock(st); }
-*/