1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-12-22 18:11:43 +03:00
This commit is contained in:
Eugene Pankov 2017-04-14 15:30:19 +02:00
parent 137c100bbf
commit 00ff63f16f
20 changed files with 291 additions and 166 deletions

View File

@ -0,0 +1 @@
export * from '@angular/animations'

View File

@ -0,0 +1 @@
export * from '@angular/common'

View File

@ -0,0 +1 @@
export * from '@angular/compiler'

View File

@ -0,0 +1 @@
export * from '@angular/core'

View File

@ -0,0 +1 @@
export * from '@angular/forms'

View File

@ -0,0 +1 @@
export * from '@angular/platform-browser-dynamic'

View File

@ -0,0 +1 @@
export * from '@angular/platform-browser'

View File

@ -0,0 +1 @@
export * from '@ng-bootstrap/ng-bootstrap'

1
terminus-core/rxjs.ts Normal file
View File

@ -0,0 +1 @@
export * from 'rxjs'

1
terminus-core/zone.js.ts Normal file
View File

@ -0,0 +1 @@
export * from 'zone.js'

View File

@ -13,17 +13,22 @@ export class ColorPickerComponent {
@Output() modelChange = new EventEmitter<string>() @Output() modelChange = new EventEmitter<string>()
@ViewChild('popover') popover: NgbPopover @ViewChild('popover') popover: NgbPopover
@ViewChild('input') input @ViewChild('input') input
isOpen: boolean
open () { open () {
setImmediate(() => { setImmediate(() => {
this.popover.open() this.popover.open()
setImmediate(() => { setImmediate(() => {
this.input.nativeElement.focus() this.input.nativeElement.focus()
this.isOpen = true
}) })
}) })
} }
@HostListener('document:click', ['$event']) onOutsideClick ($event) { @HostListener('document:click', ['$event']) onOutsideClick ($event) {
if (!this.isOpen) {
return
}
let windowRef = (<any>this.popover)._windowRef let windowRef = (<any>this.popover)._windowRef
if (!windowRef) { if (!windowRef) {
return return
@ -31,6 +36,7 @@ export class ColorPickerComponent {
if ($event.target !== windowRef.location.nativeElement && if ($event.target !== windowRef.location.nativeElement &&
!windowRef.location.nativeElement.contains($event.target)) { !windowRef.location.nativeElement.contains($event.target)) {
this.popover.close() this.popover.close()
this.isOpen = false
} }
} }

View File

@ -1,151 +0,0 @@
.row
.col-lg-6
.form-group
label Preview
.appearance-preview(
[style.font-family]='config.full().terminal.font',
[style.font-size]='config.full().terminal.fontSize + "px"',
[style.background-color]='(config.full().terminal.background == "theme") ? null : config.full().terminal.colorScheme.background',
[style.color]='config.full().terminal.colorScheme.foreground',
)
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span webpack
div
span Asset Size
div
span([style.color]='config.full().terminal.colorScheme.colors[2]') main.js
span 234 kB
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
div
span([style.color]='config.full().terminal.colorScheme.colors[3]') big.js
span([style.color]='config.full().terminal.colorScheme.colors[3]') 1.2 MB
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
span([style.color]='config.full().terminal.colorScheme.colors[3]') [big]
div
span
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span ls -l
div
span drwxr-xr-x 1 root root
span([style.color]='config.full().terminal.colorScheme.colors[4]') directory
div
span -rw-r--r-- 1 root root file
div
span -rwxr-xr-x 1 root root
span([style.color]='config.full().terminal.colorScheme.colors[2]') executable
div
span -rwxr-xr-x 1 root root
span([style.color]='config.full().terminal.colorScheme.colors[6]') sym
span ->
span([style.color]='config.full().terminal.colorScheme.colors[1]') link
div
span
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span rm -rf /
span([style.background-color]='config.full().terminal.colorScheme.cursor') &nbsp;
.col-lg-6
.form-group
label Font
.row
.col-8
input.form-control(
type='text',
[ngbTypeahead]='fontAutocomplete',
'[(ngModel)]'='config.store.terminal.font',
(ngModelChange)='config.save()',
)
.col-4
input.form-control(
type='number',
'[(ngModel)]'='config.store.terminal.fontSize',
(ngModelChange)='config.save()',
)
small.form-text.text-muted Font to be used in the terminal
.form-group
label Color scheme
select.form-control(
[compareWith]='equalComparator',
'[(ngModel)]'='config.store.terminal.colorScheme',
(ngModelChange)='config.save()',
)
option(*ngFor='let scheme of colorSchemes', [ngValue]='scheme') {{scheme.name}}
div(*ngIf='config.store.terminal.colorScheme.colors')
color-picker(
'[(model)]'='config.store.terminal.colorScheme.foreground',
(modelChange)='config.save()',
title='FG',
)
color-picker(
'[(model)]'='config.store.terminal.colorScheme.background',
(modelChange)='config.save()',
title='BG',
)
color-picker(
'[(model)]'='config.store.terminal.colorScheme.cursor',
(modelChange)='config.save()',
title='CU',
)
color-picker(
*ngFor='let _ of config.store.terminal.colorScheme.colors; let idx = index',
'[(model)]'='config.store.terminal.colorScheme.colors[idx]',
(modelChange)='config.save()',
[title]='idx',
)
.form-group
label Terminal background
br
div(
'[(ngModel)]'='config.store.terminal.background',
(ngModelChange)='config.save()',
ngbRadioGroup
)
label.btn.btn-secondary
input(
type='radio',
[value]='"theme"'
)
| From the app theme
label.btn.btn-secondary
input(
type='radio',
[value]='"colorScheme"'
)
| From the terminal colors
.form-group
label Terminal bell
br
div(
'[(ngModel)]'='config.store.terminal.bell',
(ngModelChange)='config.save()',
ngbRadioGroup
)
label.btn.btn-secondary
input(
type='radio',
[value]='"off"'
)
| Off
label.btn.btn-secondary
input(
type='radio',
[value]='"visual"'
)
| Visual
label.btn.btn-secondary
input(
type='radio',
[value]='"audible"'
)
| Audible

View File

@ -0,0 +1,223 @@
.row
.col-md-6
.form-group
label Preview
.appearance-preview(
[style.font-family]='config.full().terminal.font',
[style.font-size]='config.full().terminal.fontSize + "px"',
[style.background-color]='(config.full().terminal.background == "theme") ? null : config.full().terminal.colorScheme.background',
[style.color]='config.full().terminal.colorScheme.foreground',
)
div
span([style.background-color]='config.full().terminal.colorScheme.colors[0]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[1]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[2]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[3]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[4]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[5]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[6]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[7]') &nbsp;
span &nbsp;&nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[0]') B
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[1]') R
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[2]') G
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[3]') Y
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[4]') B
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[5]') M
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[6]') T
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[7]') W
div
span([style.background-color]='config.full().terminal.colorScheme.colors[8]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[9]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[10]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[11]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[12]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[13]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[14]') &nbsp;
span([style.background-color]='config.full().terminal.colorScheme.colors[15]') &nbsp;
span &nbsp;&nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[8]') B
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[9]') R
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[10]') G
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[11]') Y
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[12]') B
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[13]') M
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[14]') T
span &nbsp;
span([style.color]='config.full().terminal.colorScheme.colors[15]') W
div
span
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span webpack
div
span Asset Size
div
span([style.color]='config.full().terminal.colorScheme.colors[2]') main.js
span 234 kB
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
div
span([style.color]='config.full().terminal.colorScheme.colors[3]') big.js
span([style.color]='config.full().terminal.colorScheme.colors[3]') 1.2 MB
span([style.color]='config.full().terminal.colorScheme.colors[2]') [emitted]
span([style.color]='config.full().terminal.colorScheme.colors[3]') [big]
div
span
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span ls -l
div
span drwxr-xr-x 1 root
span([style.color]='config.full().terminal.colorScheme.colors[4]') directory
div
span -rw-r--r-- 1 root file
div
span -rwxr-xr-x 1 root
span([style.color]='config.full().terminal.colorScheme.colors[2]') executable
div
span -rwxr-xr-x 1 root
span([style.color]='config.full().terminal.colorScheme.colors[6]') sym
span ->
span([style.color]='config.full().terminal.colorScheme.colors[1]') link
div
span
div
span john@doe-pc
span([style.color]='config.full().terminal.colorScheme.colors[1]') $
span rm -rf /
span([style.background-color]='config.full().terminal.colorScheme.cursor') &nbsp;
.col-md-6
.form-group
label Font
.row
.col-8
input.form-control(
type='text',
[ngbTypeahead]='fontAutocomplete',
'[(ngModel)]'='config.store.terminal.font',
(ngModelChange)='config.save()',
)
.col-4
input.form-control(
type='number',
'[(ngModel)]'='config.store.terminal.fontSize',
(ngModelChange)='config.save()',
)
small.form-text.text-muted Font to be used in the terminal
.form-group(*ngIf='!editingColorScheme')
label Color scheme
.input-group
select.form-control(
[compareWith]='equalComparator',
'[(ngModel)]'='config.store.terminal.colorScheme',
(ngModelChange)='config.save()',
)
option(*ngFor='let scheme of config.full().terminal.customColorSchemes', [ngValue]='scheme') Custom: {{scheme.name}}
option(*ngFor='let scheme of colorSchemes', [ngValue]='scheme') {{scheme.name}}
.input-group-btn
button.btn.btn-secondary((click)='editScheme(config.store.terminal.colorScheme)') Edit
.input-group-btn
button.btn.btn-outline-danger(
(click)='deleteScheme(config.store.terminal.colorScheme)',
*ngIf='isCustomScheme(config.store.terminal.colorScheme)'
)
i.fa.fa-trash-o
.form-group(*ngIf='editingColorScheme')
label Editing
.input-group
input.form-control(type='text', '[(ngModel)]'='editingColorScheme.name')
.input-group-btn
button.btn.btn-secondary((click)='saveScheme()') Save
.input-group-btn
button.btn.btn-secondary((click)='cancelEditing()') Cancel
.form-group(*ngIf='editingColorScheme')
color-picker(
'[(model)]'='editingColorScheme.foreground',
(modelChange)='config.save(); schemeChanged = true',
title='FG',
)
color-picker(
'[(model)]'='editingColorScheme.background',
(modelChange)='config.save(); schemeChanged = true',
title='BG',
)
color-picker(
'[(model)]'='editingColorScheme.cursor',
(modelChange)='config.save(); schemeChanged = true',
title='CU',
)
color-picker(
*ngFor='let _ of editingColorScheme.colors; let idx = index; trackBy: colorsTrackBy',
'[(model)]'='editingColorScheme.colors[idx]',
(modelChange)='config.save(); schemeChanged = true',
[title]='idx',
)
.form-group
label Terminal background
br
div(
'[(ngModel)]'='config.store.terminal.background',
(ngModelChange)='config.save()',
ngbRadioGroup
)
label.btn.btn-secondary
input(
type='radio',
[value]='"theme"'
)
| From the app theme
label.btn.btn-secondary
input(
type='radio',
[value]='"colorScheme"'
)
| From the terminal colors
.form-group
label Terminal bell
br
div(
'[(ngModel)]'='config.store.terminal.bell',
(ngModelChange)='config.save()',
ngbRadioGroup
)
label.btn.btn-secondary
input(
type='radio',
[value]='"off"'
)
| Off
label.btn.btn-secondary
input(
type='radio',
[value]='"visual"'
)
| Visual
label.btn.btn-secondary
input(
type='radio',
[value]='"audible"'
)
| Audible

View File

@ -1,6 +1,7 @@
.appearance-preview { .appearance-preview {
padding: 10px 20px; padding: 10px 20px;
margin: 0 0 10px; margin: 0 0 10px;
overflow: hidden;
span { span {
white-space: pre; white-space: pre;
} }

View File

@ -2,24 +2,25 @@ import { Observable } from 'rxjs/Observable'
import 'rxjs/add/operator/map' import 'rxjs/add/operator/map'
import 'rxjs/add/operator/debounceTime' import 'rxjs/add/operator/debounceTime'
import 'rxjs/add/operator/distinctUntilChanged' import 'rxjs/add/operator/distinctUntilChanged'
const equal = require('deep-equal')
const fontManager = require('font-manager') const fontManager = require('font-manager')
const equal = require('deep-equal')
import { Component, Inject } from '@angular/core' import { Component, Inject } from '@angular/core'
import { ConfigService, HostAppService, Platform } from 'terminus-core' import { ConfigService, HostAppService, Platform } from 'terminus-core'
const { exec } = require('child-process-promise')
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api' import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
const { exec } = require('child-process-promise')
@Component({ @Component({
template: require('./settings.pug'), template: require('./terminalSettingsTab.pug'),
styles: [require('./settings.scss')], styles: [require('./terminalSettingsTab.scss')],
}) })
export class SettingsComponent { export class TerminalSettingsTabComponent {
fonts: string[] = [] fonts: string[] = []
colorSchemes: ITerminalColorScheme[] = [] colorSchemes: ITerminalColorScheme[] = []
equalComparator = equal equalComparator = equal
editingColorScheme: ITerminalColorScheme
schemeChanged = false
constructor( constructor(
public config: ConfigService, public config: ConfigService,
@ -54,5 +55,38 @@ export class SettingsComponent {
.map(list => Array.from(new Set(list))) .map(list => Array.from(new Set(list)))
} }
editScheme (scheme: ITerminalColorScheme) {
this.editingColorScheme = scheme
this.schemeChanged = false
}
saveScheme () {
let schemes = this.config.full().terminal.customColorSchemes
schemes = schemes.filter(x => x !== this.editingColorScheme && x.name !== this.editingColorScheme.name)
schemes.push(this.editingColorScheme)
this.config.store.terminal.customColorSchemes = schemes
this.config.save()
this.cancelEditing()
}
cancelEditing () {
this.editingColorScheme = null
}
deleteScheme (scheme: ITerminalColorScheme) {
if (confirm(`Delete "${scheme.name}"?`)) {
let schemes = this.config.full().terminal.customColorSchemes
schemes = schemes.filter(x => x !== scheme)
this.config.store.terminal.customColorSchemes = schemes
this.config.save()
}
}
isCustomScheme (scheme: ITerminalColorScheme) {
return this.config.full().terminal.customColorSchemes.some(x => equal(x, scheme))
}
colorsTrackBy (index) {
return index
}
} }

View File

@ -181,6 +181,7 @@ export class TerminalTabComponent extends BaseTabComponent {
let config = this.config.full() let config = this.config.full()
preferenceManager.set('font-family', config.terminal.font) preferenceManager.set('font-family', config.terminal.font)
preferenceManager.set('font-size', config.terminal.fontSize) preferenceManager.set('font-size', config.terminal.fontSize)
preferenceManager.set('enable-bold', true)
preferenceManager.set('audible-bell-sound', '') preferenceManager.set('audible-bell-sound', '')
preferenceManager.set('desktop-notification-bell', config.terminal.bell == 'notification') preferenceManager.set('desktop-notification-bell', config.terminal.bell == 'notification')
preferenceManager.set('enable-clipboard-notice', false) preferenceManager.set('enable-clipboard-notice', false)

View File

@ -15,6 +15,7 @@ export class TerminalConfigProvider extends ConfigProvider {
cursor: null, cursor: null,
colors: [], colors: [],
}, },
customColorSchemes: []
}, },
hotkeys: { hotkeys: {
'new-tab': [ 'new-tab': [

View File

@ -7,14 +7,14 @@ import { HostAppService, Platform, ToolbarButtonProvider, TabRecoveryProvider, C
import { SettingsTabProvider } from 'terminus-settings' import { SettingsTabProvider } from 'terminus-settings'
import { TerminalTabComponent } from './components/terminalTab' import { TerminalTabComponent } from './components/terminalTab'
import { SettingsComponent } from './components/settings' import { TerminalSettingsTabComponent } from './components/terminalSettingsTab'
import { ColorPickerComponent } from './components/colorPicker' import { ColorPickerComponent } from './components/colorPicker'
import { SessionsService } from './services/sessions' import { SessionsService } from './services/sessions'
import { ScreenPersistenceProvider } from './persistenceProviders' import { ScreenPersistenceProvider } from './persistenceProviders'
import { ButtonProvider } from './buttonProvider' import { ButtonProvider } from './buttonProvider'
import { RecoveryProvider } from './recoveryProvider' import { RecoveryProvider } from './recoveryProvider'
import { SessionPersistenceProvider, TerminalColorSchemeProvider } from './api' import { SessionPersistenceProvider, TerminalColorSchemeProvider } from './api'
import { TerminalSettingsProvider } from './settings' import { TerminalSettingsTabProvider } from './settings'
import { TerminalConfigProvider } from './config' import { TerminalConfigProvider } from './config'
import { HyperColorSchemes } from './colorSchemes' import { HyperColorSchemes } from './colorSchemes'
import { hterm } from './hterm' import { hterm } from './hterm'
@ -42,18 +42,18 @@ import { hterm } from './hterm'
}, },
deps: [HostAppService, ScreenPersistenceProvider], deps: [HostAppService, ScreenPersistenceProvider],
}, },
{ provide: SettingsTabProvider, useClass: TerminalSettingsProvider, multi: true }, { provide: SettingsTabProvider, useClass: TerminalSettingsTabProvider, multi: true },
{ provide: ConfigProvider, useClass: TerminalConfigProvider, multi: true }, { provide: ConfigProvider, useClass: TerminalConfigProvider, multi: true },
{ provide: TerminalColorSchemeProvider, useClass: HyperColorSchemes, multi: true }, { provide: TerminalColorSchemeProvider, useClass: HyperColorSchemes, multi: true },
], ],
entryComponents: [ entryComponents: [
TerminalTabComponent, TerminalTabComponent,
SettingsComponent, TerminalSettingsTabComponent,
], ],
declarations: [ declarations: [
ColorPickerComponent, ColorPickerComponent,
TerminalTabComponent, TerminalTabComponent,
SettingsComponent, TerminalSettingsTabComponent,
], ],
}) })
export default class TerminalModule { export default class TerminalModule {

View File

@ -47,7 +47,7 @@ export class ScreenPersistenceProvider extends SessionPersistenceProvider {
altscreen on altscreen on
`, 'utf-8') `, 'utf-8')
let recoveryId = `term-tab-${Date.now()}` let recoveryId = `term-tab-${Date.now()}`
let args = ['-d', '-m', '-c', configPath, '-U', '-S', recoveryId, '--', options.command].concat(options.args || []) let args = ['-d', '-m', '-c', configPath, '-U', '-S', recoveryId, '-T', 'xterm-256color', '--', options.command].concat(options.args || [])
await spawn('screen', args, { await spawn('screen', args, {
cwd: options.cwd, cwd: options.cwd,
env: options.env || process.env, env: options.env || process.env,

View File

@ -1,14 +1,14 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { SettingsTabProvider, ComponentType } from 'terminus-settings' import { SettingsTabProvider, ComponentType } from 'terminus-settings'
import { SettingsComponent } from './components/settings' import { TerminalSettingsTabComponent } from './components/terminalSettingsTab'
@Injectable() @Injectable()
export class TerminalSettingsProvider extends SettingsTabProvider { export class TerminalSettingsTabProvider extends SettingsTabProvider {
title = 'Terminal' title = 'Terminal'
getComponentType (): ComponentType { getComponentType (): ComponentType {
return SettingsComponent return TerminalSettingsTabComponent
} }
} }