Commit de527d06 authored by Leandro Melo's avatar Leandro Melo
Browse files

Snippets: Set indenters.

parent 920967d9
......@@ -30,6 +30,7 @@
#include "cppsnippeteditordecorator.h"
#include "cpphighlighter.h"
#include "cppeditor.h"
#include "cppqtstyleindenter.h"
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
......@@ -61,4 +62,6 @@ void CppSnippetEditorDecorator::apply(TextEditor::SnippetEditor *editor) const
fs.toTextCharFormats(CPPEditor::highlighterFormatCategories());
highlighter->setFormats(formats.constBegin(), formats.constEnd());
editor->installSyntaxHighlighter(highlighter);
editor->setIndenter(new CppQtStyleIndenter);
}
......@@ -30,6 +30,7 @@
#include "qmljssnippeteditordecorator.h"
#include "qmljshighlighter.h"
#include "qmljseditor.h"
#include "qmljsindenter.h"
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
......@@ -59,4 +60,6 @@ void QmlJSSnippetEditorDecorator::apply(TextEditor::SnippetEditor *editor) const
const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::instance()->fontSettings();
highlighter->setFormats(fs.toTextCharFormats(QmlJSTextEditor::highlighterFormatCategories()));
editor->installSyntaxHighlighter(highlighter);
editor->setIndenter(new Indenter);
}
......@@ -50,12 +50,9 @@ QString SnippetEditorEditable::id() const
return Constants::SNIPPET_EDITOR_ID;
}
SnippetEditor::SnippetEditor(QWidget *parent) :
BaseTextEditor(parent),
m_indenter(new NormalIndenter)
SnippetEditor::SnippetEditor(QWidget *parent) : BaseTextEditor(parent)
{
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
setHighlightCurrentLine(false);
setLineNumbersVisible(false);
}
......@@ -68,11 +65,6 @@ void SnippetEditor::installSyntaxHighlighter(TextEditor::SyntaxHighlighter *high
baseTextDocument()->setSyntaxHighlighter(highlighter);
}
void SnippetEditor::installIndenter(Indenter *indenter)
{
m_indenter.reset(indenter);
}
void SnippetEditor::focusOutEvent(QFocusEvent *event)
{
Q_UNUSED(event);
......@@ -84,9 +76,3 @@ BaseTextEditorEditable *SnippetEditor::createEditableInterface()
{
return new SnippetEditorEditable(this);
}
void SnippetEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
if (!m_indenter.isNull())
m_indenter->indentBlock(doc, block, typedChar, tabSettings());
}
......@@ -71,7 +71,6 @@ public:
virtual ~SnippetEditor();
void installSyntaxHighlighter(SyntaxHighlighter *highlighter);
void installIndenter(Indenter *indenter);
signals:
void snippetContentChanged();
......@@ -81,10 +80,6 @@ protected:
virtual int extraAreaWidth(int * /* markWidthPtr */ = 0) const { return 0; }
virtual BaseTextEditorEditable *createEditableInterface();
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
private:
QScopedPointer<Indenter> m_indenter;
};
} // TextEditor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment