MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / mount

Method mount

src/components/terminal/terminal.js:546–629  ·  view source on GitHub ↗

* Mount terminal to container * @param {HTMLElement} container - Container element

(container)

Source from the content-addressed store, hash-verified

544 * @param {HTMLElement} container - Container element
545 */
546 mount(container) {
547 if (!container) {
548 container = this.createContainer();
549 }
550
551 this.container = container;
552
553 // Apply terminal background color to container to match theme
554 this.container.style.background = this.options.theme.background;
555 this.disableNativeSelectionMenu(this.container);
556
557 try {
558 // Open first to ensure a stable renderer is attached
559 this.terminal.open(container);
560
561 // Renderer selection: 'canvas' (default core), 'webgl', or 'auto'
562 if (
563 this.options.renderer === "webgl" ||
564 this.options.renderer === "auto"
565 ) {
566 try {
567 const addon = new WebglAddon();
568 this.terminal.loadAddon(addon);
569 if (typeof addon.onContextLoss === "function") {
570 addon.onContextLoss(() => this._handleWebglContextLoss());
571 }
572 this.webglAddon = addon;
573 } catch (error) {
574 console.error("Failed to enable WebGL renderer:", error);
575 try {
576 this.webglAddon?.dispose?.();
577 } catch {}
578 this.webglAddon = null; // stay on canvas
579 }
580 }
581 const terminalSettings = getTerminalSettings();
582 // Load ligatures addon if enabled
583 if (terminalSettings.fontLigatures) {
584 this.loadLigaturesAddon();
585 }
586
587 // Setup custom touch scrolling with momentum physics
588 this.setupTouchScrolling();
589
590 // First render pass: schedule a fit + focus once the frame is ready
591 if (typeof requestAnimationFrame === "function") {
592 requestAnimationFrame(() => {
593 if (!this.terminal) return;
594 this.fitAddon.fit();
595 this.terminal.focus();
596 this.setupTouchSelection();
597 });
598 } else {
599 setTimeout(() => {
600 if (!this.terminal) return;
601 this.fitAddon.fit();
602 this.terminal.focus();
603 this.setupTouchSelection();

Callers 2

createTerminalMethod · 0.95

Calls 11

createContainerMethod · 0.95
loadLigaturesAddonMethod · 0.95
setupTouchScrollingMethod · 0.95
setupTouchSelectionMethod · 0.95
getTerminalSettingsFunction · 0.90
fitMethod · 0.80
focusMethod · 0.80
refreshMethod · 0.80
errorMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected