import { Component } from '@angular/core'
import { ConfigService } from 'tabby-core'
@Component({
template: `
Backslash Newline Settings
{{getPreviewText()}}
`,
})
export class BackslashNewlineSettingsTabComponent {
customText: string = ' \\\n'
saveStatus: boolean = false
private readonly defaultText = ' \\\n'
constructor(private config: ConfigService) {
this.customText = this.config.store?.backslashNewline?.customText || this.defaultText
}
onTextChange() {
// 直接設定配置值
if (!this.config.store.backslashNewline) {
(this.config.store as any).backslashNewline = {}
}
(this.config.store as any).backslashNewline.customText = this.customText
this.config.save()
// Show save status for 2 seconds
this.saveStatus = true
setTimeout(() => {
this.saveStatus = false
}, 2000)
}
resetToDefault() {
this.customText = this.defaultText
this.onTextChange()
}
getPreviewText(): string {
return this.customText
.replace(/\\\\/g, '\\')
.replace(/\\n/g, '⏎')
.replace(/\\t/g, '→')
.replace(/ /g, '·')
}
}