blessed-xterm
blessed-xterm copied to clipboard
how to support resize ?
when I resize the terminal, the widget not resized
Inside the xterm/lib/xterm.js there's some code that try to do that, I copy that in this way:
screen.on("resize", () => {
if (termCurrent && termCurrent.xterm.visible) {
const width = Number(screen.width) - 50;
const height = screen.height;
termCurrent.xterm.width = width;
termCurrent.xterm.height = height;
screen.render();
/* pass-through to XTerm */
termCurrent.xterm.resize(width, height);
/* pass-through to Pty */
if (termCurrent.xterm.pty !== null) {
try {
termCurrent.xterm.pty.resize(width, height);
} catch (e) {
/* NO-OP */
}
}
termCurrent.xterm.width = width;
termCurrent.xterm.height = height;
screen.render();
}
});
Now works well, the create box it's:
const terminal = new XTerm({
left: 50,
top: 0,
width: Number(screen.width) - 50,
height: screen.height,
border: "line",
label: title,
env: Object.assign({}, process.env, env),
cwd: process.cwd(),
cursorType: "block",
scrollback: 10000,
scrolling: true,
mouse: true,
style: {
fg: "default",
bg: "default",
border: { fg: "default" },
focus: { border: { fg: "green" } },
scrolling: { border: { fg: "yellow" } },
},
});