Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pyconsole.h
Go to the documentation of this file.
1 
8 #ifndef PYCONSOLE_H_
9 #define PYCONSOLE_H_
10 
11 #include <QObject>
12 #include <QTextEdit>
13 #include <QMutex>
14 #include <QWaitCondition>
15 #include <QToolBar>
16 #include "core/document.h"
17 
18 class CAPyConsole : public QTextEdit {
19  Q_OBJECT
20 public:
21  enum TxtType {
25  };
26 
27  CAPyConsole ( CADocument *doc, QWidget *parent=0);
28 
29  QString asyncBufferedInput(QString prompt);
30  void asyncBufferedOutput(QString bufInp, bool bStdErr);
31  void asyncPluginInit();
33 
34 protected:
35  void keyPressEvent (QKeyEvent * e);
36 
37 private slots:
38  void txtAppend(const QString & text, TxtType txtType = txtNormal );
39  void on_txtChanged();
40  void on_posChanged();
41  void on_selChanged();
42  void on_fmtChanged();
43  void syncPluginInit();
44 
45 signals:
46  void sig_txtAppend(const QString & text, TxtType stdType);
47  void sig_syncPluginInit();
48 
49 private:
50  enum HistLay {
53  };
54 
55  struct TxtFragment {
56  QString text;
58  };
59 
60  // void txtAppend(...) -> is in signals
61  void txtRevert();
62  QString txtGetInput(bool bReadText = false);
63  void txtSetInput(QString input, bool bUpdateText = true);
64 
65  void histAdd();
66  void histGet(HistLay histLay);
67 
68  // text in the console
69  QTextCursor _curInput, _curNew;
72 
74  QList<TxtFragment*> _txtFixed;
75  QString _strInput;
76 
77  // history
79  QList<QString> _histList;
80  QString _histOldInput; // old _strInput
81 
82  QTextCharFormat _fmtNormal;
83  QTextCharFormat _fmtStdout;
84  QTextCharFormat _fmtStderr;
85 
86  // thread
87  QString _bufSend;
88  QMutex *_thrWaitMut;
89  QWaitCondition *_thrWait;
90  QMutex *_thrIntrWaitMut;
91  QWaitCondition *_thrIntrWait;
92 
93  // pyconsole '/' commands
94  bool cmdIntern(QString strCmd);
95  QString _strEntryFunc;
96 
97  // rarely used
100 };
101 
102 #endif /* PYCONSOLE_H_ */