<commit_before>/*
 * Copyright 2021 <NAME> <<EMAIL>>
 *
 * This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
 */
import { AlignmentFlag, Direction, QComboBox, QLabel, QScrollArea, QSizePolicyPolicy, QWidget, TextFormat } from "@nodegui/nodegui";
import * as open from "open";
import { BoxLayout, CheckBox, ComboBox, ComboBoxItem, GridLayout, Label, PushButton, ScrollArea, SpinBox,
  Widget } from "qt-construct";
import { getLogger, log, Logger } from "extraterm-logging";
import { ConfigDatabase } from "../config/ConfigDatabase.js";
import { GeneralConfig, TerminalMarginStyle, TitleBarStyle } from "../config/Config.js";
import { UiStyle } from "../ui/UiStyle.js";
import { createHtmlIcon } from "../ui/Icons.js";
import { makeGroupLayout, shrinkWrap } from "../ui/QtConstructExtra.js";
import { ThemeManager } from "../theme/ThemeManager.js";
import { ThemeInfo } from "../theme/Theme.js";
import { ExtensionManager } from "../InternalTypes.js";
import { TerminalBlock } from "../terminal/TerminalBlock.js";
import * as Term from "../emulator/Term.js";
import { QtTimeout } from "../utils/QtTimeout.js";
import { TerminalVisualConfig } from "../terminal/TerminalVisualConfig.js";
import { FontAtlasCache } from "../terminal/FontAtlasCache.js";


const uiScalePercentOptions: {id: number, name: string}[] = [
  { id: 25, name: "25%"},
  { id: 50, name: "50%"},
  { id: 65, name: "65%"},
  { id: 80, name: "80%"},
  { id: 90, name: "90%"},
  { id: 100, name: "100%"},
  { id: 110, name: "110%"},
  { id: 120, name: "120%"},
  { id: 150, name: "150%"},
  { id: 175, name: "175%"},
  { id: 200, name: "200%"},
  { id: 250, name: "250%"},
  { id: 300, name: "300%"},
];

const titleBarOptions: {id: TitleBarStyle, name: string}[] = [
  { id: "native", name: "Native" },
  { id: "theme", name: "Theme" },
  { id: "compact", name: "Compact Theme" },
];

const PREVIEW_WIDTH_CELLS = 45;


export class AppearancePage {
  private _log: Logger = null;
  #configDatabase: ConfigDatabase = null;
  #themeManager: ThemeManager = null;
  #extensionManager: ExtensionManager = null;
  #uiStyle: UiStyle = null;
  #fontAtlasCache: FontAtlasCache = null;

  #previewTerminalBlock: TerminalBlock = null;
  #previewEmulator: Term.Emulator = null;
  #qtTimeout: QtTimeout = null;
  #terminalVisualConfig: TerminalVisualConfig = null;
  #previewContainer: QWidget = null;

  #terminalThemeCombo: QComboBox = null;
  #terminalThemes: ThemeInfo[];
  #terminalThemeCommentSpacer: QLabel = null;
  #terminalThemeCommentLabel: QLabel = null;

  constructor(configDatabase: ConfigDatabase, extensionManager: ExtensionManager, themeManager: ThemeManager,
      uiStyle: UiStyle, fontAtlasCache: FontAtlasCache) {

    this._log = getLogger("AppearancePage", this);
    this.#configDatabase = configDatabase;
    this.#extensionManager = extensionManager;
    this.#themeManager = themeManager;
    this.#uiStyle = uiStyle;
  }

  getPage(): QScrollArea {
    const generalConfig = this.#configDatabase.getGeneralConfig();<commit_msg>Fix a tiny crasher I just introduced<commit_after>/*
 * Copyright 2021 <NAME> <<EMAIL>>
 *
 * This source code is licensed under the MIT license which is detailed in the LICENSE.txt file.
 */
import { AlignmentFlag, Direction, QComboBox, QLabel, QScrollArea, QSizePolicyPolicy, QWidget, TextFormat } from "@nodegui/nodegui";
import * as open from "open";
import { BoxLayout, CheckBox, ComboBox, ComboBoxItem, GridLayout, Label, PushButton, ScrollArea, SpinBox,
  Widget } from "qt-construct";
import { getLogger, log, Logger } from "extraterm-logging";
import { ConfigDatabase } from "../config/ConfigDatabase.js";
import { GeneralConfig, TerminalMarginStyle, TitleBarStyle } from "../config/Config.js";
import { UiStyle } from "../ui/UiStyle.js";
import { createHtmlIcon } from "../ui/Icons.js";
import { makeGroupLayout, shrinkWrap } from "../ui/QtConstructExtra.js";
import { ThemeManager } from "../theme/ThemeManager.js";
import { ThemeInfo } from "../theme/Theme.js";
import { ExtensionManager } from "../InternalTypes.js";
import { TerminalBlock } from "../terminal/TerminalBlock.js";
import * as Term from "../emulator/Term.js";
import { QtTimeout } from "../utils/QtTimeout.js";
import { TerminalVisualConfig } from "../terminal/TerminalVisualConfig.js";
import { FontAtlasCache } from "../terminal/FontAtlasCache.js";


const uiScalePercentOptions: {id: number, name: string}[] = [
  { id: 25, name: "25%"},
  { id: 50, name: "50%"},
  { id: 65, name: "65%"},
  { id: 80, name: "80%"},
  { id: 90, name: "90%"},
  { id: 100, name: "100%"},
  { id: 110, name: "110%"},
  { id: 120, name: "120%"},
  { id: 150, name: "150%"},
  { id: 175, name: "175%"},
  { id: 200, name: "200%"},
  { id: 250, name: "250%"},
  { id: 300, name: "300%"},
];

const titleBarOptions: {id: TitleBarStyle, name: string}[] = [
  { id: "native", name: "Native" },
  { id: "theme", name: "Theme" },
  { id: "compact", name: "Compact Theme" },
];

const PREVIEW_WIDTH_CELLS = 45;


export class AppearancePage {
  private _log: Logger = null;
  #configDatabase: ConfigDatabase = null;
  #themeManager: ThemeManager = null;
  #extensionManager: ExtensionManager = null;
  #uiStyle: UiStyle = null;
  #fontAtlasCache: FontAtlasCache = null;

  #previewTerminalBlock: TerminalBlock = null;
  #previewEmulator: Term.Emulator = null;
  #qtTimeout: QtTimeout = null;
  #terminalVisualConfig: TerminalVisualConfig = null;
  #previewContainer: QWidget = null;

  #terminalThemeCombo: QComboBox = null;
  #terminalThemes: ThemeInfo[];
  #terminalThemeCommentSpacer: QLabel = null;
  #terminalThemeCommentLabel: QLabel = null;

  constructor(configDatabase: ConfigDatabase, extensionManager: ExtensionManager, themeManager: ThemeManager,
      uiStyle: UiStyle, fontAtlasCache: FontAtlasCache) {

    this._log = getLogger("AppearancePage", this);
    this.#configDatabase = configDatabase;
    this.#extensionManager = extensionManager;
    this.#themeManager = themeManager;
    this.#uiStyle = uiStyle;
    this.#fontAtlasCache = fontAtlasCache;
  }

  getPage(): QScrollArea {
    const generalConfig = this.#configDatabase.getGeneralConfig();
{'fraction_non_alphanumeric': 0.15387107223841917, 'fraction_numerical': 0.02397149335924846, 'mean_word_length': 4.588235294117647, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4210392', 'n_tokens_mistral': 2110, 'n_tokens_neox': 1941, 'n_words': 539}