Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't change keybindings to emacs for dumb terminals #953

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading