浏览代码

Implemented some commands

charnpreetsingh185 8 年之前
父节点
当前提交
2c51fb3877
共有 2 个文件被更改,包括 78 次插入10 次删除
  1. 77 9
      src/terminal/plugin.ts
  2. 1 1
      src/widgettracker/index.ts

+ 77 - 9
src/terminal/plugin.ts

@@ -27,6 +27,9 @@ const terminalExtension = {
 function activateTerminal(app: Application): void {
 function activateTerminal(app: Application): void {
 
 
   let newTerminalId = 'terminal:create-new';
   let newTerminalId = 'terminal:create-new';
+  let increaseTerminalFontSize = 'terminal:increase-font';
+  let decreaseTerminalFontSize = 'terminal:decrease-font';
+  let toggleTerminalTheme = 'terminal:toggle-theme';
 
 
   // Track the current active terminal.
   // Track the current active terminal.
   let tracker = new WidgetTracker<TerminalWidget>();
   let tracker = new WidgetTracker<TerminalWidget>();
@@ -35,21 +38,86 @@ function activateTerminal(app: Application): void {
     activeTerm = widget;
     activeTerm = widget;
   });
   });
 
 
-  app.commands.add([{
-    id: newTerminalId,
-    handler: () => {
-      let term = new TerminalWidget();
-      term.title.closable = true;
-      app.shell.addToMainArea(term);
-      tracker.addWidget(term);
+  app.commands.add([
+    {
+      id: newTerminalId,
+      handler: () => {
+        let term = new TerminalWidget();
+        term.title.closable = true;
+        app.shell.addToMainArea(term);
+        tracker.addWidget(term);
+      }
+    },
+    {
+      id: increaseTerminalFontSize,
+      handler: increaseFont
+    },
+    {
+      id: decreaseTerminalFontSize,
+      handler: decreaseFont
+    },
+    {
+      id: toggleTerminalTheme,
+      handler: toggleTheme
     }
     }
-  }]);
+]);
   app.palette.add([
   app.palette.add([
     {
     {
       command: newTerminalId,
       command: newTerminalId,
       category: 'Terminal',
       category: 'Terminal',
-      text: 'New Terminal',
+      text: 'Create a new Terminal',
       caption: 'Start a new terminal session'
       caption: 'Start a new terminal session'
+    },
+    {
+      command: increaseTerminalFontSize,
+      category: 'Terminal',
+      text: 'Increase Terminal Font Size',
+    },
+    {
+      command: decreaseTerminalFontSize,
+      category: 'Terminal',
+      text: 'Decrease Terminal Font Size',
+    },
+    {
+      command: toggleTerminalTheme,
+      category: 'Terminal',
+      text: 'Toggle Terminal Theme',
+      caption: 'Switch Terminal Background and Font Colors'
     }
     }
   ]);
   ]);
+
+  function increaseFont(): void {
+    if (!tracker.isDisposed) {
+      for (var i = 0; i < tracker.widgets.length; i++) {
+        if (tracker.widgets[i].fontSize < 72) {
+          tracker.widgets[i].fontSize = tracker.widgets[i].fontSize + 1;
+        }
+      }
+    }
+  }
+
+  function decreaseFont(): void {
+    if (!tracker.isDisposed) {
+      for (var i = 0; i < tracker.widgets.length; i++) {
+        if (tracker.widgets[i].fontSize > 9) {
+          tracker.widgets[i].fontSize = tracker.widgets[i].fontSize - 1;
+        }
+      }
+    }
+  }
+
+  function toggleTheme(): void {
+    if (!tracker.isDisposed) {
+      for (var i = 0; i < tracker.widgets.length; i++) {
+        if (tracker.widgets[i].background === 'black') {
+          tracker.widgets[i].background = 'white';
+          tracker.widgets[i].color = 'black';
+        }
+        else {
+          tracker.widgets[i].background = 'black';
+          tracker.widgets[i].color = 'white';
+        }
+      }
+    }
+  }
 }
 }

+ 1 - 1
src/widgettracker/index.ts

@@ -52,7 +52,7 @@ class WidgetTracker<T extends Widget> implements IDisposable {
    * This is a read-only property.
    * This is a read-only property.
    */
    */
   get isDisposed(): boolean {
   get isDisposed(): boolean {
-    return this._widgets = null;
+    return this._widgets === null;
   }
   }
 
 
   /**
   /**