private static void setVar(LineReader reader, String key, String val) { if (LineReader.KEYMAP.equalsIgnoreCase(key)) { reader.setKeyMap(val); return; } for (LineReader.Option option : LineReader.Option.values()) { if (option.name().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(val)) { if ("on".equalsIgnoreCase(val)) { reader.setOpt(option); } else if ("off".equalsIgnoreCase(val)) { reader.unsetOpt(option); } return; } } reader.setVariable(key, val); }
private static void setVar(LineReader reader, String key, String val) { if (LineReader.KEYMAP.equalsIgnoreCase(key)) { reader.setKeyMap(val); return; } for (LineReader.Option option : LineReader.Option.values()) { if (option.name().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(val)) { if ("on".equalsIgnoreCase(val)) { reader.setOpt(option); } else if ("off".equalsIgnoreCase(val)) { reader.unsetOpt(option); } return; } } reader.setVariable(key, val); }
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)); } }
.build(); reader.setKeyMap("emacs");