How to use xterm-addon-fit - 10 common examples

To help you get started, weโ€™ve selected a few xterm-addon-fit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esrlabs / chipmunk / application / client.plugins / projects / xterminal / src / lib / view / component.ts View on Github external
private _createXTerm() {
        if (this._xterm !== undefined) {
            return;
        }
        if (this._ng_xtermholder === null || this._ng_xtermholder === undefined) {
            return null;
        }
        this._fitAddon = new FitAddon();
        this._xterm = new Terminal();
        this._xterm.loadAddon(this._fitAddon);
        this._xterm.open(this._ng_xtermholder.nativeElement);
        this._fitAddon.fit();
        this._setTheme(this._xterm);
        this._xterm.onData((data) => {
            this.api.getIPC().requestToHost({
                session: this.session,
                command: EHostCommands.write,
                data: data
            }, this.session).then((response) => {
                // TODO: feedback based on response
            });
        });
        // Send command to host to create instance of pty
        this.api.getIPC().requestToHost({
github jsmecham / atom-terminal-tab / lib / terminal-view.js View on Github external
constructor(session) {
    this.disposables = new CompositeDisposable();
    this.session = session;

    // Load the Fit Addon
    this.fitAddon = new FitAddon();
    this.session.xterm.loadAddon(this.fitAddon);
    this.disposables.add(this.fitAddon);

    //
    // Observe the Session to know when it is destroyed so that we can
    // clean up our state (i.e. remove event observers).
    //
    this.session.onDidDestroy(this.destroy.bind(this));

    // TODO: Documentation says this should be set for Atom... Research!
    etch.setScheduler(atom.views);
    etch.initialize(this);

    this.observeResizeEvents();
  }
github spyder-ide / spyder-terminal / spyder_terminal / server / static / js / main.js View on Github external
// Clean terminal
  while (terminalContainer.children.length) {
      terminalContainer.removeChild(terminalContainer.children[0]);
  }

  term = new Terminal({
      cursorBlink: true,
      scrollback: 10000,
      tabStopWidth: 10,
      windowsMode: isWindows
      });

  term.loadAddon(new WebLinksAddon());
  searchAddon = new SearchAddon();
  term.loadAddon(searchAddon);
  fitAddon = new FitAddon();
  term.loadAddon(fitAddon);

  term.onResize((size) => {
      if (!pid) {
          return;
      }
      const cols = size.cols;
      const rows = size.rows;
      const url = '/api/terminals/' + pid + '/size?cols=' + cols + '&rows=' + rows;

      fetch(url, {method: 'POST', headers: myHeaders});
      term.setOption('theme', curTheme);
      term.setOption('fontFamily', curFont);
  });

  protocol = (location.protocol === 'https:') ? 'wss://' : 'ws://';
github nickvdyck / webtty / src / WebTty.UI / components / Tab / Tab.tsx View on Github external
import { FitAddon } from "xterm-addon-fit"
import { WebglAddon } from "xterm-addon-webgl"
import Terminal from "components/Terminal/Terminal"
import ResizeObserver from "components/ResizeObserver/ResizeObserver"
import { useDebounce } from "lib/hooks/useDebounce"
import { ITheme } from "application/themes"

interface TabProps {
    source: AsyncIterableIterator
    theme?: ITheme
    onInput: (msg: string) => void
    onResize: (data: { cols: number; rows: number }) => void
}

const fit = new FitAddon()
const webgl = new WebglAddon()
const addons = [fit, webgl]

const setDocumentTitle = (title: string): void => {
    document.title = title
}

const Tab: FunctionComponent = ({
    source,
    theme,
    onInput,
    onResize,
}) => {
    const debounceFit = useDebounce((): void => fit.fit(), 200)

    return (
github hashicorp / nomad / ui / app / components / exec-terminal.js View on Github external
didInsertElement() {
    let fitAddon = new FitAddon();
    this.fitAddon = fitAddon;
    this.terminal.loadAddon(fitAddon);

    this.terminal.open(this.element.querySelector('.terminal'));

    fitAddon.fit();
  }
github zhen-ke / ffmpegGUI / src / components / Xterm.vue View on Github external
init() {
      const fitAddon = new FitAddon();
      const ligaturesAddon = new LigaturesAddon();
      xterm = new Terminal({
        cursorStyle: "bar",
        fontSize: 12,
        experimentalCharAtlas: 'dynamic',
        fontFamily: "Monaco,Mono,Consolas,Liberation Mono,Menlo,monospace"
      });

      xterm.open(this.$refs.xterm);
      xterm.loadAddon(fitAddon);
      xterm.loadAddon(ligaturesAddon);
      fitAddon.fit();
      const ptyProcess = pty.spawn(shell, [], {
        name: "xterm-color",
        cols: xterm.cols || 80,
        rows: xterm.rows || 30,
github umijs / umi / packages / umi-ui-tasks / src / ui / hooks / terminal.ts View on Github external
const useTerminal = ({ terminal, ref: container }) => {
  const fitAddon = new FitAddon();
  useEffect(
    () => {
      if (!container) {
        return;
      }
      terminal.loadAddon(fitAddon);
      terminal.open(container);
      fitAddon.fit();
    },
    [container],
  );
  return {
    fitAddon,
  };
};
github inspursoft / board / src / ui / src / app / service / step0-list-service / service-control / console / console.component.ts View on Github external
constructor(private appInitService: AppInitService,
              private k8sService: K8sService,
              private messageService: MessageService,
              private changeRef: ChangeDetectorRef,
              private translateService: TranslateService) {
    this.fitAddon = new FitAddon();
    this.searchAddon = new SearchAddon();
    this.webLinkAddon = new WebLinksAddon(this.webLinksHandle);
    this.serviceDetailInfo = new ServiceDetailInfo();
    this.actionIsEnabledEvent = new EventEmitter();
    this.updateProgressEvent = new EventEmitter();
    this.isActionInWIPChange = new EventEmitter();
  }
github GitSquared / edex-ui / src / classes / terminal.class.js View on Github external
yellow: window.theme.colors.yellow || colorify("#c4a000", themeColor),
                    blue: window.theme.colors.blue || colorify("#3465a4", themeColor),
                    magenta: window.theme.colors.magenta || colorify("#75507b", themeColor),
                    cyan: window.theme.colors.cyan || colorify("#06989a", themeColor),
                    white: window.theme.colors.white || colorify("#d3d7cf", themeColor),
                    brightBlack: window.theme.colors.brightBlack || colorify("#555753", themeColor),
                    brightRed: window.theme.colors.brightRed || colorify("#ef2929", themeColor),
                    brightGreen: window.theme.colors.brightGreen || colorify("#8ae234", themeColor),
                    brightYellow: window.theme.colors.brightYellow || colorify("#fce94f", themeColor),
                    brightBlue: window.theme.colors.brightBlue || colorify("#729fcf", themeColor),
                    brightMagenta: window.theme.colors.brightMagenta || colorify("#ad7fa8", themeColor),
                    brightCyan: window.theme.colors.brightCyan || colorify("#34e2e2", themeColor),
                    brightWhite: window.theme.colors.brightWhite || colorify("#eeeeec", themeColor)
                }
            });
            let fitAddon = new FitAddon();
            this.term.loadAddon(fitAddon);
            this.term.open(document.getElementById(opts.parentId));
            let ligaturesAddon = new LigaturesAddon();
            this.term.loadAddon(ligaturesAddon);
            this.term.attachCustomKeyEventHandler(e => {
                window.keyboard.keydownHandler(e);
                return true;
            });
            this.term.focus();

            this.Ipc.send("terminal_channel-"+this.port, "Renderer startup");
            this.Ipc.on("terminal_channel-"+this.port, (e, ...args) => {
                switch(args[0]) {
                    case "New cwd":
                        this.cwd = args[1];
                        this.oncwdchange(this.cwd);
github npezza93 / archipelago / app / renderer / sessions / session.js View on Github external
constructor(type, branch) {
    this.branch = branch
    this.currentProfile = new CurrentProfile()
    this.id = Math.random()
    this.subscriptions = new CompositeDisposable()
    this.title = ''
    this.ptyId = ipc.callMain('pty-create', {sessionId: this.id, sessionWindowId: activeWindow().id})
    this.type = type || 'default'
    this.fitAddon = new FitAddon()
    this.searchAddon = new SearchAddon()
    this.webglAddon = new WebglAddon()
    this.xterm = new Terminal(this.settings())
    this.xterm.loadAddon(this.fitAddon)
    this.xterm.loadAddon(this.searchAddon)

    this.resetKeymaps()
    autoBind(this)

    this.bindListeners()
  }

xterm-addon-fit

An addon for [xterm.js](https://github.com/xtermjs/xterm.js) that enables fitting the terminal's dimensions to a containing element. This addon requires xterm.js v4+.

MIT
Latest version published 8 months ago

Package Health Score

70 / 100
Full package analysis

Popular xterm-addon-fit functions