summaryrefslogtreecommitdiff
path: root/src/highlighter.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-12 23:37:20 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-12 23:37:20 (GMT)
commit987cd438f64b6b06cffe31a512584e55b41cad9d (patch)
tree3427e768415af0699d44f0e13970a83cab74edd4 /src/highlighter.cc
parentf4f06d48d852437ee0d70b7541c9b8a1893d9624 (diff)
fix qt4.4, old gcc, and mention Giles' Rapcad higlighter
Diffstat (limited to 'src/highlighter.cc')
-rw-r--r--src/highlighter.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/highlighter.cc b/src/highlighter.cc
index 98eff8c..a7592da 100644
--- a/src/highlighter.cc
+++ b/src/highlighter.cc
@@ -39,8 +39,13 @@
Also, QT 4.5 and lower do not have rehighlightBlock(), so they will be slow
on large files as well, as they re-highlight everything after each compile.
- The vast majority of OpenSCAD files, however, are not 50,000 lines
+ The vast majority of OpenSCAD files, however, are not 50,000 lines and
+ most machines ship with Qt > 4.5
+ See Also:
+
+ Giles Bathgate's Rapcad lexer-based highlighter: rapcad.org
+
Test suite:
1. action: open example001, remove first {, hit f5
@@ -177,7 +182,7 @@ void Highlighter::highlightError(int error_pos)
err_block = err_block.previous();
errorPos = err_block.position()+err_block.length() - 2;
}
- if ( errorPos == document()->characterCount()-1 ) {
+ if ( errorPos == lastDocumentPos()-1 ) {
errorPos--;
}
@@ -204,10 +209,22 @@ void Highlighter::portable_rehighlightBlock( const QTextBlock &block )
#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0))
rehighlightBlock( block );
#else
- rehighlight(); // slow on big files
+ rehighlight(); // slow on very large files
#endif
}
+int Highlighter::lastDocumentPos()
+{
+// fixme - test it
+#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
+ return document()->characterCount();
+#else
+ QTextBlock lastblock = document()->lastBlock();
+ return lastblock.position() + lastblock.length();
+#endif
+}
+
+
void Highlighter::highlightBlock(const QString &text)
{
int block_first_pos = currentBlock().position();
contact: Jan Huwald // Impressum