feat: Add scope line support

This commit is contained in:
Yaotian-Liu 2023-05-28 15:53:29 +08:00
parent 5b83128ca8
commit f163b33861
No known key found for this signature in database
GPG key ID: 160A5464FF2FBA1F
3 changed files with 62 additions and 36 deletions

View file

@ -6,6 +6,7 @@ export interface PseudocodeJsSettings {
lineNumberPunc: string;
noEnd: boolean;
captionCount: undefined;
scopeLines: boolean;
}
// Setting for this plugin
@ -27,7 +28,8 @@ export const DEFAULT_SETTINGS: PseudocodeSettings = {
lineNumberPunc: ":",
noEnd: false,
captionCount: undefined,
}
scopeLines: false,
},
};
export const PseudocodeBlockInit =

View file

@ -1,8 +1,4 @@
import {
App,
PluginSettingTab,
Setting,
} from "obsidian";
import { App, PluginSettingTab, Setting } from "obsidian";
import PseudocodePlugin from "main";
@ -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)

View file

@ -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;