private Path getPath() { Object obj = reader != null ? reader.getVariables().get(LineReader.HISTORY_FILE) : null; if (obj instanceof Path) { return (Path) obj; } else if (obj instanceof File) { return ((File) obj).toPath(); } else if (obj != null) { return Paths.get(obj.toString()); } else { return null; } }
public static void configure(LineReader reader, Reader r) throws IOException { BufferedReader br; if (r instanceof BufferedReader) { br = (BufferedReader) r; } else { br = new BufferedReader(r); } reader.getVariables().putIfAbsent(LineReader.EDITING_MODE, "emacs"); reader.setKeyMap(LineReader.MAIN); if ("vi".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.VIINS)); } else if ("emacs".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.EMACS)); } new InputRC(reader).parse(br); if ("vi".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.VIINS)); } else if ("emacs".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.EMACS)); } }
public static void configure(LineReader reader, Reader r) throws IOException { BufferedReader br; if (r instanceof BufferedReader) { br = (BufferedReader) r; } else { br = new BufferedReader(r); } reader.getVariables().putIfAbsent(LineReader.EDITING_MODE, "emacs"); reader.setKeyMap(LineReader.MAIN); if ("vi".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.VIINS)); } else if ("emacs".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.EMACS)); } new InputRC(reader).parse(br); if ("vi".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.VIINS)); } else if ("emacs".equals(reader.getVariable(LineReader.EDITING_MODE))) { reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.EMACS)); } }