Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KDevelop
KDevelop
Commits
71d864a3
Commit
71d864a3
authored
Jul 14, 2022
by
Milian Wolff
Browse files
Introduce local for currentBlock and reduce indentation depth
I.e. continue when the block isn't valid.
parent
4cbff15f
Changes
1
Hide whitespace changes
Inline
Side-by-side
kdevplatform/util/widgetcolorizer.cpp
View file @
71d864a3
...
...
@@ -122,37 +122,40 @@ void collectRanges(QTextFrame* frame, const QColor& fgcolor, const QColor& bgcol
}
}
if
(
it
.
currentBlock
()
.
isValid
())
{
for
(
auto
jt
=
it
.
currentBlock
().
begin
();
jt
!=
it
.
currentBlock
().
end
();
++
jt
)
{
auto
fragment
=
jt
.
fragment
()
;
auto
text
=
QStringView
(
fragment
.
text
()).
trimmed
();
if
(
!
text
.
isEmpty
())
{
auto
fm
t
=
fragment
.
charFormat
();
auto
foreground
=
foregroundColor
(
fmt
);
auto
background
=
backgroundColor
(
fmt
);
if
(
!
bgSet
&&
!
background
)
{
if
(
!
foreground
||
foreground
==
Qt
::
black
)
{
fmt
.
setForeground
(
fgcolor
);
}
else
if
(
foreground
->
valueF
()
<
0.7
)
{
fmt
.
setForeground
(
WidgetColorizer
::
blendForeground
(
*
foreground
,
1.0
,
fgcolor
,
bgcolor
));
}
}
else
{
auto
bg
=
back
ground
.
value
_or
(
bgcolor
);
auto
fg
=
foreground
.
value_or
(
f
gcolor
);
if
(
background
&&
isBrightColor
(
bg
))
{
bg
=
invertColor
(
bg
);
fmt
.
setBackground
(
bg
);
if
(
fg
.
valueF
()
<
0.7
)
{
fmt
.
setForeground
(
WidgetColorizer
::
blendForeground
(
fg
,
1.0
,
fgc
olor
,
bg
))
;
}
}
else
if
(
bg
.
valueF
()
>
0.3
&&
isBrightColor
(
fg
))
{
fg
=
invertColor
(
fg
);
fmt
.
setForeground
(
fg
);
const
auto
block
=
it
.
currentBlock
()
;
if
(
!
block
.
isValid
()
)
{
continue
;
}
for
(
auto
j
t
=
block
.
begin
();
jt
!=
block
.
end
();
++
jt
)
{
auto
fragment
=
jt
.
fragment
(
);
auto
text
=
QStringView
(
fragment
.
text
()).
trimmed
(
);
if
(
!
text
.
isEmpty
())
{
auto
fmt
=
fragment
.
charFormat
();
auto
foreground
=
foreground
Color
(
fmt
);
auto
background
=
backgroundColor
(
fmt
);
if
(
!
bgSet
&&
!
background
)
{
if
(
!
foreground
||
foreground
==
Qt
::
black
)
{
fmt
.
setForeground
(
fgcolor
);
}
else
if
(
fore
ground
->
value
F
()
<
0.7
)
{
fmt
.
setForeground
(
WidgetColorizer
::
blendForeground
(
*
foreground
,
1.0
,
fgcolor
,
b
gcolor
)
)
;
}
}
else
{
auto
bg
=
background
.
value_or
(
bgcolor
);
auto
fg
=
foreground
.
value_or
(
fgcolor
);
if
(
background
&&
isBrightC
olor
(
bg
))
{
bg
=
invertColor
(
bg
);
fmt
.
setBackground
(
bg
);
if
(
fg
.
valueF
()
<
0.7
)
{
fmt
.
setForeground
(
WidgetColorizer
::
blendForeground
(
fg
,
1.0
,
fgcolor
,
bg
)
);
}
}
else
if
(
bg
.
valueF
()
>
0.3
&&
isBrightColor
(
fg
))
{
fg
=
invertColor
(
fg
);
fmt
.
setForeground
(
fg
);
}
ranges
.
push_back
({
fragment
.
position
(),
fragment
.
position
()
+
fragment
.
length
(),
fmt
});
}
ranges
.
push_back
({
fragment
.
position
(),
fragment
.
position
()
+
fragment
.
length
(),
fmt
});
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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