mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Add setting for script editor tab width
This commit is contained in:
parent
a3903d374f
commit
25d9b77d10
@ -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").
|
||||
|
@ -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 <<CSMWorld::UniversalId::Type_Journal
|
||||
@ -194,9 +194,8 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
|
||||
return !(string.contains(mWhiteListQoutes));
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::setTabWidth()
|
||||
void CSVWorld::ScriptEdit::setTabWidth(const int numCharacters)
|
||||
{
|
||||
const int numCharacters = 4;
|
||||
QFontMetrics metrics(mMonoFont);
|
||||
setTabStopWidth(numCharacters * metrics.width(' '));
|
||||
}
|
||||
@ -232,6 +231,10 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
||||
{
|
||||
wrapLines(setting->isTrue());
|
||||
}
|
||||
else if (*setting == "Scripts/tab-width")
|
||||
{
|
||||
setTabWidth(setting->toInt());
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::idListChanged()
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user