00001 /* 00002 Aseba - an event-based framework for distributed robot control 00003 Copyright (C) 2007--2009: 00004 Stephane Magnenat <stephane at magnenat dot net> 00005 (http://stephane.magnenat.net) 00006 and other contributors, see authors.txt for details 00007 Mobots group, Laboratory of Robotics Systems, EPFL, Lausanne 00008 00009 This program is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 any other version as decided by the two original authors 00013 Stephane Magnenat and Valentin Longchamp. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 #ifndef AESL_EDITOR_H 00025 #define AESL_EDITOR_H 00026 00027 #include <QSyntaxHighlighter> 00028 00029 #include <QHash> 00030 #include <QTextCharFormat> 00031 #include <QTextBlockUserData> 00032 #include <QTextEdit> 00033 00034 class QTextDocument; 00035 00036 namespace Aseba 00037 { 00040 00041 class AeslEditor; 00042 00043 class AeslHighlighter : public QSyntaxHighlighter 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 AeslHighlighter(AeslEditor *editor, QTextDocument *parent = 0); 00049 00050 protected: 00051 void highlightBlock(const QString &text); 00052 00053 private: 00054 struct HighlightingRule 00055 { 00056 QRegExp pattern; 00057 QTextCharFormat format; 00058 }; 00059 QVector<HighlightingRule> highlightingRules; 00060 AeslEditor *editor; 00061 }; 00062 00063 struct AeslEditorUserData : public QTextBlockUserData 00064 { 00065 QMap<QString, QVariant> properties; 00066 00067 AeslEditorUserData(const QString &property, const QVariant &value = QVariant()) { properties.insert(property, value); } 00068 virtual ~AeslEditorUserData() { } 00069 }; 00070 00071 class AeslEditor : public QTextEdit 00072 { 00073 Q_OBJECT 00074 00075 signals: 00076 void breakpointSet(unsigned line); 00077 void breakpointCleared(unsigned line); 00078 void breakpointClearedAll(); 00079 00080 public: 00081 AeslEditor(); 00082 virtual ~AeslEditor() { } 00083 virtual void contextMenuEvent ( QContextMenuEvent * e ); 00084 00085 public: 00086 bool debugging; 00087 00088 protected: 00089 virtual void dropEvent(QDropEvent *event); 00090 virtual void keyPressEvent(QKeyEvent * event); 00091 }; 00092 00094 }; // Aseba 00095 00096 #endif