ctkPythonConsole.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. /*=========================================================================
  15. Program: ParaView
  16. Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
  17. All rights reserved.
  18. ParaView is a free software; you can redistribute it and/or modify it
  19. under the terms of the ParaView license version 1.2.
  20. See http://www.paraview.org/paraview/project/license.html for the full ParaView license.
  21. A copy of this license can be obtained by contacting
  22. Kitware Inc.
  23. 28 Corporate Drive
  24. Clifton Park, NY 12065
  25. USA
  26. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  27. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  28. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  29. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
  30. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  31. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  32. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  33. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. =========================================================================*/
  38. // Qt includes
  39. #include <QAbstractItemView>
  40. #include <QCoreApplication>
  41. #include <QIcon>
  42. #include <QResizeEvent>
  43. #include <QScrollBar>
  44. #include <QStringListModel>
  45. #include <QTextCharFormat>
  46. #include <QVBoxLayout>
  47. // PythonQt includes
  48. #include <PythonQt.h>
  49. #include <PythonQtObjectPtr.h>
  50. // CTK includes
  51. #include <ctkConsole.h>
  52. #include <ctkConsole_p.h>
  53. #include <ctkAbstractPythonManager.h>
  54. #include "ctkPythonConsole.h"
  55. #ifdef __GNUC__
  56. // Disable warnings related to Python macros and functions
  57. // See http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
  58. // Note: Ideally the incriminated functions and macros should be fixed upstream ...
  59. #pragma GCC diagnostic ignored "-Wold-style-cast"
  60. #endif
  61. //----------------------------------------------------------------------------
  62. // ctkPythonConsoleCompleter
  63. //----------------------------------------------------------------------------
  64. class ctkPythonConsoleCompleter : public ctkConsoleCompleter
  65. {
  66. public:
  67. ctkPythonConsoleCompleter(ctkAbstractPythonManager& pythonManager);
  68. virtual int cursorOffset(const QString& completion);
  69. virtual void updateCompletionModel(const QString& completion);
  70. protected:
  71. bool isInUserDefinedClass(const QString &pythonFunctionPath);
  72. bool isUserDefinedFunction(const QString &pythonFunctionName);
  73. bool isBuiltInFunction(const QString &pythonFunctionName);
  74. int parameterCountUserDefinedClassFunction(const QString &pythonFunctionName);
  75. int parameterCountBuiltInFunction(const QString& pythonFunctionName);
  76. int parameterCountUserDefinedFunction(const QString& pythonFunctionName);
  77. int parameterCountFromDocumentation(const QString& pythonFunctionPath);
  78. ctkAbstractPythonManager& PythonManager;
  79. };
  80. //----------------------------------------------------------------------------
  81. ctkPythonConsoleCompleter::ctkPythonConsoleCompleter(ctkAbstractPythonManager& pythonManager)
  82. : PythonManager(pythonManager)
  83. {
  84. this->setParent(&pythonManager);
  85. }
  86. //----------------------------------------------------------------------------
  87. int ctkPythonConsoleCompleter::cursorOffset(const QString& completion)
  88. {
  89. QString allTextFromShell = completion;
  90. int parameterCount = 0;
  91. int cursorOffset = 0;
  92. if (allTextFromShell.contains("()"))
  93. {
  94. allTextFromShell.replace("()", "");
  95. // Search backward through the string for usable characters
  96. QString currentCompletionText;
  97. for (int i = allTextFromShell.length()-1; i >= 0; --i)
  98. {
  99. QChar c = allTextFromShell.at(i);
  100. if (c.isLetterOrNumber() || c == '.' || c == '_')
  101. {
  102. currentCompletionText.prepend(c);
  103. }
  104. else
  105. {
  106. break;
  107. }
  108. }
  109. QStringList lineSplit = currentCompletionText.split(".", QString::KeepEmptyParts);
  110. QString functionName = lineSplit.at(lineSplit.length()-1);
  111. QStringList builtinFunctionPath = QStringList() << "__main__" << "__builtins__";
  112. QStringList userDefinedFunctionPath = QStringList() << "__main__";
  113. if (this->isBuiltInFunction(functionName))
  114. {
  115. parameterCount = this->parameterCountBuiltInFunction(QStringList(builtinFunctionPath+lineSplit).join("."));
  116. }
  117. else if (this->isUserDefinedFunction(functionName))
  118. {
  119. parameterCount = this->parameterCountUserDefinedFunction(QStringList(userDefinedFunctionPath+lineSplit).join("."));
  120. }
  121. else if (this->isInUserDefinedClass(currentCompletionText))
  122. {
  123. // "self" parameter can be ignored
  124. parameterCount = this->parameterCountUserDefinedClassFunction(QStringList(userDefinedFunctionPath+lineSplit).join(".")) - 1;
  125. }
  126. else
  127. {
  128. QStringList variableNameAndFunctionList = userDefinedFunctionPath + lineSplit;
  129. QString variableNameAndFunction = variableNameAndFunctionList.join(".");
  130. parameterCount = this->parameterCountFromDocumentation(variableNameAndFunction);
  131. }
  132. }
  133. if (parameterCount > 0)
  134. {
  135. cursorOffset = 1;
  136. }
  137. return cursorOffset;
  138. }
  139. //---------------------------------------------------------------------------
  140. bool ctkPythonConsoleCompleter::isInUserDefinedClass(const QString &pythonFunctionPath)
  141. {
  142. return this->PythonManager.pythonAttributes(pythonFunctionPath).contains("__func__");
  143. }
  144. //---------------------------------------------------------------------------
  145. bool ctkPythonConsoleCompleter::isUserDefinedFunction(const QString &pythonFunctionName)
  146. {
  147. return this->PythonManager.pythonAttributes(pythonFunctionName).contains("__call__");
  148. }
  149. //---------------------------------------------------------------------------
  150. bool ctkPythonConsoleCompleter::isBuiltInFunction(const QString &pythonFunctionName)
  151. {
  152. return this->PythonManager.pythonAttributes(pythonFunctionName, QLatin1String("__main__.__builtins__")).contains("__call__");
  153. }
  154. //---------------------------------------------------------------------------
  155. int ctkPythonConsoleCompleter::parameterCountBuiltInFunction(const QString& pythonFunctionName)
  156. {
  157. int parameterCount = 0;
  158. PyObject* pFunction = this->PythonManager.pythonModule(pythonFunctionName);
  159. if (pFunction && PyObject_HasAttrString(pFunction, "__doc__"))
  160. {
  161. PyObject* pDoc = PyObject_GetAttrString(pFunction, "__doc__");
  162. QString docString = PyString_AsString(pDoc);
  163. QString argumentExtract = docString.mid(docString.indexOf("(")+1, docString.indexOf(")") - docString.indexOf("(")-1);
  164. QStringList arguments = argumentExtract.split(",", QString::SkipEmptyParts);
  165. parameterCount = arguments.count();
  166. Py_DECREF(pDoc);
  167. Py_DECREF(pFunction);
  168. }
  169. return parameterCount;
  170. }
  171. //----------------------------------------------------------------------------
  172. int ctkPythonConsoleCompleter::parameterCountUserDefinedFunction(const QString& pythonFunctionName)
  173. {
  174. int parameterCount = 0;
  175. PyObject* pFunction = this->PythonManager.pythonModule(pythonFunctionName);
  176. if (PyCallable_Check(pFunction))
  177. {
  178. PyObject* fc = PyObject_GetAttrString(pFunction, "func_code");
  179. if (fc)
  180. {
  181. PyObject* ac = PyObject_GetAttrString(fc, "co_argcount");
  182. if (ac)
  183. {
  184. parameterCount = PyInt_AsLong(ac);
  185. Py_DECREF(ac);
  186. }
  187. Py_DECREF(fc);
  188. }
  189. }
  190. return parameterCount;
  191. }
  192. //----------------------------------------------------------------------------
  193. int ctkPythonConsoleCompleter::parameterCountUserDefinedClassFunction(const QString& pythonFunctionName)
  194. {
  195. int parameterCount = 0;
  196. PyObject* pFunction = this->PythonManager.pythonObject(pythonFunctionName);
  197. if (PyCallable_Check(pFunction))
  198. {
  199. PyObject* fc = PyObject_GetAttrString(pFunction, "func_code");
  200. if (fc)
  201. {
  202. PyObject* ac = PyObject_GetAttrString(fc, "co_argcount");
  203. if (ac)
  204. {
  205. parameterCount = PyInt_AsLong(ac);
  206. Py_DECREF(ac);
  207. }
  208. Py_DECREF(fc);
  209. }
  210. }
  211. return parameterCount;
  212. }
  213. //----------------------------------------------------------------------------
  214. int ctkPythonConsoleCompleter::parameterCountFromDocumentation(const QString& pythonFunctionPath)
  215. {
  216. int parameterCount = 0;
  217. PyObject* pFunction = this->PythonManager.pythonObject(pythonFunctionPath);
  218. if (pFunction)
  219. {
  220. if (PyObject_HasAttrString(pFunction, "__call__"))
  221. {
  222. PyObject* pDoc = PyObject_GetAttrString(pFunction, "__doc__");
  223. if (PyString_Check(pDoc))
  224. {
  225. QString docString = PyString_AsString(pDoc);
  226. QString argumentExtract = docString.mid(docString.indexOf("(")+1, docString.indexOf(")") - docString.indexOf("(")-1);
  227. QStringList arguments = argumentExtract.split(",", QString::SkipEmptyParts);
  228. parameterCount = arguments.count();
  229. }
  230. }
  231. Py_DECREF(pFunction);
  232. }
  233. return parameterCount;
  234. }
  235. void ctkPythonConsoleCompleter::updateCompletionModel(const QString& completion)
  236. {
  237. // Start by clearing the model
  238. this->setModel(0);
  239. // Don't try to complete the empty string
  240. if (completion.isEmpty())
  241. {
  242. return;
  243. }
  244. // Search backward through the string for usable characters
  245. QString textToComplete;
  246. for (int i = completion.length()-1; i >= 0; --i)
  247. {
  248. QChar c = completion.at(i);
  249. if (c.isLetterOrNumber() || c == '.' || c == '_')
  250. {
  251. textToComplete.prepend(c);
  252. }
  253. else
  254. {
  255. break;
  256. }
  257. }
  258. // Split the string at the last dot, if one exists
  259. QString lookup;
  260. QString compareText = textToComplete;
  261. int dot = compareText.lastIndexOf('.');
  262. if (dot != -1)
  263. {
  264. lookup = compareText.mid(0, dot);
  265. compareText = compareText.mid(dot+1);
  266. }
  267. // Lookup python names
  268. QStringList attrs;
  269. if (!lookup.isEmpty() || !compareText.isEmpty())
  270. {
  271. bool appendParenthesis = true;
  272. attrs = this->PythonManager.pythonAttributes(lookup, QLatin1String("__main__"), appendParenthesis);
  273. attrs << this->PythonManager.pythonAttributes(lookup, QLatin1String("__main__.__builtins__"),
  274. appendParenthesis);
  275. attrs.removeDuplicates();
  276. }
  277. // Initialize the completion model
  278. if (!attrs.isEmpty())
  279. {
  280. this->setCompletionMode(QCompleter::PopupCompletion);
  281. this->setModel(new QStringListModel(attrs, this));
  282. this->setCaseSensitivity(Qt::CaseInsensitive);
  283. this->setCompletionPrefix(compareText.toLower());
  284. //qDebug() << "completion" << completion;
  285. // If a dot as been entered and if an item of possible
  286. // choices matches one of the preference list, it will be selected.
  287. QModelIndex preferredIndex = this->completionModel()->index(0, 0);
  288. int dotCount = completion.count('.');
  289. if (dotCount == 0 || completion.at(completion.count() - 1) == '.')
  290. {
  291. foreach(const QString& pref, this->AutocompletePreferenceList)
  292. {
  293. //qDebug() << "pref" << pref;
  294. int dotPref = pref.count('.');
  295. // Skip if there are dots in pref and if the completion has already more dots
  296. // than the pref
  297. if ((dotPref != 0) && (dotCount > dotPref))
  298. {
  299. continue;
  300. }
  301. // Extract string before the last dot
  302. int lastDot = pref.lastIndexOf('.');
  303. QString prefBeforeLastDot;
  304. if (lastDot != -1)
  305. {
  306. prefBeforeLastDot = pref.left(lastDot);
  307. }
  308. //qDebug() << "prefBeforeLastDot" << prefBeforeLastDot;
  309. if (!prefBeforeLastDot.isEmpty() && QString::compare(prefBeforeLastDot, lookup) != 0)
  310. {
  311. continue;
  312. }
  313. QString prefAfterLastDot = pref;
  314. if (lastDot != -1 )
  315. {
  316. prefAfterLastDot = pref.right(pref.size() - lastDot - 1);
  317. }
  318. //qDebug() << "prefAfterLastDot" << prefAfterLastDot;
  319. QModelIndexList list = this->completionModel()->match(
  320. this->completionModel()->index(0, 0), Qt::DisplayRole, QVariant(prefAfterLastDot));
  321. if (list.count() > 0)
  322. {
  323. preferredIndex = list.first();
  324. break;
  325. }
  326. }
  327. }
  328. this->popup()->setCurrentIndex(preferredIndex);
  329. }
  330. }
  331. //----------------------------------------------------------------------------
  332. // ctkPythonConsolePrivate
  333. //----------------------------------------------------------------------------
  334. class ctkPythonConsolePrivate : public ctkConsolePrivate
  335. {
  336. Q_DECLARE_PUBLIC(ctkPythonConsole);
  337. public:
  338. ctkPythonConsolePrivate(ctkPythonConsole& object);
  339. ~ctkPythonConsolePrivate();
  340. void initializeInteractiveConsole();
  341. bool push(const QString& code);
  342. /// Reset the input buffer of the interactive console
  343. // void resetInputBuffer();
  344. void printWelcomeMessage();
  345. ctkAbstractPythonManager* PythonManager;
  346. PyObject* InteractiveConsole;
  347. };
  348. //----------------------------------------------------------------------------
  349. // ctkPythonConsolePrivate methods
  350. //----------------------------------------------------------------------------
  351. ctkPythonConsolePrivate::ctkPythonConsolePrivate(ctkPythonConsole& object)
  352. : ctkConsolePrivate(object), PythonManager(0), InteractiveConsole(0)
  353. {
  354. }
  355. //----------------------------------------------------------------------------
  356. ctkPythonConsolePrivate::~ctkPythonConsolePrivate()
  357. {
  358. }
  359. //----------------------------------------------------------------------------
  360. void ctkPythonConsolePrivate::initializeInteractiveConsole()
  361. {
  362. Q_ASSERT(this->PythonManager);
  363. // set up the code.InteractiveConsole instance that we'll use.
  364. const char* code =
  365. "import code\n"
  366. "__ctkConsole = code.InteractiveConsole(locals())\n";
  367. PyRun_SimpleString(code);
  368. // Now get the reference to __ctkConsole and save the pointer.
  369. PyObject* main_module = PyImport_AddModule("__main__");
  370. PyObject* global_dict = PyModule_GetDict(main_module);
  371. this->InteractiveConsole = PyDict_GetItemString(
  372. global_dict, "__ctkConsole");
  373. if (!this->InteractiveConsole)
  374. {
  375. qCritical("Failed to locate the InteractiveConsole object.");
  376. }
  377. }
  378. //----------------------------------------------------------------------------
  379. bool ctkPythonConsolePrivate::push(const QString& code)
  380. {
  381. Q_ASSERT(this->PythonManager);
  382. bool ret_value = false;
  383. QString buffer = code;
  384. // The embedded python interpreter cannot handle DOS line-endings, see
  385. // http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1167922
  386. buffer.remove('\r');
  387. PyObject *res = PyObject_CallMethod(this->InteractiveConsole,
  388. const_cast<char*>("push"),
  389. const_cast<char*>("z"),
  390. buffer.toLatin1().data());
  391. if (res)
  392. {
  393. int status = 0;
  394. if (PyArg_Parse(res, "i", &status))
  395. {
  396. ret_value = (status > 0);
  397. }
  398. Py_DECREF(res);
  399. }
  400. return ret_value;
  401. }
  402. ////----------------------------------------------------------------------------
  403. //void ctkPythonConsolePrivate::resetInputBuffer()
  404. //{
  405. // if (this->InteractiveConsole)
  406. // {
  407. // //this->MakeCurrent();
  408. // const char* code = "__ctkConsole.resetbuffer()\n";
  409. // PyRun_SimpleString(code);
  410. // //this->ReleaseControl();
  411. // }
  412. //}
  413. //----------------------------------------------------------------------------
  414. void ctkPythonConsolePrivate::printWelcomeMessage()
  415. {
  416. Q_Q(ctkPythonConsole);
  417. q->printMessage(
  418. QString("Python %1 on %2\n").arg(Py_GetVersion()).arg(Py_GetPlatform()),
  419. q->welcomeTextColor());
  420. }
  421. //----------------------------------------------------------------------------
  422. // ctkPythonConsole methods
  423. //----------------------------------------------------------------------------
  424. ctkPythonConsole::ctkPythonConsole(QWidget* parentObject):
  425. Superclass(new ctkPythonConsolePrivate(*this), parentObject)
  426. {
  427. this->setObjectName("pythonConsole");
  428. this->setWindowIcon(QIcon(":/python-icon.png"));
  429. // Disable RemoveTrailingSpaces and AutomaticIndentation
  430. this->setEditorHints(this->editorHints() ^ (RemoveTrailingSpaces | AutomaticIndentation));
  431. // Enable SplitCopiedTextByLine
  432. this->setEditorHints(this->editorHints() | SplitCopiedTextByLine);
  433. this->setDisabled(true);
  434. }
  435. //----------------------------------------------------------------------------
  436. ctkPythonConsole::~ctkPythonConsole()
  437. {
  438. }
  439. ////----------------------------------------------------------------------------
  440. void ctkPythonConsole::initialize(ctkAbstractPythonManager* newPythonManager)
  441. {
  442. Q_D(ctkPythonConsole);
  443. if (d->PythonManager)
  444. {
  445. qWarning() << "ctkPythonConsole already initialized !";
  446. return;
  447. }
  448. // The call to mainContext() ensures that python has been initialized.
  449. Q_ASSERT(newPythonManager);
  450. newPythonManager->mainContext();
  451. Q_ASSERT(PythonQt::self()); // PythonQt should be initialized
  452. ctkPythonConsoleCompleter* completer = new ctkPythonConsoleCompleter(*newPythonManager);
  453. this->setCompleter(completer);
  454. d->PythonManager = newPythonManager;
  455. d->initializeInteractiveConsole();
  456. this->connect(PythonQt::self(), SIGNAL(pythonStdOut(QString)),
  457. d, SLOT(printOutputMessage(QString)));
  458. this->connect(PythonQt::self(), SIGNAL(pythonStdErr(QString)),
  459. d, SLOT(printErrorMessage(QString)));
  460. PythonQt::self()->setRedirectStdInCallback(
  461. ctkConsole::stdInRedirectCallBack, reinterpret_cast<void*>(this));
  462. // Set primary and secondary prompt
  463. this->setPs1(">>> ");
  464. this->setPs2("... ");
  465. this->reset();
  466. // Expose help() function
  467. QStringList helpImportCode;
  468. helpImportCode << "from pydoc import help";
  469. d->PythonManager->executeString(helpImportCode.join("\n"));
  470. this->setDisabled(false);
  471. }
  472. ////----------------------------------------------------------------------------
  473. //void ctkPythonConsole::executeScript(const QString& script)
  474. //{
  475. // Q_D(ctkPythonConsole);
  476. // Q_UNUSED(script);
  477. // d->printOutputMessage("\n");
  478. // emit this->executing(true);
  479. //// d->Interpreter->RunSimpleString(
  480. //// script.toLatin1().data());
  481. // emit this->executing(false);
  482. // d->promptForInput();
  483. //}
  484. //----------------------------------------------------------------------------
  485. QString ctkPythonConsole::ps1() const
  486. {
  487. PyObject * ps1 = PySys_GetObject(const_cast<char*>("ps1"));
  488. const char * ps1_str = PyString_AsString(ps1);
  489. return QLatin1String(ps1_str);
  490. }
  491. //----------------------------------------------------------------------------
  492. void ctkPythonConsole::setPs1(const QString& newPs1)
  493. {
  494. PySys_SetObject(const_cast<char*>("ps1"), PyString_FromString(newPs1.toLatin1().data()));
  495. }
  496. //----------------------------------------------------------------------------
  497. QString ctkPythonConsole::ps2() const
  498. {
  499. PyObject * ps2 = PySys_GetObject(const_cast<char*>("ps2"));
  500. const char * ps2_str = PyString_AsString(ps2);
  501. return QLatin1String(ps2_str);
  502. }
  503. //----------------------------------------------------------------------------
  504. void ctkPythonConsole::setPs2(const QString& newPs2)
  505. {
  506. PySys_SetObject(const_cast<char*>("ps2"), PyString_FromString(newPs2.toLatin1().data()));
  507. }
  508. //----------------------------------------------------------------------------
  509. void ctkPythonConsole::executeCommand(const QString& command)
  510. {
  511. Q_D(ctkPythonConsole);
  512. d->MultilineStatement = d->push(command);
  513. }
  514. //----------------------------------------------------------------------------
  515. void ctkPythonConsole::reset()
  516. {
  517. // Set primary and secondary prompt
  518. this->setPs1(">>> ");
  519. this->setPs2("... ");
  520. this->Superclass::reset();
  521. }