Compare commits

...
4 Commits
Author SHA1 Message Date
paris c6a7e15b03 [fit addon] Restore row content after proposing geometry
- Restore `subjectRow.innerHTML`, using the `contentBuffer`
- Bump version to 0.25
2014-11-17 12:36:13 +02:00
paris 87979aeed4 Bind window to AMD module
- Bind window to Xterm AMD module
- Fix typo in fit addon
- Bump version to 0.24
2014-11-17 12:28:52 +02:00
paris 615f633f25 [fit addon] Introduce proposeGeometry method
- Introduce new method to propose optimal geometry for the current terminal
- Bump version to 0.23
2014-11-17 12:21:05 +02:00
paris 567b39dc98 Fix #6 2014-09-22 05:48:05 +00:00
5 changed files with 56 additions and 37 deletions
+16 -3
View File
@@ -24,7 +24,7 @@
fit(this.Xterm); fit(this.Xterm);
} }
})(function (Xterm) { })(function (Xterm) {
Xterm.prototype.fit = function () { Xterm.prototype.proposeGeometry = function () {
var container = this.rowContainer, var container = this.rowContainer,
subjectRow = this.rowContainer.firstElementChild, subjectRow = this.rowContainer.firstElementChild,
rows, rows,
@@ -34,7 +34,7 @@
subjectRow.style.display = 'inline'; subjectRow.style.display = 'inline';
contentBuffer = subjectRow.textContent; contentBuffer = subjectRow.innerHTML;
subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */ subjectRow.innerHTML = ' '; /* Arbitrary character to calculate its dimensions */
characterWidth = parseInt(subjectRow.offsetWidth); characterWidth = parseInt(subjectRow.offsetWidth);
@@ -54,6 +54,19 @@
rows = parseInt(availableHeight / rowHeight); rows = parseInt(availableHeight / rowHeight);
this.resize(cols, rows); subjectRow.innerHTML = contentBuffer; /* Replace original content */
var geometry = {
'cols': cols,
'rows': rows
};
return geometry;
};
Xterm.prototype.fit = function () {
var geometry = this.proposeGeometry();
this.resize(geometry.cols, geometry.rows);
}; };
}); });
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"name": "xterm.js", "name": "xterm.js",
"version": "0.22", "version": "0.25",
"ignore": ["demo", "docs", "test", ".gitignore"] "ignore": ["demo", "docs", "test", ".gitignore"]
} }
+9 -3
View File
@@ -1,12 +1,13 @@
var terminalContainer = document.getElementById('terminal-container'), var terminalContainer = document.getElementById('terminal-container'),
term = new Terminal(); term = new Terminal(),
prompt = '> ';
term.open(terminalContainer); term.open(terminalContainer);
term.fit(); term.fit();
term.prompt = function () { term.prompt = function () {
term.write('\r\n> '); term.write('\r\n' + prompt);
} };
term.writeln('Welcome to xterm.js'); term.writeln('Welcome to xterm.js');
term.writeln('Just type some keys in the prompt below.'); term.writeln('Just type some keys in the prompt below.');
@@ -19,7 +20,12 @@ term.on('key', function (key, ev) {
if (ev.keyIdentifier == 'Enter') { if (ev.keyIdentifier == 'Enter') {
term.prompt(); term.prompt();
} else if (ev.keyCode == 8) { } else if (ev.keyCode == 8) {
/*
* Do not delete the prompt
*/
if (term.x > 2) {
term.write('\b \b'); term.write('\b \b');
}
} else if (printable) { } else if (printable) {
term.write(key); term.write(key);
} }
+2 -2
View File
@@ -51,9 +51,9 @@ copyright = u'2014, SourceLair Limited'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.22' version = '0.25'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.22 Alpha' release = '0.25 Alpha'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
+1 -1
View File
@@ -36,7 +36,7 @@
/* /*
* Require.js is available * Require.js is available
*/ */
define([], xterm); define([], xterm.bind(window));
} else { } else {
/* /*
* Plain browser environment * Plain browser environment