Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 2613 → Rev 2614

/branches/Version13x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
45,6 → 45,7
menuBar->insertItem(tr("&File"), fileMenu);
QPopupMenu *scriptMenu = new QPopupMenu(this);
scriptMenu->insertItem(loadIcon("launch16.png"), tr("&Run"), this, SLOT(slot_runScript()), Key_F9);
scriptMenu->insertItem(tr("&Run As Console"), this, SLOT(slot_runScriptAsConsole()), Key_F5);
scriptMenu->insertItem(tr("&Save Output..."), this, SLOT(slot_saveOutput()));
menuBar->insertItem(tr("&Script"), scriptMenu);
 
111,6 → 112,19
emit runCommand();
}
 
void PythonConsole::slot_runScriptAsConsole()
{
if (commandEdit->hasSelectedText())
command = commandEdit->selectedText();
else
command = commandEdit->text();
// prevent user's wrong selection
command += '\n';
commandEdit->clear();
outputEdit->append("\n>>> " + command);
emit runCommand();
}
 
/*
* supplementary slots. Saving etc.
*/
/branches/Version13x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
338,13 → 338,16
cm += "import code\n";
cm += "ia = code.InteractiveConsole(globals())\n";
}
cm += "sc = getval()\n";
cm += "rv = ia.push(sc)\n";
cm += "if rv == 1:\n";
cm += "\tre = \"...\"\n";
cm += "else:\n";
cm += "\tre = bu.getvalue()\n";
cm += "retval(re, rv)\n";
/* HACK: following loop handles all input line by line.
It *should* use I.C. because of docstrings etc. I.I. cannot
handle docstrings right.
Calling all code in one command:
ia = code.InteractiveInterpreter() ia.runsource(getval())
works fine in plain Python. Not here. WTF?
*/
cm += "for i in getval().split('\\n'):\n";
cm += "\tia.push(i)\n";
cm += "retval(bu.getvalue(), 0)\n";
}
// FIXME: if cmd contains chars outside 7bit ascii, might be problems
QCString cmd = cm.latin1();
359,10 → 362,10
void ScripterCore::slotInteractiveScript(bool visible)
{
QObject::disconnect( scrScripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) );
 
scrScripterActions["scripterShowConsole"]->setOn(visible);
pcon->setShown(visible);
 
QObject::connect( scrScripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) );
}
 
/branches/Version13x/Scribus/scribus/plugins/scriptplugin/scriptplugin.cpp
300,7 → 300,7
{const_cast<char*>("gotoPage"), scribus_gotopage, METH_VARARGS, tr(scribus_gotopage__doc__)},
{const_cast<char*>("groupObjects"), scribus_groupobj, METH_VARARGS, tr(scribus_groupobj__doc__)},
{const_cast<char*>("haveDoc"), (PyCFunction)scribus_havedoc, METH_NOARGS, tr(scribus_havedoc__doc__)},
{const_cast<char*>("importSVG"), scribus_importsvg, METH_VARARGS, tr(scribus_importsvg__doc__)},
{const_cast<char*>("importSVG"), scribus_importsvg, METH_VARARGS, tr(scribus_importsvg__doc__)},
{const_cast<char*>("insertText"), scribus_inserttext, METH_VARARGS, tr(scribus_inserttext__doc__)},
{const_cast<char*>("isLayerPrintable"), scribus_glayerprint, METH_VARARGS, tr(scribus_glayerprint__doc__)},
{const_cast<char*>("isLayerVisible"), scribus_glayervisib, METH_VARARGS, tr(scribus_glayervisib__doc__)},
/branches/Version13x/Scribus/scribus/plugins/scriptplugin/pconsole.h
45,7 → 45,7
QTextEdit* commandEdit;
//! Results viewer
QTextEdit* outputEdit;
 
//! Close event for turning the action off
void closeEvent(QCloseEvent *);
 
52,6 → 52,7
public slots:
//! menu operations
virtual void slot_runScript();
virtual void slot_runScriptAsConsole();
virtual void slot_open();
virtual void slot_save();
virtual void slot_saveAs();