mirror of
https://github.com/Eugeny/tabby.git
synced 2024-11-26 03:27:23 +03:00
local: UI to support single "command line" in profiles
This commit is contained in:
parent
66098b5c6d
commit
1eed32f8d8
@ -67,6 +67,7 @@
|
||||
"ts-loader": "^9.2.3",
|
||||
"tslib": "^2.3.0",
|
||||
"typedoc": "^0.21.4",
|
||||
"shell-quote": "^1.7.2",
|
||||
"typescript": "^4.3.5",
|
||||
"url-loader": "^4.1.1",
|
||||
"val-loader": "4.0.0",
|
||||
|
@ -22,13 +22,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/deep-equal": "^1.0.0",
|
||||
"@types/shell-escape": "^0.2.0",
|
||||
"ansi-colors": "^4.1.1",
|
||||
"dataurl": "0.1.0",
|
||||
"deep-equal": "2.0.5",
|
||||
"ps-node": "^0.1.6",
|
||||
"runes": "^0.4.2",
|
||||
"shell-escape": "^0.2.0",
|
||||
"utils-decorators": "^1.8.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
41
tabby-local/src/components/commandLineEditor.component.pug
Normal file
41
tabby-local/src/components/commandLineEditor.component.pug
Normal file
@ -0,0 +1,41 @@
|
||||
ng-container(*ngIf='!argvMode')
|
||||
.form-group
|
||||
label Command line
|
||||
.input-group
|
||||
.input-group-prepend
|
||||
button.btn.btn-secondary((click)='switchToArgv()', title='Switch to split arguments')
|
||||
i.fas.fa-fw.fa-caret-right
|
||||
input.form-control.text-monospace(
|
||||
[(ngModel)]='command',
|
||||
(ngModelChange)='parseCommand()'
|
||||
)
|
||||
|
||||
ng-container(*ngIf='argvMode')
|
||||
.form-group
|
||||
label Program
|
||||
.input-group
|
||||
.input-group-prepend
|
||||
button.btn.btn-secondary((click)='switchToCommand()', title='Switch to a single-line command')
|
||||
i.fas.fa-fw.fa-caret-down
|
||||
input.form-control.text-monospace(
|
||||
type='text',
|
||||
[(ngModel)]='_model.command',
|
||||
)
|
||||
|
||||
.form-group
|
||||
label Arguments
|
||||
.input-group(
|
||||
*ngFor='let arg of _model.args; index as i; trackBy: trackByIndex',
|
||||
)
|
||||
input.form-control.text-monospace(
|
||||
type='text',
|
||||
[(ngModel)]='_model.args[i]',
|
||||
)
|
||||
.input-group-append
|
||||
button.btn.btn-secondary((click)='_model.args.splice(i, 1)')
|
||||
i.fas.fa-fw.fa-trash
|
||||
|
||||
.mt-2
|
||||
button.btn.btn-secondary((click)='_model.args.push("")')
|
||||
i.fas.fa-plus.mr-2
|
||||
| Add
|
50
tabby-local/src/components/commandLineEditor.component.ts
Normal file
50
tabby-local/src/components/commandLineEditor.component.ts
Normal file
@ -0,0 +1,50 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import * as shellQuote from 'shell-quote'
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { SessionOptions } from '../api'
|
||||
|
||||
/** @hidden */
|
||||
@Component({
|
||||
selector: 'command-line-editor',
|
||||
template: require('./commandLineEditor.component.pug'),
|
||||
})
|
||||
export class CommandLineEditorComponent {
|
||||
@Input() argvMode = false
|
||||
@Input() _model: SessionOptions
|
||||
command = ''
|
||||
|
||||
@Input() get model (): SessionOptions {
|
||||
return this._model
|
||||
}
|
||||
|
||||
set model (value: SessionOptions) {
|
||||
this._model = value
|
||||
this.updateCommand()
|
||||
}
|
||||
|
||||
switchToCommand () {
|
||||
this.updateCommand()
|
||||
this.argvMode = false
|
||||
}
|
||||
|
||||
switchToArgv () {
|
||||
this.argvMode = true
|
||||
}
|
||||
|
||||
parseCommand () {
|
||||
const args = shellQuote.parse(this.command)
|
||||
this.model.command = args[0] ?? ''
|
||||
this.model.args = args.slice(1)
|
||||
}
|
||||
|
||||
updateCommand () {
|
||||
this.command = shellQuote.quote([
|
||||
this.model.command,
|
||||
...this.model.args ?? [],
|
||||
])
|
||||
}
|
||||
|
||||
trackByIndex (index) {
|
||||
return index
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
.mb-2.d-flex.align-items-center(*ngFor='let pair of vars')
|
||||
.input-group
|
||||
input.form-control.w-25([(ngModel)]='pair.key', (blur)='emitUpdate()', placeholder='Variable name')
|
||||
input.form-control.w-25.text-monospace([(ngModel)]='pair.key', (blur)='emitUpdate()', placeholder='Variable name')
|
||||
.input-group-append
|
||||
.input-group-text =
|
||||
input.form-control.w-50([(ngModel)]='pair.value', (blur)='emitUpdate()', placeholder='Value')
|
||||
input.form-control.w-50.text-monospace([(ngModel)]='pair.value', (blur)='emitUpdate()', placeholder='Value')
|
||||
.input-group-append
|
||||
button.btn.btn-secondary((click)='removeEnvironmentVar(pair.key)')
|
||||
i.fas.fa-trash
|
||||
i.fas.fa-fw.fa-trash
|
||||
|
||||
button.btn.btn-secondary((click)='addEnvironmentVar()')
|
||||
i.fas.fa-plus.mr-2
|
||||
|
@ -1,27 +1,4 @@
|
||||
.form-group
|
||||
label Command
|
||||
input.form-control(
|
||||
type='text',
|
||||
[(ngModel)]='profile.options.command',
|
||||
)
|
||||
|
||||
.form-group
|
||||
label Arguments
|
||||
.input-group(
|
||||
*ngFor='let arg of profile.options.args; index as i; trackBy: trackByIndex',
|
||||
)
|
||||
input.form-control(
|
||||
type='text',
|
||||
[(ngModel)]='profile.options.args[i]',
|
||||
)
|
||||
.input-group-append
|
||||
button.btn.btn-secondary((click)='profile.options.args.splice(i, 1)')
|
||||
i.fas.fa-trash
|
||||
|
||||
.mt-2
|
||||
button.btn.btn-secondary((click)='profile.options.args.push("")')
|
||||
i.fas.fa-plus.mr-2
|
||||
| Add
|
||||
command-line-editor([model]='profile.options')
|
||||
|
||||
.form-line(*ngIf='uac.isAvailable')
|
||||
.header
|
||||
|
@ -40,8 +40,4 @@ export class LocalProfileSettingsComponent implements ProfileSettingsComponent<L
|
||||
)).filePaths
|
||||
this.profile.options.cwd = paths[0]
|
||||
}
|
||||
|
||||
trackByIndex (index) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import { TerminalTabComponent } from './components/terminalTab.component'
|
||||
import { ShellSettingsTabComponent } from './components/shellSettingsTab.component'
|
||||
import { EnvironmentEditorComponent } from './components/environmentEditor.component'
|
||||
import { LocalProfileSettingsComponent } from './components/localProfileSettings.component'
|
||||
import { CommandLineEditorComponent } from './components/commandLineEditor.component'
|
||||
|
||||
import { TerminalService } from './services/terminal.service'
|
||||
import { DockMenuService } from './services/dockMenu.service'
|
||||
@ -96,11 +97,13 @@ import { LocalProfilesService } from './profiles'
|
||||
TerminalTabComponent,
|
||||
ShellSettingsTabComponent,
|
||||
EnvironmentEditorComponent,
|
||||
CommandLineEditorComponent,
|
||||
LocalProfileSettingsComponent,
|
||||
],
|
||||
exports: [
|
||||
TerminalTabComponent,
|
||||
EnvironmentEditorComponent,
|
||||
CommandLineEditorComponent,
|
||||
],
|
||||
})
|
||||
export default class LocalTerminalModule { // eslint-disable-line @typescript-eslint/no-extraneous-class
|
||||
|
@ -7,11 +7,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03"
|
||||
integrity sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg==
|
||||
|
||||
"@types/shell-escape@^0.2.0":
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/shell-escape/-/shell-escape-0.2.0.tgz#cd2f0df814388599dd07196dcc510de2669d1ed2"
|
||||
integrity sha512-7kUdtJtUylvyISJbe9FMcvMTjRdP0EvNDO1WbT0lT22k/IPBiPRTpmWaKu5HTWLCGLQRWVHrzVHZktTDvvR23g==
|
||||
|
||||
ansi-colors@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
|
||||
@ -357,11 +352,6 @@ runes@^0.4.2:
|
||||
resolved "https://registry.yarnpkg.com/runes/-/runes-0.4.3.tgz#32f7738844bc767b65cc68171528e3373c7bb355"
|
||||
integrity sha512-K6p9y4ZyL9wPzA+PMDloNQPfoDGTiFYDvdlXznyGKgD10BJpcAosvATKrExRKOrNLgD8E7Um7WGW0lxsnOuNLg==
|
||||
|
||||
shell-escape@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133"
|
||||
integrity sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=
|
||||
|
||||
side-channel@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
|
||||
|
@ -22,7 +22,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/deep-equal": "^1.0.0",
|
||||
"@types/shell-escape": "^0.2.0",
|
||||
"ansi-colors": "^4.1.1",
|
||||
"binstring": "^0.2.1",
|
||||
"buffer-replace": "^1.0.0",
|
||||
@ -32,7 +31,6 @@
|
||||
"hexer": "^1.5.0",
|
||||
"ps-node": "^0.1.6",
|
||||
"runes": "^0.4.2",
|
||||
"shell-escape": "^0.2.0",
|
||||
"utils-decorators": "^1.8.1",
|
||||
"xterm": "^4.9.0-beta.7",
|
||||
"xterm-addon-fit": "^0.5.0",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import shellEscape from 'shell-escape'
|
||||
import shellQuote from 'shell-quote'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { CLIHandler, CLIEvent, AppService, HostWindowService } from 'tabby-core'
|
||||
import { BaseTerminalTabComponent } from './api/baseTerminalTab.component'
|
||||
@ -21,7 +21,7 @@ export class TerminalCLIHandler extends CLIHandler {
|
||||
if (op === 'paste') {
|
||||
let text = event.argv.text
|
||||
if (event.argv.escape) {
|
||||
text = shellEscape([text])
|
||||
text = shellQuote.quote([text])
|
||||
}
|
||||
this.handlePaste(text)
|
||||
return true
|
||||
|
@ -7,11 +7,6 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03"
|
||||
integrity sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg==
|
||||
|
||||
"@types/shell-escape@^0.2.0":
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/shell-escape/-/shell-escape-0.2.0.tgz#cd2f0df814388599dd07196dcc510de2669d1ed2"
|
||||
integrity sha512-7kUdtJtUylvyISJbe9FMcvMTjRdP0EvNDO1WbT0lT22k/IPBiPRTpmWaKu5HTWLCGLQRWVHrzVHZktTDvvR23g==
|
||||
|
||||
ansi-color@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-color/-/ansi-color-0.2.1.tgz#3e75c037475217544ed763a8db5709fa9ae5bf9a"
|
||||
@ -456,11 +451,6 @@ runes@^0.4.2:
|
||||
resolved "https://registry.yarnpkg.com/runes/-/runes-0.4.3.tgz#32f7738844bc767b65cc68171528e3373c7bb355"
|
||||
integrity sha512-K6p9y4ZyL9wPzA+PMDloNQPfoDGTiFYDvdlXznyGKgD10BJpcAosvATKrExRKOrNLgD8E7Um7WGW0lxsnOuNLg==
|
||||
|
||||
shell-escape@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133"
|
||||
integrity sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=
|
||||
|
||||
side-channel@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
|
||||
|
@ -7042,6 +7042,11 @@ shebang-regex@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
|
||||
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
|
||||
|
||||
shell-quote@^1.7.2:
|
||||
version "1.7.2"
|
||||
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
|
||||
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==
|
||||
|
||||
shelljs@0.8.4:
|
||||
version "0.8.4"
|
||||
resolved "https://registry.npmjs.org/shelljs/-/shelljs-0.8.4.tgz"
|
||||
|
Loading…
Reference in New Issue
Block a user