From b5f96a59f8a987cb62b8d955f7d5c64cfa287b67 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Fri, 30 Mar 2018 23:24:34 +0200 Subject: [PATCH] copy notification --- app/src/entry.ts | 1 + app/src/toastr.scss | 16 ++++++++++++++++ .../src/components/terminalTab.component.ts | 9 ++++++++- terminus-terminal/src/index.ts | 2 ++ terminus-terminal/webpack.config.js | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 app/src/toastr.scss diff --git a/app/src/entry.ts b/app/src/entry.ts index fb804cbc..ee03e958 100644 --- a/app/src/entry.ts +++ b/app/src/entry.ts @@ -2,6 +2,7 @@ import 'zone.js' import 'core-js/es7/reflect' import 'core-js/core/delay' import 'rxjs' +import './toastr.scss' // Always land on the start view location.hash = '' diff --git a/app/src/toastr.scss b/app/src/toastr.scss new file mode 100644 index 00000000..ce64cd03 --- /dev/null +++ b/app/src/toastr.scss @@ -0,0 +1,16 @@ +#toast-container { + display: flex; + flex-direction: column; + align-items: center; + + .toast { + box-shadow: 0 1px 0 rgba(0,0,0,.25); + padding: 10px; + background-image: none; + width: auto; + + &.toast-info { + background-color: #555; + } + } +} diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 459ef2c6..f4da64e6 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -1,5 +1,5 @@ import { BehaviorSubject, Subject, Subscription } from 'rxjs' -import 'rxjs/add/operator/bufferTime' +import { ToastrService } from 'ngx-toastr' import { Component, NgZone, Inject, Optional, ViewChild, HostBinding, Input } from '@angular/core' import { AppService, ConfigService, BaseTabComponent, ElectronService, ThemesService, HostAppService, HotkeysService, Platform } from 'terminus-core' @@ -54,6 +54,7 @@ export class TerminalTabComponent extends BaseTabComponent { private electron: ElectronService, private terminalService: TerminalService, public config: ConfigService, + private toastr: ToastrService, @Optional() @Inject(TerminalDecorator) private decorators: TerminalDecorator[], ) { super() @@ -219,6 +220,12 @@ export class TerminalTabComponent extends BaseTabComponent { this.alternateScreenActive$.next(state) } + const _copySelectionToClipboard = hterm.copySelectionToClipboard.bind(hterm) + hterm.copySelectionToClipboard = () => { + _copySelectionToClipboard() + this.toastr.info('Copied') + } + hterm.primaryScreen_.syncSelectionCaret = () => null hterm.alternateScreen_.syncSelectionCaret = () => null hterm.primaryScreen_.terminal = hterm diff --git a/terminus-terminal/src/index.ts b/terminus-terminal/src/index.ts index 1d970ef7..f1cfba7d 100644 --- a/terminus-terminal/src/index.ts +++ b/terminus-terminal/src/index.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' import { FormsModule } from '@angular/forms' import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { ToastrModule } from 'ngx-toastr' import { ToolbarButtonProvider, TabRecoveryProvider, ConfigProvider, HotkeysService, HotkeyProvider, AppService, ConfigService } from 'terminus-core' import { SettingsTabProvider } from 'terminus-settings' @@ -41,6 +42,7 @@ import { hterm } from './hterm' BrowserModule, FormsModule, NgbModule, + ToastrModule, ], providers: [ SessionsService, diff --git a/terminus-terminal/webpack.config.js b/terminus-terminal/webpack.config.js index 5312559a..0092e851 100644 --- a/terminus-terminal/webpack.config.js +++ b/terminus-terminal/webpack.config.js @@ -55,6 +55,7 @@ module.exports = { /^rxjs/, /^@angular/, /^@ng-bootstrap/, + 'ngx-toastr', /^terminus-/, ], plugins: [