Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
Tabby
提交
a5ecdeb5
T
Tabby
项目概览
后端镜像
/
Tabby
通知
35
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Tabby
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a5ecdeb5
编写于
6月 14, 2019
作者:
E
Eugene Pankov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lint
上级
82e33481
变更
62
隐藏空白更改
内联
并排
Showing
62 changed file
with
271 addition
and
280 deletion
+271
-280
app/src/app.module.ts
app/src/app.module.ts
+2
-2
app/src/entry.preload.ts
app/src/entry.preload.ts
+2
-2
app/src/entry.ts
app/src/entry.ts
+2
-2
app/src/plugins.ts
app/src/plugins.ts
+16
-16
terminus-community-color-schemes/src/colorSchemes.ts
terminus-community-color-schemes/src/colorSchemes.ts
+5
-5
terminus-core/src/components/appRoot.component.ts
terminus-core/src/components/appRoot.component.ts
+1
-1
terminus-core/src/components/checkbox.component.ts
terminus-core/src/components/checkbox.component.ts
+1
-1
terminus-core/src/components/splitTab.component.ts
terminus-core/src/components/splitTab.component.ts
+29
-29
terminus-core/src/components/splitTabSpanner.component.ts
terminus-core/src/components/splitTabSpanner.component.ts
+3
-3
terminus-core/src/components/tabHeader.component.ts
terminus-core/src/components/tabHeader.component.ts
+2
-2
terminus-core/src/services/app.service.ts
terminus-core/src/services/app.service.ts
+11
-11
terminus-core/src/services/config.service.ts
terminus-core/src/services/config.service.ts
+6
-6
terminus-core/src/services/docking.service.ts
terminus-core/src/services/docking.service.ts
+8
-8
terminus-core/src/services/homeBase.service.ts
terminus-core/src/services/homeBase.service.ts
+2
-2
terminus-core/src/services/hostApp.service.ts
terminus-core/src/services/hostApp.service.ts
+1
-1
terminus-core/src/services/hotkeys.service.ts
terminus-core/src/services/hotkeys.service.ts
+28
-28
terminus-core/src/services/hotkeys.util.ts
terminus-core/src/services/hotkeys.util.ts
+6
-16
terminus-core/src/services/shellIntegration.service.ts
terminus-core/src/services/shellIntegration.service.ts
+4
-4
terminus-core/src/services/tabRecovery.service.ts
terminus-core/src/services/tabRecovery.service.ts
+5
-5
terminus-core/src/services/tabs.service.ts
terminus-core/src/services/tabs.service.ts
+5
-5
terminus-core/src/services/touchbar.service.ts
terminus-core/src/services/touchbar.service.ts
+6
-6
terminus-core/src/services/updater.service.ts
terminus-core/src/services/updater.service.ts
+3
-3
terminus-core/src/tabContextMenu.ts
terminus-core/src/tabContextMenu.ts
+4
-4
terminus-core/tsconfig.json
terminus-core/tsconfig.json
+1
-1
terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts
...in-manager/src/components/pluginsSettingsTab.component.ts
+1
-1
terminus-settings/src/buttonProvider.ts
terminus-settings/src/buttonProvider.ts
+1
-1
terminus-settings/src/components/settingsTab.component.ts
terminus-settings/src/components/settingsTab.component.ts
+2
-2
terminus-ssh/src/api.ts
terminus-ssh/src/api.ts
+4
-4
terminus-ssh/src/components/editConnectionModal.component.ts
terminus-ssh/src/components/editConnectionModal.component.ts
+7
-7
terminus-ssh/src/components/sshModal.component.ts
terminus-ssh/src/components/sshModal.component.ts
+2
-2
terminus-ssh/src/components/sshSettingsTab.component.ts
terminus-ssh/src/components/sshSettingsTab.component.ts
+7
-7
terminus-ssh/src/components/sshTab.component.ts
terminus-ssh/src/components/sshTab.component.ts
+1
-1
terminus-ssh/src/services/ssh.service.ts
terminus-ssh/src/services/ssh.service.ts
+10
-10
terminus-terminal/src/api/baseTerminalTab.component.ts
terminus-terminal/src/api/baseTerminalTab.component.ts
+5
-5
terminus-terminal/src/buttonProvider.ts
terminus-terminal/src/buttonProvider.ts
+3
-3
terminus-terminal/src/colorSchemes.ts
terminus-terminal/src/colorSchemes.ts
+4
-4
terminus-terminal/src/components/appearanceSettingsTab.component.ts
...erminal/src/components/appearanceSettingsTab.component.ts
+1
-1
terminus-terminal/src/components/colorPicker.component.ts
terminus-terminal/src/components/colorPicker.component.ts
+1
-1
terminus-terminal/src/components/environmentEditor.component.ts
...us-terminal/src/components/environmentEditor.component.ts
+2
-2
terminus-terminal/src/components/shellSettingsTab.component.ts
...nus-terminal/src/components/shellSettingsTab.component.ts
+4
-4
terminus-terminal/src/components/terminalTab.component.ts
terminus-terminal/src/components/terminalTab.component.ts
+4
-4
terminus-terminal/src/contextMenu.ts
terminus-terminal/src/contextMenu.ts
+2
-2
terminus-terminal/src/frontends/frontend.ts
terminus-terminal/src/frontends/frontend.ts
+1
-1
terminus-terminal/src/frontends/hterm.ts
terminus-terminal/src/frontends/hterm.ts
+7
-7
terminus-terminal/src/frontends/htermFrontend.ts
terminus-terminal/src/frontends/htermFrontend.ts
+6
-6
terminus-terminal/src/frontends/xtermFrontend.ts
terminus-terminal/src/frontends/xtermFrontend.ts
+5
-5
terminus-terminal/src/hotkeys.ts
terminus-terminal/src/hotkeys.ts
+1
-1
terminus-terminal/src/index.ts
terminus-terminal/src/index.ts
+5
-5
terminus-terminal/src/pathDrop.ts
terminus-terminal/src/pathDrop.ts
+3
-3
terminus-terminal/src/services/sessions.service.ts
terminus-terminal/src/services/sessions.service.ts
+6
-6
terminus-terminal/src/services/terminal.service.ts
terminus-terminal/src/services/terminal.service.ts
+6
-6
terminus-terminal/src/services/terminalFrontend.service.ts
terminus-terminal/src/services/terminalFrontend.service.ts
+1
-1
terminus-terminal/src/services/uac.service.ts
terminus-terminal/src/services/uac.service.ts
+1
-1
terminus-terminal/src/shells/custom.ts
terminus-terminal/src/shells/custom.ts
+1
-1
terminus-terminal/src/shells/cygwin32.ts
terminus-terminal/src/shells/cygwin32.ts
+1
-1
terminus-terminal/src/shells/cygwin64.ts
terminus-terminal/src/shells/cygwin64.ts
+1
-1
terminus-terminal/src/shells/linuxDefault.ts
terminus-terminal/src/shells/linuxDefault.ts
+1
-1
terminus-terminal/src/shells/macDefault.ts
terminus-terminal/src/shells/macDefault.ts
+1
-1
terminus-terminal/src/shells/winDefault.ts
terminus-terminal/src/shells/winDefault.ts
+3
-3
terminus-terminal/src/shells/wsl.ts
terminus-terminal/src/shells/wsl.ts
+5
-5
terminus-terminal/src/tabContextMenu.ts
terminus-terminal/src/tabContextMenu.ts
+1
-1
tslint.json
tslint.json
+1
-0
未找到文件。
app/src/app.module.ts
浏览文件 @
a5ecdeb5
...
...
@@ -4,7 +4,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import
{
ToastrModule
}
from
'
ngx-toastr
'
export
function
getRootModule
(
plugins
:
any
[])
{
le
t
imports
=
[
cons
t
imports
=
[
BrowserModule
,
...
plugins
,
NgbModule
.
forRoot
(),
...
...
@@ -15,7 +15,7 @@ export function getRootModule (plugins: any[]) {
extendedTimeOut
:
5000
,
}),
]
le
t
bootstrap
=
[
cons
t
bootstrap
=
[
...(
plugins
.
filter
(
x
=>
x
.
bootstrap
).
map
(
x
=>
x
.
bootstrap
)),
]
...
...
app/src/entry.preload.ts
浏览文件 @
a5ecdeb5
...
...
@@ -16,8 +16,8 @@ Raven.config(
{
release
:
require
(
'
electron
'
).
remote
.
app
.
getVersion
(),
dataCallback
:
(
data
:
any
)
=>
{
const
normalize
=
(
filename
)
=>
{
le
t
splitArray
=
filename
.
split
(
'
/
'
)
const
normalize
=
(
filename
:
string
)
=>
{
cons
t
splitArray
=
filename
.
split
(
'
/
'
)
return
splitArray
[
splitArray
.
length
-
1
]
}
...
...
app/src/entry.ts
浏览文件 @
a5ecdeb5
...
...
@@ -32,10 +32,10 @@ async function bootstrap (plugins: IPluginInfo[], safeMode = false): Promise<NgM
if
(
safeMode
)
{
plugins
=
plugins
.
filter
(
x
=>
x
.
isBuiltin
)
}
le
t
pluginsModules
=
await
loadPlugins
(
plugins
,
(
current
,
total
)
=>
{
cons
t
pluginsModules
=
await
loadPlugins
(
plugins
,
(
current
,
total
)
=>
{
(
document
.
querySelector
(
'
.progress .bar
'
)
as
HTMLElement
).
style
.
width
=
100
*
current
/
total
+
'
%
'
})
le
t
module
=
getRootModule
(
pluginsModules
)
cons
t
module
=
getRootModule
(
pluginsModules
)
window
[
'
rootModule
'
]
=
module
return
platformBrowserDynamic
().
bootstrapModule
(
module
)
}
...
...
app/src/plugins.ts
浏览文件 @
a5ecdeb5
...
...
@@ -12,7 +12,7 @@ function normalizePath (path: string): string {
return
path
}
nodeRequire
.
main
.
paths
.
map
(
x
=>
nodeModule
.
globalPaths
.
push
(
normalizePath
(
x
)))
nodeRequire
.
main
.
paths
.
map
(
(
x
:
string
)
=>
nodeModule
.
globalPaths
.
push
(
normalizePath
(
x
)))
if
(
process
.
env
.
TERMINUS_DEV
)
{
nodeModule
.
globalPaths
.
unshift
(
path
.
dirname
(
require
(
'
electron
'
).
remote
.
app
.
getAppPath
()))
...
...
@@ -38,7 +38,7 @@ if (process.env.TERMINUS_PLUGINS) {
process
.
env
.
TERMINUS_PLUGINS
.
split
(
'
:
'
).
map
(
x
=>
nodeModule
.
globalPaths
.
push
(
normalizePath
(
x
)))
}
export
declare
type
ProgressCallback
=
(
current
,
total
)
=>
void
export
declare
type
ProgressCallback
=
(
current
:
number
,
total
:
number
)
=>
void
export
interface
IPluginInfo
{
name
:
string
...
...
@@ -80,7 +80,7 @@ builtinModules.forEach(m => {
})
const
originalRequire
=
(
global
as
any
).
require
;(
global
as
any
).
require
=
function
(
query
)
{
;(
global
as
any
).
require
=
function
(
query
:
string
)
{
if
(
cachedBuiltinModules
[
query
])
{
return
cachedBuiltinModules
[
query
]
}
...
...
@@ -88,9 +88,9 @@ const originalRequire = (global as any).require
}
export
async
function
findPlugins
():
Promise
<
IPluginInfo
[]
>
{
le
t
paths
=
nodeModule
.
globalPaths
cons
t
paths
=
nodeModule
.
globalPaths
let
foundPlugins
:
IPluginInfo
[]
=
[]
le
t
candidateLocations
:
{
pluginDir
:
string
,
packageName
:
string
}[]
=
[]
cons
t
candidateLocations
:
{
pluginDir
:
string
,
packageName
:
string
}[]
=
[]
const
PREFIX
=
'
terminus-
'
for
(
let
pluginDir
of
paths
)
{
...
...
@@ -98,28 +98,28 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
if
(
!
await
fs
.
exists
(
pluginDir
))
{
continue
}
le
t
pluginNames
=
await
fs
.
readdir
(
pluginDir
)
cons
t
pluginNames
=
await
fs
.
readdir
(
pluginDir
)
if
(
await
fs
.
exists
(
path
.
join
(
pluginDir
,
'
package.json
'
)))
{
candidateLocations
.
push
({
pluginDir
:
path
.
dirname
(
pluginDir
),
packageName
:
path
.
basename
(
pluginDir
)
})
}
for
(
le
t
packageName
of
pluginNames
)
{
for
(
cons
t
packageName
of
pluginNames
)
{
if
(
packageName
.
startsWith
(
PREFIX
))
{
candidateLocations
.
push
({
pluginDir
,
packageName
})
}
}
}
for
(
le
t
{
pluginDir
,
packageName
}
of
candidateLocations
)
{
le
t
pluginPath
=
path
.
join
(
pluginDir
,
packageName
)
le
t
infoPath
=
path
.
join
(
pluginPath
,
'
package.json
'
)
for
(
cons
t
{
pluginDir
,
packageName
}
of
candidateLocations
)
{
cons
t
pluginPath
=
path
.
join
(
pluginDir
,
packageName
)
cons
t
infoPath
=
path
.
join
(
pluginPath
,
'
package.json
'
)
if
(
!
await
fs
.
exists
(
infoPath
))
{
continue
}
le
t
name
=
packageName
.
substring
(
PREFIX
.
length
)
cons
t
name
=
packageName
.
substring
(
PREFIX
.
length
)
if
(
foundPlugins
.
some
(
x
=>
x
.
name
===
name
))
{
console
.
info
(
`Plugin
${
packageName
}
already exists, overriding`
)
...
...
@@ -127,7 +127,7 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
}
try
{
le
t
info
=
JSON
.
parse
(
await
fs
.
readFile
(
infoPath
,
{
encoding
:
'
utf-8
'
}))
cons
t
info
=
JSON
.
parse
(
await
fs
.
readFile
(
infoPath
,
{
encoding
:
'
utf-8
'
}))
if
(
!
info
.
keywords
||
!
(
info
.
keywords
.
includes
(
'
terminus-plugin
'
)
||
info
.
keywords
.
includes
(
'
terminus-builtin-plugin
'
)))
{
continue
}
...
...
@@ -153,17 +153,17 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
}
export
async
function
loadPlugins
(
foundPlugins
:
IPluginInfo
[],
progress
:
ProgressCallback
):
Promise
<
any
[]
>
{
le
t
plugins
:
any
[]
=
[]
cons
t
plugins
:
any
[]
=
[]
progress
(
0
,
1
)
let
index
=
0
for
(
le
t
foundPlugin
of
foundPlugins
)
{
for
(
cons
t
foundPlugin
of
foundPlugins
)
{
console
.
info
(
`Loading
${
foundPlugin
.
name
}
:
${
nodeRequire
.
resolve
(
foundPlugin
.
path
)}
`
)
progress
(
index
,
foundPlugins
.
length
)
try
{
const
label
=
'
Loading
'
+
foundPlugin
.
name
console
.
time
(
label
)
le
t
packageModule
=
nodeRequire
(
foundPlugin
.
path
)
le
t
pluginModule
=
packageModule
.
default
.
forRoot
?
packageModule
.
default
.
forRoot
()
:
packageModule
.
default
cons
t
packageModule
=
nodeRequire
(
foundPlugin
.
path
)
cons
t
pluginModule
=
packageModule
.
default
.
forRoot
?
packageModule
.
default
.
forRoot
()
:
packageModule
.
default
pluginModule
[
'
pluginName
'
]
=
foundPlugin
.
name
pluginModule
[
'
bootstrap
'
]
=
packageModule
.
bootstrap
plugins
.
push
(
pluginModule
)
...
...
terminus-community-color-schemes/src/colorSchemes.ts
浏览文件 @
a5ecdeb5
...
...
@@ -6,13 +6,13 @@ const schemeContents = require.context('../schemes/', true, /.*/)
@
Injectable
()
export
class
ColorSchemes
extends
TerminalColorSchemeProvider
{
async
getSchemes
():
Promise
<
ITerminalColorScheme
[]
>
{
le
t
schemes
:
ITerminalColorScheme
[]
=
[]
cons
t
schemes
:
ITerminalColorScheme
[]
=
[]
schemeContents
.
keys
().
forEach
(
schemeFile
=>
{
le
t
lines
=
(
schemeContents
(
schemeFile
).
default
as
string
).
split
(
'
\n
'
)
cons
t
lines
=
(
schemeContents
(
schemeFile
).
default
as
string
).
split
(
'
\n
'
)
// process #define variables
le
t
variables
:
any
=
{}
cons
t
variables
:
any
=
{}
lines
.
filter
(
x
=>
x
.
startsWith
(
'
#define
'
))
.
map
(
x
=>
x
.
split
(
'
'
).
map
(
v
=>
v
.
trim
()))
...
...
@@ -20,7 +20,7 @@ export class ColorSchemes extends TerminalColorSchemeProvider {
variables
[
variableName
]
=
variableValue
})
le
t
values
:
any
=
{}
cons
t
values
:
any
=
{}
lines
.
filter
(
x
=>
x
.
startsWith
(
'
*.
'
))
.
map
(
x
=>
x
.
substring
(
2
))
...
...
@@ -29,7 +29,7 @@ export class ColorSchemes extends TerminalColorSchemeProvider {
values
[
key
]
=
variables
[
value
]
?
variables
[
value
]
:
value
})
le
t
colors
:
string
[]
=
[]
cons
t
colors
:
string
[]
=
[]
let
colorIndex
=
0
while
(
values
[
`color
${
colorIndex
}
`
])
{
colors
.
push
(
values
[
`color
${
colorIndex
}
`
])
...
...
terminus-core/src/components/appRoot.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -91,7 +91,7 @@ export class AppRootComponent {
this
.
hotkeys
.
matchedHotkey
.
subscribe
((
hotkey
)
=>
{
if
(
hotkey
.
startsWith
(
'
tab-
'
))
{
le
t
index
=
parseInt
(
hotkey
.
split
(
'
-
'
)[
1
])
cons
t
index
=
parseInt
(
hotkey
.
split
(
'
-
'
)[
1
])
if
(
index
<=
this
.
app
.
tabs
.
length
)
{
this
.
app
.
selectTab
(
this
.
app
.
tabs
[
index
-
1
])
}
...
...
terminus-core/src/components/checkbox.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -23,7 +23,7 @@ export class CheckboxComponent implements ControlValueAccessor {
}
this
.
model
=
!
this
.
model
for
(
le
t
fx
of
this
.
changed
)
{
for
(
cons
t
fx
of
this
.
changed
)
{
fx
(
this
.
model
)
}
}
...
...
terminus-core/src/components/splitTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -35,7 +35,7 @@ export class SplitContainer {
*/
getAllTabs
()
{
let
r
=
[]
for
(
le
t
child
of
this
.
children
)
{
for
(
cons
t
child
of
this
.
children
)
{
if
(
child
instanceof
SplitContainer
)
{
r
=
r
.
concat
(
child
.
getAllTabs
())
}
else
{
...
...
@@ -50,7 +50,7 @@ export class SplitContainer {
*/
normalize
()
{
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
le
t
child
=
this
.
children
[
i
]
cons
t
child
=
this
.
children
[
i
]
if
(
child
instanceof
SplitContainer
)
{
child
.
normalize
()
...
...
@@ -63,7 +63,7 @@ export class SplitContainer {
}
else
if
(
child
.
children
.
length
===
1
)
{
this
.
children
[
i
]
=
child
.
children
[
0
]
}
else
if
(
child
.
orientation
===
this
.
orientation
)
{
le
t
ratio
=
this
.
ratios
[
i
]
cons
t
ratio
=
this
.
ratios
[
i
]
this
.
children
.
splice
(
i
,
1
)
this
.
ratios
.
splice
(
i
,
1
)
for
(
let
j
=
0
;
j
<
child
.
children
.
length
;
j
++
)
{
...
...
@@ -76,7 +76,7 @@ export class SplitContainer {
}
let
s
=
0
for
(
le
t
x
of
this
.
ratios
)
{
for
(
cons
t
x
of
this
.
ratios
)
{
s
+=
x
}
this
.
ratios
=
this
.
ratios
.
map
(
x
=>
x
/
s
)
...
...
@@ -94,8 +94,8 @@ export class SplitContainer {
}
async
serialize
()
{
le
t
children
=
[]
for
(
le
t
child
of
this
.
children
)
{
cons
t
children
=
[]
for
(
cons
t
child
of
this
.
children
)
{
if
(
child
instanceof
SplitContainer
)
{
children
.
push
(
await
child
.
serialize
())
}
else
{
...
...
@@ -257,7 +257,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
focus
(
tab
:
BaseTabComponent
)
{
this
.
focusedTab
=
tab
for
(
le
t
x
of
this
.
getAllTabs
())
{
for
(
cons
t
x
of
this
.
getAllTabs
())
{
if
(
x
!==
tab
)
{
x
.
emitBlurred
()
}
...
...
@@ -294,7 +294,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
(
target
.
orientation
===
'
v
'
&&
[
'
l
'
,
'
r
'
].
includes
(
side
))
||
(
target
.
orientation
===
'
h
'
&&
[
'
t
'
,
'
b
'
].
includes
(
side
))
)
{
le
t
newContainer
=
new
SplitContainer
()
cons
t
newContainer
=
new
SplitContainer
()
newContainer
.
orientation
=
(
target
.
orientation
===
'
v
'
)
?
'
h
'
:
'
v
'
newContainer
.
children
=
[
relative
]
newContainer
.
ratios
=
[
1
]
...
...
@@ -326,8 +326,8 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
removeTab
(
tab
:
BaseTabComponent
)
{
le
t
parent
=
this
.
getParentOf
(
tab
)
le
t
index
=
parent
.
children
.
indexOf
(
tab
)
cons
t
parent
=
this
.
getParentOf
(
tab
)
cons
t
index
=
parent
.
children
.
indexOf
(
tab
)
parent
.
ratios
.
splice
(
index
,
1
)
parent
.
children
.
splice
(
index
,
1
)
...
...
@@ -350,7 +350,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
navigate
(
dir
:
SplitDirection
)
{
let
rel
:
BaseTabComponent
|
SplitContainer
=
this
.
focusedTab
let
parent
=
this
.
getParentOf
(
rel
)
le
t
orientation
=
[
'
l
'
,
'
r
'
].
includes
(
dir
)
?
'
h
'
:
'
v
'
cons
t
orientation
=
[
'
l
'
,
'
r
'
].
includes
(
dir
)
?
'
h
'
:
'
v
'
while
(
parent
!==
this
.
root
&&
parent
.
orientation
!==
orientation
)
{
rel
=
parent
...
...
@@ -361,7 +361,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
return
}
le
t
index
=
parent
.
children
.
indexOf
(
rel
)
cons
t
index
=
parent
.
children
.
indexOf
(
rel
)
if
([
'
l
'
,
'
t
'
].
includes
(
dir
))
{
if
(
index
>
0
)
{
this
.
focusAnyIn
(
parent
.
children
[
index
-
1
])
...
...
@@ -374,7 +374,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
async
splitTab
(
tab
:
BaseTabComponent
,
dir
:
SplitDirection
)
{
le
t
newTab
=
await
this
.
tabsService
.
duplicate
(
tab
)
cons
t
newTab
=
await
this
.
tabsService
.
duplicate
(
tab
)
this
.
addTab
(
newTab
,
tab
,
dir
)
}
...
...
@@ -383,9 +383,9 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
*/
getParentOf
(
tab
:
BaseTabComponent
|
SplitContainer
,
root
?:
SplitContainer
):
SplitContainer
{
root
=
root
||
this
.
root
for
(
le
t
child
of
root
.
children
)
{
for
(
cons
t
child
of
root
.
children
)
{
if
(
child
instanceof
SplitContainer
)
{
le
t
r
=
this
.
getParentOf
(
tab
,
child
)
cons
t
r
=
this
.
getParentOf
(
tab
,
child
)
if
(
r
)
{
return
r
}
...
...
@@ -419,7 +419,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private
attachTabView
(
tab
:
BaseTabComponent
)
{
le
t
ref
=
this
.
viewContainer
.
insert
(
tab
.
hostView
)
as
EmbeddedViewRef
<
any
>
cons
t
ref
=
this
.
viewContainer
.
insert
(
tab
.
hostView
)
as
EmbeddedViewRef
<
any
>
this
.
viewRefs
.
set
(
tab
,
ref
)
ref
.
rootNodes
[
0
].
addEventListener
(
'
click
'
,
()
=>
this
.
focus
(
tab
))
...
...
@@ -436,7 +436,7 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private
detachTabView
(
tab
:
BaseTabComponent
)
{
le
t
ref
=
this
.
viewRefs
.
get
(
tab
)
cons
t
ref
=
this
.
viewRefs
.
get
(
tab
)
this
.
viewRefs
.
delete
(
tab
)
this
.
viewContainer
.
remove
(
this
.
viewContainer
.
indexOf
(
ref
))
}
...
...
@@ -448,8 +448,8 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private
layoutInternal
(
root
:
SplitContainer
,
x
:
number
,
y
:
number
,
w
:
number
,
h
:
number
)
{
le
t
size
=
(
root
.
orientation
===
'
v
'
)
?
h
:
w
le
t
sizes
=
root
.
ratios
.
map
(
x
=>
x
*
size
)
cons
t
size
=
(
root
.
orientation
===
'
v
'
)
?
h
:
w
cons
t
sizes
=
root
.
ratios
.
map
(
x
=>
x
*
size
)
root
.
x
=
x
root
.
y
=
y
...
...
@@ -458,14 +458,14 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
let
offset
=
0
root
.
children
.
forEach
((
child
,
i
)
=>
{
le
t
childX
=
(
root
.
orientation
===
'
v
'
)
?
x
:
(
x
+
offset
)
le
t
childY
=
(
root
.
orientation
===
'
v
'
)
?
(
y
+
offset
)
:
y
le
t
childW
=
(
root
.
orientation
===
'
v
'
)
?
w
:
sizes
[
i
]
le
t
childH
=
(
root
.
orientation
===
'
v
'
)
?
sizes
[
i
]
:
h
cons
t
childX
=
(
root
.
orientation
===
'
v
'
)
?
x
:
(
x
+
offset
)
cons
t
childY
=
(
root
.
orientation
===
'
v
'
)
?
(
y
+
offset
)
:
y
cons
t
childW
=
(
root
.
orientation
===
'
v
'
)
?
w
:
sizes
[
i
]
cons
t
childH
=
(
root
.
orientation
===
'
v
'
)
?
sizes
[
i
]
:
h
if
(
child
instanceof
SplitContainer
)
{
this
.
layoutInternal
(
child
,
childX
,
childY
,
childW
,
childH
)
}
else
{
le
t
element
=
this
.
viewRefs
.
get
(
child
).
rootNodes
[
0
]
cons
t
element
=
this
.
viewRefs
.
get
(
child
).
rootNodes
[
0
]
element
.
style
.
position
=
'
absolute
'
element
.
style
.
left
=
`
${
childX
}
%`
element
.
style
.
top
=
`
${
childY
}
%`
...
...
@@ -486,19 +486,19 @@ export class SplitTabComponent extends BaseTabComponent implements OnInit, OnDes
}
private
async
recoverContainer
(
root
:
SplitContainer
,
state
:
any
)
{
le
t
children
:
(
SplitContainer
|
BaseTabComponent
)[]
=
[]
cons
t
children
:
(
SplitContainer
|
BaseTabComponent
)[]
=
[]
root
.
orientation
=
state
.
orientation
root
.
ratios
=
state
.
ratios
root
.
children
=
children
for
(
le
t
childState
of
state
.
children
)
{
for
(
cons
t
childState
of
state
.
children
)
{
if
(
childState
.
type
===
'
app:split-tab
'
)
{
le
t
child
=
new
SplitContainer
()
cons
t
child
=
new
SplitContainer
()
await
this
.
recoverContainer
(
child
,
childState
)
children
.
push
(
child
)
}
else
{
le
t
recovered
=
await
this
.
tabRecovery
.
recoverTab
(
childState
)
cons
t
recovered
=
await
this
.
tabRecovery
.
recoverTab
(
childState
)
if
(
recovered
)
{
le
t
tab
=
this
.
tabsService
.
create
(
recovered
.
type
,
recovered
.
options
)
cons
t
tab
=
this
.
tabsService
.
create
(
recovered
.
type
,
recovered
.
options
)
children
.
push
(
tab
)
this
.
attachTabView
(
tab
)
}
else
{
...
...
terminus-core/src/components/splitTabSpanner.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -25,13 +25,13 @@ export class SplitTabSpannerComponent {
ngAfterViewInit
()
{
this
.
element
.
nativeElement
.
addEventListener
(
'
mousedown
'
,
e
=>
{
this
.
isActive
=
true
le
t
start
=
this
.
isVertical
?
e
.
pageY
:
e
.
pageX
cons
t
start
=
this
.
isVertical
?
e
.
pageY
:
e
.
pageX
let
current
=
start
le
t
oldPosition
=
this
.
isVertical
?
this
.
element
.
nativeElement
.
offsetTop
:
this
.
element
.
nativeElement
.
offsetLeft
cons
t
oldPosition
=
this
.
isVertical
?
this
.
element
.
nativeElement
.
offsetTop
:
this
.
element
.
nativeElement
.
offsetLeft
const
dragHandler
=
e
=>
{
current
=
this
.
isVertical
?
e
.
pageY
:
e
.
pageX
le
t
newPosition
=
oldPosition
+
(
current
-
start
)
cons
t
newPosition
=
oldPosition
+
(
current
-
start
)
if
(
this
.
isVertical
)
{
this
.
element
.
nativeElement
.
style
.
top
=
`
${
newPosition
-
this
.
marginOffset
}
px`
}
else
{
...
...
terminus-core/src/components/tabHeader.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -52,7 +52,7 @@ export class TabHeaderComponent {
}
showRenameTabModal
():
void
{
le
t
modal
=
this
.
ngbModal
.
open
(
RenameTabModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
RenameTabModalComponent
)
modal
.
componentInstance
.
value
=
this
.
tab
.
customTitle
||
this
.
tab
.
title
modal
.
result
.
then
(
result
=>
{
this
.
tab
.
setTitle
(
result
)
...
...
@@ -62,7 +62,7 @@ export class TabHeaderComponent {
async
buildContextMenu
():
Promise
<
Electron
.
MenuItemConstructorOptions
[]
>
{
let
items
:
Electron
.
MenuItemConstructorOptions
[]
=
[]
for
(
le
t
section
of
await
Promise
.
all
(
this
.
contextMenuProviders
.
map
(
x
=>
x
.
getItems
(
this
.
tab
,
this
))))
{
for
(
cons
t
section
of
await
Promise
.
all
(
this
.
contextMenuProviders
.
map
(
x
=>
x
.
getItems
(
this
.
tab
,
this
))))
{
items
.
push
({
type
:
'
separator
'
})
items
=
items
.
concat
(
section
)
}
...
...
terminus-core/src/services/app.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -68,7 +68,7 @@ export class AppService {
private
tabsService
:
TabsService
,
)
{
this
.
tabRecovery
.
recoverTabs
().
then
(
tabs
=>
{
for
(
le
t
tab
of
tabs
)
{
for
(
cons
t
tab
of
tabs
)
{
this
.
openNewTabRaw
(
tab
.
type
,
tab
.
options
)
}
...
...
@@ -98,7 +98,7 @@ export class AppService {
})
tab
.
destroyed$
.
subscribe
(()
=>
{
le
t
newIndex
=
Math
.
max
(
0
,
this
.
tabs
.
indexOf
(
tab
)
-
1
)
cons
t
newIndex
=
Math
.
max
(
0
,
this
.
tabs
.
indexOf
(
tab
)
-
1
)
this
.
tabs
=
this
.
tabs
.
filter
((
x
)
=>
x
!==
tab
)
if
(
tab
===
this
.
_activeTab
)
{
this
.
selectTab
(
this
.
tabs
[
newIndex
])
...
...
@@ -113,7 +113,7 @@ export class AppService {
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTabRaw
(
type
:
TabComponentType
,
inputs
?:
any
):
BaseTabComponent
{
le
t
tab
=
this
.
tabsService
.
create
(
type
,
inputs
)
cons
t
tab
=
this
.
tabsService
.
create
(
type
,
inputs
)
this
.
addTabRaw
(
tab
)
return
tab
}
...
...
@@ -123,8 +123,8 @@ export class AppService {
* @param inputs Properties to be assigned on the new tab component instance
*/
openNewTab
(
type
:
TabComponentType
,
inputs
?:
any
):
BaseTabComponent
{
le
t
splitTab
=
this
.
tabsService
.
create
(
SplitTabComponent
)
as
SplitTabComponent
le
t
tab
=
this
.
tabsService
.
create
(
type
,
inputs
)
cons
t
splitTab
=
this
.
tabsService
.
create
(
SplitTabComponent
)
as
SplitTabComponent
cons
t
tab
=
this
.
tabsService
.
create
(
type
,
inputs
)
splitTab
.
addTab
(
tab
,
null
,
'
r
'
)
this
.
addTabRaw
(
splitTab
)
return
tab
...
...
@@ -164,7 +164,7 @@ export class AppService {
nextTab
()
{
if
(
this
.
tabs
.
length
>
1
)
{
le
t
tabIndex
=
this
.
tabs
.
indexOf
(
this
.
_activeTab
)
cons
t
tabIndex
=
this
.
tabs
.
indexOf
(
this
.
_activeTab
)
if
(
tabIndex
<
this
.
tabs
.
length
-
1
)
{
this
.
selectTab
(
this
.
tabs
[
tabIndex
+
1
])
}
else
if
(
this
.
config
.
store
.
appearance
.
cycleTabs
)
{
...
...
@@ -175,7 +175,7 @@ export class AppService {
previousTab
()
{
if
(
this
.
tabs
.
length
>
1
)
{
le
t
tabIndex
=
this
.
tabs
.
indexOf
(
this
.
_activeTab
)
cons
t
tabIndex
=
this
.
tabs
.
indexOf
(
this
.
_activeTab
)
if
(
tabIndex
>
0
)
{
this
.
selectTab
(
this
.
tabs
[
tabIndex
-
1
])
}
else
if
(
this
.
config
.
store
.
appearance
.
cycleTabs
)
{
...
...
@@ -200,19 +200,19 @@ export class AppService {
}
async
duplicateTab
(
tab
:
BaseTabComponent
)
{
le
t
dup
=
await
this
.
tabsService
.
duplicate
(
tab
)
cons
t
dup
=
await
this
.
tabsService
.
duplicate
(
tab
)
if
(
dup
)
{
this
.
addTabRaw
(
dup
)
}
}
async
closeAllTabs
()
{
for
(
le
t
tab
of
this
.
tabs
)
{
for
(
cons
t
tab
of
this
.
tabs
)
{
if
(
!
await
tab
.
canClose
())
{
return
}
}
for
(
le
t
tab
of
this
.
tabs
)
{
for
(
cons
t
tab
of
this
.
tabs
)
{
tab
.
destroy
()
}
}
...
...
@@ -230,7 +230,7 @@ export class AppService {
*/
observeTabCompletion
(
tab
:
BaseTabComponent
):
Observable
<
void
>
{
if
(
!
this
.
completionObservers
.
has
(
tab
))
{
le
t
observer
=
new
CompletionObserver
(
tab
)
cons
t
observer
=
new
CompletionObserver
(
tab
)
observer
.
destroyed$
.
subscribe
(()
=>
{
this
.
stopObservingTabCompletion
(
tab
)
})
...
...
terminus-core/src/services/config.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -21,12 +21,12 @@ function isNonStructuralObjectMember (v) {
/** @hidden */
export
class
ConfigProxy
{
constructor
(
real
:
any
,
defaults
:
any
)
{
for
(
le
t
key
in
defaults
)
{
for
(
cons
t
key
in
defaults
)
{
if
(
isStructuralMember
(
defaults
[
key
]))
{
if
(
!
real
[
key
])
{
real
[
key
]
=
{}
}
le
t
proxy
=
new
ConfigProxy
(
real
[
key
],
defaults
[
key
])
cons
t
proxy
=
new
ConfigProxy
(
real
[
key
],
defaults
[
key
])
Object
.
defineProperty
(
this
,
key
,
...
...
@@ -177,9 +177,9 @@ export class ConfigService {
enabledServices
<
T
>
(
services
:
T
[]):
T
[]
{
if
(
!
this
.
servicesCache
)
{
this
.
servicesCache
=
{}
le
t
ngModule
=
window
[
'
rootModule
'
].
ngInjectorDef
for
(
le
t
imp
of
ngModule
.
imports
)
{
le
t
module
=
(
imp
[
'
ngModule
'
]
||
imp
)
cons
t
ngModule
=
window
[
'
rootModule
'
].
ngInjectorDef
for
(
cons
t
imp
of
ngModule
.
imports
)
{
cons
t
module
=
(
imp
[
'
ngModule
'
]
||
imp
)
if
(
module
.
ngInjectorDef
&&
module
.
ngInjectorDef
.
providers
)
{
this
.
servicesCache
[
module
[
'
pluginName
'
]]
=
module
.
ngInjectorDef
.
providers
.
map
(
provider
=>
{
return
provider
[
'
useClass
'
]
||
provider
...
...
@@ -188,7 +188,7 @@ export class ConfigService {
}
}
return
services
.
filter
(
service
=>
{
for
(
le
t
pluginName
in
this
.
servicesCache
)
{
for
(
cons
t
pluginName
in
this
.
servicesCache
)
{
if
(
this
.
servicesCache
[
pluginName
].
includes
(
service
.
constructor
))
{
return
!
this
.
store
.
pluginBlacklist
.
includes
(
pluginName
)
}
...
...
terminus-core/src/services/docking.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -21,7 +21,7 @@ export class DockingService {
}
dock
()
{
le
t
dockSide
=
this
.
config
.
store
.
appearance
.
dock
cons
t
dockSide
=
this
.
config
.
store
.
appearance
.
dock
if
(
dockSide
===
'
off
'
)
{
this
.
hostApp
.
setAlwaysOnTop
(
false
)
...
...
@@ -34,9 +34,9 @@ export class DockingService {
display
=
this
.
getCurrentScreen
()
}
le
t
newBounds
:
Bounds
=
{
x
:
0
,
y
:
0
,
width
:
0
,
height
:
0
}
le
t
fill
=
this
.
config
.
store
.
appearance
.
dockFill
le
t
[
minWidth
,
minHeight
]
=
this
.
hostApp
.
getWindow
().
getMinimumSize
()
cons
t
newBounds
:
Bounds
=
{
x
:
0
,
y
:
0
,
width
:
0
,
height
:
0
}
cons
t
fill
=
this
.
config
.
store
.
appearance
.
dockFill
cons
t
[
minWidth
,
minHeight
]
=
this
.
hostApp
.
getWindow
().
getMinimumSize
()
if
(
dockSide
===
'
left
'
||
dockSide
===
'
right
'
)
{
newBounds
.
width
=
Math
.
max
(
minWidth
,
Math
.
round
(
fill
*
display
.
bounds
.
width
))
...
...
@@ -80,14 +80,14 @@ export class DockingService {
}
private
repositionWindow
()
{
le
t
[
x
,
y
]
=
this
.
hostApp
.
getWindow
().
getPosition
()
for
(
le
t
screen
of
this
.
electron
.
screen
.
getAllDisplays
())
{
le
t
bounds
=
screen
.
bounds
cons
t
[
x
,
y
]
=
this
.
hostApp
.
getWindow
().
getPosition
()
for
(
cons
t
screen
of
this
.
electron
.
screen
.
getAllDisplays
())
{
cons
t
bounds
=
screen
.
bounds
if
(
x
>=
bounds
.
x
&&
x
<=
bounds
.
x
+
bounds
.
width
&&
y
>=
bounds
.
y
&&
y
<=
bounds
.
y
+
bounds
.
height
)
{
return
}
}
le
t
screen
=
this
.
electron
.
screen
.
getPrimaryDisplay
()
cons
t
screen
=
this
.
electron
.
screen
.
getPrimaryDisplay
()
this
.
hostApp
.
getWindow
().
setPosition
(
screen
.
bounds
.
x
,
screen
.
bounds
.
y
)
}
}
terminus-core/src/services/homeBase.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -29,12 +29,12 @@ export class HomeBaseService {
reportBug
()
{
let
body
=
`Version:
${
this
.
appVersion
}
\n`
body
+=
`Platform:
${
os
.
platform
()}
${
os
.
release
()}
\n`
le
t
label
=
{
cons
t
label
=
{
darwin
:
'
OS: macOS
'
,
windows
:
'
OS: Windows
'
,
linux
:
'
OS: Linux
'
,
}[
os
.
platform
()]
le
t
plugins
=
(
window
as
any
).
installedPlugins
.
filter
(
x
=>
!
x
.
isBuiltin
).
map
(
x
=>
x
.
name
)
cons
t
plugins
=
(
window
as
any
).
installedPlugins
.
filter
(
x
=>
!
x
.
isBuiltin
).
map
(
x
=>
x
.
name
)
body
+=
`Plugins:
${
plugins
.
join
(
'
,
'
)
||
'
none
'
}
\n\n`
this
.
electron
.
shell
.
openExternal
(
`https://github.com/eugeny/terminus/issues/new?body=
${
encodeURIComponent
(
body
)}
&labels=
${
label
}
`
)
}
...
...
terminus-core/src/services/hostApp.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -170,7 +170,7 @@ export class HostAppService {
}
toggleFullscreen
()
{
le
t
window
=
this
.
getWindow
()
cons
t
window
=
this
.
getWindow
()
window
.
setFullScreen
(
!
this
.
isFullScreen
)
}
...
...
terminus-core/src/services/hotkeys.service.ts
浏览文件 @
a5ecdeb5
import
{
Injectable
,
Inject
,
NgZone
,
EventEmitter
}
from
'
@angular/core
'
import
{
IHotkeyDescription
,
HotkeyProvider
}
from
'
../api/hotkeyProvider
'
import
{
NativeKeyEvent
,
stringifyKeySequence
}
from
'
./hotkeys.util
'
import
{
stringifyKeySequence
}
from
'
./hotkeys.util
'
import
{
ConfigService
}
from
'
../services/config.service
'
import
{
ElectronService
}
from
'
../services/electron.service
'
...
...
@@ -13,13 +13,13 @@ export interface PartialHotkeyMatch {
const
KEY_TIMEOUT
=
2000
interface
EventBufferEntry
{
event
:
NativeKey
Event
event
:
Keyboard
Event
time
:
number
}
@
Injectable
({
providedIn
:
'
root
'
})
export
class
HotkeysService
{
key
=
new
EventEmitter
<
NativeKey
Event
>
()
key
=
new
EventEmitter
<
Keyboard
Event
>
()
matchedHotkey
=
new
EventEmitter
<
string
>
()
globalHotkey
=
new
EventEmitter
()
private
currentKeystrokes
:
EventBufferEntry
[]
=
[]
...
...
@@ -33,9 +33,9 @@ export class HotkeysService {
private
config
:
ConfigService
,
@
Inject
(
HotkeyProvider
)
private
hotkeyProviders
:
HotkeyProvider
[],
)
{
le
t
events
=
[
'
keydown
'
,
'
keyup
'
]
events
.
forEach
(
(
event
)
=>
{
document
.
addEventListener
(
event
,
(
nativeEvent
)
=>
{
cons
t
events
=
[
'
keydown
'
,
'
keyup
'
]
events
.
forEach
(
event
=>
{
document
.
addEventListener
(
event
,
(
nativeEvent
:
KeyboardEvent
)
=>
{
if
(
document
.
querySelectorAll
(
'
input:focus
'
).
length
===
0
)
{
this
.
pushKeystroke
(
event
,
nativeEvent
)
this
.
processKeystrokes
()
...
...
@@ -58,8 +58,8 @@ export class HotkeysService {
* @param name DOM event name
* @param nativeEvent event object
*/
pushKeystroke
(
name
,
native
Event
)
{
nativeEvent
.
event
=
name
pushKeystroke
(
name
:
string
,
nativeEvent
:
Keyboard
Event
)
{
(
nativeEvent
as
any
)
.
event
=
name
this
.
currentKeystrokes
.
push
({
event
:
nativeEvent
,
time
:
performance
.
now
()
})
}
...
...
@@ -69,7 +69,7 @@ export class HotkeysService {
processKeystrokes
()
{
if
(
this
.
isEnabled
())
{
this
.
zone
.
run
(()
=>
{
le
t
matched
=
this
.
getCurrentFullyMatchedHotkey
()
cons
t
matched
=
this
.
getCurrentFullyMatchedHotkey
()
if
(
matched
)
{
console
.
log
(
'
Matched hotkey
'
,
matched
)
this
.
matchedHotkey
.
emit
(
matched
)
...
...
@@ -79,7 +79,7 @@ export class HotkeysService {
}
}
emitKeyEvent
(
nativeEvent
)
{
emitKeyEvent
(
nativeEvent
:
KeyboardEvent
)
{
this
.
zone
.
run
(()
=>
{
this
.
key
.
emit
(
nativeEvent
)
})
...
...
@@ -100,7 +100,7 @@ export class HotkeysService {
if
(
typeof
value
===
'
string
'
)
{
value
=
[
value
]
}
value
.
forEach
(
item
=>
{
value
.
forEach
(
(
item
:
string
|
string
[])
=>
{
item
=
(
typeof
item
===
'
string
'
)
?
[
item
]
:
item
try
{
...
...
@@ -121,13 +121,13 @@ export class HotkeysService {
return
this
.
getHotkeysConfigRecursive
(
this
.
config
.
store
.
hotkeys
)
}
private
getHotkeysConfigRecursive
(
branch
)
{
le
t
keys
=
{}
for
(
le
t
key
in
branch
)
{
private
getHotkeysConfigRecursive
(
branch
:
any
)
{
cons
t
keys
=
{}
for
(
cons
t
key
in
branch
)
{
let
value
=
branch
[
key
]
if
(
value
instanceof
Object
&&
!
(
value
instanceof
Array
))
{
le
t
subkeys
=
this
.
getHotkeysConfigRecursive
(
value
)
for
(
le
t
subkey
in
subkeys
)
{
cons
t
subkeys
=
this
.
getHotkeysConfigRecursive
(
value
)
for
(
cons
t
subkey
in
subkeys
)
{
keys
[
key
+
'
.
'
+
subkey
]
=
subkeys
[
subkey
]
}
}
else
{
...
...
@@ -135,7 +135,7 @@ export class HotkeysService {
value
=
[
value
]
}
if
(
value
)
{
value
=
value
.
map
(
item
=>
(
typeof
item
===
'
string
'
)
?
[
item
]
:
item
)
value
=
value
.
map
(
(
item
:
string
|
string
[])
=>
(
typeof
item
===
'
string
'
)
?
[
item
]
:
item
)
keys
[
key
]
=
value
}
}
...
...
@@ -144,15 +144,15 @@ export class HotkeysService {
}
private
getCurrentFullyMatchedHotkey
():
string
{
le
t
currentStrokes
=
this
.
getCurrentKeystrokes
()
le
t
config
=
this
.
getHotkeysConfig
()
for
(
le
t
id
in
config
)
{
for
(
le
t
sequence
of
config
[
id
])
{
cons
t
currentStrokes
=
this
.
getCurrentKeystrokes
()
cons
t
config
=
this
.
getHotkeysConfig
()
for
(
cons
t
id
in
config
)
{
for
(
cons
t
sequence
of
config
[
id
])
{
if
(
currentStrokes
.
length
<
sequence
.
length
)
{
continue
}
if
(
sequence
.
every
(
(
x
,
index
)
=>
(
x
:
string
,
index
:
number
)
=>
x
.
toLowerCase
()
===
currentStrokes
[
currentStrokes
.
length
-
sequence
.
length
+
index
].
toLowerCase
()
))
{
...
...
@@ -164,14 +164,14 @@ export class HotkeysService {
}
getCurrentPartiallyMatchedHotkeys
():
PartialHotkeyMatch
[]
{
le
t
currentStrokes
=
this
.
getCurrentKeystrokes
()
le
t
config
=
this
.
getHotkeysConfig
()
le
t
result
=
[]
for
(
le
t
id
in
config
)
{
for
(
le
t
sequence
of
config
[
id
])
{
cons
t
currentStrokes
=
this
.
getCurrentKeystrokes
()
cons
t
config
=
this
.
getHotkeysConfig
()
cons
t
result
=
[]
for
(
cons
t
id
in
config
)
{
for
(
cons
t
sequence
of
config
[
id
])
{
for
(
let
matchLength
=
Math
.
min
(
currentStrokes
.
length
,
sequence
.
length
);
matchLength
>
0
;
matchLength
--
)
{
if
(
sequence
.
slice
(
0
,
matchLength
).
every
(
(
x
,
index
)
=>
(
x
:
string
,
index
:
number
)
=>
x
.
toLowerCase
()
===
currentStrokes
[
currentStrokes
.
length
-
matchLength
+
index
].
toLowerCase
()
))
{
...
...
terminus-core/src/services/hotkeys.util.ts
浏览文件 @
a5ecdeb5
...
...
@@ -10,24 +10,14 @@ export const altKeyName = {
linux
:
'
Alt
'
,
}[
process
.
platform
]
export
interface
NativeKeyEvent
{
event
?:
string
altKey
:
boolean
ctrlKey
:
boolean
metaKey
:
boolean
shiftKey
:
boolean
key
:
string
keyCode
:
string
}
export
function
stringifyKeySequence
(
events
:
NativeKeyEvent
[]):
string
[]
{
let
items
:
string
[]
=
[]
export
function
stringifyKeySequence
(
events
:
KeyboardEvent
[]):
string
[]
{
const
items
:
string
[]
=
[]
events
=
events
.
slice
()
while
(
events
.
length
>
0
)
{
le
t
event
=
events
.
shift
()
if
(
event
.
event
===
'
keydown
'
)
{
le
t
itemKeys
:
string
[]
=
[]
cons
t
event
=
events
.
shift
()
if
(
(
event
as
any
)
.
event
===
'
keydown
'
)
{
cons
t
itemKeys
:
string
[]
=
[]
if
(
event
.
ctrlKey
)
{
itemKeys
.
push
(
'
Ctrl
'
)
}
...
...
@@ -46,7 +36,7 @@ export function stringifyKeySequence (events: NativeKeyEvent[]): string[] {
continue
}
let
key
=
(
event
as
any
)
.
code
let
key
=
event
.
code
key
=
key
.
replace
(
'
Key
'
,
''
)
key
=
key
.
replace
(
'
Arrow
'
,
''
)
key
=
key
.
replace
(
'
Digit
'
,
''
)
...
...
terminus-core/src/services/shellIntegration.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -61,11 +61,11 @@ export class ShellIntegrationService {
async
install
()
{
const
exe
=
process
.
env
.
PORTABLE_EXECUTABLE_FILE
||
this
.
electron
.
app
.
getPath
(
'
exe
'
)
if
(
this
.
hostApp
.
platform
===
Platform
.
macOS
)
{
for
(
le
t
wf
of
this
.
automatorWorkflows
)
{
for
(
cons
t
wf
of
this
.
automatorWorkflows
)
{
await
exec
(
`cp -r "
${
this
.
automatorWorkflowsLocation
}
/
${
wf
}
" "
${
this
.
automatorWorkflowsDestination
}
"`
)
}
}
else
if
(
this
.
hostApp
.
platform
===
Platform
.
Windows
)
{
for
(
le
t
registryKey
of
this
.
registryKeys
)
{
for
(
cons
t
registryKey
of
this
.
registryKeys
)
{
wnr
.
createRegistryKey
(
wnr
.
HK
.
CU
,
registryKey
.
path
)
wnr
.
createRegistryKey
(
wnr
.
HK
.
CU
,
registryKey
.
path
+
'
\\
command
'
)
wnr
.
setRegistryValue
(
wnr
.
HK
.
CU
,
registryKey
.
path
,
'
Icon
'
,
wnr
.
REG
.
SZ
,
exe
)
...
...
@@ -76,11 +76,11 @@ export class ShellIntegrationService {
async
remove
()
{
if
(
this
.
hostApp
.
platform
===
Platform
.
macOS
)
{
for
(
le
t
wf
of
this
.
automatorWorkflows
)
{
for
(
cons
t
wf
of
this
.
automatorWorkflows
)
{
await
exec
(
`rm -rf "
${
this
.
automatorWorkflowsDestination
}
/
${
wf
}
"`
)
}
}
else
if
(
this
.
hostApp
.
platform
===
Platform
.
Windows
)
{
for
(
le
t
registryKey
of
this
.
registryKeys
)
{
for
(
cons
t
registryKey
of
this
.
registryKeys
)
{
wnr
.
deleteRegistryKey
(
wnr
.
HK
.
CU
,
registryKey
.
path
)
}
}
...
...
terminus-core/src/services/tabRecovery.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -28,9 +28,9 @@ export class TabRecoveryService {
}
async
recoverTab
(
token
:
any
):
Promise
<
RecoveredTab
>
{
for
(
le
t
provider
of
this
.
config
.
enabledServices
(
this
.
tabRecoveryProviders
))
{
for
(
cons
t
provider
of
this
.
config
.
enabledServices
(
this
.
tabRecoveryProviders
))
{
try
{
le
t
tab
=
await
provider
.
recover
(
token
)
cons
t
tab
=
await
provider
.
recover
(
token
)
if
(
tab
)
{
return
tab
}
...
...
@@ -43,9 +43,9 @@ export class TabRecoveryService {
async
recoverTabs
():
Promise
<
RecoveredTab
[]
>
{
if
(
window
.
localStorage
.
tabsRecovery
)
{
le
t
tabs
:
RecoveredTab
[]
=
[]
for
(
le
t
token
of
JSON
.
parse
(
window
.
localStorage
.
tabsRecovery
))
{
le
t
tab
=
await
this
.
recoverTab
(
token
)
cons
t
tabs
:
RecoveredTab
[]
=
[]
for
(
cons
t
token
of
JSON
.
parse
(
window
.
localStorage
.
tabsRecovery
))
{
cons
t
tab
=
await
this
.
recoverTab
(
token
)
if
(
tab
)
{
tabs
.
push
(
tab
)
}
...
...
terminus-core/src/services/tabs.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -17,9 +17,9 @@ export class TabsService {
* Instantiates a tab component and assigns given inputs
*/
create
(
type
:
TabComponentType
,
inputs
?:
any
):
BaseTabComponent
{
le
t
componentFactory
=
this
.
componentFactoryResolver
.
resolveComponentFactory
(
type
)
le
t
componentRef
=
componentFactory
.
create
(
this
.
injector
)
le
t
tab
=
componentRef
.
instance
cons
t
componentFactory
=
this
.
componentFactoryResolver
.
resolveComponentFactory
(
type
)
cons
t
componentRef
=
componentFactory
.
create
(
this
.
injector
)
cons
t
tab
=
componentRef
.
instance
tab
.
hostView
=
componentRef
.
hostView
Object
.
assign
(
tab
,
inputs
||
{})
return
tab
...
...
@@ -29,11 +29,11 @@ export class TabsService {
* Duplicates an existing tab instance (using the tab recovery system)
*/
async
duplicate
(
tab
:
BaseTabComponent
):
Promise
<
BaseTabComponent
>
{
le
t
token
=
await
tab
.
getRecoveryToken
()
cons
t
token
=
await
tab
.
getRecoveryToken
()
if
(
!
token
)
{
return
null
}
le
t
dup
=
await
this
.
tabRecovery
.
recoverTab
(
token
)
cons
t
dup
=
await
this
.
tabRecovery
.
recoverTab
(
token
)
if
(
dup
)
{
return
this
.
create
(
dup
.
type
,
dup
.
options
)
}
...
...
terminus-core/src/services/touchbar.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -28,19 +28,19 @@ export class TouchbarService {
app
.
tabsChanged$
.
subscribe
(()
=>
this
.
updateTabs
())
app
.
activeTabChange$
.
subscribe
(()
=>
this
.
updateTabs
())
le
t
activityIconPath
=
`
${
electron
.
app
.
getAppPath
()}
/assets/activity.png`
le
t
activityIcon
=
this
.
electron
.
nativeImage
.
createFromPath
(
activityIconPath
)
cons
t
activityIconPath
=
`
${
electron
.
app
.
getAppPath
()}
/assets/activity.png`
cons
t
activityIcon
=
this
.
electron
.
nativeImage
.
createFromPath
(
activityIconPath
)
app
.
tabOpened$
.
subscribe
(
tab
=>
{
tab
.
titleChange$
.
subscribe
(
title
=>
{
le
t
segment
=
this
.
tabSegments
[
app
.
tabs
.
indexOf
(
tab
)]
cons
t
segment
=
this
.
tabSegments
[
app
.
tabs
.
indexOf
(
tab
)]
if
(
segment
)
{
segment
.
label
=
this
.
shortenTitle
(
title
)
this
.
tabsSegmentedControl
.
segments
=
this
.
tabSegments
}
})
tab
.
activity$
.
subscribe
(
hasActivity
=>
{
le
t
showIcon
=
this
.
app
.
activeTab
!==
tab
&&
hasActivity
le
t
segment
=
this
.
tabSegments
[
app
.
tabs
.
indexOf
(
tab
)]
cons
t
showIcon
=
this
.
app
.
activeTab
!==
tab
&&
hasActivity
cons
t
segment
=
this
.
tabSegments
[
app
.
tabs
.
indexOf
(
tab
)]
if
(
segment
)
{
segment
.
icon
=
showIcon
?
activityIcon
:
null
}
...
...
@@ -87,7 +87,7 @@ export class TouchbarService {
})
})
le
t
touchBar
=
new
this
.
electron
.
TouchBar
({
cons
t
touchBar
=
new
this
.
electron
.
TouchBar
({
items
:
[
this
.
tabsSegmentedControl
,
new
this
.
electron
.
TouchBar
.
TouchBarSpacer
({
size
:
'
flexible
'
}),
...
...
terminus-core/src/services/updater.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -49,9 +49,9 @@ export class UpdaterService {
async
check
():
Promise
<
boolean
>
{
if
(
!
this
.
electronUpdaterAvailable
)
{
this
.
logger
.
debug
(
'
Checking for updates
'
)
le
t
response
=
await
axios
.
get
(
UPDATES_URL
)
le
t
data
=
response
.
data
le
t
version
=
data
.
tag_name
.
substring
(
1
)
cons
t
response
=
await
axios
.
get
(
UPDATES_URL
)
cons
t
data
=
response
.
data
cons
t
version
=
data
.
tag_name
.
substring
(
1
)
if
(
this
.
electron
.
app
.
getVersion
()
!==
version
)
{
this
.
logger
.
info
(
'
Update available
'
)
this
.
updateURL
=
data
.
html_url
...
...
terminus-core/src/tabContextMenu.ts
浏览文件 @
a5ecdeb5
...
...
@@ -27,7 +27,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label
:
'
Close other tabs
'
,
click
:
()
=>
this
.
zone
.
run
(()
=>
{
for
(
le
t
t
of
this
.
app
.
tabs
.
filter
(
x
=>
x
!==
tab
))
{
for
(
cons
t
t
of
this
.
app
.
tabs
.
filter
(
x
=>
x
!==
tab
))
{
this
.
app
.
closeTab
(
t
,
true
)
}
})
...
...
@@ -35,7 +35,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label
:
'
Close tabs to the right
'
,
click
:
()
=>
this
.
zone
.
run
(()
=>
{
for
(
le
t
t
of
this
.
app
.
tabs
.
slice
(
this
.
app
.
tabs
.
indexOf
(
tab
)
+
1
))
{
for
(
cons
t
t
of
this
.
app
.
tabs
.
slice
(
this
.
app
.
tabs
.
indexOf
(
tab
)
+
1
))
{
this
.
app
.
closeTab
(
t
,
true
)
}
})
...
...
@@ -43,7 +43,7 @@ export class CloseContextMenu extends TabContextMenuItemProvider {
{
label
:
'
Close tabs to the left
'
,
click
:
()
=>
this
.
zone
.
run
(()
=>
{
for
(
le
t
t
of
this
.
app
.
tabs
.
slice
(
0
,
this
.
app
.
tabs
.
indexOf
(
tab
)))
{
for
(
cons
t
t
of
this
.
app
.
tabs
.
slice
(
0
,
this
.
app
.
tabs
.
indexOf
(
tab
)))
{
this
.
app
.
closeTab
(
t
,
true
)
}
})
...
...
@@ -111,7 +111,7 @@ export class TaskCompletionContextMenu extends TabContextMenuItemProvider {
}
async
getItems
(
tab
:
BaseTabComponent
):
Promise
<
Electron
.
MenuItemConstructorOptions
[]
>
{
le
t
process
=
await
tab
.
getCurrentProcess
()
cons
t
process
=
await
tab
.
getCurrentProcess
()
if
(
process
)
{
return
[
{
...
...
terminus-core/tsconfig.json
浏览文件 @
a5ecdeb5
...
...
@@ -2,6 +2,6 @@
"extends"
:
"../tsconfig.json"
,
"exclude"
:
[
"node_modules"
,
"dist"
],
"compilerOptions"
:
{
"baseUrl"
:
"src"
,
"baseUrl"
:
"src"
}
}
terminus-plugin-manager/src/components/pluginsSettingsTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -44,7 +44,7 @@ export class PluginsSettingsTabComponent {
})
)
this
.
availablePlugins$
.
pipe
(
first
()).
subscribe
(
available
=>
{
for
(
le
t
plugin
of
this
.
pluginManager
.
installedPlugins
)
{
for
(
cons
t
plugin
of
this
.
pluginManager
.
installedPlugins
)
{
this
.
knownUpgrades
[
plugin
.
name
]
=
available
.
find
(
x
=>
x
.
name
===
plugin
.
name
&&
semver
.
gt
(
x
.
version
,
plugin
.
version
))
}
})
...
...
terminus-settings/src/buttonProvider.ts
浏览文件 @
a5ecdeb5
...
...
@@ -34,7 +34,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
}
open
():
void
{
le
t
settingsTab
=
this
.
app
.
tabs
.
find
(
tab
=>
tab
instanceof
SettingsTabComponent
)
cons
t
settingsTab
=
this
.
app
.
tabs
.
find
(
tab
=>
tab
instanceof
SettingsTabComponent
)
if
(
settingsTab
)
{
this
.
app
.
selectTab
(
settingsTab
)
}
else
{
...
...
terminus-settings/src/components/settingsTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -124,7 +124,7 @@ export class SettingsTabComponent extends BaseTabComponent {
getHotkey
(
id
:
string
)
{
let
ptr
=
this
.
config
.
store
.
hotkeys
for
(
le
t
token
of
id
.
split
(
/
\.
/g
))
{
for
(
cons
t
token
of
id
.
split
(
/
\.
/g
))
{
ptr
=
ptr
[
token
]
}
return
ptr
...
...
@@ -133,7 +133,7 @@ export class SettingsTabComponent extends BaseTabComponent {
setHotkey
(
id
:
string
,
value
)
{
let
ptr
=
this
.
config
.
store
let
prop
=
'
hotkeys
'
for
(
le
t
token
of
id
.
split
(
/
\.
/g
))
{
for
(
cons
t
token
of
id
.
split
(
/
\.
/g
))
{
ptr
=
ptr
[
prop
]
prop
=
token
}
...
...
terminus-ssh/src/api.ts
浏览文件 @
a5ecdeb5
...
...
@@ -43,16 +43,16 @@ export class SSHSession extends BaseSession {
this
.
open
=
true
this
.
shell
.
on
(
'
data
'
,
data
=>
{
le
t
dataString
=
data
.
toString
()
cons
t
dataString
=
data
.
toString
()
this
.
emitOutput
(
dataString
)
if
(
this
.
scripts
)
{
let
found
=
false
for
(
le
t
script
of
this
.
scripts
)
{
for
(
cons
t
script
of
this
.
scripts
)
{
let
match
=
false
let
cmd
=
''
if
(
script
.
isRegex
)
{
le
t
re
=
new
RegExp
(
script
.
expect
,
'
g
'
)
cons
t
re
=
new
RegExp
(
script
.
expect
,
'
g
'
)
if
(
dataString
.
match
(
re
))
{
cmd
=
dataString
.
replace
(
re
,
script
.
send
)
match
=
true
...
...
@@ -128,7 +128,7 @@ export class SSHSession extends BaseSession {
private
executeUnconditionalScripts
()
{
if
(
this
.
scripts
)
{
for
(
le
t
script
of
this
.
scripts
)
{
for
(
cons
t
script
of
this
.
scripts
)
{
if
(
!
script
.
expect
)
{
console
.
log
(
'
Executing script:
'
,
script
.
send
)
this
.
shell
.
write
(
script
.
send
+
'
\n
'
)
...
...
terminus-ssh/src/components/editConnectionModal.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -26,7 +26,7 @@ export class EditConnectionModalComponent {
)
{
this
.
newScript
=
{
expect
:
''
,
send
:
''
}
for
(
le
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
for
(
cons
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
this
.
supportedAlgorithms
[
k
]
=
ALGORITHMS
[{
[
SSHAlgorithmType
.
KEX
]:
'
SUPPORTED_KEX
'
,
[
SSHAlgorithmType
.
HOSTKEY
]:
'
SUPPORTED_SERVER_HOST_KEY
'
,
...
...
@@ -45,13 +45,13 @@ export class EditConnectionModalComponent {
async
ngOnInit
()
{
this
.
hasSavedPassword
=
!!
(
await
this
.
passwordStorage
.
loadPassword
(
this
.
connection
))
this
.
connection
.
algorithms
=
this
.
connection
.
algorithms
||
{}
for
(
le
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
for
(
cons
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
if
(
!
this
.
connection
.
algorithms
[
k
])
{
this
.
connection
.
algorithms
[
k
]
=
this
.
defaultAlgorithms
[
k
]
}
this
.
algorithms
[
k
]
=
{}
for
(
le
t
alg
of
this
.
connection
.
algorithms
[
k
])
{
for
(
cons
t
alg
of
this
.
connection
.
algorithms
[
k
])
{
this
.
algorithms
[
k
][
alg
]
=
true
}
}
...
...
@@ -63,7 +63,7 @@ export class EditConnectionModalComponent {
}
selectPrivateKey
()
{
le
t
path
=
this
.
electron
.
dialog
.
showOpenDialog
(
cons
t
path
=
this
.
electron
.
dialog
.
showOpenDialog
(
this
.
hostApp
.
getWindow
(),
{
title
:
'
Select private key
'
,
...
...
@@ -75,7 +75,7 @@ export class EditConnectionModalComponent {
}
save
()
{
for
(
le
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
for
(
cons
t
k
of
Object
.
values
(
SSHAlgorithmType
))
{
this
.
connection
.
algorithms
[
k
]
=
Object
.
entries
(
this
.
algorithms
[
k
])
.
filter
(([
k
,
v
])
=>
!!
v
)
.
map
(([
k
,
v
])
=>
k
)
...
...
@@ -88,7 +88,7 @@ export class EditConnectionModalComponent {
}
moveScriptUp
(
script
:
LoginScript
)
{
le
t
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
cons
t
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
if
(
index
>
0
)
{
this
.
connection
.
scripts
.
splice
(
index
,
1
)
this
.
connection
.
scripts
.
splice
(
index
-
1
,
0
,
script
)
...
...
@@ -96,7 +96,7 @@ export class EditConnectionModalComponent {
}
moveScriptDown
(
script
:
LoginScript
)
{
le
t
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
cons
t
index
=
this
.
connection
.
scripts
.
indexOf
(
script
)
if
(
index
>=
0
&&
index
<
this
.
connection
.
scripts
.
length
-
1
)
{
this
.
connection
.
scripts
.
splice
(
index
,
1
)
this
.
connection
.
scripts
.
splice
(
index
+
1
,
0
,
script
)
...
...
terminus-ssh/src/components/sshModal.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -47,7 +47,7 @@ export class SSHModalComponent {
host
=
host
.
split
(
'
:
'
)[
0
]
}
le
t
connection
:
SSHConnection
=
{
cons
t
connection
:
SSHConnection
=
{
name
:
this
.
quickTarget
,
host
,
user
,
port
}
...
...
@@ -88,7 +88,7 @@ export class SSHModalComponent {
connections
=
connections
.
filter
(
connection
=>
(
connection
.
name
+
connection
.
group
).
toLowerCase
().
includes
(
this
.
quickTarget
))
}
for
(
le
t
connection
of
connections
)
{
for
(
cons
t
connection
of
connections
)
{
connection
.
group
=
connection
.
group
||
null
let
group
=
this
.
childGroups
.
find
(
x
=>
x
.
name
===
connection
.
group
)
if
(
!
group
)
{
...
...
terminus-ssh/src/components/sshSettingsTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -25,14 +25,14 @@ export class SSHSettingsTabComponent {
}
createConnection
()
{
le
t
connection
:
SSHConnection
=
{
cons
t
connection
:
SSHConnection
=
{
name
:
''
,
host
:
''
,
port
:
22
,
user
:
'
root
'
,
}
le
t
modal
=
this
.
ngbModal
.
open
(
EditConnectionModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
EditConnectionModalComponent
)
modal
.
componentInstance
.
connection
=
connection
modal
.
result
.
then
(
result
=>
{
this
.
connections
.
push
(
result
)
...
...
@@ -43,7 +43,7 @@ export class SSHSettingsTabComponent {
}
editConnection
(
connection
:
SSHConnection
)
{
le
t
modal
=
this
.
ngbModal
.
open
(
EditConnectionModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
EditConnectionModalComponent
)
modal
.
componentInstance
.
connection
=
Object
.
assign
({},
connection
)
modal
.
result
.
then
(
result
=>
{
Object
.
assign
(
connection
,
result
)
...
...
@@ -71,12 +71,12 @@ export class SSHSettingsTabComponent {
}
editGroup
(
group
:
ISSHConnectionGroup
)
{
le
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
modal
.
componentInstance
.
prompt
=
'
New group name
'
modal
.
componentInstance
.
value
=
group
.
name
modal
.
result
.
then
(
result
=>
{
if
(
result
)
{
for
(
le
t
connection
of
this
.
connections
.
filter
(
x
=>
x
.
group
===
group
.
name
))
{
for
(
cons
t
connection
of
this
.
connections
.
filter
(
x
=>
x
.
group
===
group
.
name
))
{
connection
.
group
=
result
}
this
.
config
.
store
.
ssh
.
connections
=
this
.
connections
...
...
@@ -96,7 +96,7 @@ export class SSHSettingsTabComponent {
defaultId
:
1
,
}
)).
response
===
1
)
{
for
(
le
t
connection
of
this
.
connections
.
filter
(
x
=>
x
.
group
===
group
.
name
))
{
for
(
cons
t
connection
of
this
.
connections
.
filter
(
x
=>
x
.
group
===
group
.
name
))
{
connection
.
group
=
null
}
this
.
config
.
save
()
...
...
@@ -108,7 +108,7 @@ export class SSHSettingsTabComponent {
this
.
connections
=
this
.
config
.
store
.
ssh
.
connections
this
.
childGroups
=
[]
for
(
le
t
connection
of
this
.
connections
)
{
for
(
cons
t
connection
of
this
.
connections
)
{
connection
.
group
=
connection
.
group
||
null
let
group
=
this
.
childGroups
.
find
(
x
=>
x
.
name
===
connection
.
group
)
if
(
!
group
)
{
...
...
terminus-ssh/src/components/sshTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -44,7 +44,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
this
.
session
=
new
SSHSession
(
this
.
connection
)
this
.
attachSessionHandlers
()
this
.
write
(
`Connecting to
${
this
.
connection
.
host
}
`
)
le
t
interval
=
setInterval
(()
=>
this
.
write
(
'
.
'
),
500
)
cons
t
interval
=
setInterval
(()
=>
this
.
write
(
'
.
'
),
500
)
try
{
await
this
.
ssh
.
connectSession
(
this
.
session
,
message
=>
{
this
.
write
(
'
\r\n
'
+
message
)
...
...
terminus-ssh/src/services/ssh.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -55,7 +55,7 @@ export class SSHService {
}
if
(
!
privateKeyPath
)
{
le
t
userKeyPath
=
path
.
join
(
process
.
env
.
HOME
,
'
.ssh
'
,
'
id_rsa
'
)
cons
t
userKeyPath
=
path
.
join
(
process
.
env
.
HOME
,
'
.ssh
'
,
'
id_rsa
'
)
if
(
await
fs
.
exists
(
userKeyPath
))
{
log
(
`Using user's default private key:
${
userKeyPath
}
`
)
privateKeyPath
=
userKeyPath
...
...
@@ -78,7 +78,7 @@ export class SSHService {
encrypted
=
encrypted
||
privateKey
.
includes
(
'
Encryption:
'
)
&&
!
privateKey
.
includes
(
'
Encryption: none
'
)
}
if
(
encrypted
)
{
le
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
log
(
'
Key requires passphrase
'
)
modal
.
componentInstance
.
prompt
=
'
Private key passphrase
'
modal
.
componentInstance
.
password
=
true
...
...
@@ -89,7 +89,7 @@ export class SSHService {
}
}
le
t
ssh
=
new
Client
()
cons
t
ssh
=
new
Client
()
let
connected
=
false
let
savedPassword
:
string
=
null
await
new
Promise
(
async
(
resolve
,
reject
)
=>
{
...
...
@@ -113,9 +113,9 @@ export class SSHService {
ssh
.
on
(
'
keyboard-interactive
'
,
(
name
,
instructions
,
instructionsLang
,
prompts
,
finish
)
=>
this
.
zone
.
run
(
async
()
=>
{
log
(
`Keyboard-interactive auth requested:
${
name
}
`
)
this
.
logger
.
info
(
'
Keyboard-interactive auth:
'
,
name
,
instructions
,
instructionsLang
)
le
t
results
=
[]
for
(
le
t
prompt
of
prompts
)
{
le
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
cons
t
results
=
[]
for
(
cons
t
prompt
of
prompts
)
{
cons
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
modal
.
componentInstance
.
prompt
=
prompt
.
prompt
modal
.
componentInstance
.
password
=
!
prompt
.
echo
results
.
push
(
await
modal
.
result
)
...
...
@@ -133,7 +133,7 @@ export class SSHService {
let
agent
:
string
=
null
if
(
this
.
hostApp
.
platform
===
Platform
.
Windows
)
{
le
t
pageantRunning
=
new
Promise
<
boolean
>
(
resolve
=>
{
cons
t
pageantRunning
=
new
Promise
<
boolean
>
(
resolve
=>
{
windowsProcessTree
.
getProcessList
(
list
=>
{
resolve
(
list
.
some
(
x
=>
x
.
name
===
'
pageant.exe
'
))
},
0
)
...
...
@@ -180,7 +180,7 @@ export class SSHService {
}
if
(
!
keychainPasswordUsed
)
{
le
t
password
=
await
this
.
passwordStorage
.
loadPassword
(
session
.
connection
)
cons
t
password
=
await
this
.
passwordStorage
.
loadPassword
(
session
.
connection
)
if
(
password
)
{
log
(
'
Trying saved password
'
)
keychainPasswordUsed
=
true
...
...
@@ -188,7 +188,7 @@ export class SSHService {
}
}
le
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
PromptModalComponent
)
modal
.
componentInstance
.
prompt
=
`Password for
${
session
.
connection
.
user
}
@
${
session
.
connection
.
host
}
`
modal
.
componentInstance
.
password
=
true
try
{
...
...
@@ -201,7 +201,7 @@ export class SSHService {
})
try
{
le
t
shell
:
any
=
await
new
Promise
<
any
>
((
resolve
,
reject
)
=>
{
cons
t
shell
:
any
=
await
new
Promise
<
any
>
((
resolve
,
reject
)
=>
{
ssh
.
shell
({
term
:
'
xterm-256color
'
},
(
err
,
shell
)
=>
{
if
(
err
)
{
reject
(
err
)
...
...
terminus-terminal/src/api/baseTerminalTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -211,7 +211,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
async
buildContextMenu
():
Promise
<
Electron
.
MenuItemConstructorOptions
[]
>
{
let
items
:
Electron
.
MenuItemConstructorOptions
[]
=
[]
for
(
le
t
section
of
await
Promise
.
all
(
this
.
contextMenuProviders
.
map
(
x
=>
x
.
getItems
(
this
))))
{
for
(
cons
t
section
of
await
Promise
.
all
(
this
.
contextMenuProviders
.
map
(
x
=>
x
.
getItems
(
this
))))
{
items
=
items
.
concat
(
section
)
items
.
push
({
type
:
'
separator
'
})
}
...
...
@@ -220,7 +220,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
}
protected
detachTermContainerHandlers
()
{
for
(
le
t
subscription
of
this
.
termContainerSubscriptions
)
{
for
(
cons
t
subscription
of
this
.
termContainerSubscriptions
)
{
subscription
.
unsubscribe
()
}
this
.
termContainerSubscriptions
=
[]
...
...
@@ -277,7 +277,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
}
}
else
if
(
event
.
altKey
)
{
event
.
preventDefault
()
le
t
delta
=
Math
.
round
(
wheelDeltaY
/
50
)
cons
t
delta
=
Math
.
round
(
wheelDeltaY
/
50
)
this
.
sendInput
(((
delta
>
0
)
?
'
\
u001bOA
'
:
'
\
u001bOB
'
).
repeat
(
Math
.
abs
(
delta
)))
}
}
...
...
@@ -316,9 +316,9 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
* Feeds input into the terminal frontend
*/
write
(
data
:
string
)
{
le
t
percentageMatch
=
/
(
^|
[^\d])(\d
+
(\.\d
+
)?)
%
([^\d]
|$
)
/
.
exec
(
data
)
cons
t
percentageMatch
=
/
(
^|
[^\d])(\d
+
(\.\d
+
)?)
%
([^\d]
|$
)
/
.
exec
(
data
)
if
(
percentageMatch
)
{
le
t
percentage
=
percentageMatch
[
3
]
?
parseFloat
(
percentageMatch
[
2
])
:
parseInt
(
percentageMatch
[
2
])
cons
t
percentage
=
percentageMatch
[
3
]
?
parseFloat
(
percentageMatch
[
2
])
:
parseInt
(
percentageMatch
[
2
])
if
(
percentage
>
0
&&
percentage
<=
100
)
{
this
.
setProgress
(
percentage
)
this
.
logger
.
debug
(
'
Detected progress:
'
,
percentage
)
...
...
terminus-terminal/src/buttonProvider.ts
浏览文件 @
a5ecdeb5
...
...
@@ -18,8 +18,8 @@ export class ButtonProvider extends ToolbarButtonProvider {
super
()
if
(
!
electron
.
remote
.
process
.
env
.
TERMINUS_DEV
)
{
setImmediate
(
async
()
=>
{
le
t
argv
:
string
[]
=
electron
.
remote
.
process
.
argv
for
(
le
t
arg
of
argv
.
slice
(
1
).
concat
([
electron
.
remote
.
process
.
argv0
]))
{
cons
t
argv
:
string
[]
=
electron
.
remote
.
process
.
argv
for
(
cons
t
arg
of
argv
.
slice
(
1
).
concat
([
electron
.
remote
.
process
.
argv0
]))
{
if
(
await
fs
.
exists
(
arg
))
{
if
((
await
fs
.
stat
(
arg
)).
isDirectory
())
{
this
.
terminal
.
openTab
(
null
,
arg
)
...
...
@@ -44,7 +44,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
icon
:
this
.
domSanitizer
.
bypassSecurityTrustHtml
(
require
(
'
./icons/profiles.svg
'
)),
title
:
'
New terminal with profile
'
,
submenu
:
async
()
=>
{
le
t
profiles
=
await
this
.
terminal
.
getProfiles
()
cons
t
profiles
=
await
this
.
terminal
.
getProfiles
()
return
profiles
.
map
(
profile
=>
({
icon
:
profile
.
icon
,
title
:
profile
.
name
,
...
...
terminus-terminal/src/colorSchemes.ts
浏览文件 @
a5ecdeb5
...
...
@@ -8,15 +8,15 @@ import { ITerminalColorScheme } from './api/interfaces'
@
Injectable
()
export
class
HyperColorSchemes
extends
TerminalColorSchemeProvider
{
async
getSchemes
():
Promise
<
ITerminalColorScheme
[]
>
{
le
t
pluginsPath
=
path
.
join
(
process
.
env
.
HOME
,
'
.hyper_plugins
'
,
'
node_modules
'
)
cons
t
pluginsPath
=
path
.
join
(
process
.
env
.
HOME
,
'
.hyper_plugins
'
,
'
node_modules
'
)
if
(
!
(
await
fs
.
exists
(
pluginsPath
)))
return
[]
le
t
plugins
=
await
fs
.
readdir
(
pluginsPath
)
cons
t
plugins
=
await
fs
.
readdir
(
pluginsPath
)
le
t
themes
:
ITerminalColorScheme
[]
=
[]
cons
t
themes
:
ITerminalColorScheme
[]
=
[]
plugins
.
forEach
(
plugin
=>
{
try
{
le
t
module
=
(
global
as
any
).
require
(
path
.
join
(
pluginsPath
,
plugin
))
cons
t
module
=
(
global
as
any
).
require
(
path
.
join
(
pluginsPath
,
plugin
))
if
(
module
.
decorateConfig
)
{
let
config
:
any
try
{
...
...
terminus-terminal/src/components/appearanceSettingsTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -31,7 +31,7 @@ export class AppearanceSettingsTabComponent {
async
ngOnInit
()
{
if
(
this
.
hostApp
.
platform
===
Platform
.
Windows
||
this
.
hostApp
.
platform
===
Platform
.
macOS
)
{
le
t
fonts
=
await
new
Promise
<
any
[]
>
((
resolve
)
=>
fontManager
.
findFonts
({
monospace
:
true
},
resolve
))
cons
t
fonts
=
await
new
Promise
<
any
[]
>
((
resolve
)
=>
fontManager
.
findFonts
({
monospace
:
true
},
resolve
))
this
.
fonts
=
fonts
.
map
(
x
=>
(
x
.
family
+
'
'
+
x
.
style
).
trim
())
this
.
fonts
.
sort
()
}
...
...
terminus-terminal/src/components/colorPicker.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -29,7 +29,7 @@ export class ColorPickerComponent {
if
(
!
this
.
isOpen
)
{
return
}
le
t
windowRef
=
(
this
.
popover
as
any
).
_windowRef
cons
t
windowRef
=
(
this
.
popover
as
any
).
_windowRef
if
(
!
windowRef
)
{
return
}
...
...
terminus-terminal/src/components/environmentEditor.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -22,8 +22,8 @@ export class EnvironmentEditorComponent {
}
getModel
()
{
le
t
model
=
{}
for
(
le
t
pair
of
this
.
vars
)
{
cons
t
model
=
{}
for
(
cons
t
pair
of
this
.
vars
)
{
model
[
pair
.
key
]
=
pair
.
value
}
return
model
...
...
terminus-terminal/src/components/shellSettingsTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -51,8 +51,8 @@ export class ShellSettingsTabComponent {
}
pickWorkingDirectory
()
{
le
t
shell
=
this
.
shells
.
find
(
x
=>
x
.
id
===
this
.
config
.
store
.
terminal
.
shell
)
le
t
paths
=
this
.
electron
.
dialog
.
showOpenDialog
(
cons
t
shell
=
this
.
shells
.
find
(
x
=>
x
.
id
===
this
.
config
.
store
.
terminal
.
shell
)
cons
t
paths
=
this
.
electron
.
dialog
.
showOpenDialog
(
this
.
hostApp
.
getWindow
(),
{
defaultPath
:
shell
.
fsBase
,
...
...
@@ -65,7 +65,7 @@ export class ShellSettingsTabComponent {
}
newProfile
(
shell
:
IShell
)
{
le
t
profile
:
Profile
=
{
cons
t
profile
:
Profile
=
{
name
:
shell
.
name
,
sessionOptions
:
this
.
terminalService
.
optionsFromShell
(
shell
),
}
...
...
@@ -75,7 +75,7 @@ export class ShellSettingsTabComponent {
}
editProfile
(
profile
:
Profile
)
{
le
t
modal
=
this
.
ngbModal
.
open
(
EditProfileModalComponent
)
cons
t
modal
=
this
.
ngbModal
.
open
(
EditProfileModalComponent
)
modal
.
componentInstance
.
profile
=
Object
.
assign
({},
profile
)
modal
.
result
.
then
(
result
=>
{
Object
.
assign
(
profile
,
result
)
...
...
terminus-terminal/src/components/terminalTab.component.ts
浏览文件 @
a5ecdeb5
...
...
@@ -22,7 +22,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
this
.
logger
=
this
.
log
.
create
(
'
terminalTab
'
)
this
.
session
=
new
Session
(
this
.
config
)
le
t
isConPTY
=
isWindowsBuild
(
WIN_BUILD_CONPTY_SUPPORTED
)
&&
this
.
config
.
store
.
terminal
.
useConPTY
cons
t
isConPTY
=
isWindowsBuild
(
WIN_BUILD_CONPTY_SUPPORTED
)
&&
this
.
config
.
store
.
terminal
.
useConPTY
this
.
homeEndSubscription
=
this
.
hotkeys
.
matchedHotkey
.
subscribe
(
hotkey
=>
{
if
(
!
this
.
hasFocus
)
{
...
...
@@ -58,7 +58,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
}
async
getRecoveryToken
():
Promise
<
any
>
{
le
t
cwd
=
this
.
session
?
await
this
.
session
.
getWorkingDirectory
()
:
null
cons
t
cwd
=
this
.
session
?
await
this
.
session
.
getWorkingDirectory
()
:
null
return
{
type
:
'
app:terminal-tab
'
,
sessionOptions
:
{
...
...
@@ -69,7 +69,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
}
async
getCurrentProcess
():
Promise
<
BaseTabProcess
>
{
le
t
children
=
await
this
.
session
.
getChildProcesses
()
cons
t
children
=
await
this
.
session
.
getChildProcesses
()
if
(
!
children
.
length
)
{
return
null
}
...
...
@@ -79,7 +79,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
}
async
canClose
():
Promise
<
boolean
>
{
le
t
children
=
await
this
.
session
.
getChildProcesses
()
cons
t
children
=
await
this
.
session
.
getChildProcesses
()
if
(
children
.
length
===
0
)
{
return
true
}
...
...
terminus-terminal/src/contextMenu.ts
浏览文件 @
a5ecdeb5
...
...
@@ -21,9 +21,9 @@ export class NewTabContextMenu extends TerminalContextMenuItemProvider {
}
async
getItems
(
tab
:
BaseTerminalTabComponent
):
Promise
<
Electron
.
MenuItemConstructorOptions
[]
>
{
le
t
profiles
=
await
this
.
terminalService
.
getProfiles
()
cons
t
profiles
=
await
this
.
terminalService
.
getProfiles
()
le
t
items
:
Electron
.
MenuItemConstructorOptions
[]
=
[
cons
t
items
:
Electron
.
MenuItemConstructorOptions
[]
=
[
{
label
:
'
New terminal
'
,
click
:
()
=>
this
.
zone
.
run
(()
=>
{
...
...
terminus-terminal/src/frontends/frontend.ts
浏览文件 @
a5ecdeb5
...
...
@@ -43,7 +43,7 @@ export abstract class Frontend {
detach
(
host
:
HTMLElement
):
void
{
}
// tslint:disable-line
destroy
():
void
{
for
(
le
t
o
of
[
for
(
cons
t
o
of
[
this
.
ready
,
this
.
title
,
this
.
alternateScreenActive
,
...
...
terminus-terminal/src/frontends/hterm.ts
浏览文件 @
a5ecdeb5
...
...
@@ -46,7 +46,7 @@ hterm.lib.wc.charWidthDisregardAmbiguous = codepoint => {
}
hterm
.
hterm
.
Terminal
.
prototype
.
applyCursorShape
=
function
()
{
le
t
modes
=
[
cons
t
modes
=
[
[
hterm
.
hterm
.
Terminal
.
cursorShape
.
BLOCK
,
true
],
[
this
.
defaultCursorShape
||
hterm
.
hterm
.
Terminal
.
cursorShape
.
BLOCK
,
false
],
[
hterm
.
hterm
.
Terminal
.
cursorShape
.
BLOCK
,
false
],
...
...
@@ -55,7 +55,7 @@ hterm.hterm.Terminal.prototype.applyCursorShape = function () {
[
hterm
.
hterm
.
Terminal
.
cursorShape
.
BEAM
,
true
],
[
hterm
.
hterm
.
Terminal
.
cursorShape
.
BEAM
,
false
],
]
le
t
modeNumber
=
this
.
cursorMode
||
1
cons
t
modeNumber
=
this
.
cursorMode
||
1
if
(
modeNumber
>=
modes
.
length
)
{
console
.
warn
(
'
Unknown cursor style:
'
+
modeNumber
)
return
...
...
@@ -76,14 +76,14 @@ hterm.hterm.VT.CSI[' q'] = function (parseState) {
}
hterm
.
hterm
.
VT
.
OSC
[
'
4
'
]
=
function
(
parseState
)
{
le
t
args
=
parseState
.
args
[
0
].
split
(
'
;
'
)
cons
t
args
=
parseState
.
args
[
0
].
split
(
'
;
'
)
le
t
pairCount
=
args
.
length
/
2
le
t
colorPalette
=
this
.
terminal
.
getTextAttributes
().
colorPalette
le
t
responseArray
=
[]
cons
t
pairCount
=
args
.
length
/
2
cons
t
colorPalette
=
this
.
terminal
.
getTextAttributes
().
colorPalette
cons
t
responseArray
=
[]
for
(
let
pairNumber
=
0
;
pairNumber
<
pairCount
;
++
pairNumber
)
{
le
t
colorIndex
=
parseInt
(
args
[
pairNumber
*
2
])
cons
t
colorIndex
=
parseInt
(
args
[
pairNumber
*
2
])
let
colorValue
=
args
[
pairNumber
*
2
+
1
]
if
(
colorIndex
>=
colorPalette
.
length
)
{
...
...
terminus-terminal/src/frontends/htermFrontend.ts
浏览文件 @
a5ecdeb5
...
...
@@ -54,7 +54,7 @@ export class HTermFrontend extends Frontend {
}
configure
():
void
{
le
t
config
=
this
.
configService
.
store
cons
t
config
=
this
.
configService
.
store
this
.
configuredFontSize
=
config
.
terminal
.
fontSize
this
.
configuredLinePadding
=
config
.
terminal
.
linePadding
...
...
@@ -157,7 +157,7 @@ export class HTermFrontend extends Frontend {
}
private
setFontSize
()
{
le
t
size
=
this
.
configuredFontSize
*
Math
.
pow
(
1.1
,
this
.
zoom
)
cons
t
size
=
this
.
configuredFontSize
*
Math
.
pow
(
1.1
,
this
.
zoom
)
preferenceManager
.
set
(
'
font-size
'
,
size
)
if
(
this
.
term
)
{
setTimeout
(()
=>
{
...
...
@@ -229,7 +229,7 @@ export class HTermFrontend extends Frontend {
this
.
term
.
ringBell
=
()
=>
this
.
bell
.
next
()
for
(
le
t
screen
of
[
this
.
term
.
primaryScreen_
,
this
.
term
.
alternateScreen_
])
{
for
(
cons
t
screen
of
[
this
.
term
.
primaryScreen_
,
this
.
term
.
alternateScreen_
])
{
const
_insertString
=
screen
.
insertString
.
bind
(
screen
)
screen
.
insertString
=
(
data
)
=>
{
_insertString
(
data
)
...
...
@@ -238,7 +238,7 @@ export class HTermFrontend extends Frontend {
const
_deleteChars
=
screen
.
deleteChars
.
bind
(
screen
)
screen
.
deleteChars
=
(
count
)
=>
{
le
t
ret
=
_deleteChars
(
count
)
cons
t
ret
=
_deleteChars
(
count
)
this
.
contentUpdated
.
next
()
return
ret
}
...
...
@@ -246,7 +246,7 @@ export class HTermFrontend extends Frontend {
const
_expandSelection
=
screen
.
expandSelection
.
bind
(
screen
)
screen
.
expandSelection
=
(
selection
)
=>
{
// Drop whitespace at the end of selection
le
t
range
=
selection
.
getRangeAt
(
0
)
cons
t
range
=
selection
.
getRangeAt
(
0
)
if
(
range
.
endOffset
>
0
&&
range
.
endContainer
.
nodeType
===
3
&&
range
.
endContainer
.
textContent
!==
''
)
{
while
(
/
[\s\S]
+
\s
$/
.
test
(
range
.
endContainer
.
textContent
.
substr
(
0
,
range
.
endOffset
)))
{
range
.
setEnd
(
range
.
endContainer
,
range
.
endOffset
-
1
)
...
...
@@ -258,7 +258,7 @@ export class HTermFrontend extends Frontend {
const
_measureCharacterSize
=
this
.
term
.
scrollPort_
.
measureCharacterSize
.
bind
(
this
.
term
.
scrollPort_
)
this
.
term
.
scrollPort_
.
measureCharacterSize
=
()
=>
{
le
t
size
=
_measureCharacterSize
()
cons
t
size
=
_measureCharacterSize
()
size
.
height
+=
this
.
configuredLinePadding
return
size
}
...
...
terminus-terminal/src/frontends/xtermFrontend.ts
浏览文件 @
a5ecdeb5
...
...
@@ -123,7 +123,7 @@ export class XTermFrontend extends Frontend {
host
.
addEventListener
(
'
mouseup
'
,
event
=>
this
.
mouseEvent
.
next
(
event
as
MouseEvent
))
host
.
addEventListener
(
'
mousewheel
'
,
event
=>
this
.
mouseEvent
.
next
(
event
as
MouseEvent
))
le
t
ro
=
new
window
[
'
ResizeObserver
'
](()
=>
this
.
resizeHandler
())
cons
t
ro
=
new
window
[
'
ResizeObserver
'
](()
=>
this
.
resizeHandler
())
ro
.
observe
(
host
)
}
...
...
@@ -167,7 +167,7 @@ export class XTermFrontend extends Frontend {
}
configure
():
void
{
le
t
config
=
this
.
configService
.
store
cons
t
config
=
this
.
configService
.
store
setImmediate
(()
=>
{
if
(
this
.
xterm
.
cols
&&
this
.
xterm
.
rows
&&
this
.
xtermCore
.
charMeasure
)
{
...
...
@@ -194,7 +194,7 @@ export class XTermFrontend extends Frontend {
this
.
copyOnSelect
=
config
.
terminal
.
copyOnSelect
le
t
theme
:
ITheme
=
{
cons
t
theme
:
ITheme
=
{
foreground
:
config
.
terminal
.
colorScheme
.
foreground
,
background
:
(
config
.
terminal
.
background
===
'
colorScheme
'
)
?
config
.
terminal
.
colorScheme
.
background
:
(
config
.
appearance
.
vibrancy
?
'
transparent
'
:
this
.
themesService
.
findCurrentTheme
().
terminalBackground
),
cursor
:
config
.
terminal
.
colorScheme
.
cursor
,
...
...
@@ -252,7 +252,7 @@ export class XTermFrontend extends Frontend {
private
getHexColor
(
mode
:
number
,
color
:
number
):
string
{
if
(
mode
===
Attributes
.
CM_RGB
)
{
le
t
rgb
=
AttributeData
.
toColorRGB
(
color
)
cons
t
rgb
=
AttributeData
.
toColorRGB
(
color
)
return
rgb
.
map
(
x
=>
x
.
toString
(
16
).
padStart
(
2
,
'
0
'
)).
join
(
''
)
}
if
(
mode
===
Attributes
.
CM_P16
||
mode
===
Attributes
.
CM_P256
)
{
...
...
@@ -265,7 +265,7 @@ export class XTermFrontend extends Frontend {
let
html
=
'
<div>
'
let
lastStyle
=
null
const
line
=
(
this
.
xterm
.
buffer
.
getLine
(
y
)
as
any
).
_line
le
t
cell
=
new
CellData
()
cons
t
cell
=
new
CellData
()
for
(
let
i
=
start
;
i
<
end
;
i
++
)
{
line
.
loadCell
(
i
,
cell
)
const
fg
=
this
.
getHexColor
(
cell
.
getFgColorMode
(),
cell
.
getFgColor
())
...
...
terminus-terminal/src/hotkeys.ts
浏览文件 @
a5ecdeb5
...
...
@@ -74,7 +74,7 @@ export class TerminalHotkeyProvider extends HotkeyProvider {
)
{
super
()
}
async
provide
():
Promise
<
IHotkeyDescription
[]
>
{
le
t
profiles
=
await
this
.
terminal
.
getProfiles
()
cons
t
profiles
=
await
this
.
terminal
.
getProfiles
()
return
[
...
this
.
hotkeys
,
...
profiles
.
map
(
profile
=>
({
...
...
terminus-terminal/src/index.ts
浏览文件 @
a5ecdeb5
...
...
@@ -131,7 +131,7 @@ export default class TerminalModule {
hostApp
:
HostAppService
,
dockMenu
:
DockMenuService
,
)
{
le
t
events
=
[
cons
t
events
=
[
{
name
:
'
keydown
'
,
htermHandler
:
'
onKeyDown_
'
,
...
...
@@ -142,7 +142,7 @@ export default class TerminalModule {
},
]
events
.
forEach
((
event
)
=>
{
le
t
oldHandler
=
hterm
.
hterm
.
Keyboard
.
prototype
[
event
.
htermHandler
]
cons
t
oldHandler
=
hterm
.
hterm
.
Keyboard
.
prototype
[
event
.
htermHandler
]
hterm
.
hterm
.
Keyboard
.
prototype
[
event
.
htermHandler
]
=
function
(
nativeEvent
)
{
hotkeys
.
pushKeystroke
(
event
.
name
,
nativeEvent
)
if
(
hotkeys
.
getCurrentPartiallyMatchedHotkeys
().
length
===
0
)
{
...
...
@@ -169,8 +169,8 @@ export default class TerminalModule {
hostApp
.
newWindow
()
}
if
(
hotkey
.
startsWith
(
'
profile.
'
))
{
le
t
profiles
=
await
terminal
.
getProfiles
()
le
t
profile
=
profiles
.
find
(
x
=>
slug
(
x
.
name
).
toLowerCase
()
===
hotkey
.
split
(
'
.
'
)[
1
])
cons
t
profiles
=
await
terminal
.
getProfiles
()
cons
t
profile
=
profiles
.
find
(
x
=>
slug
(
x
.
name
).
toLowerCase
()
===
hotkey
.
split
(
'
.
'
)[
1
])
if
(
profile
)
{
terminal
.
openTabWithOptions
(
profile
.
sessionOptions
)
}
...
...
@@ -205,7 +205,7 @@ export default class TerminalModule {
})
hostApp
.
cliOpenProfile$
.
subscribe
(
async
profileName
=>
{
le
t
profile
=
config
.
store
.
terminal
.
profiles
.
find
(
x
=>
x
.
name
===
profileName
)
cons
t
profile
=
config
.
store
.
terminal
.
profiles
.
find
(
x
=>
x
.
name
===
profileName
)
if
(
!
profile
)
{
console
.
error
(
'
Requested profile
'
,
profileName
,
'
not found
'
)
return
...
...
terminus-terminal/src/pathDrop.ts
浏览文件 @
a5ecdeb5
...
...
@@ -15,7 +15,7 @@ export class PathDropDecorator extends TerminalDecorator {
event
.
preventDefault
()
}),
terminal
.
frontend
.
drop$
.
subscribe
(
event
=>
{
for
(
le
t
file
of
event
.
dataTransfer
.
files
as
any
)
{
for
(
cons
t
file
of
event
.
dataTransfer
.
files
as
any
)
{
this
.
injectPath
(
terminal
,
file
.
path
)
}
event
.
preventDefault
()
...
...
@@ -32,8 +32,8 @@ export class PathDropDecorator extends TerminalDecorator {
terminal
.
sendInput
(
path
+
'
'
)
}
detach
(
terminal
:
TerminalTabComponent
):
void
{
for
(
le
t
s
of
this
.
subscriptions
)
{
detach
(
_
terminal
:
TerminalTabComponent
):
void
{
for
(
cons
t
s
of
this
.
subscriptions
)
{
s
.
unsubscribe
()
}
}
...
...
terminus-terminal/src/services/sessions.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -94,7 +94,7 @@ export class Session extends BaseSession {
start
(
options
:
SessionOptions
)
{
this
.
name
=
options
.
name
le
t
env
=
{
cons
t
env
=
{
...
process
.
env
,
TERM
:
'
xterm-256color
'
,
TERM_PROGRAM
:
'
Terminus
'
,
...
...
@@ -103,7 +103,7 @@ export class Session extends BaseSession {
}
if
(
process
.
platform
===
'
darwin
'
&&
!
process
.
env
.
LC_ALL
)
{
le
t
locale
=
process
.
env
.
LC_CTYPE
||
'
en_US.UTF-8
'
cons
t
locale
=
process
.
env
.
LC_CTYPE
||
'
en_US.UTF-8
'
Object
.
assign
(
env
,
{
LANG
:
locale
,
LC_ALL
:
locale
,
...
...
@@ -175,9 +175,9 @@ export class Session extends BaseSession {
processOSC1337
(
data
)
{
if
(
data
.
includes
(
OSC1337Prefix
))
{
le
t
preData
=
data
.
substring
(
0
,
data
.
indexOf
(
OSC1337Prefix
))
cons
t
preData
=
data
.
substring
(
0
,
data
.
indexOf
(
OSC1337Prefix
))
let
params
=
data
.
substring
(
data
.
indexOf
(
OSC1337Prefix
)
+
OSC1337Prefix
.
length
)
le
t
postData
=
params
.
substring
(
params
.
indexOf
(
OSC1337Suffix
)
+
OSC1337Suffix
.
length
)
cons
t
postData
=
params
.
substring
(
params
.
indexOf
(
OSC1337Suffix
)
+
OSC1337Suffix
.
length
)
params
=
params
.
substring
(
0
,
params
.
indexOf
(
OSC1337Suffix
))
if
(
params
.
startsWith
(
'
CurrentDir=
'
))
{
...
...
@@ -216,7 +216,7 @@ export class Session extends BaseSession {
return
[]
}
if
(
process
.
platform
===
'
darwin
'
)
{
le
t
processes
=
await
macOSNativeProcessList
.
getProcessList
()
cons
t
processes
=
await
macOSNativeProcessList
.
getProcessList
()
return
processes
.
filter
(
x
=>
x
.
ppid
===
this
.
truePID
).
map
(
p
=>
({
pid
:
p
.
pid
,
ppid
:
p
.
ppid
,
...
...
@@ -304,7 +304,7 @@ export class Session extends BaseSession {
}
private
guessWindowsCWD
(
data
:
string
)
{
le
t
match
=
windowsDirectoryRegex
.
exec
(
data
)
cons
t
match
=
windowsDirectoryRegex
.
exec
(
data
)
if
(
match
)
{
this
.
guessedCWD
=
match
[
0
]
}
...
...
terminus-terminal/src/services/terminal.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -35,12 +35,12 @@ export class TerminalService {
}
private
async
getShells
():
Promise
<
IShell
[]
>
{
le
t
shellLists
=
await
Promise
.
all
(
this
.
config
.
enabledServices
(
this
.
shellProviders
).
map
(
x
=>
x
.
provide
()))
cons
t
shellLists
=
await
Promise
.
all
(
this
.
config
.
enabledServices
(
this
.
shellProviders
).
map
(
x
=>
x
.
provide
()))
return
shellLists
.
reduce
((
a
,
b
)
=>
a
.
concat
(
b
),
[])
}
async
getProfiles
(
includeHidden
?:
boolean
):
Promise
<
Profile
[]
>
{
le
t
shells
=
await
this
.
shells$
.
toPromise
()
cons
t
shells
=
await
this
.
shells$
.
toPromise
()
return
[
...
this
.
config
.
store
.
terminal
.
profiles
,
...
shells
.
filter
(
x
=>
includeHidden
||
!
x
.
hidden
).
map
(
shell
=>
({
...
...
@@ -54,7 +54,7 @@ export class TerminalService {
private
async
reloadShells
()
{
this
.
shells
=
new
AsyncSubject
<
IShell
[]
>
()
le
t
shells
=
await
this
.
getShells
()
cons
t
shells
=
await
this
.
getShells
()
this
.
logger
.
debug
(
'
Shells list:
'
,
shells
)
this
.
shells
.
next
(
shells
)
this
.
shells
.
complete
()
...
...
@@ -66,7 +66,7 @@ export class TerminalService {
*/
async
openTab
(
profile
?:
Profile
,
cwd
?:
string
,
pause
?:
boolean
):
Promise
<
TerminalTabComponent
>
{
if
(
!
profile
)
{
le
t
profiles
=
await
this
.
getProfiles
(
true
)
cons
t
profiles
=
await
this
.
getProfiles
(
true
)
profile
=
profiles
.
find
(
x
=>
slug
(
x
.
name
).
toLowerCase
()
===
this
.
config
.
store
.
terminal
.
profile
)
||
profiles
[
0
]
}
...
...
@@ -82,7 +82,7 @@ export class TerminalService {
cwd
=
await
this
.
app
.
activeTab
.
session
.
getWorkingDirectory
()
}
if
(
this
.
app
.
activeTab
instanceof
SplitTabComponent
)
{
le
t
focusedTab
=
this
.
app
.
activeTab
.
getFocusedTab
()
cons
t
focusedTab
=
this
.
app
.
activeTab
.
getFocusedTab
()
if
(
focusedTab
instanceof
TerminalTabComponent
&&
focusedTab
.
session
)
{
cwd
=
await
focusedTab
.
session
.
getWorkingDirectory
()
...
...
@@ -93,7 +93,7 @@ export class TerminalService {
}
this
.
logger
.
info
(
`Starting profile
${
profile
.
name
}
`
,
profile
)
le
t
sessionOptions
=
{
cons
t
sessionOptions
=
{
...
profile
.
sessionOptions
,
pauseAfterExit
:
pause
,
cwd
,
...
...
terminus-terminal/src/services/terminalFrontend.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -18,7 +18,7 @@ export class TerminalFrontendService {
getFrontend
(
session
?:
BaseSession
):
Frontend
{
if
(
!
session
)
{
le
t
frontend
:
Frontend
=
new
({
cons
t
frontend
:
Frontend
=
new
({
'
xterm
'
:
XTermFrontend
,
'
xterm-webgl
'
:
XTermWebGLFrontend
,
'
hterm
'
:
HTermFrontend
,
...
...
terminus-terminal/src/services/uac.service.ts
浏览文件 @
a5ecdeb5
...
...
@@ -33,7 +33,7 @@ export class UACService {
)
}
le
t
options
=
{
...
sessionOptions
}
cons
t
options
=
{
...
sessionOptions
}
options
.
args
=
[
options
.
command
,
...
options
.
args
]
options
.
command
=
helperPath
return
options
...
...
terminus-terminal/src/shells/custom.ts
浏览文件 @
a5ecdeb5
...
...
@@ -14,7 +14,7 @@ export class CustomShellProvider extends ShellProvider {
}
async
provide
():
Promise
<
IShell
[]
>
{
le
t
args
=
this
.
config
.
store
.
terminal
.
customShell
.
split
(
'
'
)
cons
t
args
=
this
.
config
.
store
.
terminal
.
customShell
.
split
(
'
'
)
return
[{
id
:
'
custom
'
,
name
:
'
Custom shell
'
,
...
...
terminus-terminal/src/shells/cygwin32.ts
浏览文件 @
a5ecdeb5
...
...
@@ -25,7 +25,7 @@ export class Cygwin32ShellProvider extends ShellProvider {
return
[]
}
le
t
cygwinPath
=
wnr
.
getRegistryValue
(
wnr
.
HK
.
LM
,
'
Software
\\
WOW6432Node
\\
Cygwin
\\
setup
'
,
'
rootdir
'
)
cons
t
cygwinPath
=
wnr
.
getRegistryValue
(
wnr
.
HK
.
LM
,
'
Software
\\
WOW6432Node
\\
Cygwin
\\
setup
'
,
'
rootdir
'
)
if
(
!
cygwinPath
)
{
return
[]
...
...
terminus-terminal/src/shells/cygwin64.ts
浏览文件 @
a5ecdeb5
...
...
@@ -25,7 +25,7 @@ export class Cygwin64ShellProvider extends ShellProvider {
return
[]
}
le
t
cygwinPath
=
wnr
.
getRegistryValue
(
wnr
.
HK
.
LM
,
'
Software
\\
Cygwin
\\
setup
'
,
'
rootdir
'
)
cons
t
cygwinPath
=
wnr
.
getRegistryValue
(
wnr
.
HK
.
LM
,
'
Software
\\
Cygwin
\\
setup
'
,
'
rootdir
'
)
if
(
!
cygwinPath
)
{
return
[]
...
...
terminus-terminal/src/shells/linuxDefault.ts
浏览文件 @
a5ecdeb5
...
...
@@ -22,7 +22,7 @@ export class LinuxDefaultShellProvider extends ShellProvider {
if
(
this
.
hostApp
.
platform
!==
Platform
.
Linux
)
{
return
[]
}
le
t
line
=
(
await
fs
.
readFile
(
'
/etc/passwd
'
,
{
encoding
:
'
utf-8
'
}))
cons
t
line
=
(
await
fs
.
readFile
(
'
/etc/passwd
'
,
{
encoding
:
'
utf-8
'
}))
.
split
(
'
\n
'
).
find
(
x
=>
x
.
startsWith
(
process
.
env
.
LOGNAME
+
'
:
'
))
if
(
!
line
)
{
this
.
logger
.
warn
(
'
Could not detect user shell
'
)
...
...
terminus-terminal/src/shells/macDefault.ts
浏览文件 @
a5ecdeb5
...
...
@@ -18,7 +18,7 @@ export class MacOSDefaultShellProvider extends ShellProvider {
if
(
this
.
hostApp
.
platform
!==
Platform
.
macOS
)
{
return
[]
}
le
t
shellEntry
=
(
await
exec
(
`/usr/bin/dscl . -read /Users/
${
process
.
env
.
LOGNAME
}
UserShell`
))[
0
].
toString
()
cons
t
shellEntry
=
(
await
exec
(
`/usr/bin/dscl . -read /Users/
${
process
.
env
.
LOGNAME
}
UserShell`
))[
0
].
toString
()
return
[{
id
:
'
default
'
,
name
:
'
User default
'
,
...
...
terminus-terminal/src/shells/winDefault.ts
浏览文件 @
a5ecdeb5
...
...
@@ -32,10 +32,10 @@ export class WindowsDefaultShellProvider extends ShellProvider {
return
[]
}
// Figure out a sensible default
le
t
shellLists
=
await
Promise
.
all
(
this
.
providers
.
map
(
x
=>
x
.
provide
()))
for
(
le
t
list
of
shellLists
)
{
cons
t
shellLists
=
await
Promise
.
all
(
this
.
providers
.
map
(
x
=>
x
.
provide
()))
for
(
cons
t
list
of
shellLists
)
{
if
(
list
.
length
)
{
le
t
shell
=
list
[
list
.
length
-
1
]
cons
t
shell
=
list
[
list
.
length
-
1
]
return
[{
...
shell
,
...
...
terminus-terminal/src/shells/wsl.ts
浏览文件 @
a5ecdeb5
...
...
@@ -29,7 +29,7 @@ export class WSLShellProvider extends ShellProvider {
const
bashPath
=
`
${
process
.
env
.
windir
}
\\system32\\bash.exe`
const
wslPath
=
`
${
process
.
env
.
windir
}
\\system32\\wsl.exe`
le
t
shells
:
IShell
[]
=
[{
cons
t
shells
:
IShell
[]
=
[{
id
:
'
wsl
'
,
name
:
'
WSL / Default distro
'
,
command
:
wslPath
,
...
...
@@ -40,7 +40,7 @@ export class WSLShellProvider extends ShellProvider {
}]
const
lxssPath
=
'
Software
\\
Microsoft
\\
Windows
\\
CurrentVersion
\\
Lxss
'
le
t
lxss
=
wnr
.
getRegistryKey
(
wnr
.
HK
.
CU
,
lxssPath
)
cons
t
lxss
=
wnr
.
getRegistryKey
(
wnr
.
HK
.
CU
,
lxssPath
)
if
(
!
lxss
||
!
lxss
.
DefaultDistribution
||
!
isWindowsBuild
(
WIN_BUILD_WSL_EXE_DISTRO_FLAG
))
{
if
(
await
fs
.
exists
(
bashPath
))
{
return
[{
...
...
@@ -56,12 +56,12 @@ export class WSLShellProvider extends ShellProvider {
return
[]
}
}
for
(
le
t
child
of
wnr
.
listRegistrySubkeys
(
wnr
.
HK
.
CU
,
lxssPath
))
{
le
t
childKey
=
wnr
.
getRegistryKey
(
wnr
.
HK
.
CU
,
lxssPath
+
'
\\
'
+
child
)
for
(
cons
t
child
of
wnr
.
listRegistrySubkeys
(
wnr
.
HK
.
CU
,
lxssPath
))
{
cons
t
childKey
=
wnr
.
getRegistryKey
(
wnr
.
HK
.
CU
,
lxssPath
+
'
\\
'
+
child
)
if
(
!
childKey
.
DistributionName
)
{
continue
}
le
t
name
=
childKey
.
DistributionName
.
value
cons
t
name
=
childKey
.
DistributionName
.
value
shells
.
push
({
id
:
`wsl-
${
slug
(
name
)}
`
,
name
:
`WSL /
${
name
}
`
,
...
...
terminus-terminal/src/tabContextMenu.ts
浏览文件 @
a5ecdeb5
...
...
@@ -22,7 +22,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
{
label
:
'
Save as profile
'
,
click
:
()
=>
this
.
zone
.
run
(
async
()
=>
{
le
t
profile
=
{
cons
t
profile
=
{
sessionOptions
:
{
...
tab
.
sessionOptions
,
cwd
:
(
await
tab
.
session
.
getWorkingDirectory
())
||
tab
.
sessionOptions
.
cwd
,
...
...
tslint.json
浏览文件 @
a5ecdeb5
...
...
@@ -10,6 +10,7 @@
"spaces"
],
"ter-indent"
:
[
true
,
4
],
"prefer-const"
:
true
,
"trailing-comma"
:
[
true
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录