Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b6ad0fd7b | ||
|
|
189a556408 | ||
|
|
fb1c484224 | ||
|
|
59ebbbaaf0 | ||
|
|
6e6b5dad8c | ||
|
|
0b603952c3 |
@@ -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);
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "xterm.js",
|
"name": "xterm.js",
|
||||||
"version": "0.8",
|
"version": "0.10",
|
||||||
"ignore": ["demo", "docs", "test", ".gitignore"]
|
"ignore": ["demo", "docs", "test", ".gitignore"]
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -5,9 +5,10 @@
|
|||||||
<link rel="stylesheet" href="../src/xterm.css" />
|
<link rel="stylesheet" href="../src/xterm.css" />
|
||||||
<link rel="stylesheet" href="../addon/fullscreen/fullscreen.css" />
|
<link rel="stylesheet" href="../addon/fullscreen/fullscreen.css" />
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
<script src="../src/xterm.js"></script>
|
<script src="../src/xterm.js" ></script>
|
||||||
<script src="../addon/fullscreen/fullscreen.js"></script>
|
<script src="../addons/fit/fit.js" ></script>
|
||||||
<script src="main.js" defer></script>
|
<script src="../addons/fullscreen/fullscreen.js" ></script>
|
||||||
|
<script src="main.js" defer ></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>
|
<h1>
|
||||||
|
|||||||
@@ -40,12 +40,18 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
outline: none;
|
outline: none;
|
||||||
font-family: courier-new, courier, monospace;
|
font-family: courier-new, courier, monospace;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.xterm .terminal-cursor {
|
.xterm .terminal-cursor {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.xterm .xterm-helpers {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.xterm .xterm-helper-textarea {
|
.xterm .xterm-helper-textarea {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
|
|||||||
+1
-34
@@ -568,9 +568,7 @@ Terminal.prototype.open = function(parent) {
|
|||||||
|
|
||||||
on(this.element, 'mouseup', function() {
|
on(this.element, 'mouseup', function() {
|
||||||
var selection = document.getSelection();
|
var selection = document.getSelection();
|
||||||
if (selection.type == 'Range') {
|
if (selection.type != 'Range') {
|
||||||
console.log(selection);
|
|
||||||
} else {
|
|
||||||
self.focus();
|
self.focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -2361,7 +2359,6 @@ Terminal.prototype.keyDown = function(ev) {
|
|||||||
|
|
||||||
this.emit('keydown', ev);
|
this.emit('keydown', ev);
|
||||||
this.emit('key', key, ev);
|
this.emit('key', key, ev);
|
||||||
console.log('keydown');
|
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
this.handler(key);
|
this.handler(key);
|
||||||
|
|
||||||
@@ -2403,7 +2400,6 @@ Terminal.prototype.keyPress = function(ev) {
|
|||||||
|
|
||||||
this.emit('keypress', key, ev);
|
this.emit('keypress', key, ev);
|
||||||
this.emit('key', key, ev);
|
this.emit('key', key, ev);
|
||||||
console.log('keypress');
|
|
||||||
this.showCursor();
|
this.showCursor();
|
||||||
this.handler(key);
|
this.handler(key);
|
||||||
|
|
||||||
@@ -2525,35 +2521,6 @@ Terminal.prototype.resize = function(x, y) {
|
|||||||
this.emit('resize', {terminal: this, cols: x, rows: 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.scrollHeight / subjectRow.offsetHeight),
|
|
||||||
characterWidth,
|
|
||||||
cols;
|
|
||||||
|
|
||||||
subjectRow.style.display = 'inline';
|
|
||||||
characterWidth = parseInt(subjectRow.offsetWidth / this.cols);
|
|
||||||
subjectRow.style.display = '';
|
|
||||||
|
|
||||||
cols = parseInt(container.scrollWidth / characterWidth);
|
|
||||||
|
|
||||||
this.resize(cols, rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
Terminal.prototype.updateRange = function(y) {
|
Terminal.prototype.updateRange = function(y) {
|
||||||
if (y < this.refreshStart) this.refreshStart = y;
|
if (y < this.refreshStart) this.refreshStart = y;
|
||||||
if (y > this.refreshEnd) this.refreshEnd = y;
|
if (y > this.refreshEnd) this.refreshEnd = y;
|
||||||
|
|||||||
Reference in New Issue
Block a user