diff --git a/src/components/inputs/Codemirror.vue b/src/components/inputs/Codemirror.vue index 24207298..ddbbdaf3 100644 --- a/src/components/inputs/Codemirror.vue +++ b/src/components/inputs/Codemirror.vue @@ -19,6 +19,7 @@ import { gcode } from '@/plugins/StreamParserGcode' import { indentWithTab } from '@codemirror/commands' import { json } from '@codemirror/lang-json' import { css } from '@codemirror/lang-css' +import { indentUnit } from '@codemirror/language' @Component export default class Codemirror extends Mixins(BaseMixin) { @@ -83,6 +84,7 @@ export default class Codemirror extends Mixins(BaseMixin) { const extensions = [ basicSetup, mainsailTheme, + indentUnit.of(' '.repeat(this.getTabSize())), keymap.of([indentWithTab]), EditorView.updateListener.of((update) => { this.content = update.state?.doc.toString() @@ -103,5 +105,9 @@ export default class Codemirror extends Mixins(BaseMixin) { visibilityChanged(isVisible: boolean) { if (isVisible) this.cminstance?.focus() } + + getTabSize() { + return this.$store.state.gui.editor.tabSize || 2 + } } diff --git a/src/components/settings/SettingsEditorTab.vue b/src/components/settings/SettingsEditorTab.vue index 9bc074ec..5b83a391 100644 --- a/src/components/settings/SettingsEditorTab.vue +++ b/src/components/settings/SettingsEditorTab.vue @@ -15,6 +15,15 @@ :dynamic-slot-width="true"> + + + + + + ({ + text: this.$t('Settings.EditorTab.Spaces', { count: space }), + value: space, + })) + } + get escToClose() { return this.$store.state.gui.editor.escToClose } @@ -83,6 +100,14 @@ export default class SettingsEditorTab extends Mixins(BaseMixin) { this.$store.dispatch('gui/saveSetting', { name: 'editor.confirmUnsavedChanges', value: newVal }) } + get tabSize() { + return this.$store.state.gui.editor.tabSize || 2 + } + + set tabSize(newVal) { + this.$store.dispatch('gui/saveSetting', { name: 'editor.tabSize', value: newVal }) + } + get klipperRestartMethod() { return this.$store.state.gui.editor.klipperRestartMethod } diff --git a/src/locales/de.json b/src/locales/de.json index 26d353f3..39dc605a 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -799,7 +799,10 @@ "MoonrakerRestartInstance": "Moonraker Neustartinstanz", "MoonrakerRestartInstanceDescription": "Wähle aus, welche Moonrakerinstanz neu gestartet werden soll wenn 'Speichern & Neustarten' im Editor geklickt wird.", "UseEscToClose": "ESC drücken um Editor zu schließen", - "UseEscToCloseDescription": "Erlaubt es den Editor mit ESC zu schließen." + "UseEscToCloseDescription": "Erlaubt es den Editor mit ESC zu schließen.", + "TabSize": "TAB Größe", + "TabSizeDescription": "Legt fest, um wie viele Leerzeichen für TAB eingerückt werden sollen", + "Spaces": "Leerzeichen: {count}" }, "GCodeViewerTab": { "BackgroundColor": "Hintergrundfarbe", diff --git a/src/locales/en.json b/src/locales/en.json index a25d5e67..dc7d2854 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -804,7 +804,10 @@ "MoonrakerRestartInstance": "Moonraker restart instance", "MoonrakerRestartInstanceDescription": "Select which Moonraker service will restart on 'Save & Restart' when editing Moonraker config files.", "UseEscToClose": "Use ESC to close editor", - "UseEscToCloseDescription": "Allows the ESC key to close the editor" + "UseEscToCloseDescription": "Allows the ESC key to close the editor", + "TabSize": "TAB Size", + "TabSizeDescription": "Adjusts how many spaces should be indented for TAB", + "Spaces": "Spaces: {count}" }, "GCodeViewerTab": { "BackgroundColor": "Background Color", diff --git a/src/locales/hu.json b/src/locales/hu.json index 274dddac..6b45a7d0 100644 --- a/src/locales/hu.json +++ b/src/locales/hu.json @@ -725,7 +725,10 @@ "MoonrakerRestartInstance": "Moonraker példány Újraindítása", "MoonrakerRestartInstanceDescription": "Válaszd ki melyik Moonraker szolgáltatást indítsuk újra a 'Ment és Újraindít' esetén, amikor a Moonraker konfig fájlait szerkeszted.", "UseEscToClose": "Kilépéshez nyomd meg az ESC gombot", - "UseEscToCloseDescription": "Az ESC gomb megnyomása bezárja a szerkesztőt" + "UseEscToCloseDescription": "Az ESC gomb megnyomása bezárja a szerkesztőt", + "TabSize": "TAB Méret", + "TabSizeDescription": "Beállítja, hogy hány szóközzel legyen behúzva a TAB-oknál", + "Spaces": "Szóközök: {count}" }, "GCodeViewerTab": { "BackgroundColor": "Háttérszín", diff --git a/src/locales/ru.json b/src/locales/ru.json index 1828dce5..ea4a6d3e 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -726,7 +726,10 @@ "MoonrakerRestartInstance": "Инстанция перезапуска Moonraker", "MoonrakerRestartInstanceDescription": "Выберите, какая служба Moonraker будет перезапускаться при 'Save & Restart' при редактировании файлов конфигурации Moonraker.", "UseEscToClose": "Нажмите ESC, чтобы закрыть редактор", - "UseEscToCloseDescription": "Позволяет закрыть редактор с помощью ESC." + "UseEscToCloseDescription": "Позволяет закрыть редактор с помощью ESC.", + "TabSize": "Размер TAB", + "TabSizeDescription": "Регулирует, сколько пробелов должно быть отступом для TAB", + "Spaces": "Пробе́лов: {count}" }, "GCodeViewerTab": { "BackgroundColor": "Цвет фона", diff --git a/src/store/gui/index.ts b/src/store/gui/index.ts index 8940c8eb..29e7ad9d 100644 --- a/src/store/gui/index.ts +++ b/src/store/gui/index.ts @@ -111,6 +111,7 @@ export const getDefaultState = (): GuiState => { escToClose: true, confirmUnsavedChanges: true, klipperRestartMethod: 'FIRMWARE_RESTART', + tabSize: 2, moonrakerRestartInstance: null, }, gcodeViewer: { diff --git a/src/store/gui/types.ts b/src/store/gui/types.ts index d79bcf96..172b9183 100644 --- a/src/store/gui/types.ts +++ b/src/store/gui/types.ts @@ -59,6 +59,7 @@ export interface GuiState { escToClose: boolean confirmUnsavedChanges: boolean klipperRestartMethod: 'FIRMWARE_RESTART' | 'RESTART' + tabSize: number moonrakerRestartInstance: string | null } gcodeViewer: {