/
githubmirror
/
tabby
Обзор
Документация
Войти
/
githubmirror
/
tabby
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tabby-electron/src/terminalContextMenu.ts
44 строки
2 KB
Utkarsh Adhran
feat: add 'Export to file' option to terminal context menu (#11109)
17 май 2026, 13:02
Не верифицирован
17 май 2026, 13:02
ecf2a48
Код
Авторство
О чём код?
import * as fs from 'fs' import { Injectable } from '@angular/core' import { MenuItemOptions, NotificationsService, TranslateService } from 'tabby-core' import { BaseTerminalTabComponent, TerminalContextMenuItemProvider } from 'tabby-terminal' import { ElectronService } from './services/electron.service' /** @hidden */ @Injectable() export class ExportTerminalContextMenu extends TerminalContextMenuItemProvider { weight = 0 constructor ( private electron: ElectronService, private notifications: NotificationsService, private translate: TranslateService, ) { super() } async getItems (tab: BaseTerminalTabComponent<any>): Promise<MenuItemOptions[]> { return [ { label: this.translate.instant('Export to file'), click: async () => { const frontend = tab.frontend if (!frontend) { return } const result = await this.electron.dialog.showSaveDialog({ defaultPath: 'terminal.txt', }) if (!result.filePath) { return } frontend.selectAll() const content = frontend.getSelection() frontend.clearSelection() await fs.promises.writeFile(result.filePath, content) this.notifications.info(this.translate.instant('Saved to {path}', { path: result.filePath })) }, }, ] } }