(display, doc, viewPort)
| 452 | // the the current scroll position). viewPort may contain top, |
| 453 | // height, and ensure (see op.scrollToPos) properties. |
| 454 | function visibleLines(display, doc, viewPort) { |
| 455 | var top = viewPort && viewPort.top != null ? viewPort.top : display.scroller.scrollTop; |
| 456 | top = Math.floor(top - paddingTop(display)); |
| 457 | var bottom = viewPort && viewPort.bottom != null ? viewPort.bottom : top + display.wrapper.clientHeight; |
| 458 | |
| 459 | var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); |
| 460 | // Ensure is a {from: {line, ch}, to: {line, ch}} object, and |
| 461 | // forces those lines into the viewport (if possible). |
| 462 | if (viewPort && viewPort.ensure) { |
| 463 | var ensureFrom = viewPort.ensure.from.line, ensureTo = viewPort.ensure.to.line; |
| 464 | if (ensureFrom < from) |
| 465 | return {from: ensureFrom, |
| 466 | to: lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)}; |
| 467 | if (Math.min(ensureTo, doc.lastLine()) >= to) |
| 468 | return {from: lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight), |
| 469 | to: ensureTo}; |
| 470 | } |
| 471 | return {from: from, to: to}; |
| 472 | } |
| 473 | |
| 474 | // LINE NUMBERS |
| 475 |
no test coverage detected