diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 70456ee1d..c70e71deb 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -136,6 +136,9 @@ void CSMPrefs::State::declare() declareBool ("wrap-lines", "Wrap Lines", false). setTooltip ("Wrap lines longer than width of script editor."); declareBool ("mono-font", "Use monospace font", true); + declareInt ("tab-width", "Tab Width", 4). + setTooltip ("Number of characters for tab width"). + setRange (1, 10); EnumValue warningsNormal ("Normal", "Report warnings as warning"); declareEnum ("warnings", "Warning Mode", warningsNormal). addValue ("Ignore", "Do not report warning"). diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index a6689bf53..39497ac1e 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -52,7 +52,7 @@ CSVWorld::ScriptEdit::ScriptEdit( mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) { wrapLines(false); - setTabWidth(); + setTabWidth(4); setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead mAllowedTypes <isTrue()); } + else if (*setting == "Scripts/tab-width") + { + setTabWidth(setting->toInt()); + } } void CSVWorld::ScriptEdit::idListChanged() diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 7a3f074e9..db2936a74 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -92,7 +92,8 @@ namespace CSVWorld bool stringNeedsQuote(const std::string& id) const; /// \brief Set tab width for script editor. - void setTabWidth(); + /// \param numCharacters Number of characters for tab width. + void setTabWidth(const int numCharacters); /// \brief Turn line wrapping in script editor on or off. /// \param wrap Whether or not to wrap lines.