Skip to content

Commit

Permalink
Don't change keybindings to emacs for dumb terminals (fixes #864) (#953)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvesalai authored Apr 17, 2024
1 parent c8b3caa commit f086431
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions reader/src/main/java/org/jline/reader/impl/InputRC.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jline.reader.LineReader;
import org.jline.reader.Macro;
import org.jline.reader.Reference;
import org.jline.terminal.Terminal;
import org.jline.utils.Log;

public final class InputRC {
Expand All @@ -44,18 +45,23 @@ public static void configure(LineReader reader, Reader r) throws IOException {
} 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));

Terminal terminal = reader.getTerminal();

if (Terminal.TYPE_DUMB.equals(terminal.getType()) || Terminal.TYPE_DUMB_COLOR.equals(terminal.getType())) {
reader.getVariables().putIfAbsent(LineReader.EDITING_MODE, "dumb");
} else {
reader.getVariables().putIfAbsent(LineReader.EDITING_MODE, "emacs");
}

reader.setKeyMap(LineReader.MAIN);
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));
} else if ("dumb".equals(reader.getVariable(LineReader.EDITING_MODE))) {
reader.getKeyMaps().put(LineReader.MAIN, reader.getKeyMaps().get(LineReader.DUMB));
}
}

Expand Down

0 comments on commit f086431

Please sign in to comment.