]> git.proxmox.com Git - mirror_xterm.js.git/blobdiff - src/Parser.ts
Merge pull request #926 from ficristo/search-fix
[mirror_xterm.js.git] / src / Parser.ts
index 01821a5a031b3c9819c9e0f0d3ad0d8166779855..1c2fb6b038e7bacbf4ed21d18c6f6397fab04984 100644 (file)
@@ -52,7 +52,7 @@ escapedStateHandler['c'] = (parser, terminal) => {
 };
 escapedStateHandler['E'] = (parser, terminal) => {
   // ESC E Next Line ( NEL is 0x85).
-  terminal.x = 0;
+  terminal.buffer.x = 0;
   terminal.index();
   parser.setState(ParserState.NORMAL);
 };
@@ -181,9 +181,13 @@ export class Parser {
    *
    * @param data The data to parse.
    */
-  public parse(data: string) {
+  public parse(data: string): ParserState {
     let l = data.length, j, cs, ch, code, low;
 
+    if (this._terminal.debug) {
+      this._terminal.log('data: ' + data);
+    }
+
     this._position = 0;
     // apply leftover surrogate high from last write
     if (this._terminal.surrogate_high) {
@@ -458,6 +462,9 @@ export class Parser {
 
         case ParserState.CSI:
           if (ch in csiStateHandler) {
+            if (this._terminal.debug) {
+              this._terminal.log(`CSI ${this._terminal.prefix ? this._terminal.prefix : ''} ${this._terminal.params ? this._terminal.params.join(';') : ''} ${this._terminal.postfix ? this._terminal.postfix : ''} ${ch}`);
+            }
             csiStateHandler[ch](this._inputHandler, this._terminal.params, this._terminal.prefix, this._terminal.postfix, this);
           } else {
             this._terminal.error('Unknown CSI code: %s.', ch);
@@ -471,6 +478,8 @@ export class Parser {
         case ParserState.DCS:
           if (ch === C0.ESC || ch === C0.BEL) {
             if (ch === C0.ESC) this._position++;
+            let pt;
+            let valid: boolean;
 
             switch (this._terminal.prefix) {
               // User-Defined Keys (DECUDK).
@@ -480,8 +489,8 @@ export class Parser {
               // Request Status String (DECRQSS).
               // test: echo -e '\eP$q"p\e\\'
               case '$q':
-                let pt = this._terminal.currentParam
-                valid = false;
+                pt = this._terminal.currentParam;
+                valid = false;
 
                 switch (pt) {
                   // DECSCA
@@ -497,9 +506,9 @@ export class Parser {
                   // DECSTBM
                   case 'r':
                     pt = ''
-                      + (this._terminal.scrollTop + 1)
+                      + (this._terminal.buffer.scrollTop + 1)
                       + ';'
-                      + (this._terminal.scrollBottom + 1)
+                      + (this._terminal.buffer.scrollBottom + 1)
                       + 'r';
                     break;
 
@@ -526,9 +535,8 @@ export class Parser {
               // This can cause a small glitch in vim.
               // test: echo -ne '\eP+q6b64\e\\'
               case '+q':
-                // TODO: Don't declare pt twice
-                /*let*/ pt = this._terminal.currentParam
-                , valid = false;
+                pt = this._terminal.currentParam;
+                valid = false;
 
                 this._terminal.send(C0.ESC + 'P' + +valid + '+r' + pt + C0.ESC + '\\');
                 break;
@@ -563,6 +571,7 @@ export class Parser {
           break;
       }
     }
+    return this._state;
   }
 
   /**