Ejemplo n.º 1
0
bool ScintillaWrapper::addCallback(PyObject* callback, boost::python::list events)
{
	if (PyCallable_Check(callback))
	{
		size_t eventCount = _len(events);
		for(idx_t i = 0; i < eventCount; ++i)
		{
			m_callbacks.insert(std::pair<int, PyObject*>(boost::python::extract<int>(events[i]), callback));
			Py_INCREF(callback);
		}
		
		m_notificationsEnabled = true;
		startConsumer();
	    return true;
	}
	else
	{
		return false;
	}
}
Ejemplo n.º 2
0
void PythonConsole::runStatement(const char *statement)
{
	assert(mp_consoleDlg);
	if (mp_consoleDlg)
	{
		mp_consoleDlg->runEnabled(false);
	}

	// Console statements executed whilst a script is in progress MUST run on a separate 
	// thread.  Otherwise, we wait for the GIL, no problem, except that that blocks the UI thread
	// so if the script happens to be sending a message to scintilla (likely), then 
	// it will deadlock.
	// PyProducerConsumer used here to keep one thread running the actual statements

	if (!m_consumerStarted)
	{
		m_consumerStarted = true;
		startConsumer();
	}

	produce(std::shared_ptr<std::string>(new std::string(statement)));
}