mirror of
https://github.com/atom/atom.git
synced 2026-02-07 21:25:05 -05:00
Add TextEditorComponent.screenPositionForPixelPositionSync
This method can be used to translate a pixel position to a screen position even if the line is not currently rendered on screen.
This commit is contained in:
committed by
Antonio Scandurra
parent
3d6921cca3
commit
1cc68e408e
@@ -152,6 +152,22 @@ class TextEditorComponent {
|
||||
return {top, left}
|
||||
}
|
||||
|
||||
screenPositionForPixelPositionSync (pixelPosition) {
|
||||
const {model} = this.props
|
||||
|
||||
const row = Math.max(0, Math.min(
|
||||
this.rowForPixelPosition(pixelPosition.top),
|
||||
model.getApproximateScreenLineCount() - 1
|
||||
))
|
||||
|
||||
if (!this.renderedScreenLineForRow(row)) {
|
||||
this.requestExtraLineToMeasure(row, model.screenLineForScreenRow(row))
|
||||
this.updateSyncBeforeMeasuringContent()
|
||||
this.measureContentDuringUpdateSync()
|
||||
}
|
||||
return this.screenPositionForPixelPosition(pixelPosition)
|
||||
}
|
||||
|
||||
scheduleUpdate (nextUpdateOnlyBlinksCursors = false) {
|
||||
if (!this.visible) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user