| 450 | } |
| 451 | |
| 452 | void LuaHighlighter::highlightBlock(const QString& text) |
| 453 | { |
| 454 | QString line = text; |
| 455 | BlockRule *rule = nullptr; |
| 456 | int match = 0; |
| 457 | int start = 0; |
| 458 | int state = previousBlockState(); |
| 459 | if (state < 0) |
| 460 | rule = nextBlockRule(line, &start, &match); |
| 461 | else |
| 462 | rule = &blockrules[state]; |
| 463 | |
| 464 | while (rule) |
| 465 | { |
| 466 | QRegularExpressionMatch m = rule->end.match(text, match); |
| 467 | if (m.hasMatch()) |
| 468 | { |
| 469 | markFormated(&line, start, line.length() - start, rule->format); |
| 470 | break; |
| 471 | } |
| 472 | else |
| 473 | { |
| 474 | int end = m.capturedEnd(); |
| 475 | markFormated(&line, start, end - start, rule->format); |
| 476 | start = end; |
| 477 | rule = nextBlockRule(line, &start, &match); |
| 478 | } |
| 479 | } |
| 480 | if (rule) |
| 481 | setCurrentBlockState(rule - &blockrules[0]); |
| 482 | else |
| 483 | setCurrentBlockState(-1); |
| 484 | |
| 485 | for (const Rule &rule : qAsConst(rules)) |
| 486 | { |
| 487 | const QString *l = rule.overlay ? &text : &line; |
| 488 | QRegularExpressionMatch m = rule.pattern.match(*l); |
| 489 | while (m.hasMatch()) |
| 490 | { |
| 491 | setFormat(m.capturedStart(), m.capturedLength(), rule.format); |
| 492 | m = rule.pattern.match(*l, m.capturedEnd()); |
| 493 | } |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void LuaHighlighter::markFormated(QString *text, int start, int count, const QTextCharFormat& format) |
| 498 | { |
nothing calls this directly
no outgoing calls
no test coverage detected