xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.43k stars 1.62k forks source link

FitAddon cannot input in full screen #4914

Closed Yorlg closed 9 months ago

Yorlg commented 9 months ago

Details

Steps to reproduce

import { Terminal } from 'xterm';
import 'xterm/css/xterm.css';
import { FitAddon } from 'xterm-addon-fit';

const term = new Terminal({
  cursorStyle: "underline",
  cursorBlink: true,
  rightClickSelectsWord: true,
  theme: {
    foreground: '#F8F8F8',
    background: '#2D2E2C',
    cursor: "help",
    lineHeight: 10,
  },
  fontFamily: '"Cascadia Code", Menlo, monospace',
  screenKeys: true,
  useStyle: true,
});

const fitAddon = new FitAddon();
term.loadAddon(fitAddon);

term.writeln("Welcome to \x1b[1;32mYorlg\x1b[0m.")
term.writeln('This is Web Terminal of Modb;\n')

term.open(terminal);
term.focus()

window.onresize = function () {
  resize();
};

function resize () {
  fitAddon.fit();
  const dimensions = fitAddon.proposeDimensions();
  if (dimensions?.cols && dimensions?.rows) {
    // term.resize(dimensions.cols, dimensions.rows);
    term.resize(dimensions.cols, dimensions.rows);
  }
}

.terminal,
.terminal-container,
.xterm-screen {
  width: 100% !important;
  height: 100% !important;
  overflow: hidden;
}

.xterm .xterm-viewport {
  /* see : https://github.com/xtermjs/xterm.js/issues/3564#issuecomment-1004417440 */
  width: initial !important;
}

The problem I am currently facing is that I am using fitAddon. fit() and term.resize web terminals, and still can only have 80 characters per line. How can I install the width of my page size to adapt to it

image

Yorlg commented 9 months ago

image

@Tyriar Minimizing Chrome resolution can also cause erroneous line breaks

carolin-violet commented 7 months ago

how to resolve this problem

Yorlg commented 6 months ago

how to resolve this problem

Using the backend to set up windows

The following is a code snippet web:https://github.com/Yorlg/WebSSH/blob/f9d90d7a23efe27400012a2dc424d0845b49fe6b/static/js/main.js#L107C6-L107C99 server:https://github.com/Yorlg/WebSSH/blob/f9d90d7a23efe27400012a2dc424d0845b49fe6b/server/app.js#L104C37-L104C82