| 559 | } |
| 560 | |
| 561 | void PatchHighlighter::addLineMarker(KTextEditor::MovingRange* range, const KompareDiff2::Difference* diff) |
| 562 | { |
| 563 | KTextEditor::Attribute::Ptr t( new KTextEditor::Attribute() ); |
| 564 | |
| 565 | bool isOriginalState = diff->applied() == m_plugin->patch()->isAlreadyApplied(); |
| 566 | |
| 567 | if( isOriginalState ) { |
| 568 | t->setProperty( QTextFormat::BackgroundBrush, QBrush( ColorCache::self()->blendBackground( QColor( 0, 255, 255 ), 20 ) ) ); |
| 569 | }else{ |
| 570 | t->setProperty( QTextFormat::BackgroundBrush, QBrush( ColorCache::self()->blendBackground( QColor( 255, 0, 255 ), 20 ) ) ); |
| 571 | } |
| 572 | range->setAttribute( t ); |
| 573 | range->setZDepth( -500 ); |
| 574 | |
| 575 | MarkType mark; |
| 576 | |
| 577 | if( isOriginalState ) { |
| 578 | mark = MarkType::markType27; |
| 579 | |
| 580 | if( isInsertion( diff ) ) |
| 581 | mark = MarkType::markType25; |
| 582 | if( isRemoval( diff ) ) |
| 583 | mark = MarkType::markType26; |
| 584 | }else{ |
| 585 | mark = MarkType::markType24; |
| 586 | |
| 587 | if( isInsertion( diff ) ) |
| 588 | mark = MarkType::markType22; |
| 589 | if( isRemoval( diff ) ) |
| 590 | mark = MarkType::markType23; |
| 591 | } |
| 592 | |
| 593 | auto* const document = range->document(); |
| 594 | |
| 595 | document->addMark(range->start().line(), mark); |
| 596 | |
| 597 | KompareDiff2::DifferenceStringList lines; |
| 598 | if( diff->applied() ) |
| 599 | lines = diff->destinationLines(); |
| 600 | else |
| 601 | lines = diff->sourceLines(); |
| 602 | |
| 603 | for( int a = 0; a < lines.size(); ++a ) { |
| 604 | const auto* const line = lines[a]; |
| 605 | int currentPos = 0; |
| 606 | const uint lineLength = static_cast<uint>(line->string().size()); |
| 607 | |
| 608 | const auto markers = line->markerList(); |
| 609 | |
| 610 | for (auto* marker : markers) { |
| 611 | if (marker->type() == KompareDiff2::Marker::End) { |
| 612 | if (currentPos != 0 || marker->offset() != lineLength) { |
| 613 | auto* const r2 = document->newMovingRange( |
| 614 | KTextEditor::Range(KTextEditor::Cursor(a + range->start().line(), currentPos), |
| 615 | KTextEditor::Cursor(a + range->start().line(), marker->offset()))); |
| 616 | m_ranges[r2] = nullptr; |
| 617 | |
| 618 | KTextEditor::Attribute::Ptr t( new KTextEditor::Attribute() ); |
nothing calls this directly
no test coverage detected