Try to guess a good text size.
When starting, resize the fonts if there isn't room for the terminal, or if there is a lot of empty space.
This commit is contained in:
parent
a48b02dc13
commit
fcd1965cd0
1 changed files with 21 additions and 3 deletions
24
rlgterm.js
24
rlgterm.js
|
|
@ -386,6 +386,24 @@ function setup() {
|
|||
termemu.init("termwrap", 24, 80);
|
||||
setTitle("Not connected.");
|
||||
setmode("login");
|
||||
/* Set up the text size. */
|
||||
var cssSize = termemu.view.style.fontSize;
|
||||
var match = cssSize.match(/\d*/);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
var csize = Number(match[0]);
|
||||
var allscreen = document.getElementById("termwrap");
|
||||
while (csize > 9 && csize < 48) {
|
||||
if (allscreen.scrollWidth * 1.2 > window.innerWidth) {
|
||||
csize = textsize(false);
|
||||
}
|
||||
else if (allscreen.scrollWidth * 2 < window.innerWidth) {
|
||||
csize = textsize(true);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -790,11 +808,11 @@ function debug(level, msg) {
|
|||
function textsize(larger) {
|
||||
var cssSize = termemu.view.style.fontSize;
|
||||
if (!cssSize) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
var match = cssSize.match(/\d*/);
|
||||
if (!match) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
var csize = Number(match[0]);
|
||||
var nsize;
|
||||
|
|
@ -827,7 +845,7 @@ function textsize(larger) {
|
|||
document.getElementById("keys").style.fontSize = cssvalstr;
|
||||
termemu.fixsize();
|
||||
debug(1, "Changing font size to " + nsize.toString());
|
||||
return;
|
||||
return nsize;
|
||||
}
|
||||
|
||||
function idlestr(ms) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue