How do you determine if cursor is off-screen?


I haven’t been able to figure out a way to do this yet from the API docs - how do you determine if a cursor is off-screen? Comparing screen and buffer coordinates doesn’t work because screen coordinates aren’t relative to the viewport.


What do you mean by screen?


Out of the viewport (ie. not visible)


So you mean the browser window? Maybe this?

$(window).mouseleave ->


Oops sorry, I mean an instance of Atom’s Cursor.


No, my problem. I’m too literal-minded.

Aren’t there first-visible-line and last-visible line functions? I seem to remember using them. I’ll check my code.


Maybe this? (untested)

    editorEle = atom.views.getView editor
    topRow = editorEle.getFirstVisibleScreenRow() 
    botRow = editorEle.getLastVisibleScreenRow()
    curRow = editor.getCursorBufferPosition().row
    visible =  (topRow <= curRow <= botRow)

Edit: I just checked and getFirstVisibleScreenRow is not in the API. It works in my code though. Hopefully they haven’t deprecated it.