Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
15e655b7
Commit
15e655b7
authored
Jul 15, 2010
by
Thorbjørn Lindeijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the highlighting for locals and fields configurable
Reviewed-by: mae
parent
08bc6c00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
9 deletions
+20
-9
src/plugins/cppeditor/cppeditor.cpp
src/plugins/cppeditor/cppeditor.cpp
+14
-9
src/plugins/cppeditor/cppeditor.h
src/plugins/cppeditor/cppeditor.h
+2
-0
src/plugins/texteditor/texteditorconstants.h
src/plugins/texteditor/texteditorconstants.h
+2
-0
src/plugins/texteditor/texteditorsettings.cpp
src/plugins/texteditor/texteditorsettings.cpp
+2
-0
No files found.
src/plugins/cppeditor/cppeditor.cpp
View file @
15e655b7
...
...
@@ -898,12 +898,6 @@ void CPPEditor::highlightTypeUsages(int from, int to)
Q_ASSERT
(
!
chunks
.
isEmpty
());
QTextBlock
b
=
doc
->
findBlockByNumber
(
m_nextHighlightBlockNumber
);
QTextCharFormat
localUseFormat
;
localUseFormat
.
setForeground
(
Qt
::
darkBlue
);
// ### hardcoded
QTextCharFormat
memberUseFormat
;
memberUseFormat
.
setForeground
(
Qt
::
darkRed
);
// ### hardcoded
QMapIterator
<
int
,
QVector
<
SemanticInfo
::
Use
>
>
it
(
chunks
);
while
(
b
.
isValid
()
&&
it
.
hasNext
())
{
it
.
next
();
...
...
@@ -926,11 +920,11 @@ void CPPEditor::highlightTypeUsages(int from, int to)
break
;
case
SemanticInfo
::
Use
::
Field
:
formatRange
.
format
=
m
emberUse
Format
;
formatRange
.
format
=
m
_field
Format
;
break
;
case
SemanticInfo
::
Use
::
Local
:
formatRange
.
format
=
local
Use
Format
;
formatRange
.
format
=
m_
localFormat
;
break
;
default:
...
...
@@ -1641,7 +1635,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
const
QVector
<
QTextCharFormat
>
formats
=
fs
.
toTextCharFormats
(
categories
);
highlighter
->
setFormats
(
formats
.
constBegin
(),
formats
.
constEnd
());
highlighter
->
rehighlight
();
m_occurrencesFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_OCCURRENCES
));
m_occurrencesUnusedFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_OCCURRENCES_UNUSED
));
...
...
@@ -1651,11 +1644,23 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
m_occurrencesUnusedFormat
.
setToolTip
(
tr
(
"Unused variable"
));
m_occurrenceRenameFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_OCCURRENCES_RENAME
));
m_typeFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_TYPE
));
m_localFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_LOCAL
));
m_fieldFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_FIELD
));
m_keywordFormat
=
fs
.
toTextCharFormat
(
QLatin1String
(
TextEditor
::
Constants
::
C_KEYWORD
));
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
m_occurrencesFormat
.
clearForeground
();
m_occurrenceRenameFormat
.
clearForeground
();
// Clear all additional formats since they may have changed
QTextBlock
b
=
document
()
->
firstBlock
();
while
(
b
.
isValid
())
{
highlighter
->
setExtraAdditionalFormats
(
b
,
QList
<
QTextLayout
::
FormatRange
>
());
b
=
b
.
next
();
}
// This also triggers an update of the additional formats
highlighter
->
rehighlight
();
}
void
CPPEditor
::
setTabSettings
(
const
TextEditor
::
TabSettings
&
ts
)
...
...
src/plugins/cppeditor/cppeditor.h
View file @
15e655b7
...
...
@@ -285,6 +285,8 @@ private:
QTextCharFormat
m_occurrencesUnusedFormat
;
QTextCharFormat
m_occurrenceRenameFormat
;
QTextCharFormat
m_typeFormat
;
QTextCharFormat
m_localFormat
;
QTextCharFormat
m_fieldFormat
;
QTextCharFormat
m_keywordFormat
;
QList
<
QTextEdit
::
ExtraSelection
>
m_renameSelections
;
...
...
src/plugins/texteditor/texteditorconstants.h
View file @
15e655b7
...
...
@@ -108,6 +108,8 @@ const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
const
char
*
const
C_NUMBER
=
"Number"
;
const
char
*
const
C_STRING
=
"String"
;
const
char
*
const
C_TYPE
=
"Type"
;
const
char
*
const
C_LOCAL
=
"Local"
;
const
char
*
const
C_FIELD
=
"Field"
;
const
char
*
const
C_KEYWORD
=
"Keyword"
;
const
char
*
const
C_OPERATOR
=
"Operator"
;
const
char
*
const
C_PREPROCESSOR
=
"Preprocessor"
;
...
...
src/plugins/texteditor/texteditorsettings.cpp
View file @
15e655b7
...
...
@@ -126,6 +126,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_NUMBER
),
tr
(
"Number"
),
Qt
::
darkBlue
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_STRING
),
tr
(
"String"
),
Qt
::
darkGreen
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_TYPE
),
tr
(
"Type"
),
Qt
::
darkMagenta
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_LOCAL
),
tr
(
"Local"
),
Qt
::
darkBlue
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_FIELD
),
tr
(
"Field"
),
Qt
::
darkRed
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_KEYWORD
),
tr
(
"Keyword"
),
Qt
::
darkYellow
));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_OPERATOR
),
tr
(
"Operator"
)));
formatDescriptions
.
append
(
FormatDescription
(
QLatin1String
(
C_PREPROCESSOR
),
tr
(
"Preprocessor"
),
Qt
::
darkBlue
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment