]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Moved fit into its own addon
authorparis <pariskasidiaris@gmail.com>
Fri, 11 Apr 2014 02:04:56 +0000 (02:04 +0000)
committerparis <pariskasidiaris@gmail.com>
Fri, 11 Apr 2014 02:04:56 +0000 (02:04 +0000)
addons/fit/fit.js [new file with mode: 0644]
bower.json
demo/index.html
src/xterm.js

diff --git a/addons/fit/fit.js b/addons/fit/fit.js
new file mode 100644 (file)
index 0000000..0b0eb14
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  Fit terminal columns and rows to the dimensions of its
+ *  DOM element.
+ *
+ *  Approach:
+ *    - Rows: Truncate the division of the terminal parent element height
+ *            by the terminal row height
+ *
+ *    - Columns: Truncate the division of the terminal parent element width by
+ *               the terminal character width (apply display: inline at the
+ *               terminal row and truncate its width with the current number
+ *               of columns)
+ */
+Terminal.prototype.fit = function () {
+  var container = this.element.parentElement,
+      subjectRow = this.rowContainer.firstElementChild,
+      rows = parseInt(container.offsetHeight / subjectRow.offsetHeight),
+      characterWidth,
+      cols;
+  
+  subjectRow.style.display = 'inline';
+  characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
+  subjectRow.style.display = '';
+  
+  cols = parseInt(container.offsetWidth / characterWidth);
+      
+  this.resize(cols, rows);
+}
\ No newline at end of file
index e84bba591e1debec5077849cf7a7967d41ef05b9..125affaeb9de7a46f80ad762e8e3c2beda95bc44 100644 (file)
@@ -1,5 +1,5 @@
 {
   "name": "xterm.js",
-  "version": "0.9.2",
+  "version": "0.9.3",
   "ignore": ["demo", "docs", "test", ".gitignore"]
 }
index 73aa304a067657ccdc0a98e3a53a3b892aa4f8c5..b09ffa8e1fa882b2e8b45dbe82898248b99589cf 100644 (file)
@@ -5,9 +5,10 @@
         <link rel="stylesheet" href="../src/xterm.css" />
         <link rel="stylesheet" href="../addon/fullscreen/fullscreen.css" />
         <link rel="stylesheet" href="style.css" />
-        <script src="../src/xterm.js"></script>
-        <script src="../addon/fullscreen/fullscreen.js"></script>
-        <script src="main.js" defer></script>
+        <script src="../src/xterm.js" ></script>
+        <script src="../addons/fit/fit.js" ></script>
+        <script src="../addons/fullscreen/fullscreen.js" ></script>
+        <script src="main.js" defer ></script>
     </head>
     <body>
         <h1>
index 32f504a9a9f6d0c006c58ed1207000b85cec0407..7c56a60305e1b08fa65c086f0c8cfcc59db20525 100644 (file)
@@ -2521,35 +2521,6 @@ Terminal.prototype.resize = function(x, y) {
   this.emit('resize', {terminal: this, cols: x, rows: y});
 };
 
-/*
-*  Fit terminal columns and rows to the dimensions of its
-*  DOM element.
-*
-*  Approach:
-*    - Rows: Truncate the division of the terminal parent element height
-*            by the terminal row height
-*
-*    - Columns: Truncate the division of the terminal parent element width by
-*               the terminal character width (apply display: inline at the
-*               terminal row and truncate its width with the current number
-*               of columns)
-*/
-Terminal.prototype.fit = function () {
-  var container = this.element.parentElement,
-      subjectRow = this.rowContainer.firstElementChild,
-      rows = parseInt(container.offsetHeight / subjectRow.offsetHeight),
-      characterWidth,
-      cols;
-  
-  subjectRow.style.display = 'inline';
-  characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
-  subjectRow.style.display = '';
-  
-  cols = parseInt(container.offsetWidth / characterWidth);
-      
-  this.resize(cols, rows);
-}
-
 Terminal.prototype.updateRange = function(y) {
   if (y < this.refreshStart) this.refreshStart = y;
   if (y > this.refreshEnd) this.refreshEnd = y;