Commit fef9f161 authored by ibuler's avatar ibuler

[Update] 更新窗口大小

parent a0bb32eb
......@@ -46,16 +46,32 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
getWinSize() {
const activeEle = $('#winContainer');
const markerEle = $('#marker');
const cols = Math.floor(activeEle.width() / markerEle.width() * 6) - 6;
const rows = Math.floor(activeEle.height() / markerEle.height()) - 1;
return [cols, rows];
const elementStyle = window.getComputedStyle(this.term.element);
const elementPadding = {
top: parseInt(elementStyle.getPropertyValue('padding-top'), 10),
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom'), 10),
right: parseInt(elementStyle.getPropertyValue('padding-right'), 10),
left: parseInt(elementStyle.getPropertyValue('padding-left'), 10)
};
const elementPaddingVer = elementPadding.top + elementPadding.bottom;
const elementPaddingHor = elementPadding.right + elementPadding.left;
const availableHeight = activeEle.height() - elementPaddingVer;
const availableWidth = activeEle.width() - elementPaddingHor - (<any>this.term).viewport.scrollBarWidth;
const geometry = (
Math.floor(availableWidth / (<any>this.term).renderer.dimensions.actualCellWidth),
Math.floor(availableHeight / (<any>this.term).renderer.dimensions.actualCellHeight)
);
return geometry;
// const cols = Math.floor((activeEle.width() - 15) / markerEle.width() * 6) - 1;
// const rows = Math.floor(activeEle.height() / markerEle.height()) - 1;
// return [cols, rows];
}
resizeTerm() {
// fit(this.term);
const size = this.getWinSize();
if (isNaN(size[0])) {
if (isNaN(size[0]) || isNaN(size[1])) {
fit(this.term);
} else {
this.term.resize(size[0], size[1]);
......
......@@ -21,8 +21,7 @@ app-root {
top: 0;
left: 0;
z-index: -1;
font-size: 13px !important;
padding-bottom: 16px !important;
font-size: 14px !important;
font-family: 'Monaco', 'Consolas', 'monospace' !important;
color: white;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment