mirror of
https://github.com/Eugeny/tabby.git
synced 2025-08-26 03:01:54 +00:00
Compare commits
37 Commits
v1.0.0-alp
...
v1.0.0-alp
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d9e337aa46 | ||
![]() |
2881481fc2 | ||
![]() |
fa4c59e3c0 | ||
![]() |
f783e1ab06 | ||
![]() |
5cdb7527c8 | ||
![]() |
13a76db9af | ||
![]() |
0de12b6b38 | ||
![]() |
92993db122 | ||
![]() |
02082c385c | ||
![]() |
0c15f5033d | ||
![]() |
a280658bbb | ||
![]() |
3673542197 | ||
![]() |
11f188f1e8 | ||
![]() |
9a9db28054 | ||
![]() |
47d57d08ee | ||
![]() |
39e2c386f0 | ||
![]() |
c73d39026b | ||
![]() |
89dff969b1 | ||
![]() |
e1eb1beb87 | ||
![]() |
8d12d6a547 | ||
![]() |
33f67503bd | ||
![]() |
21e1656780 | ||
![]() |
ceacf5c760 | ||
![]() |
e0c0cd17bd | ||
![]() |
e81e5034b9 | ||
![]() |
11e0c36ebc | ||
![]() |
e52fd0a3dd | ||
![]() |
48ccc538e5 | ||
![]() |
53ac39232c | ||
![]() |
f68e06c9ed | ||
![]() |
6c884e090c | ||
![]() |
38cda117e2 | ||
![]() |
fb64ca08d3 | ||
![]() |
0fe7edc5b5 | ||
![]() |
1614405c62 | ||
![]() |
87730ba7b3 | ||
![]() |
eb2eef64fc |
@@ -5,7 +5,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
|||||||
export function getRootModule (plugins: any[]) {
|
export function getRootModule (plugins: any[]) {
|
||||||
let imports = [
|
let imports = [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
...(plugins.map(x => x.default.forRoot ? x.default.forRoot() : x.default)),
|
...plugins,
|
||||||
NgbModule.forRoot(),
|
NgbModule.forRoot(),
|
||||||
]
|
]
|
||||||
let bootstrap = [
|
let bootstrap = [
|
||||||
|
@@ -30,6 +30,7 @@ async function bootstrap (plugins: IPluginInfo[], safeMode = false): Promise<NgM
|
|||||||
(document.querySelector('.progress .bar') as HTMLElement).style.width = 100 * current / total + '%'
|
(document.querySelector('.progress .bar') as HTMLElement).style.width = 100 * current / total + '%'
|
||||||
})
|
})
|
||||||
let module = getRootModule(pluginsModules)
|
let module = getRootModule(pluginsModules)
|
||||||
|
window['rootModule'] = module
|
||||||
return await platformBrowserDynamic().bootstrapModule(module)
|
return await platformBrowserDynamic().bootstrapModule(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,7 @@ nodeRequire('module').prototype.require = function (query) {
|
|||||||
export async function findPlugins (): Promise<IPluginInfo[]> {
|
export async function findPlugins (): Promise<IPluginInfo[]> {
|
||||||
let paths = nodeModule.globalPaths
|
let paths = nodeModule.globalPaths
|
||||||
let foundPlugins: IPluginInfo[] = []
|
let foundPlugins: IPluginInfo[] = []
|
||||||
let candidateLocations: { pluginDir: string, pluginName: string }[] = []
|
let candidateLocations: { pluginDir: string, packageName: string }[] = []
|
||||||
|
|
||||||
for (let pluginDir of paths) {
|
for (let pluginDir of paths) {
|
||||||
pluginDir = normalizePath(pluginDir)
|
pluginDir = normalizePath(pluginDir)
|
||||||
@@ -93,36 +93,38 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
|
|||||||
if (await fs.exists(path.join(pluginDir, 'package.json'))) {
|
if (await fs.exists(path.join(pluginDir, 'package.json'))) {
|
||||||
candidateLocations.push({
|
candidateLocations.push({
|
||||||
pluginDir: path.dirname(pluginDir),
|
pluginDir: path.dirname(pluginDir),
|
||||||
pluginName: path.basename(pluginDir)
|
packageName: path.basename(pluginDir)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for (let pluginName of pluginNames) {
|
for (let packageName of pluginNames) {
|
||||||
candidateLocations.push({ pluginDir, pluginName })
|
candidateLocations.push({ pluginDir, packageName })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let { pluginDir, pluginName } of candidateLocations) {
|
for (let { pluginDir, packageName } of candidateLocations) {
|
||||||
let pluginPath = path.join(pluginDir, pluginName)
|
let pluginPath = path.join(pluginDir, packageName)
|
||||||
let infoPath = path.join(pluginPath, 'package.json')
|
let infoPath = path.join(pluginPath, 'package.json')
|
||||||
if (!await fs.exists(infoPath)) {
|
if (!await fs.exists(infoPath)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundPlugins.some(x => x.name === pluginName.substring('terminus-'.length))) {
|
let name = packageName.substring('terminus-'.length)
|
||||||
console.info(`Plugin ${pluginName} already exists, overriding`)
|
|
||||||
foundPlugins = foundPlugins.filter(x => x.name !== pluginName.substring('terminus-'.length))
|
if (foundPlugins.some(x => x.name === name)) {
|
||||||
|
console.info(`Plugin ${packageName} already exists, overriding`)
|
||||||
|
foundPlugins = foundPlugins.filter(x => x.name !== name)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'}))
|
let info = JSON.parse(await fs.readFile(infoPath, {encoding: 'utf-8'}))
|
||||||
if (!info.keywords || info.keywords.indexOf('terminus-plugin') === -1) {
|
if (!info.keywords || !(info.keywords.includes('terminus-plugin') || info.keywords.includes('terminus-builtin-plugin'))) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
let author = info.author
|
let author = info.author
|
||||||
author = author.name || author
|
author = author.name || author
|
||||||
foundPlugins.push({
|
foundPlugins.push({
|
||||||
name: pluginName.substring('terminus-'.length),
|
name: name,
|
||||||
packageName: pluginName,
|
packageName: packageName,
|
||||||
isBuiltin: pluginDir === builtinPluginsPath,
|
isBuiltin: pluginDir === builtinPluginsPath,
|
||||||
version: info.version,
|
version: info.version,
|
||||||
description: info.description,
|
description: info.description,
|
||||||
@@ -131,7 +133,7 @@ export async function findPlugins (): Promise<IPluginInfo[]> {
|
|||||||
info,
|
info,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Cannot load package info for', pluginName)
|
console.error('Cannot load package info for', packageName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +149,10 @@ export async function loadPlugins (foundPlugins: IPluginInfo[], progress: Progre
|
|||||||
console.info(`Loading ${foundPlugin.name}: ${nodeRequire.resolve(foundPlugin.path)}`)
|
console.info(`Loading ${foundPlugin.name}: ${nodeRequire.resolve(foundPlugin.path)}`)
|
||||||
progress(index, foundPlugins.length)
|
progress(index, foundPlugins.length)
|
||||||
try {
|
try {
|
||||||
let pluginModule = nodeRequire(foundPlugin.path)
|
let packageModule = nodeRequire(foundPlugin.path)
|
||||||
|
let pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
||||||
|
pluginModule['pluginName'] = foundPlugin.name
|
||||||
|
pluginModule['bootstrap'] = packageModule.bootstrap
|
||||||
plugins.push(pluginModule)
|
plugins.push(pluginModule)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Could not load ${foundPlugin.name}:`, error)
|
console.error(`Could not load ${foundPlugin.name}:`, error)
|
||||||
|
@@ -58,3 +58,7 @@
|
|||||||
color: #842fe0;
|
color: #842fe0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-dialog {
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
}
|
||||||
|
16
package.json
16
package.json
@@ -15,6 +15,7 @@
|
|||||||
"electron-rebuild": "1.5.11",
|
"electron-rebuild": "1.5.11",
|
||||||
"file-loader": "0.9.0",
|
"file-loader": "0.9.0",
|
||||||
"font-awesome": "4.7.0",
|
"font-awesome": "4.7.0",
|
||||||
|
"graceful-fs": "^4.1.11",
|
||||||
"html-loader": "0.4.4",
|
"html-loader": "0.4.4",
|
||||||
"json-loader": "0.5.4",
|
"json-loader": "0.5.4",
|
||||||
"less": "2.7.1",
|
"less": "2.7.1",
|
||||||
@@ -53,7 +54,9 @@
|
|||||||
],
|
],
|
||||||
"win": {
|
"win": {
|
||||||
"icon": "./build/windows/icon.ico",
|
"icon": "./build/windows/icon.ico",
|
||||||
"publish": ["github"]
|
"publish": [
|
||||||
|
"github"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"squirrelWindows": {
|
"squirrelWindows": {
|
||||||
"iconUrl": "https://github.com/Eugeny/terminus/raw/master/build/windows/icon.ico",
|
"iconUrl": "https://github.com/Eugeny/terminus/raw/master/build/windows/icon.ico",
|
||||||
@@ -63,7 +66,9 @@
|
|||||||
"category": "public.app-category.video",
|
"category": "public.app-category.video",
|
||||||
"icon": "./build/mac/icon.icns",
|
"icon": "./build/mac/icon.icns",
|
||||||
"identity": null,
|
"identity": null,
|
||||||
"publish": ["github"]
|
"publish": [
|
||||||
|
"github"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"dmg": {
|
"dmg": {
|
||||||
"artifactName": "terminus-${version}-${os}-${arch}.dmg"
|
"artifactName": "terminus-${version}-${os}-${arch}.dmg"
|
||||||
@@ -71,7 +76,9 @@
|
|||||||
"linux": {
|
"linux": {
|
||||||
"category": "Utilities",
|
"category": "Utilities",
|
||||||
"icon": "./build/icons",
|
"icon": "./build/icons",
|
||||||
"publish": ["github"]
|
"publish": [
|
||||||
|
"github"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"deb": {
|
"deb": {
|
||||||
"depends": [
|
"depends": [
|
||||||
@@ -82,6 +89,7 @@
|
|||||||
"libappindicator1",
|
"libappindicator1",
|
||||||
"libxtst6",
|
"libxtst6",
|
||||||
"libnss3",
|
"libnss3",
|
||||||
|
"python-gnomekeyring",
|
||||||
"tmux"
|
"tmux"
|
||||||
],
|
],
|
||||||
"artifactName": "terminus-${version}-${os}-${arch}.deb"
|
"artifactName": "terminus-${version}-${os}-${arch}.deb"
|
||||||
@@ -94,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack --color --config app/webpack.config.js && webpack --color --config terminus-core/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-terminal/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-plugin-manager/webpack.config.js && webpack --color --config terminus-community-color-schemes/webpack.config.js",
|
"build": "webpack --color --config app/webpack.config.js && webpack --color --config terminus-core/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-terminal/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-plugin-manager/webpack.config.js && webpack --color --config terminus-community-color-schemes/webpack.config.js && webpack --color --config terminus-ssh/webpack.config.js",
|
||||||
"watch": "webpack --progress --color --watch",
|
"watch": "webpack --progress --color --watch",
|
||||||
"start": "cross-env DEV=1 electron --js-flags='--ignition' app --debug",
|
"start": "cross-env DEV=1 electron --js-flags='--ignition' app --debug",
|
||||||
"prod": "cross-env DEV=1 electron --js-flags='--ignition' app",
|
"prod": "cross-env DEV=1 electron --js-flags='--ignition' app",
|
||||||
|
@@ -3,7 +3,5 @@ const rebuild = require('electron-rebuild').default
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const vars = require('./vars')
|
const vars = require('./vars')
|
||||||
|
|
||||||
let buildPath = path.resolve(__dirname, '../terminus-terminal')
|
rebuild(path.resolve(__dirname, '../terminus-ssh'), vars.electronVersion, process.arch, [], true)
|
||||||
rebuild(buildPath, vars.electronVersion, process.arch, [], true).then(() => {
|
rebuild(path.resolve(__dirname, '../terminus-terminal'), vars.electronVersion, process.arch, [], true)
|
||||||
console.log('Done')
|
|
||||||
})
|
|
||||||
|
@@ -14,6 +14,7 @@ exports.builtinPlugins = [
|
|||||||
'terminus-terminal',
|
'terminus-terminal',
|
||||||
'terminus-community-color-schemes',
|
'terminus-community-color-schemes',
|
||||||
'terminus-plugin-manager',
|
'terminus-plugin-manager',
|
||||||
|
'terminus-ssh',
|
||||||
]
|
]
|
||||||
exports.nativeModules = ['node-pty', 'font-manager']
|
exports.nativeModules = ['node-pty-tmp', 'font-manager', 'xkeychain']
|
||||||
exports.electronVersion = pkgInfo.devDependencies.electron
|
exports.electronVersion = pkgInfo.devDependencies.electron
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-community-color-schemes",
|
"name": "terminus-community-color-schemes",
|
||||||
"version": "1.0.0-alpha.24",
|
"version": "1.0.0-alpha.36",
|
||||||
"description": "Community color schemes for Terminus",
|
"description": "Community color schemes for Terminus",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-builtin-plugin"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@@ -19,29 +19,19 @@ export class ColorSchemes extends TerminalColorSchemeProvider {
|
|||||||
values[key] = value
|
values[key] = value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let colors: string[] = []
|
||||||
|
let colorIndex = 0
|
||||||
|
while (values[`color${colorIndex}`]) {
|
||||||
|
colors.push(values[`color${colorIndex}`])
|
||||||
|
colorIndex++
|
||||||
|
}
|
||||||
|
|
||||||
schemes.push({
|
schemes.push({
|
||||||
name: schemeFile.split('/')[1].trim(),
|
name: schemeFile.split('/')[1].trim(),
|
||||||
foreground: values.foreground,
|
foreground: values.foreground,
|
||||||
background: values.background,
|
background: values.background,
|
||||||
cursor: values.cursorColor,
|
cursor: values.cursorColor,
|
||||||
colors: [
|
colors,
|
||||||
values.color0,
|
|
||||||
values.color1,
|
|
||||||
values.color2,
|
|
||||||
values.color3,
|
|
||||||
values.color4,
|
|
||||||
values.color5,
|
|
||||||
values.color6,
|
|
||||||
values.color7,
|
|
||||||
values.color8,
|
|
||||||
values.color9,
|
|
||||||
values.color10,
|
|
||||||
values.color11,
|
|
||||||
values.color12,
|
|
||||||
values.color13,
|
|
||||||
values.color14,
|
|
||||||
values.color15,
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-core",
|
"name": "terminus-core",
|
||||||
"version": "1.0.0-alpha.24",
|
"version": "1.0.0-alpha.36",
|
||||||
"description": "Terminus core",
|
"description": "Terminus core",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-builtin-plugin"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@@ -20,7 +20,8 @@
|
|||||||
"@types/js-yaml": "^3.9.0",
|
"@types/js-yaml": "^3.9.0",
|
||||||
"@types/node": "^7.0.37",
|
"@types/node": "^7.0.37",
|
||||||
"@types/webpack-env": "^1.13.0",
|
"@types/webpack-env": "^1.13.0",
|
||||||
"axios": "^0.16.2",
|
"@types/winston": "^2.3.6",
|
||||||
|
"axios": "0.16.2",
|
||||||
"bootstrap": "4.0.0-alpha.6",
|
"bootstrap": "4.0.0-alpha.6",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
"electron-updater": "^2.8.9",
|
"electron-updater": "^2.8.9",
|
||||||
@@ -39,7 +40,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"deepmerge": "^1.5.0",
|
"deepmerge": "^1.5.0",
|
||||||
"js-yaml": "^3.9.0"
|
"js-yaml": "^3.9.0",
|
||||||
|
"winston": "^2.4.0"
|
||||||
},
|
},
|
||||||
"false": {}
|
"false": {}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,6 @@ title-bar(
|
|||||||
[class.drag-region]='hostApp.platform == Platform.macOS',
|
[class.drag-region]='hostApp.platform == Platform.macOS',
|
||||||
@animateTab,
|
@animateTab,
|
||||||
(click)='app.selectTab(tab)',
|
(click)='app.selectTab(tab)',
|
||||||
(closeClicked)='app.closeTab(tab, true)',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
.btn-group
|
.btn-group
|
||||||
@@ -30,7 +29,7 @@ title-bar(
|
|||||||
)
|
)
|
||||||
i.fa([class]='"fa fa-" + button.icon')
|
i.fa([class]='"fa fa-" + button.icon')
|
||||||
|
|
||||||
.drag-space
|
.drag-space(*ngIf='config.store.appearance.frame == "thin" && hostApp.platform != Platform.macOS')
|
||||||
|
|
||||||
.btn-group
|
.btn-group
|
||||||
button.btn.btn-secondary.btn-tab-bar(
|
button.btn.btn-secondary.btn-tab-bar(
|
||||||
|
@@ -150,6 +150,8 @@ export class AppRootComponent {
|
|||||||
if (this.app.tabs.length === 0) {
|
if (this.app.tabs.length === 0) {
|
||||||
this.app.openDefaultTab()
|
this.app.openDefaultTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.app.emitReady()
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('dragover')
|
@HostListener('dragover')
|
||||||
@@ -168,7 +170,7 @@ export class AppRootComponent {
|
|||||||
|
|
||||||
private getToolbarButtons (aboveZero: boolean): IToolbarButton[] {
|
private getToolbarButtons (aboveZero: boolean): IToolbarButton[] {
|
||||||
let buttons: IToolbarButton[] = []
|
let buttons: IToolbarButton[] = []
|
||||||
this.toolbarButtonProviders.forEach((provider) => {
|
this.config.enabledServices(this.toolbarButtonProviders).forEach(provider => {
|
||||||
buttons = buttons.concat(provider.provide())
|
buttons = buttons.concat(provider.provide())
|
||||||
})
|
})
|
||||||
return buttons
|
return buttons
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import { Component, Inject } from '@angular/core'
|
import { Component, Inject } from '@angular/core'
|
||||||
import { ElectronService } from '../services/electron.service'
|
import { ElectronService } from '../services/electron.service'
|
||||||
|
import { ConfigService } from '../services/config.service'
|
||||||
import { IToolbarButton, ToolbarButtonProvider } from '../api'
|
import { IToolbarButton, ToolbarButtonProvider } from '../api'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -13,13 +14,14 @@ export class StartPageComponent {
|
|||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private electron: ElectronService,
|
private electron: ElectronService,
|
||||||
|
private config: ConfigService,
|
||||||
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
|
@Inject(ToolbarButtonProvider) private toolbarButtonProviders: ToolbarButtonProvider[],
|
||||||
) {
|
) {
|
||||||
this.version = electron.app.getVersion()
|
this.version = electron.app.getVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
getButtons (): IToolbarButton[] {
|
getButtons (): IToolbarButton[] {
|
||||||
return this.toolbarButtonProviders
|
return this.config.enabledServices(this.toolbarButtonProviders)
|
||||||
.map(provider => provider.provide())
|
.map(provider => provider.provide())
|
||||||
.reduce((a, b) => a.concat(b))
|
.reduce((a, b) => a.concat(b))
|
||||||
.sort((a: IToolbarButton, b: IToolbarButton) => (a.weight || 0) - (b.weight || 0))
|
.sort((a: IToolbarButton, b: IToolbarButton) => (a.weight || 0) - (b.weight || 0))
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
.index {{index + 1}}
|
.index {{index + 1}}
|
||||||
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
.name([title]='tab.customTitle || tab.title') {{tab.customTitle || tab.title}}
|
||||||
button((click)='closeClicked.emit()') ×
|
button((click)='app.closeTab(tab, true)') ×
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
$tabs-height: 36px;
|
$tabs-height: 36px;
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
line-height: $tabs-height - 2px;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
flex: 1000 1 200px;
|
flex: 1000 1 200px;
|
||||||
@@ -24,9 +23,9 @@ $tabs-height: 36px;
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
line-height: 35px;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
transition: 0.25s all;
|
transition: 0.25s all;
|
||||||
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
@@ -36,6 +35,7 @@ $tabs-height: 36px;
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
@@ -49,7 +49,7 @@ $tabs-height: 36px;
|
|||||||
height: $button-size;
|
height: $button-size;
|
||||||
border-radius: $button-size / 2;
|
border-radius: $button-size / 2;
|
||||||
line-height: $button-size * 0.87;
|
line-height: $button-size * 0.87;
|
||||||
margin-top: ($tabs-height - $button-size) * 0.5;
|
align-self: center;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import { Component, Input, Output, EventEmitter, HostBinding, HostListener } from '@angular/core'
|
import { Component, Input, HostBinding, HostListener, NgZone } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { BaseTabComponent } from './baseTab.component'
|
import { BaseTabComponent } from './baseTab.component'
|
||||||
import { RenameTabModalComponent } from './renameTabModal.component'
|
import { RenameTabModalComponent } from './renameTabModal.component'
|
||||||
|
import { ElectronService } from '../services/electron.service'
|
||||||
|
import { AppService } from '../services/app.service'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tab-header',
|
selector: 'tab-header',
|
||||||
@@ -13,11 +15,55 @@ export class TabHeaderComponent {
|
|||||||
@Input() @HostBinding('class.active') active: boolean
|
@Input() @HostBinding('class.active') active: boolean
|
||||||
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
@Input() @HostBinding('class.has-activity') hasActivity: boolean
|
||||||
@Input() tab: BaseTabComponent
|
@Input() tab: BaseTabComponent
|
||||||
@Output() closeClicked = new EventEmitter()
|
private contextMenu: any
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
zone: NgZone,
|
||||||
|
electron: ElectronService,
|
||||||
|
public app: AppService,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
) { }
|
) {
|
||||||
|
this.contextMenu = electron.remote.Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: 'Close',
|
||||||
|
click: () => {
|
||||||
|
zone.run(() => {
|
||||||
|
app.closeTab(this.tab, true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Close other tabs',
|
||||||
|
click: () => {
|
||||||
|
zone.run(() => {
|
||||||
|
for (let tab of app.tabs.filter(x => x !== this.tab)) {
|
||||||
|
app.closeTab(tab, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Close tabs to the right',
|
||||||
|
click: () => {
|
||||||
|
zone.run(() => {
|
||||||
|
for (let tab of app.tabs.slice(app.tabs.indexOf(this.tab) + 1)) {
|
||||||
|
app.closeTab(tab, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Close tabs to the left',
|
||||||
|
click: () => {
|
||||||
|
zone.run(() => {
|
||||||
|
for (let tab of app.tabs.slice(0, app.tabs.indexOf(this.tab))) {
|
||||||
|
app.closeTab(tab, true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
@HostListener('dblclick') onDoubleClick (): void {
|
@HostListener('dblclick') onDoubleClick (): void {
|
||||||
let modal = this.ngbModal.open(RenameTabModalComponent)
|
let modal = this.ngbModal.open(RenameTabModalComponent)
|
||||||
@@ -29,7 +75,15 @@ export class TabHeaderComponent {
|
|||||||
|
|
||||||
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {
|
@HostListener('auxclick', ['$event']) onAuxClick ($event: MouseEvent): void {
|
||||||
if ($event.which === 2) {
|
if ($event.which === 2) {
|
||||||
this.closeClicked.emit()
|
this.app.closeTab(this.tab, true)
|
||||||
|
}
|
||||||
|
if ($event.which === 3) {
|
||||||
|
this.contextMenu.popup({
|
||||||
|
x: $event.pageX,
|
||||||
|
y: $event.pageY,
|
||||||
|
async: true,
|
||||||
|
})
|
||||||
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,3 +43,4 @@ hotkeys:
|
|||||||
tab-10:
|
tab-10:
|
||||||
- 'Alt-0'
|
- 'Alt-0'
|
||||||
- ['Ctrl-A', '0']
|
- ['Ctrl-A', '0']
|
||||||
|
pluginBlacklist: ['ssh']
|
||||||
|
@@ -43,3 +43,4 @@ hotkeys:
|
|||||||
tab-10:
|
tab-10:
|
||||||
- '⌘-0'
|
- '⌘-0'
|
||||||
- ['Ctrl-A', '0']
|
- ['Ctrl-A', '0']
|
||||||
|
pluginBlacklist: ['ssh']
|
||||||
|
@@ -43,3 +43,4 @@ hotkeys:
|
|||||||
tab-10:
|
tab-10:
|
||||||
- 'Alt-0'
|
- 'Alt-0'
|
||||||
- ['Ctrl-A', '0']
|
- ['Ctrl-A', '0']
|
||||||
|
pluginBlacklist: []
|
||||||
|
@@ -29,7 +29,7 @@ import { HotkeyProvider } from './api/hotkeyProvider'
|
|||||||
import { ConfigProvider } from './api/configProvider'
|
import { ConfigProvider } from './api/configProvider'
|
||||||
import { Theme } from './api/theme'
|
import { Theme } from './api/theme'
|
||||||
|
|
||||||
import { StandardTheme } from './theme'
|
import { StandardTheme, StandardCompactTheme } from './theme'
|
||||||
import { CoreConfigProvider } from './config'
|
import { CoreConfigProvider } from './config'
|
||||||
|
|
||||||
import 'perfect-scrollbar/dist/css/perfect-scrollbar.css'
|
import 'perfect-scrollbar/dist/css/perfect-scrollbar.css'
|
||||||
@@ -47,6 +47,7 @@ const PROVIDERS = [
|
|||||||
UpdaterService,
|
UpdaterService,
|
||||||
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
|
{ provide: HotkeyProvider, useClass: AppHotkeyProvider, multi: true },
|
||||||
{ provide: Theme, useClass: StandardTheme, multi: true },
|
{ provide: Theme, useClass: StandardTheme, multi: true },
|
||||||
|
{ provide: Theme, useClass: StandardCompactTheme, multi: true },
|
||||||
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
|
{ provide: ConfigProvider, useClass: CoreConfigProvider, multi: true },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Subject } from 'rxjs'
|
import { Subject, AsyncSubject } from 'rxjs'
|
||||||
import { Injectable, ComponentFactoryResolver, Injector, Optional } from '@angular/core'
|
import { Injectable, ComponentFactoryResolver, Injector, Optional } from '@angular/core'
|
||||||
import { DefaultTabProvider } from '../api/defaultTabProvider'
|
import { DefaultTabProvider } from '../api/defaultTabProvider'
|
||||||
import { BaseTabComponent } from '../components/baseTab.component'
|
import { BaseTabComponent } from '../components/baseTab.component'
|
||||||
@@ -12,7 +12,8 @@ export class AppService {
|
|||||||
activeTab: BaseTabComponent
|
activeTab: BaseTabComponent
|
||||||
lastTabIndex = 0
|
lastTabIndex = 0
|
||||||
logger: Logger
|
logger: Logger
|
||||||
tabsChanged$ = new Subject()
|
tabsChanged$ = new Subject<void>()
|
||||||
|
ready$ = new AsyncSubject<void>()
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
private componentFactoryResolver: ComponentFactoryResolver,
|
||||||
@@ -97,4 +98,9 @@ export class AppService {
|
|||||||
}
|
}
|
||||||
this.tabsChanged$.next()
|
this.tabsChanged$.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitReady () {
|
||||||
|
this.ready$.next(null)
|
||||||
|
this.ready$.complete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@ import { Injectable, Inject } from '@angular/core'
|
|||||||
import { ConfigProvider } from '../api/configProvider'
|
import { ConfigProvider } from '../api/configProvider'
|
||||||
import { ElectronService } from './electron.service'
|
import { ElectronService } from './electron.service'
|
||||||
import { HostAppService } from './hostApp.service'
|
import { HostAppService } from './hostApp.service'
|
||||||
|
import * as Reflect from 'core-js/es7/reflect'
|
||||||
|
|
||||||
const configMerge = (a, b) => require('deepmerge')(a, b, { arrayMerge: (_d, s) => s })
|
const configMerge = (a, b) => require('deepmerge')(a, b, { arrayMerge: (_d, s) => s })
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ export class ConfigService {
|
|||||||
private _store: any
|
private _store: any
|
||||||
private path: string
|
private path: string
|
||||||
private defaults: any
|
private defaults: any
|
||||||
|
private servicesCache: { [id: string]: Function[] } = null
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
electron: ElectronService,
|
electron: ElectronService,
|
||||||
@@ -98,4 +100,28 @@ export class ConfigService {
|
|||||||
requestRestart (): void {
|
requestRestart (): void {
|
||||||
this.restartRequested = true
|
this.restartRequested = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enabledServices<T> (services: T[]): T[] {
|
||||||
|
if (!this.servicesCache) {
|
||||||
|
this.servicesCache = {}
|
||||||
|
let ngModule = Reflect.getMetadata('annotations', window['rootModule'])[0]
|
||||||
|
for (let imp of ngModule.imports) {
|
||||||
|
let module = imp['module'] || imp
|
||||||
|
let annotations = Reflect.getMetadata('annotations', module)
|
||||||
|
if (annotations) {
|
||||||
|
this.servicesCache[module['pluginName']] = annotations[0].providers.map(provider => {
|
||||||
|
return provider['useClass'] || provider
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return services.filter(service => {
|
||||||
|
for (let pluginName in this.servicesCache) {
|
||||||
|
if (this.servicesCache[pluginName].includes(service.constructor)) {
|
||||||
|
return !this.store.pluginBlacklist.includes(pluginName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,10 @@ export class DockingService {
|
|||||||
private electron: ElectronService,
|
private electron: ElectronService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
private hostApp: HostAppService,
|
private hostApp: HostAppService,
|
||||||
) {}
|
) {
|
||||||
|
electron.screen.on('display-removed', () => this.repositionWindow())
|
||||||
|
electron.screen.on('display-metrics-changed', () => this.repositionWindow())
|
||||||
|
}
|
||||||
|
|
||||||
dock () {
|
dock () {
|
||||||
let display = this.electron.screen.getAllDisplays()
|
let display = this.electron.screen.getAllDisplays()
|
||||||
@@ -71,4 +74,20 @@ export class DockingService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWindow () {
|
||||||
|
return this.electron.app.window
|
||||||
|
}
|
||||||
|
|
||||||
|
repositionWindow () {
|
||||||
|
let [x, y] = this.getWindow().getPosition()
|
||||||
|
for (let screen of this.electron.screen.getAllDisplays()) {
|
||||||
|
let bounds = screen.bounds
|
||||||
|
if (x >= bounds.x && x <= bounds.x + bounds.width && y >= bounds.y && y <= bounds.y + bounds.height) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let screen = this.electron.screen.getPrimaryDisplay()
|
||||||
|
this.getWindow().setPosition(screen.bounds.x, screen.bounds.y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ export class HotkeysService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
this.hotkeyDescriptions = hotkeyProviders.map(x => x.hotkeys).reduce((a, b) => a.concat(b))
|
this.hotkeyDescriptions = this.config.enabledServices(hotkeyProviders).map(x => x.hotkeys).reduce((a, b) => a.concat(b))
|
||||||
this.config.changed$.subscribe(() => {
|
this.config.changed$.subscribe(() => {
|
||||||
this.registerGlobalHotkey()
|
this.registerGlobalHotkey()
|
||||||
})
|
})
|
||||||
|
@@ -1,12 +1,47 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
|
import { ElectronService } from './electron.service'
|
||||||
|
import * as winston from 'winston'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
import * as path from 'path'
|
||||||
|
|
||||||
|
const initializeWinston = (electron: ElectronService) => {
|
||||||
|
const logDirectory = electron.app.getPath('userData')
|
||||||
|
|
||||||
|
if (!fs.existsSync(logDirectory)) {
|
||||||
|
fs.mkdirSync(logDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
|
return new winston.Logger({
|
||||||
|
transports: [
|
||||||
|
new winston.transports.File({
|
||||||
|
level: 'debug',
|
||||||
|
filename: path.join(logDirectory, 'log.txt'),
|
||||||
|
handleExceptions: false,
|
||||||
|
json: false,
|
||||||
|
maxsize: 5242880,
|
||||||
|
maxFiles: 5,
|
||||||
|
colorize: false
|
||||||
|
}),
|
||||||
|
new winston.transports.Console({
|
||||||
|
level: 'info',
|
||||||
|
handleExceptions: false,
|
||||||
|
json: false,
|
||||||
|
colorize: true
|
||||||
|
})
|
||||||
|
],
|
||||||
|
exitOnError: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export class Logger {
|
export class Logger {
|
||||||
constructor (
|
constructor (
|
||||||
|
private winstonLogger: any,
|
||||||
private name: string,
|
private name: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
doLog (level: string, ...args: any[]) {
|
doLog (level: string, ...args: any[]) {
|
||||||
console[level](`%c[${this.name}]`, 'color: #aaa', ...args)
|
console[level](`%c[${this.name}]`, 'color: #aaa', ...args)
|
||||||
|
this.winstonLogger[level](...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug (...args: any[]) { this.doLog('debug', ...args) }
|
debug (...args: any[]) { this.doLog('debug', ...args) }
|
||||||
@@ -18,7 +53,13 @@ export class Logger {
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class LogService {
|
export class LogService {
|
||||||
|
private log: any
|
||||||
|
|
||||||
|
constructor (electron: ElectronService) {
|
||||||
|
this.log = initializeWinston(electron)
|
||||||
|
}
|
||||||
|
|
||||||
create (name: string): Logger {
|
create (name: string): Logger {
|
||||||
return new Logger(name)
|
return new Logger(this.log, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ import { TabRecoveryProvider, RecoveredTab } from '../api/tabRecovery'
|
|||||||
import { BaseTabComponent } from '../components/baseTab.component'
|
import { BaseTabComponent } from '../components/baseTab.component'
|
||||||
import { Logger, LogService } from '../services/log.service'
|
import { Logger, LogService } from '../services/log.service'
|
||||||
import { AppService } from '../services/app.service'
|
import { AppService } from '../services/app.service'
|
||||||
|
import { ConfigService } from '../services/config.service'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TabRecoveryService {
|
export class TabRecoveryService {
|
||||||
@@ -11,6 +12,7 @@ export class TabRecoveryService {
|
|||||||
constructor (
|
constructor (
|
||||||
@Inject(TabRecoveryProvider) private tabRecoveryProviders: TabRecoveryProvider[],
|
@Inject(TabRecoveryProvider) private tabRecoveryProviders: TabRecoveryProvider[],
|
||||||
private app: AppService,
|
private app: AppService,
|
||||||
|
private config: ConfigService,
|
||||||
log: LogService
|
log: LogService
|
||||||
) {
|
) {
|
||||||
this.logger = log.create('tabRecovery')
|
this.logger = log.create('tabRecovery')
|
||||||
@@ -31,7 +33,7 @@ export class TabRecoveryService {
|
|||||||
if (window.localStorage.tabsRecovery) {
|
if (window.localStorage.tabsRecovery) {
|
||||||
let tabs: RecoveredTab[] = []
|
let tabs: RecoveredTab[] = []
|
||||||
for (let token of JSON.parse(window.localStorage.tabsRecovery)) {
|
for (let token of JSON.parse(window.localStorage.tabsRecovery)) {
|
||||||
for (let provider of this.tabRecoveryProviders) {
|
for (let provider of this.config.enabledServices(this.tabRecoveryProviders)) {
|
||||||
try {
|
try {
|
||||||
let tab = await provider.recover(token)
|
let tab = await provider.recover(token)
|
||||||
if (tab) {
|
if (tab) {
|
||||||
|
@@ -17,7 +17,7 @@ export class ThemesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findTheme (name: string): Theme {
|
findTheme (name: string): Theme {
|
||||||
return this.themes.find(x => x.name === name)
|
return this.config.enabledServices(this.themes).find(x => x.name === name)
|
||||||
}
|
}
|
||||||
|
|
||||||
findCurrentTheme (): Theme {
|
findCurrentTheme (): Theme {
|
||||||
|
15
terminus-core/src/theme.compact.scss
Normal file
15
terminus-core/src/theme.compact.scss
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
@import './theme.scss';
|
||||||
|
|
||||||
|
app-root {
|
||||||
|
.tab-bar {
|
||||||
|
height: 27px !important;
|
||||||
|
|
||||||
|
.btn-tab-bar {
|
||||||
|
line-height: 29px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
terminaltab .content {
|
||||||
|
margin: 5px !important;
|
||||||
|
}
|
||||||
|
}
|
@@ -131,6 +131,7 @@ app-root {
|
|||||||
background: $body-bg2;
|
background: $body-bg2;
|
||||||
border-left: 1px solid transparent;
|
border-left: 1px solid transparent;
|
||||||
border-right: 1px solid transparent;
|
border-right: 1px solid transparent;
|
||||||
|
border-top: 1px solid transparent;
|
||||||
|
|
||||||
.index {
|
.index {
|
||||||
color: #555;
|
color: #555;
|
||||||
@@ -159,10 +160,12 @@ app-root {
|
|||||||
|
|
||||||
tab-header {
|
tab-header {
|
||||||
border-top: 1px solid transparent;
|
border-top: 1px solid transparent;
|
||||||
|
border-bottom: 1px solid $border-color;
|
||||||
|
margin-bottom: -1px;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
border-top: 1px solid $teal;
|
border-top: 1px solid $teal;
|
||||||
margin-bottom: -1px;
|
border-bottom-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.has-activity:not(.active) {
|
&.has-activity:not(.active) {
|
||||||
@@ -176,6 +179,8 @@ app-root {
|
|||||||
|
|
||||||
tab-header {
|
tab-header {
|
||||||
border-bottom: 1px solid transparent;
|
border-bottom: 1px solid transparent;
|
||||||
|
border-top: 1px solid $border-color;
|
||||||
|
margin-top: -1px;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
border-bottom: 1px solid $teal;
|
border-bottom: 1px solid $teal;
|
||||||
|
@@ -7,3 +7,10 @@ export class StandardTheme extends Theme {
|
|||||||
css = require('./theme.scss')
|
css = require('./theme.scss')
|
||||||
terminalBackground = '#1D272D'
|
terminalBackground = '#1D272D'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class StandardCompactTheme extends Theme {
|
||||||
|
name = 'Compact'
|
||||||
|
css = require('./theme.compact.scss')
|
||||||
|
terminalBackground = '#1D272D'
|
||||||
|
}
|
||||||
|
@@ -45,6 +45,7 @@ module.exports = {
|
|||||||
'path',
|
'path',
|
||||||
'deepmerge',
|
'deepmerge',
|
||||||
'untildify',
|
'untildify',
|
||||||
|
'winston',
|
||||||
'js-yaml',
|
'js-yaml',
|
||||||
/^rxjs/,
|
/^rxjs/,
|
||||||
/^@angular/,
|
/^@angular/,
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
version "3.9.1"
|
version "3.9.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.9.1.tgz#2f3c142771bb345829ce690c5838760b6b9ba553"
|
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.9.1.tgz#2f3c142771bb345829ce690c5838760b6b9ba553"
|
||||||
|
|
||||||
"@types/node@^7.0.37":
|
"@types/node@*", "@types/node@^7.0.37":
|
||||||
version "7.0.43"
|
version "7.0.43"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
|
||||||
|
|
||||||
@@ -14,13 +14,23 @@
|
|||||||
version "1.13.1"
|
version "1.13.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.13.1.tgz#b45c222e24301bd006e3edfc762cc6b51bda236a"
|
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.13.1.tgz#b45c222e24301bd006e3edfc762cc6b51bda236a"
|
||||||
|
|
||||||
|
"@types/winston@^2.3.6":
|
||||||
|
version "2.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/winston/-/winston-2.3.6.tgz#0f0954b9e16abd40598dc6e9cc2ea43044237997"
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
argparse@^1.0.7:
|
argparse@^1.0.7:
|
||||||
version "1.0.9"
|
version "1.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
|
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
|
||||||
dependencies:
|
dependencies:
|
||||||
sprintf-js "~1.0.2"
|
sprintf-js "~1.0.2"
|
||||||
|
|
||||||
axios@^0.16.2:
|
async@~1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9"
|
||||||
|
|
||||||
|
axios@0.16.2:
|
||||||
version "0.16.2"
|
version "0.16.2"
|
||||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.16.2.tgz#ba4f92f17167dfbab40983785454b9ac149c3c6d"
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -44,10 +54,18 @@ bootstrap@4.0.0-alpha.6:
|
|||||||
jquery ">=1.9.1"
|
jquery ">=1.9.1"
|
||||||
tether "^1.4.0"
|
tether "^1.4.0"
|
||||||
|
|
||||||
|
colors@1.0.x:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
|
||||||
|
|
||||||
core-js@^2.4.1:
|
core-js@^2.4.1:
|
||||||
version "2.5.1"
|
version "2.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b"
|
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.1.tgz#ae6874dc66937789b80754ff5428df66819ca50b"
|
||||||
|
|
||||||
|
cycle@1.0.x:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2"
|
||||||
|
|
||||||
debug@^2.4.5:
|
debug@^2.4.5:
|
||||||
version "2.6.8"
|
version "2.6.8"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
|
||||||
@@ -97,6 +115,10 @@ esprima@^4.0.0:
|
|||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
|
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
|
||||||
|
|
||||||
|
eyes@0.1.x:
|
||||||
|
version "0.1.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
|
||||||
|
|
||||||
follow-redirects@^1.2.3:
|
follow-redirects@^1.2.3:
|
||||||
version "1.2.4"
|
version "1.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.4.tgz#355e8f4d16876b43f577b0d5ce2668b9723214ea"
|
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.4.tgz#355e8f4d16876b43f577b0d5ce2668b9723214ea"
|
||||||
@@ -126,6 +148,10 @@ is-buffer@^1.1.5:
|
|||||||
version "1.1.5"
|
version "1.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
|
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
|
||||||
|
|
||||||
|
isstream@0.1.x:
|
||||||
|
version "0.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
|
||||||
|
|
||||||
jquery@>=1.9.1:
|
jquery@>=1.9.1:
|
||||||
version "3.2.1"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787"
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787"
|
||||||
@@ -191,6 +217,10 @@ sprintf-js@~1.0.2:
|
|||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
|
||||||
|
|
||||||
|
stack-trace@0.0.x:
|
||||||
|
version "0.0.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0"
|
||||||
|
|
||||||
tether@^1.4.0:
|
tether@^1.4.0:
|
||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.0.tgz#0f9fa171f75bf58485d8149e94799d7ae74d1c1a"
|
resolved "https://registry.yarnpkg.com/tether/-/tether-1.4.0.tgz#0f9fa171f75bf58485d8149e94799d7ae74d1c1a"
|
||||||
@@ -209,6 +239,17 @@ uuid-1345@^0.99.6:
|
|||||||
dependencies:
|
dependencies:
|
||||||
macaddress "^0.2.7"
|
macaddress "^0.2.7"
|
||||||
|
|
||||||
|
winston@^2.4.0:
|
||||||
|
version "2.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/winston/-/winston-2.4.0.tgz#808050b93d52661ed9fb6c26b3f0c826708b0aee"
|
||||||
|
dependencies:
|
||||||
|
async "~1.0.0"
|
||||||
|
colors "1.0.x"
|
||||||
|
cycle "1.0.x"
|
||||||
|
eyes "0.1.x"
|
||||||
|
isstream "0.1.x"
|
||||||
|
stack-trace "0.0.x"
|
||||||
|
|
||||||
xelement@^1.0.16:
|
xelement@^1.0.16:
|
||||||
version "1.0.16"
|
version "1.0.16"
|
||||||
resolved "https://registry.yarnpkg.com/xelement/-/xelement-1.0.16.tgz#900bb46c20fc2dffadff778a9d2dc36699d0ff7e"
|
resolved "https://registry.yarnpkg.com/xelement/-/xelement-1.0.16.tgz#900bb46c20fc2dffadff778a9d2dc36699d0ff7e"
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-plugin-manager",
|
"name": "terminus-plugin-manager",
|
||||||
"version": "1.0.0-alpha.24",
|
"version": "1.0.0-alpha.36",
|
||||||
"description": "Terminus' plugin manager",
|
"description": "Terminus' plugin manager",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-builtin-plugin"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@@ -10,33 +10,23 @@ h3 Installed
|
|||||||
|
|
||||||
.list-group
|
.list-group
|
||||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins|orderBy:"name"')
|
ng-container(*ngFor='let plugin of pluginManager.installedPlugins|orderBy:"name"')
|
||||||
.list-group-item.flex-column.align-items-start(*ngIf='knownUpgrades[plugin.name]')
|
.list-group-item.flex-column.align-items-start
|
||||||
.d-flex.w-100
|
.d-flex.w-100
|
||||||
.mr-auto.d-flex.flex-column
|
.mr-auto.d-flex.flex-column
|
||||||
strong {{plugin.name}}
|
strong {{plugin.name}}
|
||||||
small.text-muted.mb-0 {{plugin.description}}
|
a.text-muted.mb-0((click)='showPluginInfo(plugin)')
|
||||||
|
small {{plugin.description}}
|
||||||
.d-flex.flex-column.align-items-end.mr-3
|
.d-flex.flex-column.align-items-end.mr-3
|
||||||
div {{plugin.version}}
|
div {{plugin.version}}
|
||||||
small.text-muted {{plugin.author}}
|
small.text-muted {{plugin.author}}
|
||||||
button.btn.btn-outline-primary(
|
button.btn.btn-outline-primary(
|
||||||
*ngIf='npmInstalled',
|
*ngIf='npmInstalled && knownUpgrades[plugin.name]',
|
||||||
(click)='upgradePlugin(plugin)',
|
(click)='upgradePlugin(plugin)',
|
||||||
[disabled]='busy[plugin.name] != undefined'
|
[disabled]='busy[plugin.name] != undefined'
|
||||||
)
|
)
|
||||||
i.fa.fa-fw.fa-arrow-up(*ngIf='busy[plugin.name] != BusyState.Installing')
|
i.fa.fa-fw.fa-arrow-up(*ngIf='busy[plugin.name] != BusyState.Installing')
|
||||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Installing')
|
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Installing')
|
||||||
span Upgrade ({{knownUpgrades[plugin.name].version}})
|
span Upgrade ({{knownUpgrades[plugin.name].version}})
|
||||||
|
|
||||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins|orderBy:"name"')
|
|
||||||
.list-group-item.flex-column.align-items-start(*ngIf='!knownUpgrades[plugin.name]')
|
|
||||||
.d-flex.w-100
|
|
||||||
.mr-auto.d-flex.flex-column
|
|
||||||
strong {{plugin.name}}
|
|
||||||
small.text-muted.mb-0 {{plugin.description}}
|
|
||||||
.d-flex.flex-column.align-items-end.mr-3
|
|
||||||
div {{plugin.version}}
|
|
||||||
small.text-muted {{plugin.author}}
|
|
||||||
i.fa.fa-check.text-success.ml-1(*ngIf='plugin.isOfficial', title='Official')
|
|
||||||
button.btn.btn-outline-danger(
|
button.btn.btn-outline-danger(
|
||||||
(click)='uninstallPlugin(plugin)',
|
(click)='uninstallPlugin(plugin)',
|
||||||
*ngIf='!plugin.isBuiltin && npmInstalled',
|
*ngIf='!plugin.isBuiltin && npmInstalled',
|
||||||
@@ -44,6 +34,16 @@ h3 Installed
|
|||||||
)
|
)
|
||||||
i.fa.fa-fw.fa-trash-o(*ngIf='busy[plugin.name] != BusyState.Uninstalling')
|
i.fa.fa-fw.fa-trash-o(*ngIf='busy[plugin.name] != BusyState.Uninstalling')
|
||||||
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Uninstalling')
|
i.fa.fa-fw.fa-circle-o-notch.fa-spin(*ngIf='busy[plugin.name] == BusyState.Uninstalling')
|
||||||
|
button.btn.btn-outline-danger(
|
||||||
|
*ngIf='config.store.pluginBlacklist.includes(plugin.name)',
|
||||||
|
(click)='enablePlugin(plugin)'
|
||||||
|
)
|
||||||
|
i.fa.fa-fw.fa-play
|
||||||
|
button.btn.btn-outline-primary(
|
||||||
|
*ngIf='!config.store.pluginBlacklist.includes(plugin.name)',
|
||||||
|
(click)='disablePlugin(plugin)'
|
||||||
|
)
|
||||||
|
i.fa.fa-fw.fa-pause
|
||||||
|
|
||||||
.text-center.mt-5(*ngIf='npmMissing')
|
.text-center.mt-5(*ngIf='npmMissing')
|
||||||
h4 npm not installed
|
h4 npm not installed
|
||||||
@@ -77,7 +77,8 @@ div(*ngIf='npmInstalled')
|
|||||||
.d-flex.w-100
|
.d-flex.w-100
|
||||||
.mr-auto.d-flex.flex-column
|
.mr-auto.d-flex.flex-column
|
||||||
strong {{plugin.name}}
|
strong {{plugin.name}}
|
||||||
small.text-muted.mb-0 {{plugin.description}}
|
a.text-muted.mb-0((click)='showPluginInfo(plugin)')
|
||||||
|
small {{plugin.description}}
|
||||||
.d-flex.flex-column.align-items-end.mr-3
|
.d-flex.flex-column.align-items-end.mr-3
|
||||||
div {{plugin.version}}
|
div {{plugin.version}}
|
||||||
small.text-muted {{plugin.author}}
|
small.text-muted {{plugin.author}}
|
||||||
|
@@ -2,7 +2,7 @@ import { BehaviorSubject, Observable } from 'rxjs'
|
|||||||
import * as semver from 'semver'
|
import * as semver from 'semver'
|
||||||
|
|
||||||
import { Component, Input } from '@angular/core'
|
import { Component, Input } from '@angular/core'
|
||||||
import { ConfigService, HostAppService } from 'terminus-core'
|
import { ConfigService, HostAppService, ElectronService } from 'terminus-core'
|
||||||
import { IPluginInfo, PluginManagerService } from '../services/pluginManager.service'
|
import { IPluginInfo, PluginManagerService } from '../services/pluginManager.service'
|
||||||
|
|
||||||
enum BusyState { Installing, Uninstalling }
|
enum BusyState { Installing, Uninstalling }
|
||||||
@@ -24,6 +24,7 @@ export class PluginsSettingsTabComponent {
|
|||||||
@Input() npmMissing = false
|
@Input() npmMissing = false
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
private electron: ElectronService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
private hostApp: HostAppService,
|
private hostApp: HostAppService,
|
||||||
public pluginManager: PluginManagerService
|
public pluginManager: PluginManagerService
|
||||||
@@ -100,4 +101,20 @@ export class PluginsSettingsTabComponent {
|
|||||||
async upgradePlugin (plugin: IPluginInfo): Promise<void> {
|
async upgradePlugin (plugin: IPluginInfo): Promise<void> {
|
||||||
return this.installPlugin(this.knownUpgrades[plugin.name])
|
return this.installPlugin(this.knownUpgrades[plugin.name])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showPluginInfo (plugin: IPluginInfo) {
|
||||||
|
this.electron.shell.openExternal('https://www.npmjs.com/package/' + plugin.packageName)
|
||||||
|
}
|
||||||
|
|
||||||
|
enablePlugin (plugin: IPluginInfo) {
|
||||||
|
this.config.store.pluginBlacklist = this.config.store.pluginBlacklist.filter(x => x !== plugin.name)
|
||||||
|
this.config.save()
|
||||||
|
this.config.requestRestart()
|
||||||
|
}
|
||||||
|
|
||||||
|
disablePlugin (plugin: IPluginInfo) {
|
||||||
|
this.config.store.pluginBlacklist.push(plugin.name)
|
||||||
|
this.config.save()
|
||||||
|
this.config.requestRestart()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,6 @@ export class PluginManagerService {
|
|||||||
.fromPromise(
|
.fromPromise(
|
||||||
axios.get(`https://www.npmjs.com/-/search?text=keywords:${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`)
|
axios.get(`https://www.npmjs.com/-/search?text=keywords:${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`)
|
||||||
)
|
)
|
||||||
.do(response => console.log(response.data.objects))
|
|
||||||
.map(response => response.data.objects.map(item => ({
|
.map(response => response.data.objects.map(item => ({
|
||||||
name: item.package.name.substring(NAME_PREFIX.length),
|
name: item.package.name.substring(NAME_PREFIX.length),
|
||||||
packageName: item.package.name,
|
packageName: item.package.name,
|
||||||
@@ -85,8 +84,7 @@ export class PluginManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async installPlugin (plugin: IPluginInfo) {
|
async installPlugin (plugin: IPluginInfo) {
|
||||||
let result = await exec(`${this.npmPath} --prefix "${this.userPluginsPath}" install ${plugin.packageName}@${plugin.version}`)
|
await exec(`${this.npmPath} --prefix "${this.userPluginsPath}" install ${plugin.packageName}@${plugin.version}`)
|
||||||
console.log(result)
|
|
||||||
this.installedPlugins = this.installedPlugins.filter(x => x.packageName !== plugin.packageName)
|
this.installedPlugins = this.installedPlugins.filter(x => x.packageName !== plugin.packageName)
|
||||||
this.installedPlugins.push(plugin)
|
this.installedPlugins.push(plugin)
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SettingsTabProvider, ComponentType } from 'terminus-settings'
|
import { SettingsTabProvider } from 'terminus-settings'
|
||||||
|
|
||||||
import { PluginsSettingsTabComponent } from './components/pluginsSettingsTab.component'
|
import { PluginsSettingsTabComponent } from './components/pluginsSettingsTab.component'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PluginsSettingsTabProvider extends SettingsTabProvider {
|
export class PluginsSettingsTabProvider extends SettingsTabProvider {
|
||||||
|
id = 'plugins'
|
||||||
title = 'Plugins'
|
title = 'Plugins'
|
||||||
|
|
||||||
getComponentType (): ComponentType {
|
getComponentType (): any {
|
||||||
return PluginsSettingsTabComponent
|
return PluginsSettingsTabComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,6 @@ module.exports = {
|
|||||||
'fs',
|
'fs',
|
||||||
'font-manager',
|
'font-manager',
|
||||||
'path',
|
'path',
|
||||||
'node-pty',
|
|
||||||
'mz/fs',
|
'mz/fs',
|
||||||
'mz/child_process',
|
'mz/child_process',
|
||||||
'winreg',
|
'winreg',
|
||||||
|
@@ -8,11 +8,7 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/node@*":
|
"@types/node@*", "@types/node@7.0.12":
|
||||||
version "8.0.28"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.28.tgz#86206716f8d9251cf41692e384264cbd7058ad60"
|
|
||||||
|
|
||||||
"@types/node@7.0.12":
|
|
||||||
version "7.0.12"
|
version "7.0.12"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.12.tgz#ae5f67a19c15f752148004db07cbbb372e69efc9"
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-settings",
|
"name": "terminus-settings",
|
||||||
"version": "1.0.0-alpha.24",
|
"version": "1.0.0-alpha.36",
|
||||||
"description": "Terminus terminal settings page",
|
"description": "Terminus terminal settings page",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-builtin-plugin"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
import { Component } from '@angular/core'
|
|
||||||
|
|
||||||
export declare type ComponentType = new (...args: any[]) => Component
|
|
||||||
|
|
||||||
export abstract class SettingsTabProvider {
|
export abstract class SettingsTabProvider {
|
||||||
|
id: string
|
||||||
title: string
|
title: string
|
||||||
|
|
||||||
getComponentType (): ComponentType {
|
getComponentType (): any {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
button.btn.btn-outline-warning.btn-block(*ngIf='config.restartRequested', '(click)'='restartApp()') Restart the app to apply changes
|
button.btn.btn-outline-warning.btn-block(*ngIf='config.restartRequested', '(click)'='restartApp()') Restart the app to apply changes
|
||||||
|
|
||||||
ngb-tabset.vertical(type='tabs')
|
ngb-tabset.vertical(type='tabs', [activeId]='activeTab')
|
||||||
ngb-tab
|
ngb-tab(id='application')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
| Application
|
| Application
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
@@ -18,20 +18,22 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
.form-group
|
.form-group
|
||||||
label Show tabs
|
label Show tabs
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
'[(ngModel)]'='config.store.appearance.tabsLocation',
|
'[(ngModel)]'='config.store.appearance.tabsLocation',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"top"'
|
[value]='"top"'
|
||||||
)
|
)
|
||||||
| On the top
|
| On the top
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"bottom"'
|
[value]='"bottom"'
|
||||||
)
|
)
|
||||||
| At the bottom
|
| At the bottom
|
||||||
@@ -39,26 +41,29 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
.form-group
|
.form-group
|
||||||
label Window frame
|
label Window frame
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
'[(ngModel)]'='config.store.appearance.frame'
|
'[(ngModel)]'='config.store.appearance.frame'
|
||||||
'(ngModelChange)'='config.save(); config.requestRestart()'
|
'(ngModelChange)'='config.save(); config.requestRestart()'
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"native"'
|
[value]='"native"'
|
||||||
)
|
)
|
||||||
| Native
|
| Native
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"thin"'
|
[value]='"thin"'
|
||||||
)
|
)
|
||||||
| Thin
|
| Thin
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"full"'
|
[value]='"full"'
|
||||||
)
|
)
|
||||||
| Full
|
| Full
|
||||||
@@ -69,38 +74,43 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
.form-group
|
.form-group
|
||||||
label Dock the terminal
|
label Dock the terminal
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
'[(ngModel)]'='config.store.appearance.dock'
|
'[(ngModel)]'='config.store.appearance.dock'
|
||||||
'(ngModelChange)'='config.save(); docking.dock()'
|
'(ngModelChange)'='config.save(); docking.dock()'
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"off"'
|
[value]='"off"'
|
||||||
)
|
)
|
||||||
| Off
|
| Off
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"top"'
|
[value]='"top"'
|
||||||
)
|
)
|
||||||
| Top
|
| Top
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"left"'
|
[value]='"left"'
|
||||||
)
|
)
|
||||||
| Left
|
| Left
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"right"'
|
[value]='"right"'
|
||||||
)
|
)
|
||||||
| Right
|
| Right
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"bottom"'
|
[value]='"bottom"'
|
||||||
)
|
)
|
||||||
| Bottom
|
| Bottom
|
||||||
@@ -113,15 +123,17 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
(ngModelChange)='config.save(); docking.dock()',
|
(ngModelChange)='config.save(); docking.dock()',
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
value='current'
|
value='current'
|
||||||
)
|
)
|
||||||
| Current
|
| Current
|
||||||
label.btn.btn-secondary(*ngFor='let screen of screens')
|
label.btn.btn-secondary(*ngFor='let screen of screens', ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='screen.id'
|
[value]='screen.id'
|
||||||
)
|
)
|
||||||
| {{screen.name}}
|
| {{screen.name}}
|
||||||
@@ -152,7 +164,7 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
'(ngModelChange)'='config.save()',
|
'(ngModelChange)'='config.save()',
|
||||||
)
|
)
|
||||||
|
|
||||||
ngb-tab
|
ngb-tab(id='hotkeys')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
| Hotkeys
|
| Hotkeys
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
@@ -172,7 +184,7 @@ ngb-tabset.vertical(type='tabs')
|
|||||||
'(modelChange)'='config.save(); docking.dock()'
|
'(modelChange)'='config.save(); docking.dock()'
|
||||||
)
|
)
|
||||||
|
|
||||||
ngb-tab(*ngFor='let provider of settingsProviders')
|
ngb-tab(*ngFor='let provider of settingsProviders', [id]='provider.id')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
| {{provider.title}}
|
| {{provider.title}}
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { Component, Inject } from '@angular/core'
|
import { Component, Inject, Input } from '@angular/core'
|
||||||
import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService } from 'terminus-core'
|
import { ElectronService, DockingService, ConfigService, IHotkeyDescription, HotkeyProvider, BaseTabComponent, Theme, HostAppService } from 'terminus-core'
|
||||||
|
|
||||||
import { SettingsTabProvider } from '../api'
|
import { SettingsTabProvider } from '../api'
|
||||||
@@ -12,6 +12,7 @@ import { SettingsTabProvider } from '../api'
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SettingsTabComponent extends BaseTabComponent {
|
export class SettingsTabComponent extends BaseTabComponent {
|
||||||
|
@Input() activeTab: string
|
||||||
hotkeyFilter = ''
|
hotkeyFilter = ''
|
||||||
private hotkeyDescriptions: IHotkeyDescription[]
|
private hotkeyDescriptions: IHotkeyDescription[]
|
||||||
private screens
|
private screens
|
||||||
@@ -26,10 +27,12 @@ export class SettingsTabComponent extends BaseTabComponent {
|
|||||||
@Inject(Theme) public themes: Theme[],
|
@Inject(Theme) public themes: Theme[],
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
this.hotkeyDescriptions = hotkeyProviders.map(x => x.hotkeys).reduce((a, b) => a.concat(b))
|
this.hotkeyDescriptions = config.enabledServices(hotkeyProviders).map(x => x.hotkeys).reduce((a, b) => a.concat(b))
|
||||||
this.title = 'Settings'
|
this.title = 'Settings'
|
||||||
this.scrollable = true
|
this.scrollable = true
|
||||||
this.screens = this.docking.getScreens()
|
this.screens = this.docking.getScreens()
|
||||||
|
this.settingsProviders = config.enabledServices(this.settingsProviders)
|
||||||
|
this.themes = config.enabledServices(this.themes)
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecoveryToken (): any {
|
getRecoveryToken (): any {
|
||||||
|
@@ -40,3 +40,4 @@ export default class SettingsModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export * from './api'
|
export * from './api'
|
||||||
|
export { SettingsTabComponent }
|
||||||
|
@@ -39,7 +39,6 @@ module.exports = {
|
|||||||
externals: [
|
externals: [
|
||||||
'fs',
|
'fs',
|
||||||
'path',
|
'path',
|
||||||
'node-pty',
|
|
||||||
/^rxjs/,
|
/^rxjs/,
|
||||||
/^@angular/,
|
/^@angular/,
|
||||||
/^@ng-bootstrap/,
|
/^@ng-bootstrap/,
|
||||||
|
47
terminus-ssh/package.json
Normal file
47
terminus-ssh/package.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "terminus-ssh",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "SSH connection manager for Terminus",
|
||||||
|
"keywords": [
|
||||||
|
"terminus-builtin-plugin"
|
||||||
|
],
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "webpack --progress --color",
|
||||||
|
"watch": "webpack --progress --color --watch"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"author": "Eugene Pankov",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/ssh2": "^0.5.35",
|
||||||
|
"@types/webpack-env": "^1.13.0",
|
||||||
|
"apply-loader": "^2.0.0",
|
||||||
|
"awesome-typescript-loader": "^3.1.2",
|
||||||
|
"electron": "^1.6.11",
|
||||||
|
"pug": "^2.0.0-rc.3",
|
||||||
|
"pug-loader": "^2.3.0",
|
||||||
|
"rxjs": "^5.4.0",
|
||||||
|
"typescript": "^2.2.2",
|
||||||
|
"webpack": "^2.3.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@angular/common": "^4.1.3",
|
||||||
|
"@angular/core": "^4.1.3",
|
||||||
|
"@angular/forms": "^4.1.3",
|
||||||
|
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.29",
|
||||||
|
"terminus-core": "*",
|
||||||
|
"terminus-settings": "*",
|
||||||
|
"terminus-terminal": "*"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"wincredmgr": "^2.0.0",
|
||||||
|
"xkeychain": "^0.0.6"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ssh2": "^0.5.5"
|
||||||
|
}
|
||||||
|
}
|
51
terminus-ssh/src/api.ts
Normal file
51
terminus-ssh/src/api.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { BaseSession } from 'terminus-terminal'
|
||||||
|
|
||||||
|
export interface SSHConnection {
|
||||||
|
name?: string
|
||||||
|
host: string
|
||||||
|
user: string
|
||||||
|
password?: string
|
||||||
|
privateKey?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SSHSession extends BaseSession {
|
||||||
|
constructor (private shell: any) {
|
||||||
|
super()
|
||||||
|
|
||||||
|
this.open = true
|
||||||
|
|
||||||
|
this.shell.on('data', data => {
|
||||||
|
this.emitOutput(data.toString())
|
||||||
|
})
|
||||||
|
|
||||||
|
this.shell.on('end', () => {
|
||||||
|
if (this.open) {
|
||||||
|
this.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
resize (columns, rows) {
|
||||||
|
this.shell.setWindow(rows, columns)
|
||||||
|
}
|
||||||
|
|
||||||
|
write (data) {
|
||||||
|
this.shell.write(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
kill (signal?: string) {
|
||||||
|
this.shell.signal(signal || 'TERM')
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChildProcesses (): Promise<any[]> {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
async gracefullyKillProcess (): Promise<void> {
|
||||||
|
this.kill('TERM')
|
||||||
|
}
|
||||||
|
|
||||||
|
async getWorkingDirectory (): Promise<string> {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
37
terminus-ssh/src/buttonProvider.ts
Normal file
37
terminus-ssh/src/buttonProvider.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { HotkeysService, ToolbarButtonProvider, IToolbarButton } from 'terminus-core'
|
||||||
|
import { SSHModalComponent } from './components/sshModal.component'
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ButtonProvider extends ToolbarButtonProvider {
|
||||||
|
constructor (
|
||||||
|
private ngbModal: NgbModal,
|
||||||
|
hotkeys: HotkeysService,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
hotkeys.matchedHotkey.subscribe(async (hotkey) => {
|
||||||
|
if (hotkey === 'ssh') {
|
||||||
|
this.activate()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
activate () {
|
||||||
|
let modal = this.ngbModal.open(SSHModalComponent)
|
||||||
|
modal.result.then(() => {
|
||||||
|
//this.terminal.openTab(shell)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
provide (): IToolbarButton[] {
|
||||||
|
return [{
|
||||||
|
icon: 'globe',
|
||||||
|
weight: 5,
|
||||||
|
title: 'SSH connections',
|
||||||
|
click: async () => {
|
||||||
|
this.activate()
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
.modal-body
|
||||||
|
.form-group
|
||||||
|
label Name
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='connection.name',
|
||||||
|
)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Host
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='connection.host',
|
||||||
|
)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Username
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='connection.user',
|
||||||
|
)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Private key
|
||||||
|
.input-group
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
placeholder='Key file path',
|
||||||
|
[(ngModel)]='connection.privateKey'
|
||||||
|
)
|
||||||
|
.input-group-btn
|
||||||
|
button.btn.btn-secondary((click)='selectPrivateKey()')
|
||||||
|
i.fa.fa-folder-open
|
||||||
|
|
||||||
|
.modal-footer
|
||||||
|
button.btn.btn-outline-primary((click)='save()') Save
|
||||||
|
button.btn.btn-outline-danger((click)='cancel()') Cancel
|
38
terminus-ssh/src/components/editConnectionModal.component.ts
Normal file
38
terminus-ssh/src/components/editConnectionModal.component.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { ElectronService, HostAppService } from 'terminus-core'
|
||||||
|
import { SSHConnection } from '../api'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: require('./editConnectionModal.component.pug'),
|
||||||
|
})
|
||||||
|
export class EditConnectionModalComponent {
|
||||||
|
connection: SSHConnection
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private modalInstance: NgbActiveModal,
|
||||||
|
private electron: ElectronService,
|
||||||
|
private hostApp: HostAppService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
selectPrivateKey () {
|
||||||
|
let path = this.electron.dialog.showOpenDialog(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
title: 'Select private key',
|
||||||
|
properties: ['openDirectory']
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (path) {
|
||||||
|
this.connection.privateKey = path[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
save () {
|
||||||
|
this.modalInstance.close(this.connection)
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel () {
|
||||||
|
this.modalInstance.dismiss()
|
||||||
|
}
|
||||||
|
}
|
9
terminus-ssh/src/components/promptModal.component.pug
Normal file
9
terminus-ssh/src/components/promptModal.component.pug
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
.modal-body
|
||||||
|
input.form-control(
|
||||||
|
[type]='password ? "password" : "text"',
|
||||||
|
[(ngModel)]='value',
|
||||||
|
#input,
|
||||||
|
[placeholder]='prompt',
|
||||||
|
(keyup.enter)='ok()',
|
||||||
|
(keyup.esc)='cancel()',
|
||||||
|
)
|
27
terminus-ssh/src/components/promptModal.component.ts
Normal file
27
terminus-ssh/src/components/promptModal.component.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Component, Input, ViewChild, ElementRef } from '@angular/core'
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: require('./promptModal.component.pug'),
|
||||||
|
})
|
||||||
|
export class PromptModalComponent {
|
||||||
|
@Input() value: string
|
||||||
|
@Input() password: boolean
|
||||||
|
@ViewChild('input') input: ElementRef
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
private modalInstance: NgbActiveModal,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
ngOnInit () {
|
||||||
|
this.input.nativeElement.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
ok () {
|
||||||
|
this.modalInstance.close(this.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel () {
|
||||||
|
this.modalInstance.close('')
|
||||||
|
}
|
||||||
|
}
|
24
terminus-ssh/src/components/sshModal.component.pug
Normal file
24
terminus-ssh/src/components/sshModal.component.pug
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
.modal-body
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='quickTarget',
|
||||||
|
autofocus,
|
||||||
|
placeholder='Quick connect: [user@]host',
|
||||||
|
(keyup.enter)='quickConnect()'
|
||||||
|
)
|
||||||
|
|
||||||
|
.list-group.mt-3(*ngIf='lastConnection')
|
||||||
|
a.list-group-item.list-group-item-action((click)='connect(lastConnection)')
|
||||||
|
i.fa.fa-fw.fa-history
|
||||||
|
span {{lastConnection.name}}
|
||||||
|
|
||||||
|
.list-group.mt-3
|
||||||
|
a.list-group-item.list-group-item-action(*ngFor='let connection of connections', (click)='connect(connection)')
|
||||||
|
i.fa.fa-fw.fa-globe
|
||||||
|
span {{connection.name}}
|
||||||
|
a.list-group-item.list-group-item-action((click)='manageConnections()')
|
||||||
|
i.fa.fa-fw.fa-wrench
|
||||||
|
span Manage connections
|
||||||
|
|
||||||
|
//.modal-footer
|
||||||
|
button.btn.btn-outline-primary((click)='close()') Cancel
|
60
terminus-ssh/src/components/sshModal.component.ts
Normal file
60
terminus-ssh/src/components/sshModal.component.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { ConfigService, AppService } from 'terminus-core'
|
||||||
|
import { SettingsTabComponent } from 'terminus-settings'
|
||||||
|
import { SSHService } from '../services/ssh.service'
|
||||||
|
import { SSHConnection } from '../api'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: require('./sshModal.component.pug'),
|
||||||
|
//styles: [require('./sshModal.component.scss')],
|
||||||
|
})
|
||||||
|
export class SSHModalComponent {
|
||||||
|
connections: SSHConnection[]
|
||||||
|
quickTarget: string
|
||||||
|
lastConnection: SSHConnection
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
public modalInstance: NgbActiveModal,
|
||||||
|
private config: ConfigService,
|
||||||
|
private ssh: SSHService,
|
||||||
|
private app: AppService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
ngOnInit () {
|
||||||
|
this.connections = this.config.store.ssh.connections
|
||||||
|
if (window.localStorage.lastConnection) {
|
||||||
|
this.lastConnection = JSON.parse(window.localStorage.lastConnection)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
quickConnect () {
|
||||||
|
let user = 'root'
|
||||||
|
let host = this.quickTarget
|
||||||
|
if (host.includes('@')) {
|
||||||
|
[user, host] = host.split('@')
|
||||||
|
}
|
||||||
|
let connection: SSHConnection = {
|
||||||
|
name: this.quickTarget,
|
||||||
|
host, user,
|
||||||
|
}
|
||||||
|
window.localStorage.lastConnection = JSON.stringify(connection)
|
||||||
|
this.connect(connection)
|
||||||
|
}
|
||||||
|
|
||||||
|
connect (connection: SSHConnection) {
|
||||||
|
this.close()
|
||||||
|
this.ssh.connect(connection).catch(error => {
|
||||||
|
alert(`Could not connect: ${error}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
manageConnections () {
|
||||||
|
this.close()
|
||||||
|
this.app.openNewTab(SettingsTabComponent, { activeTab: 'ssh' })
|
||||||
|
}
|
||||||
|
|
||||||
|
close () {
|
||||||
|
this.modalInstance.close()
|
||||||
|
}
|
||||||
|
}
|
15
terminus-ssh/src/components/sshSettingsTab.component.pug
Normal file
15
terminus-ssh/src/components/sshSettingsTab.component.pug
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
h3 Connections
|
||||||
|
|
||||||
|
.list-group.mt-3.mb-3
|
||||||
|
.list-group-item(*ngFor='let connection of connections')
|
||||||
|
.d-flex.w-100
|
||||||
|
.mr-auto
|
||||||
|
div
|
||||||
|
span {{connection.name}}
|
||||||
|
.text-muted {{connection.host}}
|
||||||
|
button.btn.btn-outline-info.ml-2((click)='editConnection(connection)')
|
||||||
|
i.fa.fa-pencil
|
||||||
|
button.btn.btn-outline-danger.ml-1((click)='deleteConnection(connection)')
|
||||||
|
i.fa.fa-trash-o
|
||||||
|
|
||||||
|
button.btn.btn-outline-primary((click)='createConnection()') Add connection
|
51
terminus-ssh/src/components/sshSettingsTab.component.ts
Normal file
51
terminus-ssh/src/components/sshSettingsTab.component.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { Component } from '@angular/core'
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { ConfigService } from 'terminus-core'
|
||||||
|
import { SSHConnection } from '../api'
|
||||||
|
import { EditConnectionModalComponent } from './editConnectionModal.component'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
template: require('./sshSettingsTab.component.pug'),
|
||||||
|
})
|
||||||
|
export class SSHSettingsTabComponent {
|
||||||
|
connections: SSHConnection[]
|
||||||
|
|
||||||
|
constructor (
|
||||||
|
public config: ConfigService,
|
||||||
|
private ngbModal: NgbModal,
|
||||||
|
) {
|
||||||
|
this.connections = this.config.store.ssh.connections
|
||||||
|
}
|
||||||
|
|
||||||
|
createConnection () {
|
||||||
|
let connection: SSHConnection = {
|
||||||
|
name: '',
|
||||||
|
host: '',
|
||||||
|
user: 'root',
|
||||||
|
}
|
||||||
|
let modal = this.ngbModal.open(EditConnectionModalComponent)
|
||||||
|
modal.componentInstance.connection = connection
|
||||||
|
modal.result.then(result => {
|
||||||
|
this.connections.push(result)
|
||||||
|
this.config.store.ssh.connections = this.connections
|
||||||
|
this.config.save()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
editConnection (connection: SSHConnection) {
|
||||||
|
let modal = this.ngbModal.open(EditConnectionModalComponent)
|
||||||
|
modal.componentInstance.connection = Object.assign({}, connection)
|
||||||
|
modal.result.then(result => {
|
||||||
|
Object.assign(connection, result)
|
||||||
|
this.config.save()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteConnection (connection: SSHConnection) {
|
||||||
|
if (confirm(`Delete "${connection.name}"?`)) {
|
||||||
|
this.connections = this.connections.filter(x => x !== connection)
|
||||||
|
this.config.store.ssh.connections = this.connections
|
||||||
|
this.config.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
terminus-ssh/src/config.ts
Normal file
18
terminus-ssh/src/config.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { ConfigProvider } from 'terminus-core'
|
||||||
|
|
||||||
|
export class SSHConfigProvider extends ConfigProvider {
|
||||||
|
defaults = {
|
||||||
|
ssh: {
|
||||||
|
connections: [],
|
||||||
|
options: {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hotkeys: {
|
||||||
|
'ssh': [
|
||||||
|
'Alt-S',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
platformDefaults = { }
|
||||||
|
}
|
43
terminus-ssh/src/index.ts
Normal file
43
terminus-ssh/src/index.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { NgModule } from '@angular/core'
|
||||||
|
import { CommonModule } from '@angular/common'
|
||||||
|
import { FormsModule } from '@angular/forms'
|
||||||
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { ToolbarButtonProvider, ConfigProvider } from 'terminus-core'
|
||||||
|
import { SettingsTabProvider } from 'terminus-settings'
|
||||||
|
|
||||||
|
import { EditConnectionModalComponent } from './components/editConnectionModal.component'
|
||||||
|
import { SSHModalComponent } from './components/sshModal.component'
|
||||||
|
import { PromptModalComponent } from './components/promptModal.component'
|
||||||
|
import { SSHSettingsTabComponent } from './components/sshSettingsTab.component'
|
||||||
|
import { SSHService } from './services/ssh.service'
|
||||||
|
|
||||||
|
import { ButtonProvider } from './buttonProvider'
|
||||||
|
import { SSHConfigProvider } from './config'
|
||||||
|
import { SSHSettingsTabProvider } from './settings'
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
NgbModule,
|
||||||
|
CommonModule,
|
||||||
|
FormsModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
SSHService,
|
||||||
|
{ provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true },
|
||||||
|
{ provide: ConfigProvider, useClass: SSHConfigProvider, multi: true },
|
||||||
|
{ provide: SettingsTabProvider, useClass: SSHSettingsTabProvider, multi: true },
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
EditConnectionModalComponent,
|
||||||
|
PromptModalComponent,
|
||||||
|
SSHModalComponent,
|
||||||
|
SSHSettingsTabComponent,
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
EditConnectionModalComponent,
|
||||||
|
PromptModalComponent,
|
||||||
|
SSHModalComponent,
|
||||||
|
SSHSettingsTabComponent,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export default class SSHModule { }
|
176
terminus-ssh/src/services/ssh.service.ts
Normal file
176
terminus-ssh/src/services/ssh.service.ts
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
import { Injectable, NgZone } from '@angular/core'
|
||||||
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
import { Client } from 'ssh2'
|
||||||
|
import * as fs from 'mz/fs'
|
||||||
|
import { AppService } from 'terminus-core'
|
||||||
|
import { TerminalTabComponent } from 'terminus-terminal'
|
||||||
|
import { SSHConnection, SSHSession } from '../api'
|
||||||
|
import { PromptModalComponent } from '../components/promptModal.component'
|
||||||
|
|
||||||
|
const { SSH2Stream } = require('ssh2-streams')
|
||||||
|
|
||||||
|
let xkeychain
|
||||||
|
let wincredmgr
|
||||||
|
try {
|
||||||
|
console.log(1)
|
||||||
|
xkeychain = require('xkeychain')
|
||||||
|
} catch (error) {
|
||||||
|
try {
|
||||||
|
wincredmgr = require('wincredmgr')
|
||||||
|
} catch (error2) {
|
||||||
|
console.warn('No keychain manager available')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SSHService {
|
||||||
|
constructor (
|
||||||
|
private app: AppService,
|
||||||
|
private zone: NgZone,
|
||||||
|
private ngbModal: NgbModal,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
savePassword (connection: SSHConnection, password: string) {
|
||||||
|
if (xkeychain) {
|
||||||
|
xkeychain.setPassword({
|
||||||
|
account: connection.user,
|
||||||
|
service: `ssh@${connection.host}`,
|
||||||
|
password
|
||||||
|
}, () => null)
|
||||||
|
} else {
|
||||||
|
wincredmgr.WriteCredentials(
|
||||||
|
'user',
|
||||||
|
password,
|
||||||
|
`ssh:${connection.user}@${connection.host}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deletePassword (connection: SSHConnection) {
|
||||||
|
if (xkeychain) {
|
||||||
|
xkeychain.deletePassword({
|
||||||
|
account: connection.user,
|
||||||
|
service: `ssh@${connection.host}`,
|
||||||
|
}, () => null)
|
||||||
|
} else {
|
||||||
|
wincredmgr.DeleteCredentials(
|
||||||
|
`ssh:${connection.user}@${connection.host}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadPassword (connection: SSHConnection): Promise<string> {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (xkeychain) {
|
||||||
|
xkeychain.getPassword({
|
||||||
|
account: connection.user,
|
||||||
|
service: `ssh@${connection.host}`,
|
||||||
|
}, (_, result) => resolve(result))
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
resolve(wincredmgr.ReadCredentials(`ssh:${connection.user}@${connection.host}`).password)
|
||||||
|
} catch (error) {
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async connect (connection: SSHConnection): Promise<TerminalTabComponent> {
|
||||||
|
let privateKey: string = null
|
||||||
|
if (connection.privateKey) {
|
||||||
|
try {
|
||||||
|
privateKey = (await fs.readFile(connection.privateKey)).toString()
|
||||||
|
} catch (error) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
let ssh = new Client()
|
||||||
|
let connected = false
|
||||||
|
let savedPassword: string = null
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
ssh.on('ready', () => {
|
||||||
|
connected = true
|
||||||
|
this.savePassword(connection, savedPassword)
|
||||||
|
this.zone.run(resolve)
|
||||||
|
})
|
||||||
|
ssh.on('error', error => {
|
||||||
|
this.deletePassword(connection)
|
||||||
|
this.zone.run(() => {
|
||||||
|
if (connected) {
|
||||||
|
alert(`SSH error: ${error}`)
|
||||||
|
} else {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
ssh.on('keyboard-interactive', (name, instructions, instructionsLang, prompts, finish) => this.zone.run(async () => {
|
||||||
|
console.log(name, instructions, instructionsLang)
|
||||||
|
let results = []
|
||||||
|
for (let prompt of prompts) {
|
||||||
|
let modal = this.ngbModal.open(PromptModalComponent)
|
||||||
|
modal.componentInstance.prompt = prompt.prompt
|
||||||
|
modal.componentInstance.password = !prompt.echo
|
||||||
|
results.push(await modal.result)
|
||||||
|
}
|
||||||
|
finish(results)
|
||||||
|
}))
|
||||||
|
ssh.connect({
|
||||||
|
host: connection.host,
|
||||||
|
username: connection.user,
|
||||||
|
password: privateKey ? undefined : '',
|
||||||
|
privateKey,
|
||||||
|
tryKeyboard: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
let keychainPasswordUsed = false
|
||||||
|
|
||||||
|
;(ssh as any).config.password = () => this.zone.run(async () => {
|
||||||
|
if (connection.password) {
|
||||||
|
return connection.password
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keychainPasswordUsed && (wincredmgr || xkeychain.isSupported())) {
|
||||||
|
let password = await this.loadPassword(connection)
|
||||||
|
if (password) {
|
||||||
|
keychainPasswordUsed = true
|
||||||
|
return password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let modal = this.ngbModal.open(PromptModalComponent)
|
||||||
|
modal.componentInstance.prompt = `Password for ${connection.user}@${connection.host}`
|
||||||
|
modal.componentInstance.password = true
|
||||||
|
savedPassword = await modal.result
|
||||||
|
return savedPassword
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
let shell = await new Promise((resolve, reject) => {
|
||||||
|
ssh.shell({ term: 'xterm-256color' }, (err, shell) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err)
|
||||||
|
} else {
|
||||||
|
resolve(shell)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
let session = new SSHSession(shell)
|
||||||
|
|
||||||
|
return this.zone.run(() => this.app.openNewTab(
|
||||||
|
TerminalTabComponent,
|
||||||
|
{ session, sessionOptions: {} }
|
||||||
|
) as TerminalTabComponent)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _authPassword = SSH2Stream.prototype.authPassword
|
||||||
|
SSH2Stream.prototype.authPassword = async function (username, passwordFn) {
|
||||||
|
_authPassword.bind(this)(username, await passwordFn())
|
||||||
|
}
|
14
terminus-ssh/src/settings.ts
Normal file
14
terminus-ssh/src/settings.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { SettingsTabProvider } from 'terminus-settings'
|
||||||
|
|
||||||
|
import { SSHSettingsTabComponent } from './components/sshSettingsTab.component'
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class SSHSettingsTabProvider extends SettingsTabProvider {
|
||||||
|
id = 'ssh'
|
||||||
|
title = 'SSH'
|
||||||
|
|
||||||
|
getComponentType (): any {
|
||||||
|
return SSHSettingsTabComponent
|
||||||
|
}
|
||||||
|
}
|
12
terminus-ssh/tsconfig.json
Normal file
12
terminus-ssh/tsconfig.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": "src",
|
||||||
|
"declarationDir": "dist",
|
||||||
|
"paths": {
|
||||||
|
"terminus-*": ["terminus-*"],
|
||||||
|
"*": ["app/node_modules/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
terminus-ssh/webpack.config.js
Normal file
47
terminus-ssh/webpack.config.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
target: 'node',
|
||||||
|
entry: 'src/index.ts',
|
||||||
|
devtool: 'source-map',
|
||||||
|
context: __dirname,
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
filename: 'index.js',
|
||||||
|
pathinfo: true,
|
||||||
|
libraryTarget: 'umd',
|
||||||
|
devtoolModuleFilenameTemplate: 'webpack-terminus-ssh:///[resource-path]',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
modules: ['.', 'src', 'node_modules', '../app/node_modules'].map(x => path.join(__dirname, x)),
|
||||||
|
extensions: ['.ts', '.js'],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
loader: 'awesome-typescript-loader',
|
||||||
|
query: {
|
||||||
|
configFileName: path.resolve(__dirname, 'tsconfig.json'),
|
||||||
|
typeRoots: [path.resolve(__dirname, 'node_modules/@types')],
|
||||||
|
paths: {
|
||||||
|
"terminus-*": [path.resolve(__dirname, '../terminus-*')],
|
||||||
|
"*": [path.resolve(__dirname, '../app/node_modules/*')],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ test: /\.pug$/, use: ['apply-loader', 'pug-loader'] },
|
||||||
|
{ test: /\.scss$/, use: ['to-string-loader', 'css-loader', 'sass-loader'] },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
externals: [
|
||||||
|
'fs',
|
||||||
|
'node-ssh',
|
||||||
|
'xkeychain',
|
||||||
|
'wincredmgr',
|
||||||
|
/^rxjs/,
|
||||||
|
/^@angular/,
|
||||||
|
/^@ng-bootstrap/,
|
||||||
|
/^terminus-/,
|
||||||
|
]
|
||||||
|
}
|
2959
terminus-ssh/yarn.lock
Normal file
2959
terminus-ssh/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "terminus-terminal",
|
"name": "terminus-terminal",
|
||||||
"version": "1.0.0-alpha.24",
|
"version": "1.0.0-alpha.36",
|
||||||
"description": "Terminus' terminal emulation core",
|
"description": "Terminus' terminal emulation core",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"terminus-plugin"
|
"terminus-builtin-plugin"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"font-manager": "0.2.2",
|
"font-manager": "0.2.2",
|
||||||
"hterm-umdjs": "1.1.3",
|
"hterm-umdjs": "1.1.3",
|
||||||
"mz": "^2.6.0",
|
"mz": "^2.6.0",
|
||||||
"node-pty": "0.6.8",
|
"node-pty-tmp": "0.7.1",
|
||||||
"ps-node": "^0.1.6",
|
"ps-node": "^0.1.6",
|
||||||
"runes": "^0.4.2",
|
"runes": "^0.4.2",
|
||||||
"winreg": "^1.2.3"
|
"winreg": "^1.2.3"
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
h3.mb-2 Appearance
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.form-group
|
.form-group
|
||||||
label Preview
|
|
||||||
.appearance-preview(
|
.appearance-preview(
|
||||||
[style.font-family]='config.store.terminal.font',
|
[style.font-family]='config.store.terminal.font',
|
||||||
[style.font-size]='config.store.terminal.fontSize + "px"',
|
[style.font-size]='config.store.terminal.fontSize + "px"',
|
||||||
@@ -60,23 +60,6 @@
|
|||||||
span([style.color]='config.store.terminal.colorScheme.colors[15]') W
|
span([style.color]='config.store.terminal.colorScheme.colors[15]') W
|
||||||
div
|
div
|
||||||
span
|
span
|
||||||
div
|
|
||||||
span john@doe-pc
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
|
||||||
span webpack
|
|
||||||
div
|
|
||||||
span Asset Size
|
|
||||||
div
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') main.js
|
|
||||||
span 234 kB
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted]
|
|
||||||
div
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') big.js
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') 1.2 MB
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[2]') [emitted]
|
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[3]') [big]
|
|
||||||
div
|
|
||||||
span
|
|
||||||
div
|
div
|
||||||
span john@doe-pc
|
span john@doe-pc
|
||||||
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
span([style.color]='config.store.terminal.colorScheme.colors[1]') $
|
||||||
@@ -178,96 +161,222 @@
|
|||||||
.form-group.mr-3
|
.form-group.mr-3
|
||||||
label Terminal background
|
label Terminal background
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
'[(ngModel)]'='config.store.terminal.background',
|
'[(ngModel)]'='config.store.terminal.background',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"theme"'
|
[value]='"theme"'
|
||||||
)
|
)
|
||||||
| From theme
|
| From theme
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"colorScheme"'
|
[value]='"colorScheme"'
|
||||||
)
|
)
|
||||||
| From colors
|
| From colors
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
label Cursor shape
|
label Cursor shape
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
[(ngModel)]='config.store.terminal.cursor',
|
[(ngModel)]='config.store.terminal.cursor',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"block"'
|
[value]='"block"'
|
||||||
)
|
)
|
||||||
| █
|
| █
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"beam"'
|
[value]='"beam"'
|
||||||
)
|
)
|
||||||
| |
|
| |
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
[value]='"underline"'
|
[value]='"underline"'
|
||||||
)
|
)
|
||||||
| ▁
|
| ▁
|
||||||
|
|
||||||
.form-group
|
h3.mt-2.mb-2 Behaviour
|
||||||
label Shell
|
|
||||||
select.form-control(
|
.row
|
||||||
'[(ngModel)]'='config.store.terminal.shell',
|
.col-md-6
|
||||||
|
.d-flex
|
||||||
|
.form-group.mr-3
|
||||||
|
label Shell
|
||||||
|
select.form-control(
|
||||||
|
'[(ngModel)]'='config.store.terminal.shell',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
)
|
||||||
|
option(
|
||||||
|
*ngFor='let shell of shells',
|
||||||
|
[ngValue]='shell.id'
|
||||||
|
) {{shell.name}}
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Session persistence
|
||||||
|
select.form-control(
|
||||||
|
'[(ngModel)]'='config.store.terminal.persistence',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
)
|
||||||
|
option([ngValue]='null') Off
|
||||||
|
option(
|
||||||
|
*ngFor='let provider of persistenceProviders',
|
||||||
|
[ngValue]='provider.id'
|
||||||
|
) {{provider.displayName}}
|
||||||
|
|
||||||
|
.form-group(*ngIf='config.store.terminal.shell == "custom"')
|
||||||
|
label Custom shell
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
'[(ngModel)]'='config.store.terminal.customShell',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
)
|
)
|
||||||
option(
|
|
||||||
*ngFor='let shell of shells',
|
|
||||||
[ngValue]='shell.id'
|
|
||||||
) {{shell.name}}
|
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
label Terminal bell
|
label Working directory
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
placeholder='Home directory',
|
||||||
|
'[(ngModel)]'='config.store.terminal.workingDirectory',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
)
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Auto-open a terminal on app start
|
||||||
br
|
br
|
||||||
div(
|
.btn-group(
|
||||||
'[(ngModel)]'='config.store.terminal.bell',
|
'[(ngModel)]'='config.store.terminal.autoOpen',
|
||||||
(ngModelChange)='config.save()',
|
(ngModelChange)='config.save()',
|
||||||
ngbRadioGroup
|
ngbRadioGroup
|
||||||
)
|
)
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
[value]='"off"'
|
ngbButton,
|
||||||
|
[value]='false'
|
||||||
)
|
)
|
||||||
| Off
|
| Off
|
||||||
label.btn.btn-secondary
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
input(
|
input(
|
||||||
type='radio',
|
type='radio',
|
||||||
[value]='"visual"'
|
ngbButton,
|
||||||
|
[value]='true'
|
||||||
)
|
)
|
||||||
| Visual
|
| On
|
||||||
label.btn.btn-secondary
|
|
||||||
input(
|
.col-md-6
|
||||||
type='radio',
|
.d-flex
|
||||||
[value]='"audible"'
|
.form-group.mr-3
|
||||||
)
|
label Terminal bell
|
||||||
| Audible
|
br
|
||||||
|
.btn-group(
|
||||||
|
'[(ngModel)]'='config.store.terminal.bell',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
ngbRadioGroup
|
||||||
|
)
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='"off"'
|
||||||
|
)
|
||||||
|
| Off
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='"visual"'
|
||||||
|
)
|
||||||
|
| Visual
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='"audible"'
|
||||||
|
)
|
||||||
|
| Audible
|
||||||
|
|
||||||
.form-group
|
.form-group
|
||||||
label Session persistence
|
label Blink cursor
|
||||||
select.form-control(
|
br
|
||||||
'[(ngModel)]'='config.store.terminal.persistence',
|
.btn-group(
|
||||||
(ngModelChange)='config.save()',
|
'[(ngModel)]'='config.store.terminal.cursorBlink',
|
||||||
)
|
(ngModelChange)='config.save()',
|
||||||
option([ngValue]='null') Off
|
ngbRadioGroup
|
||||||
option(
|
)
|
||||||
*ngFor='let provider of persistenceProviders',
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
[ngValue]='provider.id'
|
input(
|
||||||
) {{provider.displayName}}
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='false'
|
||||||
|
)
|
||||||
|
| Off
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='true'
|
||||||
|
)
|
||||||
|
| On
|
||||||
|
|
||||||
|
.d-flex
|
||||||
|
.form-group.mr-3
|
||||||
|
label Copy on select
|
||||||
|
br
|
||||||
|
.btn-group(
|
||||||
|
'[(ngModel)]'='config.store.terminal.copyOnSelect',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
ngbRadioGroup
|
||||||
|
)
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='false'
|
||||||
|
)
|
||||||
|
| Off
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
[value]='true'
|
||||||
|
)
|
||||||
|
| On
|
||||||
|
|
||||||
|
.form-group
|
||||||
|
label Right click behaviour
|
||||||
|
br
|
||||||
|
.btn-group(
|
||||||
|
'[(ngModel)]'='config.store.terminal.rightClick',
|
||||||
|
(ngModelChange)='config.save()',
|
||||||
|
ngbRadioGroup
|
||||||
|
)
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
value='menu'
|
||||||
|
)
|
||||||
|
| Menu
|
||||||
|
label.btn.btn-secondary(ngbButtonLabel)
|
||||||
|
input(
|
||||||
|
type='radio',
|
||||||
|
ngbButton,
|
||||||
|
value='paste'
|
||||||
|
)
|
||||||
|
| Paste
|
||||||
|
@@ -27,7 +27,7 @@ export class TerminalSettingsTabComponent {
|
|||||||
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
||||||
@Inject(SessionPersistenceProvider) persistenceProviders: SessionPersistenceProvider[],
|
@Inject(SessionPersistenceProvider) persistenceProviders: SessionPersistenceProvider[],
|
||||||
) {
|
) {
|
||||||
this.persistenceProviders = persistenceProviders.filter(x => x.isAvailable())
|
this.persistenceProviders = this.config.enabledServices(persistenceProviders).filter(x => x.isAvailable())
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit () {
|
async ngOnInit () {
|
||||||
@@ -46,8 +46,8 @@ export class TerminalSettingsTabComponent {
|
|||||||
this.fonts.sort()
|
this.fonts.sort()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.colorSchemes = (await Promise.all(this.colorSchemeProviders.map(x => x.getSchemes()))).reduce((a, b) => a.concat(b))
|
this.colorSchemes = (await Promise.all(this.config.enabledServices(this.colorSchemeProviders).map(x => x.getSchemes()))).reduce((a, b) => a.concat(b))
|
||||||
this.shells = (await Promise.all(this.shellProviders.map(x => x.provide()))).reduce((a, b) => a.concat(b))
|
this.shells = (await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))).reduce((a, b) => a.concat(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
fontAutocomplete = (text$: Observable<string>) => {
|
fontAutocomplete = (text$: Observable<string>) => {
|
||||||
|
@@ -60,23 +60,28 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
this.decorators = this.decorators || []
|
this.decorators = this.decorators || []
|
||||||
this.title = 'Terminal'
|
this.title = 'Terminal'
|
||||||
this.resize$.first().subscribe(async (resizeEvent) => {
|
this.resize$.first().subscribe(async (resizeEvent) => {
|
||||||
this.session = this.sessions.addSession(
|
if (!this.session) {
|
||||||
Object.assign({}, this.sessionOptions, resizeEvent)
|
this.session = this.sessions.addSession(
|
||||||
)
|
Object.assign({}, this.sessionOptions, resizeEvent)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.session.resize(resizeEvent.width, resizeEvent.height)
|
this.session.resize(resizeEvent.width, resizeEvent.height)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
// this.session.output$.bufferTime(10).subscribe((datas) => {
|
// this.session.output$.bufferTime(10).subscribe((datas) => {
|
||||||
this.session.output$.subscribe(data => {
|
this.session.output$.subscribe(data => {
|
||||||
// let data = datas.join('')
|
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
this.output$.next(data)
|
this.output$.next(data)
|
||||||
|
this.write(data)
|
||||||
})
|
})
|
||||||
this.write(data)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
this.sessionCloseSubscription = this.session.closed$.subscribe(() => {
|
||||||
this.app.closeTab(this)
|
this.app.closeTab(this)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.session.releaseInitialDataBuffer()
|
this.session.releaseInitialDataBuffer()
|
||||||
})
|
})
|
||||||
this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => {
|
this.hotkeysSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => {
|
||||||
@@ -120,7 +125,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.hterm = new hterm.hterm.Terminal()
|
this.hterm = new hterm.hterm.Terminal()
|
||||||
this.decorators.forEach((decorator) => {
|
this.config.enabledServices(this.decorators).forEach((decorator) => {
|
||||||
decorator.attach(this)
|
decorator.attach(this)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -178,7 +183,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
label: 'Paste',
|
label: 'Paste',
|
||||||
click: () => {
|
click: () => {
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
this.sendInput(this.electron.clipboard.readText())
|
this.paste()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -223,12 +228,17 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
this.mouseEvent$.next(event)
|
this.mouseEvent$.next(event)
|
||||||
if (event.type === 'mousedown') {
|
if (event.type === 'mousedown') {
|
||||||
if (event.which === 3) {
|
if (event.which === 3) {
|
||||||
this.contextMenu.popup({
|
if (this.config.store.terminal.rightClick === 'menu') {
|
||||||
x: event.pageX,
|
this.contextMenu.popup({
|
||||||
y: event.pageY,
|
x: event.pageX + this.content.nativeElement.getBoundingClientRect().left,
|
||||||
async: true,
|
y: event.pageY + this.content.nativeElement.getBoundingClientRect().top,
|
||||||
})
|
async: true,
|
||||||
|
})
|
||||||
|
} else if (this.config.store.terminal.rightClick === 'paste') {
|
||||||
|
this.paste()
|
||||||
|
}
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
event.stopPropagation()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,6 +312,10 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
this.io.writeUTF8(data)
|
this.io.writeUTF8(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paste () {
|
||||||
|
this.sendInput(this.electron.clipboard.readText())
|
||||||
|
}
|
||||||
|
|
||||||
clear () {
|
clear () {
|
||||||
this.hterm.wipeContents()
|
this.hterm.wipeContents()
|
||||||
this.hterm.onVTKeystroke('\f')
|
this.hterm.onVTKeystroke('\f')
|
||||||
@@ -319,9 +333,11 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
preferenceManager.set('send-encoding', 'raw')
|
preferenceManager.set('send-encoding', 'raw')
|
||||||
preferenceManager.set('ctrl-plus-minus-zero-zoom', false)
|
preferenceManager.set('ctrl-plus-minus-zero-zoom', false)
|
||||||
preferenceManager.set('scrollbar-visible', this.hostApp.platform === Platform.macOS)
|
preferenceManager.set('scrollbar-visible', this.hostApp.platform === Platform.macOS)
|
||||||
preferenceManager.set('copy-on-select', false)
|
preferenceManager.set('copy-on-select', config.terminal.copyOnSelect)
|
||||||
preferenceManager.set('alt-sends-what', 'browser-key')
|
preferenceManager.set('alt-sends-what', 'browser-key')
|
||||||
preferenceManager.set('alt-gr-mode', 'ctrl-alt')
|
preferenceManager.set('alt-gr-mode', 'ctrl-alt')
|
||||||
|
preferenceManager.set('pass-alt-number', true)
|
||||||
|
preferenceManager.set('cursor-blink', config.terminal.cursorBlink)
|
||||||
|
|
||||||
if (config.terminal.colorScheme.foreground) {
|
if (config.terminal.colorScheme.foreground) {
|
||||||
preferenceManager.set('foreground-color', config.terminal.colorScheme.foreground)
|
preferenceManager.set('foreground-color', config.terminal.colorScheme.foreground)
|
||||||
@@ -368,6 +384,10 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
beam: hterm.hterm.Terminal.cursorShape.BEAM,
|
beam: hterm.hterm.Terminal.cursorShape.BEAM,
|
||||||
}[config.terminal.cursor]
|
}[config.terminal.cursor]
|
||||||
this.hterm.applyCursorShape()
|
this.hterm.applyCursorShape()
|
||||||
|
this.hterm.setCursorBlink(config.terminal.cursorBlink)
|
||||||
|
if (config.terminal.cursorBlink) {
|
||||||
|
this.hterm.onCursorBlink_()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomIn () {
|
zoomIn () {
|
||||||
@@ -386,7 +406,7 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy () {
|
ngOnDestroy () {
|
||||||
this.decorators.forEach(decorator => {
|
this.config.enabledServices(this.decorators).forEach(decorator => {
|
||||||
decorator.detach(this)
|
decorator.detach(this)
|
||||||
})
|
})
|
||||||
this.hotkeysSubscription.unsubscribe()
|
this.hotkeysSubscription.unsubscribe()
|
||||||
|
@@ -3,6 +3,7 @@ import { ConfigProvider, Platform } from 'terminus-core'
|
|||||||
export class TerminalConfigProvider extends ConfigProvider {
|
export class TerminalConfigProvider extends ConfigProvider {
|
||||||
defaults = {
|
defaults = {
|
||||||
terminal: {
|
terminal: {
|
||||||
|
autoOpen: false,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
linePadding: 0,
|
linePadding: 0,
|
||||||
bell: 'off',
|
bell: 'off',
|
||||||
@@ -10,6 +11,11 @@ export class TerminalConfigProvider extends ConfigProvider {
|
|||||||
background: 'theme',
|
background: 'theme',
|
||||||
ligatures: false,
|
ligatures: false,
|
||||||
cursor: 'block',
|
cursor: 'block',
|
||||||
|
cursorBlink: true,
|
||||||
|
customShell: '',
|
||||||
|
rightClick: 'menu',
|
||||||
|
copyOnSelect: false,
|
||||||
|
workingDirectory: '',
|
||||||
colorScheme: {
|
colorScheme: {
|
||||||
__nonStructural: true,
|
__nonStructural: true,
|
||||||
name: 'Material',
|
name: 'Material',
|
||||||
@@ -77,6 +83,8 @@ export class TerminalConfigProvider extends ConfigProvider {
|
|||||||
font: 'Consolas',
|
font: 'Consolas',
|
||||||
shell: 'clink',
|
shell: 'clink',
|
||||||
persistence: null,
|
persistence: null,
|
||||||
|
rightClick: 'paste',
|
||||||
|
copyOnSelect: true,
|
||||||
},
|
},
|
||||||
hotkeys: {
|
hotkeys: {
|
||||||
'copy': [
|
'copy': [
|
||||||
|
@@ -3,14 +3,14 @@ import { BrowserModule } from '@angular/platform-browser'
|
|||||||
import { FormsModule } from '@angular/forms'
|
import { FormsModule } from '@angular/forms'
|
||||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
|
||||||
import { ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService, HotkeyProvider } from 'terminus-core'
|
import { ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService, HotkeyProvider, AppService, ConfigService } from 'terminus-core'
|
||||||
import { SettingsTabProvider } from 'terminus-settings'
|
import { SettingsTabProvider } from 'terminus-settings'
|
||||||
|
|
||||||
import { TerminalTabComponent } from './components/terminalTab.component'
|
import { TerminalTabComponent } from './components/terminalTab.component'
|
||||||
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
||||||
import { ColorPickerComponent } from './components/colorPicker.component'
|
import { ColorPickerComponent } from './components/colorPicker.component'
|
||||||
|
|
||||||
import { SessionsService } from './services/sessions.service'
|
import { SessionsService, BaseSession } from './services/sessions.service'
|
||||||
import { TerminalService } from './services/terminal.service'
|
import { TerminalService } from './services/terminal.service'
|
||||||
|
|
||||||
import { ScreenPersistenceProvider } from './persistence/screen'
|
import { ScreenPersistenceProvider } from './persistence/screen'
|
||||||
@@ -24,6 +24,7 @@ import { TerminalConfigProvider } from './config'
|
|||||||
import { TerminalHotkeyProvider } from './hotkeys'
|
import { TerminalHotkeyProvider } from './hotkeys'
|
||||||
import { HyperColorSchemes } from './colorSchemes'
|
import { HyperColorSchemes } from './colorSchemes'
|
||||||
|
|
||||||
|
import { CustomShellProvider } from './shells/custom'
|
||||||
import { Cygwin32ShellProvider } from './shells/cygwin32'
|
import { Cygwin32ShellProvider } from './shells/cygwin32'
|
||||||
import { Cygwin64ShellProvider } from './shells/cygwin64'
|
import { Cygwin64ShellProvider } from './shells/cygwin64'
|
||||||
import { GitBashShellProvider } from './shells/gitBash'
|
import { GitBashShellProvider } from './shells/gitBash'
|
||||||
@@ -59,6 +60,7 @@ import { hterm } from './hterm'
|
|||||||
{ provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true },
|
{ provide: ShellProvider, useClass: WindowsStockShellsProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: MacOSDefaultShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: LinuxDefaultShellProvider, multi: true },
|
||||||
|
{ provide: ShellProvider, useClass: CustomShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: Cygwin32ShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: Cygwin64ShellProvider, multi: true },
|
||||||
{ provide: ShellProvider, useClass: GitBashShellProvider, multi: true },
|
{ provide: ShellProvider, useClass: GitBashShellProvider, multi: true },
|
||||||
@@ -76,7 +78,12 @@ import { hterm } from './hterm'
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export default class TerminalModule {
|
export default class TerminalModule {
|
||||||
constructor (hotkeys: HotkeysService) {
|
constructor (
|
||||||
|
app: AppService,
|
||||||
|
config: ConfigService,
|
||||||
|
hotkeys: HotkeysService,
|
||||||
|
terminal: TerminalService,
|
||||||
|
) {
|
||||||
let events = [
|
let events = [
|
||||||
{
|
{
|
||||||
name: 'keydown',
|
name: 'keydown',
|
||||||
@@ -101,8 +108,13 @@ export default class TerminalModule {
|
|||||||
hotkeys.emitKeyEvent(nativeEvent)
|
hotkeys.emitKeyEvent(nativeEvent)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (config.store.terminal.autoOpen) {
|
||||||
|
app.ready$.subscribe(() => {
|
||||||
|
terminal.openTab()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export * from './api'
|
export * from './api'
|
||||||
export { TerminalService }
|
export { TerminalService, BaseSession, TerminalTabComponent }
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
const psNode = require('ps-node')
|
const psNode = require('ps-node')
|
||||||
// import * as nodePTY from 'node-pty'
|
|
||||||
let nodePTY
|
let nodePTY
|
||||||
import * as fs from 'mz/fs'
|
import * as fs from 'mz/fs'
|
||||||
import { Subject } from 'rxjs'
|
import { Subject } from 'rxjs'
|
||||||
@@ -15,7 +14,7 @@ export interface IChildProcess {
|
|||||||
command: string
|
command: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Session {
|
export abstract class BaseSession {
|
||||||
open: boolean
|
open: boolean
|
||||||
name: string
|
name: string
|
||||||
output$ = new Subject<string>()
|
output$ = new Subject<string>()
|
||||||
@@ -23,11 +22,46 @@ export class Session {
|
|||||||
destroyed$ = new Subject<void>()
|
destroyed$ = new Subject<void>()
|
||||||
recoveryId: string
|
recoveryId: string
|
||||||
truePID: number
|
truePID: number
|
||||||
private pty: any
|
|
||||||
private initialDataBuffer = ''
|
private initialDataBuffer = ''
|
||||||
private initialDataBufferReleased = false
|
private initialDataBufferReleased = false
|
||||||
|
|
||||||
|
emitOutput (data: string) {
|
||||||
|
if (!this.initialDataBufferReleased) {
|
||||||
|
this.initialDataBuffer += data
|
||||||
|
} else {
|
||||||
|
this.output$.next(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseInitialDataBuffer () {
|
||||||
|
this.initialDataBufferReleased = true
|
||||||
|
this.output$.next(this.initialDataBuffer)
|
||||||
|
this.initialDataBuffer = null
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract resize (columns, rows)
|
||||||
|
abstract write (data)
|
||||||
|
abstract kill (signal?: string)
|
||||||
|
abstract async getChildProcesses (): Promise<IChildProcess[]>
|
||||||
|
abstract async gracefullyKillProcess (): Promise<void>
|
||||||
|
abstract async getWorkingDirectory (): Promise<string>
|
||||||
|
|
||||||
|
async destroy (): Promise<void> {
|
||||||
|
if (this.open) {
|
||||||
|
this.open = false
|
||||||
|
this.closed$.next()
|
||||||
|
this.destroyed$.next()
|
||||||
|
this.output$.complete()
|
||||||
|
await this.gracefullyKillProcess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Session extends BaseSession {
|
||||||
|
private pty: any
|
||||||
|
|
||||||
constructor (options: SessionOptions) {
|
constructor (options: SessionOptions) {
|
||||||
|
super()
|
||||||
this.name = options.name
|
this.name = options.name
|
||||||
this.recoveryId = options.recoveryId
|
this.recoveryId = options.recoveryId
|
||||||
|
|
||||||
@@ -66,12 +100,8 @@ export class Session {
|
|||||||
|
|
||||||
this.open = true
|
this.open = true
|
||||||
|
|
||||||
this.pty.on('data', (data) => {
|
this.pty.on('data', data => {
|
||||||
if (!this.initialDataBufferReleased) {
|
this.emitOutput(data)
|
||||||
this.initialDataBuffer += data
|
|
||||||
} else {
|
|
||||||
this.output$.next(data)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.pty.on('exit', () => {
|
this.pty.on('exit', () => {
|
||||||
@@ -87,20 +117,14 @@ export class Session {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseInitialDataBuffer () {
|
|
||||||
this.initialDataBufferReleased = true
|
|
||||||
this.output$.next(this.initialDataBuffer)
|
|
||||||
this.initialDataBuffer = null
|
|
||||||
}
|
|
||||||
|
|
||||||
resize (columns, rows) {
|
resize (columns, rows) {
|
||||||
if (this.pty.writable) {
|
if (this.pty._writable) {
|
||||||
this.pty.resize(columns, rows)
|
this.pty.resize(columns, rows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write (data) {
|
write (data) {
|
||||||
if (this.pty.writable) {
|
if (this.pty._writable) {
|
||||||
this.pty.write(Buffer.from(data, 'utf-8'))
|
this.pty.write(Buffer.from(data, 'utf-8'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,16 +169,6 @@ export class Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async destroy (): Promise<void> {
|
|
||||||
if (this.open) {
|
|
||||||
this.open = false
|
|
||||||
this.closed$.next()
|
|
||||||
this.destroyed$.next()
|
|
||||||
this.output$.complete()
|
|
||||||
await this.gracefullyKillProcess()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getWorkingDirectory (): Promise<string> {
|
async getWorkingDirectory (): Promise<string> {
|
||||||
if (!this.truePID) {
|
if (!this.truePID) {
|
||||||
return null
|
return null
|
||||||
@@ -186,9 +200,9 @@ export class SessionsService {
|
|||||||
electron: ElectronService,
|
electron: ElectronService,
|
||||||
log: LogService,
|
log: LogService,
|
||||||
) {
|
) {
|
||||||
nodePTY = electron.remoteRequirePluginModule('terminus-terminal', 'node-pty', global as any)
|
nodePTY = electron.remoteRequirePluginModule('terminus-terminal', 'node-pty-tmp', global as any)
|
||||||
this.logger = log.create('sessions')
|
this.logger = log.create('sessions')
|
||||||
this.persistenceProviders = this.persistenceProviders.filter(x => x.isAvailable())
|
this.persistenceProviders = this.config.enabledServices(this.persistenceProviders).filter(x => x.isAvailable())
|
||||||
}
|
}
|
||||||
|
|
||||||
async prepareNewSession (options: SessionOptions): Promise<SessionOptions> {
|
async prepareNewSession (options: SessionOptions): Promise<SessionOptions> {
|
||||||
|
@@ -14,19 +14,31 @@ export class TerminalService {
|
|||||||
private app: AppService,
|
private app: AppService,
|
||||||
private sessions: SessionsService,
|
private sessions: SessionsService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
@Inject(ShellProvider) shellProviders: ShellProvider[],
|
@Inject(ShellProvider) private shellProviders: ShellProvider[],
|
||||||
log: LogService,
|
log: LogService,
|
||||||
) {
|
) {
|
||||||
this.logger = log.create('terminal')
|
this.logger = log.create('terminal')
|
||||||
Promise.all(shellProviders.map(x => x.provide())).then(shellLists => {
|
this.reloadShells()
|
||||||
this.shells$.next(shellLists.reduce((a, b) => a.concat(b)))
|
|
||||||
this.shells$.complete()
|
config.changed$.subscribe(() => {
|
||||||
|
this.reloadShells()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reloadShells () {
|
||||||
|
this.shells$ = new AsyncSubject<IShell[]>()
|
||||||
|
let shellLists = await Promise.all(this.config.enabledServices(this.shellProviders).map(x => x.provide()))
|
||||||
|
this.shells$.next(shellLists.reduce((a, b) => a.concat(b)))
|
||||||
|
this.shells$.complete()
|
||||||
|
}
|
||||||
|
|
||||||
async openTab (shell?: IShell, cwd?: string): Promise<TerminalTabComponent> {
|
async openTab (shell?: IShell, cwd?: string): Promise<TerminalTabComponent> {
|
||||||
if (!cwd && this.app.activeTab instanceof TerminalTabComponent) {
|
if (!cwd) {
|
||||||
cwd = await this.app.activeTab.session.getWorkingDirectory()
|
if (this.app.activeTab instanceof TerminalTabComponent) {
|
||||||
|
cwd = await this.app.activeTab.session.getWorkingDirectory()
|
||||||
|
} else {
|
||||||
|
cwd = this.config.store.terminal.workingDirectory || null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!shell) {
|
if (!shell) {
|
||||||
let shells = await this.shells$.toPromise()
|
let shells = await this.shells$.toPromise()
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SettingsTabProvider, ComponentType } from 'terminus-settings'
|
import { SettingsTabProvider } from 'terminus-settings'
|
||||||
|
|
||||||
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
import { TerminalSettingsTabComponent } from './components/terminalSettingsTab.component'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TerminalSettingsTabProvider extends SettingsTabProvider {
|
export class TerminalSettingsTabProvider extends SettingsTabProvider {
|
||||||
|
id = 'terminal'
|
||||||
title = 'Terminal'
|
title = 'Terminal'
|
||||||
|
|
||||||
getComponentType (): ComponentType {
|
getComponentType (): any {
|
||||||
return TerminalSettingsTabComponent
|
return TerminalSettingsTabComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
terminus-terminal/src/shells/custom.ts
Normal file
23
terminus-terminal/src/shells/custom.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Injectable } from '@angular/core'
|
||||||
|
import { ConfigService } from 'terminus-core'
|
||||||
|
|
||||||
|
import { ShellProvider, IShell } from '../api'
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CustomShellProvider extends ShellProvider {
|
||||||
|
constructor (
|
||||||
|
private config: ConfigService,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
async provide (): Promise<IShell[]> {
|
||||||
|
let args = this.config.store.terminal.customShell.split(' ')
|
||||||
|
return [{
|
||||||
|
id: 'custom',
|
||||||
|
name: 'Custom',
|
||||||
|
command: args[0],
|
||||||
|
args: args.slice(1),
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
@@ -33,7 +33,8 @@ export class LinuxDefaultShellProvider extends ShellProvider {
|
|||||||
return [{
|
return [{
|
||||||
id: 'default',
|
id: 'default',
|
||||||
name: 'User default',
|
name: 'User default',
|
||||||
command: line.split(':')[6]
|
command: line.split(':')[6],
|
||||||
|
args: ['--login'],
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,8 @@ export class MacOSDefaultShellProvider extends ShellProvider {
|
|||||||
return [{
|
return [{
|
||||||
id: 'default',
|
id: 'default',
|
||||||
name: 'User default',
|
name: 'User default',
|
||||||
command: shellEntry.split(' ')[1].trim()
|
command: shellEntry.split(' ')[1].trim(),
|
||||||
|
args: ['--login'],
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ export class POSIXShellsProvider extends ShellProvider {
|
|||||||
id: x,
|
id: x,
|
||||||
name: x,
|
name: x,
|
||||||
command: x,
|
command: x,
|
||||||
|
args: ['--login'],
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,14 @@ export class WindowsStockShellsProvider extends ShellProvider {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ id: 'cmd', name: 'CMD (stock)', command: 'cmd.exe' },
|
{ id: 'cmd', name: 'CMD (stock)', command: 'cmd.exe' },
|
||||||
{ id: 'powershell', name: 'PowerShell', command: 'powershell.exe' },
|
{
|
||||||
|
id: 'powershell',
|
||||||
|
name: 'PowerShell',
|
||||||
|
command: 'powershell.exe',
|
||||||
|
env: {
|
||||||
|
TERM: 'cygwin',
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,10 @@ export class WSLShellProvider extends ShellProvider {
|
|||||||
return [{
|
return [{
|
||||||
id: 'wsl',
|
id: 'wsl',
|
||||||
name: 'Bash on Windows',
|
name: 'Bash on Windows',
|
||||||
command: wslPath
|
command: wslPath,
|
||||||
|
env: {
|
||||||
|
TERM: 'xterm-color',
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ module.exports = {
|
|||||||
'fs',
|
'fs',
|
||||||
'font-manager',
|
'font-manager',
|
||||||
'path',
|
'path',
|
||||||
'node-pty',
|
'node-pty-tmp',
|
||||||
'mz/fs',
|
'mz/fs',
|
||||||
'mz/child_process',
|
'mz/child_process',
|
||||||
'winreg',
|
'winreg',
|
||||||
|
@@ -69,7 +69,7 @@ font-manager@0.2.2:
|
|||||||
nan "~2.2.0"
|
nan "~2.2.0"
|
||||||
|
|
||||||
hterm-umdjs@1.1.3:
|
hterm-umdjs@1.1.3:
|
||||||
version "1.1.3"
|
version "1.1.3+1.58.sha.15ed490"
|
||||||
resolved "https://registry.yarnpkg.com/hterm-umdjs/-/hterm-umdjs-1.1.3.tgz#8b57bcaded5ba9541d6c8e32a82b34abb93e885e"
|
resolved "https://registry.yarnpkg.com/hterm-umdjs/-/hterm-umdjs-1.1.3.tgz#8b57bcaded5ba9541d6c8e32a82b34abb93e885e"
|
||||||
|
|
||||||
json5@^0.5.0:
|
json5@^0.5.0:
|
||||||
@@ -92,19 +92,19 @@ mz@^2.6.0:
|
|||||||
object-assign "^4.0.1"
|
object-assign "^4.0.1"
|
||||||
thenify-all "^1.0.0"
|
thenify-all "^1.0.0"
|
||||||
|
|
||||||
nan@2.5.0:
|
nan@^2.6.2:
|
||||||
version "2.5.0"
|
version "2.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.5.0.tgz#aa8f1e34531d807e9e27755b234b4a6ec0c152a8"
|
resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"
|
||||||
|
|
||||||
nan@~2.2.0:
|
nan@~2.2.0:
|
||||||
version "2.2.1"
|
version "2.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.2.1.tgz#d68693f6b34bb41d66bc68b3a4f9defc79d7149b"
|
resolved "https://registry.yarnpkg.com/nan/-/nan-2.2.1.tgz#d68693f6b34bb41d66bc68b3a4f9defc79d7149b"
|
||||||
|
|
||||||
node-pty@0.6.8:
|
node-pty-tmp@0.7.1:
|
||||||
version "0.6.8"
|
version "0.7.1"
|
||||||
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.6.8.tgz#a7b145397bef23a719128a75b20d4821726dfe90"
|
resolved "https://registry.yarnpkg.com/node-pty-tmp/-/node-pty-tmp-0.7.1.tgz#0a81179f9087b21f968206c886e543db20650d7a"
|
||||||
dependencies:
|
dependencies:
|
||||||
nan "2.5.0"
|
nan "^2.6.2"
|
||||||
|
|
||||||
object-assign@^4.0.1:
|
object-assign@^4.0.1:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
|
@@ -15,8 +15,10 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"lib": [
|
"lib": [
|
||||||
"dom",
|
"dom",
|
||||||
"es2015",
|
"es5",
|
||||||
"es7"
|
"es6",
|
||||||
|
"es7",
|
||||||
|
"es2015"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,4 +5,5 @@ module.exports = [
|
|||||||
require('./terminus-terminal/webpack.config.js'),
|
require('./terminus-terminal/webpack.config.js'),
|
||||||
require('./terminus-community-color-schemes/webpack.config.js'),
|
require('./terminus-community-color-schemes/webpack.config.js'),
|
||||||
require('./terminus-plugin-manager/webpack.config.js'),
|
require('./terminus-plugin-manager/webpack.config.js'),
|
||||||
|
require('./terminus-ssh/webpack.config.js'),
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user