summaryrefslogtreecommitdiff
path: root/src/highlighter.cc
diff options
context:
space:
mode:
authorkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-30 04:17:05 (GMT)
committerkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-01-30 04:17:05 (GMT)
commit6940d171812565209efe679a5d923417c3f47d4a (patch)
tree2a05d2f8865ff1127f854db41bf31143f64ccf2d /src/highlighter.cc
parent2b19f33ee1ddce246c2bfe0a05fe379d0117a741 (diff)
reorganized file structure layout. more to follow...
git-svn-id: http://svn.clifford.at/openscad/trunk@364 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/highlighter.cc')
-rw-r--r--src/highlighter.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/highlighter.cc b/src/highlighter.cc
new file mode 100644
index 0000000..5e15867
--- /dev/null
+++ b/src/highlighter.cc
@@ -0,0 +1,46 @@
+/*
+ * OpenSCAD (www.openscad.at)
+ * Copyright (C) 2009 Clifford Wolf <clifford@clifford.at>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "openscad.h"
+
+Highlighter::Highlighter(QTextDocument *parent)
+ : QSyntaxHighlighter(parent)
+{
+}
+
+void Highlighter::highlightBlock(const QString &text)
+{
+ int n = previousBlockState();
+ if (n < 0)
+ n = 0;
+ int k = n + text.size() + 1;
+ setCurrentBlockState(k);
+ if (parser_error_pos >= n && parser_error_pos < k) {
+ QTextCharFormat style;
+ style.setBackground(Qt::red);
+ setFormat(0, text.size(), style);
+#if 0
+ style.setBackground(Qt::black);
+ style.setForeground(Qt::white);
+ setFormat(parser_error_pos - n, 1, style);
+#endif
+ }
+}
+
contact: Jan Huwald // Impressum