]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
[fit addon] Introduce proposeGeometry method
authorparis <paris@sourcelair.com>
Mon, 17 Nov 2014 10:21:05 +0000 (12:21 +0200)
committerparis <paris@sourcelair.com>
Mon, 17 Nov 2014 10:21:05 +0000 (12:21 +0200)
- Introduce new method to propose optimal geometry for the current terminal
- Bump version to 0.23

addons/fit/fit.js
bower.json
docs/conf.py

index 69909c418c715cafe9ee7fb56710f4434dd45808..3b1df00226f9416924452fcf9919a828987c7359 100644 (file)
         fit(this.Xterm);
     }
 })(function (Xterm) {
-    Xterm.prototype.fit = function () {
-      var container = this.rowContainer,
-          subjectRow = this.rowContainer.firstElementChild,
-          rows,
-          contentBuffer,
-          characterWidth,
-          cols;
+    Xterm.prototype.proposeGeometry = function () {
+        var container = this.rowContainer,
+            subjectRow = this.rowContainer.firstElementChild,
+            rows,
+            contentBuffer,
+            characterWidth,
+            cols;
+
+        subjectRow.style.display = 'inline';
 
-      subjectRow.style.display = 'inline';
+        contentBuffer = subjectRow.textContent;
 
-      contentBuffer = subjectRow.textContent;
+        subjectRow.innerHTML = '&nbsp;'; /* Arbitrary character to calculate its dimensions */
+        characterWidth = parseInt(subjectRow.offsetWidth);
+        characterHeight = parseInt(subjectRow.offsetHeight);
 
-      subjectRow.innerHTML = '&nbsp;'; /* Arbitrary character to calculate its dimensions */
-      characterWidth = parseInt(subjectRow.offsetWidth);
-      characterHeight = parseInt(subjectRow.offsetHeight);
+        subjectRow.style.display = '';
 
-      subjectRow.style.display = '';
+        cols = container.offsetWidth / characterWidth;
+        cols = parseInt(cols);
 
-      cols = container.offsetWidth / characterWidth;
-      cols = parseInt(cols);
+        var parentElementStyle = window.getComputedStyle(this.element.parentElement),
+            parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
+            elementStyle = window.getComputedStyle(this.element),
+            elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
+            availableHeight = parentElementHeight - elementPadding,
+            rowHeight = this.rowContainer.firstElementChild.offsetHeight;
 
-      var parentElementStyle = window.getComputedStyle(this.element.parentElement),
-          parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
-          elementStyle = window.getComputedStyle(this.element),
-          elementPadding = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom')),
-          availableHeight = parentElementHeight - elementPadding,
-          rowHeight = this.rowContainer.firstElementChild.offsetHeight;
+        rows = parseInt(availableHeight / rowHeight);
+        
+        var geometry = {
+                'cols': cols,
+                'rows': rowss
+            };
 
-      rows = parseInt(availableHeight / rowHeight);
+        return geometry;
+    };
+
+    Xterm.prototype.fit = function () {
+        var geometry = this.proposeGeometry();
 
-      this.resize(cols, rows);
+        this.resize(geometry.cols, geometry.rows);
     };
 });
\ No newline at end of file
index 8648a77ee4ed1872fab9237f75d18051d2f557c7..45b934161efe0b7cbd1b4933a50ca83c8d94fa16 100644 (file)
@@ -1,5 +1,5 @@
 {
   "name": "xterm.js",
-  "version": "0.22",
+  "version": "0.23",
   "ignore": ["demo", "docs", "test", ".gitignore"]
 }
index 53ce9720687b4e880f1b635ba602f98d65ac8110..c14bb7c2b47e5bdee33022b825cb111b2420567d 100644 (file)
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
 # built documents.
 #
 # The short X.Y version.
-version = '0.22'
+version = '0.23'
 # The full version, including alpha/beta/rc tags.
-release = '0.22 Alpha'
+release = '0.23 Alpha'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.