Skip to content

Commit

Permalink
feat: support any as terminal.link.modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanSalt committed Feb 16, 2022
1 parent 7bdc2a0 commit e761208
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion addons/settings/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"Persistent the history of a launcher after it has been closed#!settings.comments.0.terminal.launcher.persistHistory": "在启动器关闭后保留其历史记录",
"Link Modifier#!settings.label.terminal.link.modifier": "链接修饰键",
"Keyboard modifier for opening link by click#!settings.comments.0.terminal.link.modifier": "点击打开链接时的键盘修饰键",
"Options: 'CmdOrCtrl' or 'Alt'#!settings.comments.1.terminal.link.modifier": "可选项: 'CmdOrCtrl' 或 'Alt'",
"any#!settings.options.0.terminal.link.modifier": "任意",
"Renderer Type#!settings.label.terminal.renderer.type": "渲染方式",
"Specify how to render the terminal#!settings.comments.0.terminal.renderer.type": "声明如何渲染终端",
"Options: 'dom', 'canvas' or 'webgl'#!settings.comments.1.terminal.renderer.type": "可选项: 'dom', 'canvas' 或 'webgl'",
Expand Down
14 changes: 12 additions & 2 deletions renderer/compositions/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,18 @@ export function loadTerminalAddons(tab: TerminalTab) {
if (!tab.addons.weblinks) {
tab.addons.weblinks = new WebLinksAddon((event, uri) => {
const currentSettings = unref(settingsRef)
const shouldOpen = currentSettings['terminal.link.modifier'] === 'Alt' ? event.altKey
: (process.platform === 'darwin' ? event.metaKey : event.ctrlKey)
let shouldOpen = false
switch (currentSettings['terminal.link.modifier']) {
case 'Alt':
shouldOpen = event.altKey
break
case 'CmdOrCtrl':
shouldOpen = process.platform === 'darwin' ? event.metaKey : event.ctrlKey
break
default:
shouldOpen = event.altKey || (process.platform === 'darwin' ? event.metaKey : event.ctrlKey)
break
}
if (shouldOpen) {
shell.openExternal(uri)
}
Expand Down
7 changes: 3 additions & 4 deletions resources/settings.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,13 @@
"key": "terminal.link.modifier",
"label": "Link Modifier",
"comments": [
"Keyboard modifier for opening link by click",
"Options: 'CmdOrCtrl' or 'Alt'"
"Keyboard modifier for opening link by click"
],
"schema": {
"type": "string",
"enum": ["CmdOrCtrl", "Alt"]
"enum": ["any", "CmdOrCtrl", "Alt"]
},
"default": "Alt"
"default": "any"
},
{
"key": "terminal.renderer.type",
Expand Down

0 comments on commit e761208

Please sign in to comment.