Create shared file for viewport constants

This commit is contained in:
Daniel Imms
2024-07-10 12:40:02 -07:00
parent d6f7133fa6
commit 1096b7f17f
3 changed files with 12 additions and 11 deletions
+2 -6
View File
@@ -6,6 +6,7 @@
import type { Terminal, ITerminalAddon } from '@xterm/xterm';
import type { FitAddon as IFitApi } from '@xterm/addon-fit';
import { IRenderDimensions } from 'browser/renderer/shared/Types';
import { ViewportConstants } from 'browser/shared/Constants';
interface ITerminalDimensions {
/**
@@ -22,11 +23,6 @@ interface ITerminalDimensions {
const MINIMUM_COLS = 2;
const MINIMUM_ROWS = 1;
// Must remain in sync with the value in core's viewport
const enum Constants {
DEFAULT_SCROLL_BAR_WIDTH = 14
}
export class FitAddon implements ITerminalAddon , IFitApi {
private _terminal: Terminal | undefined;
@@ -71,7 +67,7 @@ export class FitAddon implements ITerminalAddon , IFitApi {
const scrollbarWidth = (this._terminal.options.scrollback === 0
? 0
: (this._terminal.options.overviewRulerWidth || Constants.DEFAULT_SCROLL_BAR_WIDTH));
: (this._terminal.options.overviewRulerWidth || ViewportConstants.DEFAULT_SCROLL_BAR_WIDTH));
const parentElementStyle = window.getComputedStyle(this._terminal.element.parentElement);
const parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));