Support changing terminal background color

static
Sheng 2019-05-17 21:55:05 +08:00
parent b58be46918
commit 3d98e5d947
1 changed files with 12 additions and 0 deletions

View File

@ -116,12 +116,20 @@ jQuery(function($){
return {'cols': cols, 'rows': rows}; return {'cols': cols, 'rows': rows};
} }
function resize_terminal(term) { function resize_terminal(term) {
var geometry = current_geometry(term); var geometry = current_geometry(term);
term.on_resize(geometry.cols, geometry.rows); term.on_resize(geometry.cols, geometry.rows);
} }
function set_backgound_color(term, color) {
term.setOption('theme', {
background: color
});
}
function format_geometry(cols, rows) { function format_geometry(cols, rows) {
return JSON.stringify({'cols': cols, 'rows': rows}); return JSON.stringify({'cols': cols, 'rows': rows});
} }
@ -332,6 +340,10 @@ jQuery(function($){
} }
}; };
wssh.set_bgcolor = function(color) {
set_backgound_color(term, color);
};
term.on_resize = function(cols, rows) { term.on_resize = function(cols, rows) {
if (cols !== this.cols || rows !== this.rows) { if (cols !== this.cols || rows !== this.rows) {
console.log('Resizing terminal to geometry: ' + format_geometry(cols, rows)); console.log('Resizing terminal to geometry: ' + format_geometry(cols, rows));