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. */
| 601 | the returned value is the current firstLine. |
| 602 | */ |
| 603 | LineRef 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 | |
| 624 | void DiffTextWindow::setFastSelectorRange(qint32 line1, qint32 nofLines) |
| 625 | { |
no outgoing calls
no test coverage detected