MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / matchRight

Method matchRight

MiniZincIDE/codeeditor.cpp:507–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

505}
506
507int CodeEditor::matchRight(QTextBlock block, QChar b, int i, int nRight)
508{
509 QChar match;
510 switch (b.toLatin1()) {
511 case ')' : match = '('; break;
512 case '}' : match = '{'; break;
513 case ']' : match = '['; break;
514 default: break; // should not happen
515 }
516 if (i==-1)
517 block = block.previous();
518 while (block.isValid()) {
519 BracketData* bd = static_cast<BracketData*>(block.userData());
520 QVector<Bracket>& brackets = bd->brackets;
521 if (i==-1)
522 i = brackets.size()-1;
523 int docPos = block.position();
524 for (; i>-1 && brackets.size()>0; i--) {
525 Bracket& b = brackets[i];
526 if (b.b==')' || b.b=='}' || b.b==']') {
527 nRight++;
528 } else if (b.b==match && nRight==0) {
529 return docPos+b.pos;
530 } else {
531 nRight--;
532 }
533 }
534 block = block.previous();
535 i = -1;
536 }
537 return -1;
538}
539
540void CodeEditor::paintLineNumbers(QPaintEvent *event)
541{

Callers

nothing calls this directly

Calls 2

isValidMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected