forked from qt-creator/qt-creator
Don't show code folding margin when it isn't supported
Introduce setCodeFoldingSupported to the BaseTextEditor, and only enabled it for the C++ and QtScript editors. This removes the useless margin meant for code folding markers from the plain text editor and .pro file editor.
This commit is contained in:
@@ -185,6 +185,7 @@ CPPEditor::CPPEditor(QWidget *parent)
|
|||||||
{
|
{
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
setCodeFoldingVisible(true);
|
setCodeFoldingVisible(true);
|
||||||
baseTextDocument()->setSyntaxHighlighter(new CppHighlighter);
|
baseTextDocument()->setSyntaxHighlighter(new CppHighlighter);
|
||||||
// new QShortcut(QKeySequence("Ctrl+Alt+M"), this, SLOT(foo()), 0, Qt::WidgetShortcut);
|
// new QShortcut(QKeySequence("Ctrl+Alt+M"), this, SLOT(foo()), 0, Qt::WidgetShortcut);
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ namespace Internal {
|
|||||||
ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor, const QList<int>& context)
|
ScriptEditorEditable::ScriptEditorEditable(ScriptEditor *editor, const QList<int>& context)
|
||||||
: BaseTextEditorEditable(editor), m_context(context)
|
: BaseTextEditorEditable(editor), m_context(context)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptEditor::ScriptEditor(const Context &context,
|
ScriptEditor::ScriptEditor(const Context &context,
|
||||||
@@ -61,6 +60,7 @@ ScriptEditor::ScriptEditor(const Context &context,
|
|||||||
{
|
{
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
setCodeFoldingVisible(true);
|
setCodeFoldingVisible(true);
|
||||||
setMimeType(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE);
|
setMimeType(QtScriptEditor::Constants::C_QTSCRIPTEDITOR_MIMETYPE);
|
||||||
|
|
||||||
|
|||||||
@@ -1198,7 +1198,7 @@ bool BaseTextEditor::lineSeparatorsAllowed() const
|
|||||||
|
|
||||||
void BaseTextEditor::setCodeFoldingVisible(bool b)
|
void BaseTextEditor::setCodeFoldingVisible(bool b)
|
||||||
{
|
{
|
||||||
d->m_codeFoldingVisible = b;
|
d->m_codeFoldingVisible = b && d->m_codeFoldingSupported;
|
||||||
slotUpdateExtraAreaWidth();
|
slotUpdateExtraAreaWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,6 +1207,22 @@ bool BaseTextEditor::codeFoldingVisible() const
|
|||||||
return d->m_codeFoldingVisible;
|
return d->m_codeFoldingVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether code folding is supported by the syntax highlighter. When not
|
||||||
|
* supported (the default), this makes sure the code folding is not shown.
|
||||||
|
*
|
||||||
|
* Needs to be called before calling setCodeFoldingVisible.
|
||||||
|
*/
|
||||||
|
void BaseTextEditor::setCodeFoldingSupported(bool b)
|
||||||
|
{
|
||||||
|
d->m_codeFoldingSupported = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BaseTextEditor::codeFoldingSupported() const
|
||||||
|
{
|
||||||
|
return d->m_codeFoldingSupported;
|
||||||
|
}
|
||||||
|
|
||||||
void BaseTextEditor::setRevisionsVisible(bool b)
|
void BaseTextEditor::setRevisionsVisible(bool b)
|
||||||
{
|
{
|
||||||
d->m_revisionsVisible = b;
|
d->m_revisionsVisible = b;
|
||||||
@@ -1294,6 +1310,7 @@ BaseTextEditorPrivate::BaseTextEditorPrivate()
|
|||||||
m_extraArea(0),
|
m_extraArea(0),
|
||||||
m_marksVisible(false),
|
m_marksVisible(false),
|
||||||
m_codeFoldingVisible(false),
|
m_codeFoldingVisible(false),
|
||||||
|
m_codeFoldingSupported(false),
|
||||||
m_revisionsVisible(false),
|
m_revisionsVisible(false),
|
||||||
m_lineNumbersVisible(true),
|
m_lineNumbersVisible(true),
|
||||||
m_highlightCurrentLine(true),
|
m_highlightCurrentLine(true),
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ struct StorageSettings;
|
|||||||
|
|
||||||
struct Parenthesis;
|
struct Parenthesis;
|
||||||
typedef QVector<Parenthesis> Parentheses;
|
typedef QVector<Parenthesis> Parentheses;
|
||||||
|
|
||||||
struct TEXTEDITOR_EXPORT Parenthesis
|
struct TEXTEDITOR_EXPORT Parenthesis
|
||||||
{
|
{
|
||||||
enum Type { Opened, Closed };
|
enum Type { Opened, Closed };
|
||||||
@@ -84,7 +85,6 @@ struct TEXTEDITOR_EXPORT Parenthesis
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData
|
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -285,6 +285,9 @@ public:
|
|||||||
void setCodeFoldingVisible(bool b);
|
void setCodeFoldingVisible(bool b);
|
||||||
bool codeFoldingVisible() const;
|
bool codeFoldingVisible() const;
|
||||||
|
|
||||||
|
void setCodeFoldingSupported(bool b);
|
||||||
|
bool codeFoldingSupported() const;
|
||||||
|
|
||||||
void setRevisionsVisible(bool b);
|
void setRevisionsVisible(bool b);
|
||||||
bool revisionsVisible() const;
|
bool revisionsVisible() const;
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ public:
|
|||||||
void updateMarksBlock(const QTextBlock &block);
|
void updateMarksBlock(const QTextBlock &block);
|
||||||
uint m_marksVisible : 1;
|
uint m_marksVisible : 1;
|
||||||
uint m_codeFoldingVisible : 1;
|
uint m_codeFoldingVisible : 1;
|
||||||
|
uint m_codeFoldingSupported : 1;
|
||||||
uint m_revisionsVisible : 1;
|
uint m_revisionsVisible : 1;
|
||||||
uint m_lineNumbersVisible : 1;
|
uint m_lineNumbersVisible : 1;
|
||||||
uint m_highlightCurrentLine : 1;
|
uint m_highlightCurrentLine : 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user