aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/xterm/src/common/services/CharsetService.ts
blob: c5381065ace584255a7ed3da43926d583f8c480a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * Copyright (c) 2019 The xterm.js authors. All rights reserved.
 * @license MIT
 */

import { ICharsetService } from 'common/services/Services';
import { ICharset } from 'common/Types';

export class CharsetService implements ICharsetService {
  public serviceBrand: any;

  public charset: ICharset | undefined;
  public glevel: number = 0;

  private _charsets: (ICharset | undefined)[] = [];

  public reset(): void {
    this.charset = undefined;
    this._charsets = [];
    this.glevel = 0;
  }

  public setgLevel(g: number): void {
    this.glevel = g;
    this.charset = this._charsets[g];
  }

  public setgCharset(g: number, charset: ICharset | undefined): void {
    this._charsets[g] = charset;
    if (this.glevel === g) {
      this.charset = charset;
    }
  }
}