void () { TerminalLine terminalLine = processTerminalBuffer(this::getLineAtCursor); if (terminalLine != myTerminalLine) { myTypings.set(0); myTerminalLine = terminalLine; myMaxCursorX = -1; } String prompt = getLineTextUpToCursor(terminalLine); if (myTypings.get() == 0) { myPrompt = prompt; myTerminalLine = terminalLine; if (LOG.isDebugEnabled()) { LOG.debug("Guessed shell prompt: " + myPrompt); } } else { if (prompt.startsWith(myPrompt)) { if (LOG.isDebugEnabled()) { LOG.debug("Guessed prompt confirmed by typing# " + (myTypings.get() + 1)); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Prompt rejected by typing#" + (myTypings.get() + 1) + ", new prompt: " + prompt); } myPrompt = prompt; myTypings.set(1); } } myTypings.incrementAndGet(); }