Skip to content

Commit 6f550d5

Browse files
authored
Merge pull request #251 from JunoLab/sp/linkkeymodifier
option for ctrl/cmd modifier when clicking link
2 parents 20b29bd + 4ed293a commit 6f550d5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/console/console.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class InkTerminal extends PaneItem {
8282
cols: 100,
8383
rows: 30,
8484
scrollback: 5000,
85-
tabStopWidth: 4
85+
tabStopWidth: 4,
8686
}, opts)
8787

8888
if (process.platform === 'win32') {
@@ -98,7 +98,12 @@ export default class InkTerminal extends PaneItem {
9898
}
9999

100100
this.terminal = new Terminal(opts)
101-
const webLinksAddon = new WebLinksAddon((ev, uri) => openExternal(uri))
101+
const webLinksAddon = new WebLinksAddon((ev, uri) => {
102+
if (!this.shouldOpenLink(ev)) return false
103+
openExternal(uri)
104+
}, {
105+
willLinkActivate: ev => this.shouldOpenLink(ev)
106+
})
102107
this.terminal.loadAddon(webLinksAddon)
103108

104109
this.searchAddon = new SearchAddon()
@@ -140,6 +145,14 @@ export default class InkTerminal extends PaneItem {
140145
this.view.className = name
141146
}
142147

148+
shouldOpenLink (ev) {
149+
return true
150+
}
151+
152+
onDidOpenLink (f) {
153+
this.shouldOpenLink = f
154+
}
155+
143156
cursorPosition () {
144157
this.write('\x1b[0m')
145158
return [this.terminal._core.buffer.x, this.terminal._core.buffer.y]

0 commit comments

Comments
 (0)