private void help() throws IOException { String[] help = new String[] { help_fw_page, help_bw_page, help_fw_dline, help_bw_dline, help_fw_sline, help_bw_sline, help_go_start, help_go_end, help_fw_search1, help_fw_search2, help_bw_search1, help_bw_search2, help_help, help_quit }; // Remember the 'current' buffer so that we can repaint it // when we are done. ScreenBuffer prevBuffer = this.currentBuffer; // Prepare and paint the help screen ScreenBuffer buffer = new ScreenBuffer(true); for (int i = 0; i < help.length; i++) { prepareLine(help[i], i, buffer); } buffer.adjust(0, 0); buffer.output(); prompt(str_any_key); // Wait till the user is done, then repaint the previous screen. pr.read(); prompt(); prevBuffer.output(); }
/** * Prepare lines for output by painting them to our private buffer in the reverse direction * starting at a given end line number and (rendered) subline number. */ private ScreenBuffer prepareReverse(int endLineNo, int endSublineNo) { ScreenBuffer buffer = new ScreenBuffer(false); int lineNo = endLineNo; String line = null; boolean more = true; while (more && lineNo >= 0) { line = lineStore.getLine(lineNo); more = prepareLine(line, lineNo, buffer); lineNo--; } if (buffer.adjust(endLineNo, endSublineNo)) { return buffer; } else { return prepare(0, 0); } }
/** * Prepare lines for output by painting them to our private buffer in the forward direction * starting at a given line number and (rendered) subline number. * * @param startLineNo */ private ScreenBuffer prepare(int startLineNo, int startSublineNo) { while (true) { ScreenBuffer buffer = new ScreenBuffer(true); int lineNo = startLineNo; boolean more; do { String line = lineStore.getLine(lineNo); if (line == null) { break; } more = prepareLine(line, lineNo, buffer); lineNo++; } while (more); if (buffer.adjust(startLineNo, startSublineNo) || startLineNo == 0) { return buffer; } else { startLineNo -= 1; startSublineNo = LAST_SUBLINE; } } }