Skip to content

Commit

Permalink
Merge pull request #23 from guicassolato/refactor/default-tothom-options
Browse files Browse the repository at this point in the history
refactor: default tothom option values stored in constants
  • Loading branch information
guicassolato authored Jan 4, 2023
2 parents 02a7b1e + c8d3310 commit 58d098b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/tothom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import { Engine, EngineOptions, RendererRuleFunc } from './engine';

const WEBVIEW_PANEL_TYPE = 'tothom';

const defaultColorScheme = 'auto';
const defaultBracketedPasteMode = true;

export interface TothomOptions {
colorScheme?: string;
bracketedPasteMode?: string;
bracketedPasteMode?: boolean;
engineOptions?: EngineOptions;
};

Expand Down Expand Up @@ -82,6 +85,9 @@ export class Tothom {

// private methods

private colorScheme = (): string => this.options?.colorScheme || defaultColorScheme;
private bracketedPasteMode = (): boolean => this.options?.bracketedPasteMode || defaultBracketedPasteMode;

private mediaFilePath = (webview: vscode.Webview, filePath: string): vscode.Uri => {
return webview.asWebviewUri(vscode.Uri.joinPath(this.extensionUri, 'media', filePath));
};
Expand All @@ -93,7 +99,7 @@ export class Tothom {
const baseTag = `<base href="${baseHref}${baseHref.endsWith('/') ? '' : '/'}"/>`;

let colorScheme: string = "";
switch (this.options?.colorScheme) {
switch (this.colorScheme()) {
case "light":
colorScheme = `tothom-light`;
break;
Expand Down Expand Up @@ -144,7 +150,7 @@ export class Tothom {
const term = terminal.findOrCreateTerminal(uri.toString());
let command = terminal.decodeTerminalCommand(encodedCommand);

if (this.options?.bracketedPasteMode) {
if (this.bracketedPasteMode()) {
command = `\x1b[200~${command}\x1b[201~`;
}

Expand Down

0 comments on commit 58d098b

Please sign in to comment.