I'm starting to pull some changes off of my large WIP branch/commit that adds an alternative dynamic character atlas. We're going to need to support multiple CharAtlas implementations, and this should make that easier.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { ITerminal } from '../../Types';
|
|
import { ITheme } from 'xterm';
|
|
import { IColorSet } from '../Types';
|
|
import { ICharAtlasConfig } from './Types';
|
|
|
|
export function generateConfig(scaledCharWidth: number, scaledCharHeight: number, terminal: ITerminal, colors: IColorSet): ICharAtlasConfig {
|
|
const clonedColors = {
|
|
foreground: colors.foreground,
|
|
background: colors.background,
|
|
cursor: null,
|
|
cursorAccent: null,
|
|
selection: null,
|
|
ansi: colors.ansi.slice(0, 16)
|
|
};
|
|
return {
|
|
scaledCharWidth,
|
|
scaledCharHeight,
|
|
fontFamily: terminal.options.fontFamily,
|
|
fontSize: terminal.options.fontSize,
|
|
fontWeight: terminal.options.fontWeight,
|
|
fontWeightBold: terminal.options.fontWeightBold,
|
|
allowTransparency: terminal.options.allowTransparency,
|
|
colors: clonedColors
|
|
};
|
|
}
|
|
|
|
export function configEquals(a: ICharAtlasConfig, b: ICharAtlasConfig): boolean {
|
|
for (let i = 0; i < a.colors.ansi.length; i++) {
|
|
if (a.colors.ansi[i] !== b.colors.ansi[i]) {
|
|
return false;
|
|
}
|
|
}
|
|
return a.fontFamily === b.fontFamily &&
|
|
a.fontSize === b.fontSize &&
|
|
a.fontWeight === b.fontWeight &&
|
|
a.fontWeightBold === b.fontWeightBold &&
|
|
a.allowTransparency === b.allowTransparency &&
|
|
a.scaledCharWidth === b.scaledCharWidth &&
|
|
a.scaledCharHeight === b.scaledCharHeight &&
|
|
a.colors.foreground === b.colors.foreground &&
|
|
a.colors.background === b.colors.background;
|
|
}
|