public void printInitialStatusUpdates() { long lastPrint = System.nanoTime(); try { while (client.isValid()) { try { // exit status loop if there is there is pending output if (client.current().getData() != null) { return; } // check if time to update screen boolean update = nanosSince(lastPrint).getValue(SECONDS) >= 0.5; // check for keyboard input int key = readKey(); if (key == CTRL_P) { partialCancel(); } else if (key == CTRL_C) { updateScreen(); update = false; client.close(); } else if (toUpperCase(key) == 'D') { debug = !debug; console.resetScreen(); update = true; } // update screen if (update) { updateScreen(); lastPrint = System.nanoTime(); } // fetch next results (server will wait for a while if no data) client.advance(); } catch (RuntimeException e) { log.debug(e, "error printing status"); if (debug) { e.printStackTrace(out); } } } } finally { console.resetScreen(); } }