Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
24594c74
Commit
24594c74
authored
Dec 10, 2018
by
Nicolas
Committed by
Victor Zverovich
Dec 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable printing the reset escape code when no style modifiers where applied. (#973)
parent
b0f22247
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
include/fmt/color.h
include/fmt/color.h
+7
-1
test/format-impl-test.cc
test/format-impl-test.cc
+1
-0
No files found.
include/fmt/color.h
View file @
24594c74
...
...
@@ -438,20 +438,26 @@ template <
typename
S
,
typename
Char
=
typename
internal
::
char_t
<
S
>
::
type
>
void
vprint
(
std
::
FILE
*
f
,
const
text_style
&
ts
,
const
S
&
format
,
basic_format_args
<
typename
buffer_context
<
Char
>::
type
>
args
)
{
bool
has_style
=
false
;
if
(
ts
.
has_emphasis
())
{
has_style
=
true
;
internal
::
fputs
<
Char
>
(
internal
::
make_emphasis
<
Char
>
(
ts
.
get_emphasis
()),
f
);
}
if
(
ts
.
has_foreground
())
{
has_style
=
true
;
internal
::
fputs
<
Char
>
(
internal
::
make_foreground_color
<
Char
>
(
ts
.
get_foreground
()),
f
);
}
if
(
ts
.
has_background
())
{
has_style
=
true
;
internal
::
fputs
<
Char
>
(
internal
::
make_background_color
<
Char
>
(
ts
.
get_background
()),
f
);
}
vprint
(
f
,
format
,
args
);
internal
::
reset_color
<
Char
>
(
f
);
if
(
has_style
)
{
internal
::
reset_color
<
Char
>
(
f
);
}
}
/**
...
...
test/format-impl-test.cc
View file @
24594c74
...
...
@@ -232,4 +232,5 @@ TEST(ColorsTest, Colors) {
"
\x1b
[1mbold error
\x1b
[0m"
);
EXPECT_WRITE
(
stderr
,
fmt
::
print
(
stderr
,
fg
(
fmt
::
color
::
blue
),
"blue log"
),
"
\x1b
[38;2;000;000;255mblue log
\x1b
[0m"
);
EXPECT_WRITE
(
stdout
,
fmt
::
print
(
fmt
::
text_style
(),
"hi"
),
"hi"
);
}
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