forked from teamnwah/openmw-tes3coop
Merge remote-tracking branch 'rcutmore/bug-3286'
This commit is contained in:
commit
9d906a99a8
3 changed files with 21 additions and 10 deletions
|
@ -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").
|
||||
|
|
|
@ -48,11 +48,12 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|||
mLineNumberArea(0),
|
||||
mDefaultFont(font()),
|
||||
mMonoFont(QFont("Monospace")),
|
||||
mTabCharCount(4),
|
||||
mDocument(document),
|
||||
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
||||
{
|
||||
wrapLines(false);
|
||||
setTabStopWidth (4);
|
||||
setTabWidth();
|
||||
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
|
||||
|
||||
mAllowedTypes <<CSMWorld::UniversalId::Type_Journal
|
||||
|
@ -120,14 +121,6 @@ void CSVWorld::ScriptEdit::showLineNum(bool show)
|
|||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::setMonoFont(bool show)
|
||||
{
|
||||
if(show)
|
||||
setFont(mMonoFont);
|
||||
else
|
||||
setFont(mDefaultFont);
|
||||
}
|
||||
|
||||
bool CSVWorld::ScriptEdit::isChangeLocked() const
|
||||
{
|
||||
return mChangeLocked!=0;
|
||||
|
@ -194,6 +187,12 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
|
|||
return !(string.contains(mWhiteListQoutes));
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::setTabWidth()
|
||||
{
|
||||
// Set tab width to specified number of characters using current font.
|
||||
setTabStopWidth(mTabCharCount * fontMetrics().width(' '));
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::wrapLines(bool wrap)
|
||||
{
|
||||
if (wrap)
|
||||
|
@ -216,6 +215,7 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
|||
else if (*setting == "Scripts/mono-font")
|
||||
{
|
||||
setFont(setting->isTrue() ? mMonoFont : mDefaultFont);
|
||||
setTabWidth();
|
||||
}
|
||||
else if (*setting == "Scripts/show-linenum")
|
||||
{
|
||||
|
@ -225,6 +225,11 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
|||
{
|
||||
wrapLines(setting->isTrue());
|
||||
}
|
||||
else if (*setting == "Scripts/tab-width")
|
||||
{
|
||||
mTabCharCount = setting->toInt();
|
||||
setTabWidth();
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::idListChanged()
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace CSVWorld
|
|||
LineNumberArea *mLineNumberArea;
|
||||
QFont mDefaultFont;
|
||||
QFont mMonoFont;
|
||||
int mTabCharCount;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -71,7 +72,6 @@ namespace CSVWorld
|
|||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||
int lineNumberAreaWidth();
|
||||
void showLineNum(bool show);
|
||||
void setMonoFont(bool show);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -91,6 +91,9 @@ namespace CSVWorld
|
|||
|
||||
bool stringNeedsQuote(const std::string& id) const;
|
||||
|
||||
/// \brief Set tab width for script editor.
|
||||
void setTabWidth();
|
||||
|
||||
/// \brief Turn line wrapping in script editor on or off.
|
||||
/// \param wrap Whether or not to wrap lines.
|
||||
void wrapLines(bool wrap);
|
||||
|
|
Loading…
Reference in a new issue