2020-10-03 18:04:18 +00:00
|
|
|
/**
|
|
|
|
* options.ts
|
2021-03-16 12:01:13 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
|
|
|
*
|
|
|
|
* This file is part of vscode-texinfo.
|
|
|
|
*
|
|
|
|
* vscode-texinfo is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* vscode-texinfo is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* vscode-texinfo. If not, see <https://www.gnu.org/licenses/>.
|
2020-10-03 18:04:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import * as vscode from 'vscode';
|
|
|
|
|
|
|
|
/**
|
2020-10-05 22:31:40 +00:00
|
|
|
* Fetch extension option values.
|
2020-10-03 18:04:18 +00:00
|
|
|
*
|
|
|
|
* See `contributes.configuration` of package.json for details.
|
|
|
|
*/
|
2020-10-24 21:45:32 +00:00
|
|
|
export default class Options implements vscode.Disposable {
|
2020-10-03 18:04:18 +00:00
|
|
|
|
2020-10-15 20:16:13 +00:00
|
|
|
private static singleton?: Options;
|
|
|
|
|
2020-10-24 21:45:32 +00:00
|
|
|
static get instance() {
|
2020-10-20 20:07:44 +00:00
|
|
|
return Options.singleton ??= new Options('texinfo');
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static get makeinfo() {
|
|
|
|
return Options.instance.getString('makeinfo');
|
|
|
|
}
|
|
|
|
|
2020-11-11 12:29:30 +00:00
|
|
|
static get enableCodeLens() {
|
|
|
|
return Options.instance.getBoolean('enableCodeLens');
|
|
|
|
}
|
|
|
|
|
2020-10-26 19:37:05 +00:00
|
|
|
static get enableSnippets() {
|
|
|
|
return Options.instance.getBoolean('completion.enableSnippets');
|
|
|
|
}
|
|
|
|
|
|
|
|
static get hideSnippetCommands() {
|
|
|
|
return Options.instance.getBoolean('completion.hideSnippetCommands');
|
|
|
|
}
|
|
|
|
|
2020-10-03 18:04:18 +00:00
|
|
|
static get noHeaders() {
|
|
|
|
return Options.instance.getBoolean('preview.noHeaders');
|
|
|
|
}
|
|
|
|
|
|
|
|
static get maxSize() {
|
2020-10-24 21:45:32 +00:00
|
|
|
return Options.instance.getNumber('preview.maxSize') * 1024 * 1024;
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static get errorLimit() {
|
|
|
|
return Options.instance.getNumber('preview.errorLimit');
|
|
|
|
}
|
|
|
|
|
|
|
|
static get force() {
|
|
|
|
return Options.instance.getBoolean('preview.force');
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:41:03 +00:00
|
|
|
static get noValidation() {
|
|
|
|
return Options.instance.getBoolean('preview.noValidation');
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 13:41:03 +00:00
|
|
|
static get noWarnings() {
|
|
|
|
return Options.instance.getBoolean('preview.noWarnings');
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-04 17:26:21 +00:00
|
|
|
static get displayImage() {
|
|
|
|
return Options.instance.getBoolean('preview.displayImage');
|
|
|
|
}
|
|
|
|
|
2021-02-22 07:06:05 +00:00
|
|
|
static get customCSS() {
|
|
|
|
return Options.instance.getString('preview.customCSS');
|
|
|
|
}
|
|
|
|
|
2020-10-24 21:45:32 +00:00
|
|
|
static clear() {
|
|
|
|
Options.singleton = undefined;
|
|
|
|
}
|
|
|
|
|
2020-10-03 18:04:18 +00:00
|
|
|
private readonly configuration: vscode.WorkspaceConfiguration;
|
|
|
|
|
2020-10-22 22:40:41 +00:00
|
|
|
private getString(section: string) {
|
|
|
|
return this.configuration.get(section, '');
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 22:40:41 +00:00
|
|
|
private getBoolean(section: string) {
|
|
|
|
return this.configuration.get(section, false);
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 22:40:41 +00:00
|
|
|
private getNumber(section: string) {
|
|
|
|
return this.configuration.get(section, 0);
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|
2020-10-24 21:45:32 +00:00
|
|
|
|
2021-03-15 12:43:38 +00:00
|
|
|
private constructor(section: string) {
|
|
|
|
this.configuration = vscode.workspace.getConfiguration(section);
|
|
|
|
}
|
|
|
|
|
2020-10-24 21:45:32 +00:00
|
|
|
dispose() {
|
|
|
|
Options.singleton = undefined;
|
|
|
|
}
|
2020-10-03 18:04:18 +00:00
|
|
|
}
|