{"version":3,"file":"fit.js","sources":["../../../src/addons/fit/fit.ts","../../../node_modules/browser-pack/_prelude.js"],"sourcesContent":["/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * @license MIT\n *\n * Fit terminal columns and rows to the dimensions of its DOM element.\n *\n * ## Approach\n *\n * Rows: Truncate the division of the terminal parent element height by the\n * terminal row height.\n * Columns: Truncate the division of the terminal parent element width by the\n * terminal character width (apply display: inline at the terminal\n * row and truncate its width with the current number of columns).\n */\n\nexport function proposeGeometry(term) {\n if (!term.element.parentElement) {\n return null;\n }\n var parentElementStyle = window.getComputedStyle(term.element.parentElement);\n var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));\n var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17);\n var elementStyle = window.getComputedStyle(term.element);\n var elementPaddingVer = parseInt(elementStyle.getPropertyValue('padding-top')) + parseInt(elementStyle.getPropertyValue('padding-bottom'));\n var elementPaddingHor = parseInt(elementStyle.getPropertyValue('padding-right')) + parseInt(elementStyle.getPropertyValue('padding-left'));\n var availableHeight = parentElementHeight - elementPaddingVer;\n var availableWidth = parentElementWidth - elementPaddingHor;\n var geometry = {\n cols: Math.floor(availableWidth / term.renderer.dimensions.actualCellWidth),\n rows: Math.floor(availableHeight / term.renderer.dimensions.actualCellHeight)\n };\n\n return geometry;\n};\n\nexport function fit(term) {\n var geometry = proposeGeometry(term);\n if (geometry) {\n // Force a full render\n if (term.rows !== geometry.rows || term.cols !== geometry.cols) {\n term.renderer.clear();\n term.resize(geometry.cols, geometry.rows);\n }\n }\n};\n\nexport function apply(terminalConstructor) {\n terminalConstructor.prototype.proposeGeometry = function() {\n return proposeGeometry(this);\n }\n\n terminalConstructor.prototype.fit = function() {\n return fit(this);\n }\n}\n",null],"names":[],"mappings":"ACAA;;;ADeA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAlBA;AAkBC;AAED;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AATA;AASC;AAED;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AARA;;;"}