MCPcopy Create free account
hub / github.com/KDE/kdiff3 / getBestFirstLine

Function getBestFirstLine

src/difftextwindow.cpp:603–622  ·  view source on GitHub ↗

Returns a line number where the linerange [line, line+nofLines] can be displayed best. If it fits into the currently visible range then the returned value is the current firstLine. */

Source from the content-addressed store, hash-verified

601 the returned value is the current firstLine.
602*/
603LineRef getBestFirstLine(LineRef line, LineType nofLines, LineRef firstLine, LineType visibleLines)
604{
605 assert(visibleLines >= 0); // VisibleLines should not be < 0.
606
607 if(line < visibleLines || visibleLines == 0) //well known result.
608 return 0;
609
610 LineRef newFirstLine = firstLine;
611 if(line > firstLine && line + nofLines + 2 <= firstLine + visibleLines)
612 return newFirstLine;
613
614 if(nofLines < visibleLines)
615 newFirstLine = std::max(0, (LineType)std::ceil(line - (visibleLines - nofLines) / 2));
616 else
617 {
618 LineType numberPages = (LineType)std::floor(nofLines / visibleLines);
619 newFirstLine = std::max(0, line - (visibleLines * numberPages) / 3);
620 }
621 return newFirstLine;
622}
623
624void DiffTextWindow::setFastSelectorRange(qint32 line1, qint32 nofLines)
625{

Callers 2

setFastSelectorMethod · 0.85
setFastSelectorRangeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected