[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kate/scripting_api_updates
From: Robin Pedersen <robinpeder () gmail ! com>
Date: 2008-06-30 21:30:06
Message-ID: 1214861406.928092.19339.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 826519 by rpedersen:
When highlighting mode is changed, it is checked if the new highlighter provides the \
style required by the indenter. If not, it changes to normal indenting.
M +3 -0 document/katedocument.cpp
M +20 -2 utils/kateautoindent.cpp
M +13 -0 utils/kateautoindent.h
--- branches/kate/scripting_api_updates/document/katedocument.cpp #826518:826519
@@ -3066,6 +3066,9 @@
// update all views
makeAttribs(false);
+ // deactivate indenter if necessary
+ m_indenter.checkRequiredStyle();
+
emit highlightingModeChanged(this);
}
--- branches/kate/scripting_api_updates/utils/kateautoindent.cpp #826518:826519
@@ -220,6 +220,12 @@
doIndent (view, position.line(), newIndentInChars, align);
}
+bool KateAutoIndent::isStyleProvided(KateIndentScript *script)
+{
+ QString requiredStyle = script->information().requiredStyle;
+ return (requiredStyle.isEmpty() || requiredStyle == doc->highlight()->style());
+}
+
void KateAutoIndent::setMode (const QString &name)
{
// bail out, already set correct mode...
@@ -248,8 +254,7 @@
KateIndentScript *script = \
KateGlobal::self()->scriptManager()->indentationScript(name); if ( script )
{
- QString requiredStyle = script->information().requiredStyle;
- if (requiredStyle.isEmpty() || requiredStyle == doc->highlight()->style())
+ if (isStyleProvided(script))
{
m_script = script;
m_mode = name;
@@ -272,6 +277,18 @@
m_mode = MODE_NORMAL;
}
+void KateAutoIndent::checkRequiredStyle()
+{
+ if (m_script)
+ {
+ if (!isStyleProvided(m_script))
+ {
+ kDebug( 13060 ) << "mode" << m_mode << "requires a different highlight style";
+ doc->config()->setIndentationMode(MODE_NORMAL);
+ }
+ }
+}
+
void KateAutoIndent::updateConfig ()
{
KateDocumentConfig *config = doc->config();
@@ -385,6 +402,7 @@
QString requiredStyle = KateAutoIndent::modeRequiredStyle(z);
action->setEnabled(requiredStyle.isEmpty() || requiredStyle == \
doc->highlight()->style());
+ kDebug() << " IF ( " << doc->config()->indentationMode() << " == " << \
KateAutoIndent::modeName (z);
if ( doc->config()->indentationMode() == KateAutoIndent::modeName (z) )
action->setChecked( true );
}
--- branches/kate/scripting_api_updates/utils/kateautoindent.h #826518:826519
@@ -143,6 +143,12 @@
*/
void scriptIndent (KateView *view, const KTextEditor::Cursor &position, QChar \
typedChar);
+ /**
+ * Return true if the required style for the script is provided by the
+ * current highlighter.
+ */
+ bool isStyleProvided(KateIndentScript *script);
+
public:
/**
* Switch indenter
@@ -153,6 +159,13 @@
void setMode (const QString &name);
/**
+ * Check if the current highlighting mode provides the style required by the
+ * current indenter. If not, deactivate the indenter by changing to "normal"
+ * mode.
+ */
+ void checkRequiredStyle();
+
+ /**
* mode name
*/
const QString &modeName () const { return m_mode; }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic