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

fix Meta-Enter #585

Merged
merged 2 commits into from
Aug 6, 2019
Merged
Changes from 1 commit
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
23 changes: 12 additions & 11 deletions lib/runtime/console2.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ export function activate (_ink) {
client.boot()
}

terminal.attachCustomKeyEventHandler(e => {
if (whitelistedKeybindingsREPL.indexOf(atom.keymaps.keystrokeForKeyboardEvent(e)) > -1) {
return false
}
return e
})
terminal.attachCustomKeyEventHandler((e) => handleKeybinding(e, terminal, whitelistedKeybindingsREPL))

modules.onDidChange(debounce(() => changemodule({mod: modules.current()}), 200))

Expand Down Expand Up @@ -135,7 +130,7 @@ export function activate (_ink) {
// handle deserialized terminals
forEachPane(item => {
if (!item.ty) {
item.attachCustomKeyEventHandler(handleWhitelistedKeybindingTerminal)
item.attachCustomKeyEventHandler((e) => handleKeybinding(e, item))
addLinkHandler(item.terminal)
shellPty(item.persistentState.cwd)
.then(({pty, cwd}) => item.attach(pty, true, cwd))
Expand All @@ -157,7 +152,7 @@ export function close () {

function newTerminal () {
const term = ink.InkTerminal.fromId(`terminal-julia-${Math.floor(Math.random()*10000000)}`, terminalOptions())
term.attachCustomKeyEventHandler(handleWhitelistedKeybindingTerminal)
term.attachCustomKeyEventHandler((e) => handleKeybinding(e, term))
addLinkHandler(term.terminal)
shellPty().then(({pty, cwd}) => {
term.attach(pty, true, cwd)
Expand All @@ -170,7 +165,7 @@ function newTerminal () {

function newRemoteTerminal () {
const term = ink.InkTerminal.fromId(`terminal-remote-julia-${Math.floor(Math.random()*10000000)}`, terminalOptions())
term.attachCustomKeyEventHandler(handleWhitelistedKeybindingTerminal)
term.attachCustomKeyEventHandler((e) => handleKeybinding(e, term))
addLinkHandler(term.terminal)
remotePty().then(({pty, cwd, conf}) => {
term.attach(pty, true, cwd)
Expand Down Expand Up @@ -257,8 +252,14 @@ function addLinkHandler (terminal) {
terminal.registerLinkMatcher(uriRegex, handleLink)
}

function handleWhitelistedKeybindingTerminal (e) {
if (whitelistedKeybindingsTerminal.indexOf(atom.keymaps.keystrokeForKeyboardEvent(e)) > -1) {
function handleKeybinding (e, term, binds = whitelistedKeybindingsTerminal) {
// Meta-Enter doesn't work properly with xterm.js atm, so we send the right escape sequence ourselves:
if (e.keyCode === 13 && (e.altKey || e.metaKey)) {
if (term.ty) {
term.ty.write('\x1b\x0d')
}
return false
} else if (binds.indexOf(atom.keymaps.keystrokeForKeyboardEvent(e)) > -1) {
return false
}
return e
pfitzseb marked this conversation as resolved.
Show resolved Hide resolved
Expand Down