]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Merge remote-tracking branch 'upstream/master' into 478_cursorBlink_refresh
authorDaniel Imms <daimms@microsoft.com>
Sun, 15 Jan 2017 10:22:45 +0000 (02:22 -0800)
committerDaniel Imms <daimms@microsoft.com>
Sun, 15 Jan 2017 10:22:45 +0000 (02:22 -0800)
1  2 
demo/main.js
src/xterm.js

diff --cc demo/main.js
index 7425c05116d32eaf7ca4ebc03b99e4707a61fd87,52da2cef299f8000d1eee36d2544a693e0089ac1..078b5c8d66b225bc12c4b3ad9ad4652a3bcb0a41
@@@ -27,9 -28,10 +28,12 @@@ function setTerminalSize () 
  colsElement.addEventListener('change', setTerminalSize);
  rowsElement.addEventListener('change', setTerminalSize);
  
 -optionElements.cursorBlink.addEventListener('change', createTerminal);
 +optionElements.cursorBlink.addEventListener('change', function () {
 +  term.setOption('cursorBlink', optionElements.cursorBlink.checked);
 +});
+ optionElements.scrollback.addEventListener('change', function () {
+   terminal.setOption('scrollback', parseInt(optionElements.scrollback.value, 10));
+ });
  
  createTerminal();
  
diff --cc src/xterm.js
index a62033ddf651eb4865d7913f3f54c27f4806d753,353b96185885edb2988af4c131d36ffe49164f86..6649a0333f8d4f8f2e85830a152d562feae99468
@@@ -405,11 -405,26 +405,29 @@@ Terminal.prototype.setOption = function
    if (!(key in Terminal.defaults)) {
      throw new Error('No option with key "' + key + '"');
    }
+   switch (key) {
+     case 'scrollback':
+       if (this.options[key] !== value) {
+         if (this.lines.length > value) {
+           const amountToTrim = this.lines.length - value;
+           const needsRefresh = (this.ydisp - amountToTrim < 0);
+           this.lines.trimStart(amountToTrim);
+           this.ybase = Math.max(this.ybase - amountToTrim, 0);
+           this.ydisp = Math.max(this.ydisp - amountToTrim, 0);
+           if (needsRefresh) {
+             this.refresh(0, this.rows - 1);
+           }
+         }
+         this.lines.maxLength = value;
+         this.viewport.syncScrollArea();
+       }
+       break;
+   }
    this[key] = value;
    this.options[key] = value;
 +  switch (key) {
 +    case 'cursorBlink': this.element.classList.toggle('xterm-cursor-blink', value); break;
 +  }
  };
  
  /**