(display, doc, viewport)
| 561 | // the the current scroll position). viewport may contain top, |
| 562 | // height, and ensure (see op.scrollToPos) properties. |
| 563 | function visibleLines(display, doc, viewport) { |
| 564 | var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; |
| 565 | top = Math.floor(top - paddingTop(display)); |
| 566 | var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; |
| 567 | |
| 568 | var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); |
| 569 | // Ensure is a {from: {line, ch}, to: {line, ch}} object, and |
| 570 | // forces those lines into the viewport (if possible). |
| 571 | if (viewport && viewport.ensure) { |
| 572 | var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; |
| 573 | if (ensureFrom < from) { |
| 574 | from = ensureFrom; |
| 575 | to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); |
| 576 | } else if (Math.min(ensureTo, doc.lastLine()) >= to) { |
| 577 | from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); |
| 578 | to = ensureTo; |
| 579 | } |
| 580 | } |
| 581 | return {from: from, to: Math.max(to, from + 1)}; |
| 582 | } |
| 583 | |
| 584 | // LINE NUMBERS |
| 585 |
no test coverage detected