Tweaked cursor positioning code, and added explicit no-cache headers to our

responses. This might help with reported IE6 problems.


git-svn-id: https://shellinabox.googlecode.com/svn/trunk@81 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
zodiac 2009-03-19 22:10:48 +00:00
parent e1863d0a47
commit cdd4ae34eb
5 changed files with 53 additions and 13 deletions

View file

@ -1,3 +1,11 @@
2009-03-19 Markus Gutschke <markus@shellinabox.com>
* Fixed cursor positioning. Hopefully, more browsers will be happy
with this, now.
* Explicitly added no-cache headers to our responses. This might help
with the IE6 problems.
2009-03-17 Markus Gutschke <markus@shellinabox.com> 2009-03-17 Markus Gutschke <markus@shellinabox.com>
* Allow root to bind to privileged port. * Allow root to bind to privileged port.

View file

@ -95,7 +95,7 @@
#define STDC_HEADERS 1 #define STDC_HEADERS 1
/* Most recent revision number in the version control system */ /* Most recent revision number in the version control system */
#define VCS_REVISION "80" #define VCS_REVISION "81"
/* Version number of package */ /* Version number of package */
#define VERSION "2.4" #define VERSION "2.4"

View file

@ -225,6 +225,7 @@ static int completePendingRequest(struct Session *session,
"Content-Type: application/json; " "Content-Type: application/json; "
"charset=utf-8\r\n" "charset=utf-8\r\n"
"Content-Length: %ld\r\n" "Content-Length: %ld\r\n"
"Cache-Control: no-cache\r\n"
"\r\n" "\r\n"
"%s", "%s",
(long)strlen(json), (long)strlen(json),

View file

@ -20,10 +20,15 @@
padding: 1px; padding: 1px;
} }
#vt100 #console, #vt100 #alt_console, #vt100 #cursor { #vt100 #console, #vt100 #alt_console, #vt100 #cursor, #vt100 #lineheight {
font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, "Andale Mono", "Lucida Console", monospace; font-family: "DejaVu Sans Mono", "Everson Mono", FreeMono, "Andale Mono", "Lucida Console", monospace;
} }
#vt100 #lineheight {
position: absolute;
visibility: hidden;
}
#vt100 #cursor { #vt100 #cursor {
position: absolute; position: absolute;
left: 0px; left: 0px;

View file

@ -234,11 +234,11 @@ VT100.prototype.initializeElements = function(container) {
'</div>' + '</div>' +
'<div id="menu"></div>' + '<div id="menu"></div>' +
'<div id="scrollable">' + '<div id="scrollable">' +
'<pre id="lineheight">&nbsp;</pre>' +
'<pre id="console"></pre>' + '<pre id="console"></pre>' +
'<pre id="alt_console" style="display: none"></pre>' + '<pre id="alt_console" style="display: none"></pre>' +
'<div id="padding"></div>' + '<div id="padding"></div>' +
'<pre id="cursor">&nbsp;</pre>' + '<pre id="cursor">X</pre>' +
'<pre id="lineheight">&nbsp;</pre>' +
'</div>' + '</div>' +
'<div class="hidden">' + '<div class="hidden">' +
'<input type="textfield" id="input" />' + '<input type="textfield" id="input" />' +
@ -982,28 +982,54 @@ VT100.prototype.putString = function(x, y, text, style) {
this.cursorX = 0; this.cursorX = 0;
} }
} }
var pixelX = -1;
var pixelY = -1;
if (!this.cursor.style.visibility) { if (!this.cursor.style.visibility) {
var idx = this.cursorX - xPos; var idx = this.cursorX - xPos;
if (span) { if (span) {
var nxtIdx = idx - this.getTextContent(span).length; // If we are in a non-empty line, take the cursor Y position from the
// other elements in this line. If dealing with broken, non-proportional
// fonts, this is likely to yield better results.
pixelY = span.offsetTop;
s = this.getTextContent(span);
var nxtIdx = idx - s.length;
if (nxtIdx < 0) { if (nxtIdx < 0) {
this.setTextContent(this.cursor, this.setTextContent(this.cursor, s.charAt(idx));
this.getTextContent(span).charAt(idx)); pixelX = span.offsetLeft +
} else if (span.nextSibling) { idx*span.offsetWidth / s.length;
this.setTextContent(this.cursor,
this.getTextContent(span.nextSibling).charAt(nxtIdx));
} else { } else {
this.setTextContent(this.cursor, ' '); if (nxtIdx == 0) {
pixelX = span.offsetLeft + span.offsetWidth;
}
if (span.nextSibling) {
s = this.getTextContent(span.nextSibling);
this.setTextContent(this.cursor, s.charAt(nxtIdx));
if (pixelX < 0) {
pixelX = span.nextSibling.offsetLeft +
nxtIdx*span.offsetWidth / s.length;
} }
} else { } else {
this.setTextContent(this.cursor, ' '); this.setTextContent(this.cursor, ' ');
} }
} }
} else {
this.setTextContent(this.cursor, ' ');
}
}
if (pixelX >= 0) {
this.cursor.style.left = pixelX + 'px';
} else {
this.cursor.style.left = this.cursorX*this.cursorWidth + this.cursor.style.left = this.cursorX*this.cursorWidth +
console.offsetLeft + 'px'; console.offsetLeft + 'px';
}
this.cursorY = yIdx - this.numScrollbackLines; this.cursorY = yIdx - this.numScrollbackLines;
if (pixelY >= 0) {
this.cursor.style.top = pixelY + 'px';
} else {
this.cursor.style.top = yIdx*this.cursorHeight + this.cursor.style.top = yIdx*this.cursorHeight +
console.offsetTop + 'px'; console.offsetTop + 'px';
}
if (text.length) { if (text.length) {
// Merge <span> with previous sibling, if styles are identical // Merge <span> with previous sibling, if styles are identical