From 214bb7279f354adf1344376e26465046fc2581ce Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Thu, 11 Aug 2005 15:00:58 +0000 Subject: 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 --- externals/grill/py/source/pybase.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'externals/grill/py/source/pybase.cpp') 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); } -*/ -- cgit v1.2.1