]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
First chunk of documentation
authorParis <paris@sourcelair.com>
Sun, 19 Jun 2016 19:02:20 +0000 (22:02 +0300)
committerParis <paris@sourcelair.com>
Wed, 6 Jul 2016 09:32:40 +0000 (09:32 +0000)
src/xterm.js

index 8633ff96e6c606ae2beec40ac5e6ec384dbe8970..2b00b3de65102e1df2d5aa9a3b876980cf9b6f95 100644 (file)
      *   - cursorBlink (boolean): Whether the terminal cursor blinks
      *
      * @public
+     * @class Xterm Xterm
+     * @alias module:xterm/src/xterm
      */
     function Terminal(options) {
       var self = this;
 
     inherits(Terminal, EventEmitter);
 
-    // back_color_erase feature for xterm.
+               /**
+                *
+                * back_color_erase feature for xterm.
+                *
+                * @public
+                */
     Terminal.prototype.eraseAttr = function() {
       // if (this.is('screen')) return this.defAttr;
       return (this.defAttr & ~0x1ff) | (this.curAttr & 0x1ff);
 
     /**
      * Initialize default behavior
+     *
+     * @public
      */
     Terminal.prototype.initGlobal = function() {
       Terminal.bindKeys(this);
     };
 
 
-    /*
+    /**
      * Apply key handling to the terminal
+     *
+     * @param {Xterm} term The terminal on which to bind key handling
+     * @static
      */
     Terminal.bindKeys = function(term) {
       on(term.element, 'keydown', function(ev) {
     };
 
        /**
-        * Cancel the cut event completely
+        * Cancel the cut event completely.
+        * @param {Xterm} term The terminal on which to bind the cut event handling functionality.
+        * @static
         */
        Terminal.bindCut = function(term) {
       on(term.element, 'cut', function (ev) {
     };
 
 
+    /**
+     * Do not perform the "drop" event. Altering the contents of the
+     * terminal with drag n drop is unwanted behavior.
+        * @param {Xterm} term The terminal on which to bind the drop event handling functionality.
+        * @static
+        */
     Terminal.bindDrop = function (term) {
-      /*
-       * Do not perform the "drop" event. Altering the contents of the
-       * terminal with drag n drop is unwanted behavior.
-       */
       on(term.element, 'drop', function (ev) {
         term.cancel(ev, true);
       });
     };
 
-
+    /**
+     * Cancel click handling on the given terminal
+        * @param {Xterm} term The terminal on which to bind the click event handling functionality.
+        * @static
+        */
     Terminal.click = function (term) {
-      /*
-       * Do not perform the "drop" event. Altering the contents of the
-       * terminal with drag n drop is unwanted behavior.
-       */
       on(term.element, 'click', function (ev) {
         term.cancel(ev, true);
       });
     };
 
 
-    /*
+    /**
      * Insert the given row to the terminal or produce a new one
      * if no row argument is passed. Return the inserted row.
+     * @param {HTMLElement} row (optional) The row to append to the terminal.
      */
     Terminal.prototype.insertRow = function (row) {
       if (typeof row != 'object') {
      * Opens the terminal within an element.
      *
      * @param {HTMLElement} parent The element to create the terminal within.
-     *
      * @public
      */
     Terminal.prototype.open = function(parent) {
     };
 
 
-    // XTerm mouse events
-    // http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
-    // To better understand these
-    // the xterm code is very helpful:
-    // Relevant files:
-    //   button.c, charproc.c, misc.c
-    // Relevant functions in xterm/button.c:
-    //   BtnCode, EmitButtonCode, EditorButton, SendMousePosition
+       /**
+     * XTerm mouse events
+     * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#Mouse%20Tracking
+     * To better understand these
+     * the xterm code is very helpful:
+     * Relevant files:
+     *   button.c, charproc.c, misc.c
+     * Relevant functions in xterm/button.c:
+     *   BtnCode, EmitButtonCode, EditorButton, SendMousePosition
+     */
     Terminal.prototype.bindMouse = function() {
-      var el = this.element
-        , self = this
-        , pressed = 32;
-
-      var wheelEvent = 'onmousewheel' in this.context
-        ? 'mousewheel'
-        : 'DOMMouseScroll';
+      var el = this.element, self = this, pressed = 32;
+      var wheelEvent = ('onmousewheel' in this.context) ? 'mousewheel' : 'DOMMouseScroll';
 
       // mouseup, mousedown, mousewheel
       // left click: ^[[M 3<^[[M#3<
 
     /**
      * Destroys the terminal.
-     *
      * @public
      */
     Terminal.prototype.destroy = function() {
      * @param {number} start The row to start from (between 0 and terminal's height terminal - 1)
      * @param {number} end The row to end at (between fromRow and terminal's height terminal - 1)
      * @param {boolean} queue Whether the refresh should ran right now or be queued
-     *
-     * @public
      */
     Terminal.prototype.refresh = function(start, end, queue) {
       var self = this;
       this.emit('refresh', {element: this.element, start: start, end: end});
     };
 
+       /**
+        * Display the cursor element
+        */
     Terminal.prototype.showCursor = function() {
       if (!this.cursorState) {
         this.cursorState = 1;
       }
     };
 
+       /**
+        * Scroll the terminal
+        */
     Terminal.prototype.scroll = function() {
       var row;
 
       this.updateRange(this.scrollBottom);
     };
 
+       /**
+        * Scroll the display of the terminal
+        * @param {number} disp
+        */
     Terminal.prototype.scrollDisp = function(disp) {
       this.ydisp += disp;
 
 
     /**
      * Writes text to the terminal.
-     *
      * @param {string} text The text to write to the terminal.
-     *
-     * @public
      */
     Terminal.prototype.write = function(data) {
       var l = data.length, i = 0, j, cs, ch, code, low, ch_width, row;
       this.refresh(this.refreshStart, this.refreshEnd);
     };
 
+    /**
+     * Writes text to the terminal, followed by a break line character (\n).
+     * @param {string} text The text to write to the terminal.
+     */
     Terminal.prototype.writeln = function(data) {
       this.write(data + '\r\n');
     };
 
-    // Key Resources:
-    // https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
+       /**
+        * Handle a keydown event
+     * Key Resources:
+     *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
+     * @param {KeyboardEvent} ev The keydown event to be handled.
+     */
     Terminal.prototype.keyDown = function(ev) {
       var self = this;
       var result = this.evaluateKeyEscapeSequence(ev);
      * returned value is the new key code to pass to the PTY.
      *
      * Reference: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+     * @param {KeyboardEvent} ev The keyboard event to be translated to key escape sequence.
      */
     Terminal.prototype.evaluateKeyEscapeSequence = function(ev) {
       var result = {
       return result;
     };
 
+       /**
+        * Set the G level of the terminal
+        * @param g
+        */
     Terminal.prototype.setgLevel = function(g) {
       this.glevel = g;
       this.charset = this.charsets[g];
     };
 
+    /**
+        * Set the charset for the given G level of the terminal
+        * @param g
+        * @param charset
+        */
     Terminal.prototype.setgCharset = function(g, charset) {
       this.charsets[g] = charset;
       if (this.glevel === g) {
       }
     };
 
+    /**
+        * Handle a keypress event.
+     * Key Resources:
+     *   - https://developer.mozilla.org/en-US/docs/DOM/KeyboardEvent
+     * @param {KeyboardEvent} ev The keypress event to be handled.
+     */
     Terminal.prototype.keyPress = function(ev) {
       var key;
 
       return false;
     };
 
+       /**
+        * Send data for handling to the terminal
+        * @param {string} data
+        */
     Terminal.prototype.send = function(data) {
       var self = this;
 
       this.queue += data;
     };
 
+       /**
+        * Ring the bell.
+        * Note: We could do sweet things with webaudio here
+        */
     Terminal.prototype.bell = function() {
       if (!this.visualBell) return;
       var self = this;
       if (this.popOnBell) this.focus();
     };
 
+       /**
+        * Log the current state to the console.
+        */
     Terminal.prototype.log = function() {
       if (!this.debug) return;
       if (!this.context.console || !this.context.console.log) return;
       this.context.console.log.apply(this.context.console, args);
     };
 
+       /**
+        * Log the current state as error to the console.
+        */
     Terminal.prototype.error = function() {
       if (!this.debug) return;
       if (!this.context.console || !this.context.console.error) return;
      *
      * @param {number} x The number of columns to resize to.
      * @param {number} y The number of rows to resize to.
-     *
-     * @public
      */
     Terminal.prototype.resize = function(x, y) {
       var line
     Terminal.off = off;
     Terminal.cancel = cancel;
 
+
     return Terminal;
 });