This commit is contained in:
yumoqing 2025-08-18 17:46:01 +08:00
parent e26c6b5115
commit 6f24b88d52
2 changed files with 10 additions and 2 deletions

View File

@ -320,6 +320,9 @@ bricks.JsWidget = class {
this.dom_element.removeEventListener(eventname, handler);
}
dispatch(eventname, params){
if (typeof params === "string" || params instanceof String) {
console.log('event name=', eventname, 'params is string =', params, this);
}
var e = new Event(eventname);
e.params = params;
this.dom_element.dispatchEvent(e);

View File

@ -21,6 +21,7 @@ bricks.Wterm = class extends bricks.JsWidget {
}
send_term_size(){
try {
console.log('resize():rows=', this.term.rows, this.term.cols);
this.socket.send(JSON.stringify({ type: "resize",
width:this.get_width(),
height: this.get_height(),
@ -77,7 +78,7 @@ bricks.Wterm = class extends bricks.JsWidget {
};
ws.onopen = () => {
this.send_term_size();
this.bind('resize', this.term_resize.bind(this))
this.bind('element_resize', this.term_resize.bind(this))
this.heartbeat_task = schedule_once(this.heartbeat.bind(this),
this.ping_timeout);
};
@ -85,12 +86,16 @@ bricks.Wterm = class extends bricks.JsWidget {
console.log('key=', key);
this.send_data(key);
});
term.onResize(({cols, rows}) =>{
this.send_term_size();
});
term.focus();
}
term_resize(){
try {
console.log('widget resize event fired');
this.fitAddon.fit();
this.send_term_size();
# this.send_term_size();
} catch(e){
console.log('resize error', e);
}