synchronized TerminalPosition waitForCursorPositionReport ( ) throws IOException { long startTime = System . currentTimeMillis ( ) ; TerminalPosition cursorPosition = lastReportedCursorPosition ; while ( cursorPosition == null ) { if ( System . currentTimeMillis ( ) - startTime > 5000 ) { //throw new IllegalStateException("Terminal didn't send any position report for 5 seconds, please file a bug with a reproduce!"); return null ; } KeyStroke keyStroke = readInput ( false , false ) ; if ( keyStroke != null ) { keyQueue . add ( keyStroke ) ; } else { try { Thread . sleep ( 1 ) ; } catch ( InterruptedException ignored ) { } } cursorPosition = lastReportedCursorPosition ; } return cursorPosition ; }
Waits for up to 5 seconds for a terminal cursor position report to appear in the input stream . If the timeout expires it will return null . You should have sent the cursor position query already before calling this method .