Browse Source

copy notification

Eugene Pankov 7 years ago
parent
commit
b5f96a59f8

+ 1 - 0
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 = ''

+ 16 - 0
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;
+    }
+  }
+}

+ 8 - 1
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

+ 2 - 0
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,

+ 1 - 0
terminus-terminal/webpack.config.js

@@ -55,6 +55,7 @@ module.exports = {
     /^rxjs/,
     /^@angular/,
     /^@ng-bootstrap/,
+    'ngx-toastr',
     /^terminus-/,
   ],
   plugins: [