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

Snippets: Set indenters.

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