diff --git a/src/setting.ts b/src/setting.ts index 426e219..fd5b458 100644 --- a/src/setting.ts +++ b/src/setting.ts @@ -1,39 +1,41 @@ // This is the setting for pseudocode.js export interface PseudocodeJsSettings { - indentSize: string; - commentDelimiter: string; - lineNumber: boolean; - lineNumberPunc: string; - noEnd: boolean; - captionCount: undefined; + indentSize: string; + commentDelimiter: string; + lineNumber: boolean; + lineNumberPunc: string; + noEnd: boolean; + captionCount: undefined; + scopeLines: boolean; } // Setting for this plugin export interface PseudocodeSettings { - blockSize: number; - preamblePath: string; - preambleLoadedNotice: boolean; - jsSettings: PseudocodeJsSettings; + blockSize: number; + preamblePath: string; + preambleLoadedNotice: boolean; + jsSettings: PseudocodeJsSettings; } export const DEFAULT_SETTINGS: PseudocodeSettings = { - blockSize: 99, - preamblePath: "preamble.sty", - preambleLoadedNotice: false, - jsSettings: { - indentSize: "1.2em", - commentDelimiter: "//", - lineNumber: false, - lineNumberPunc: ":", - noEnd: false, - captionCount: undefined, - } + blockSize: 99, + preamblePath: "preamble.sty", + preambleLoadedNotice: false, + jsSettings: { + indentSize: "1.2em", + commentDelimiter: "//", + lineNumber: false, + lineNumberPunc: ":", + noEnd: false, + captionCount: undefined, + scopeLines: false, + }, }; export const PseudocodeBlockInit = - "```pseudo\n" + - "\t\\begin{algorithm}\n\t\\caption{Algo Caption}\n\t\\begin{algorithmic}" + - "\n\n\t\\end{algorithmic}\n\t\\end{algorithm}" + - "\n```"; + "```pseudo\n" + + "\t\\begin{algorithm}\n\t\\caption{Algo Caption}\n\t\\begin{algorithmic}" + + "\n\n\t\\end{algorithmic}\n\t\\end{algorithm}" + + "\n```"; -export const BLOCK_NAME = "pseudo"; \ No newline at end of file +export const BLOCK_NAME = "pseudo"; diff --git a/src/setting_tab.ts b/src/setting_tab.ts index 89b1d55..85eafd4 100644 --- a/src/setting_tab.ts +++ b/src/setting_tab.ts @@ -1,8 +1,4 @@ -import { - App, - PluginSettingTab, - Setting, -} from "obsidian"; +import { App, PluginSettingTab, Setting } from "obsidian"; import PseudocodePlugin from "main"; @@ -28,8 +24,8 @@ export class PseudocodeSettingTab extends PluginSettingTab { .setName("Block Size") .setDesc( "The width of the pseudocode block. The unit is 'em'." + - " The default value is 99, which will work as the max width of the editor." + - " '30' looks good for me." + " The default value is 99, which will work as the max width of the editor." + + " '30' looks good for me." ) .addText((text) => text @@ -63,7 +59,8 @@ export class PseudocodeSettingTab extends PluginSettingTab { text .setValue(this.plugin.settings.jsSettings.commentDelimiter) .onChange(async (value) => { - this.plugin.settings.jsSettings.commentDelimiter = value; + this.plugin.settings.jsSettings.commentDelimiter = + value; await this.plugin.saveSettings(); }) ); @@ -111,6 +108,21 @@ export class PseudocodeSettingTab extends PluginSettingTab { }) ); + // Instantiate scope lines toggle setting + new Setting(containerEl) + .setName("Scope Lines") + .setDesc( + "If enabled, pseudocode blocks will have lines indicating the scope of the block." + ) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.jsSettings.scopeLines) + .onChange(async (value) => { + this.plugin.settings.jsSettings.scopeLines = value; + await this.plugin.saveSettings(); + }) + ); + containerEl.createEl("h2", { text: "Preamble Settings" }); // Instantiate Preamble Path setting @@ -132,7 +144,9 @@ export class PseudocodeSettingTab extends PluginSettingTab { // Instantiate Preamble Load Sign setting new Setting(containerEl) .setName("Preamble Loaded Notice") - .setDesc("Whether to show a notice everytime the preamble is loaded.") + .setDesc( + "Whether to show a notice everytime the preamble is loaded." + ) .addToggle((toggle) => toggle .setValue(this.plugin.settings.preambleLoadedNotice) @@ -142,4 +156,4 @@ export class PseudocodeSettingTab extends PluginSettingTab { }) ); } -} \ No newline at end of file +} diff --git a/styles.css b/styles.css index e9fdbb3..3dc0063 100644 --- a/styles.css +++ b/styles.css @@ -1425,6 +1425,16 @@ If your plugin does not need CSS, delete this file. text-indent: 0; } +/* scope lines support */ +.ps-root .ps-algorithmic.with-scopelines div.ps-block { + border-left-style: solid; + border-left-width: 0.1em; + padding-left: 0.6em; +} +.ps-root .ps-algorithmic.with-scopelines > div.ps-block { + border-left: none; +} + .error-message { font-family: var(--font-monospace); font-size: 0.875rem;