blessed-xterm icon indicating copy to clipboard operation
blessed-xterm copied to clipboard

how to support resize ?

Open novast opened this issue 6 years ago • 1 comments

when I resize the terminal, the widget not resized

novast avatar Sep 27 '19 06:09 novast

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" } },
    },
  });


alsantos123 avatar Mar 24 '25 17:03 alsantos123