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
43fe1008
Commit
43fe1008
authored
Feb 19, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the implementation of ColorWriter::operator() to format.cc
parent
6968ef3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
format.cc
format.cc
+9
-1
format.h
format.h
+1
-8
No files found.
format.cc
View file @
43fe1008
...
...
@@ -82,6 +82,8 @@ inline int FMT_SNPRINTF(char *buffer, size_t size, const char *format, ...) {
}
#endif // _MSC_VER
const
char
RESET_COLOR
[]
=
"
\x1b
[0m"
;
}
template
<
typename
T
>
...
...
@@ -663,7 +665,13 @@ void fmt::BasicFormatter<Char>::DoFormat() {
writer
.
buffer_
.
append
(
start
,
s
);
}
const
char
fmt
::
ColorWriter
::
RESET
[]
=
"
\x1b
[0m"
;
void
fmt
::
ColorWriter
::
operator
()(
const
fmt
::
BasicWriter
<
char
>
&
w
)
const
{
char
escape
[]
=
"
\x1b
[30m"
;
escape
[
3
]
=
'0'
+
color_
;
std
::
fputs
(
escape
,
stdout
);
std
::
fwrite
(
w
.
data
(),
1
,
w
.
size
(),
stdout
);
std
::
fputs
(
RESET_COLOR
,
stdout
);
}
// Explicit instantiations for char.
...
...
format.h
View file @
43fe1008
...
...
@@ -1472,19 +1472,12 @@ enum Color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
class
ColorWriter
{
private:
Color
color_
;
static
const
char
RESET
[];
public:
explicit
ColorWriter
(
Color
c
)
:
color_
(
c
)
{}
/** Writes the colored output to stdout. */
void
operator
()(
const
BasicWriter
<
char
>
&
w
)
const
{
char
escape
[]
=
"
\x1b
[30m"
;
escape
[
3
]
=
'0'
+
color_
;
std
::
fputs
(
escape
,
stdout
);
std
::
fwrite
(
w
.
data
(),
1
,
w
.
size
(),
stdout
);
std
::
fputs
(
RESET
,
stdout
);
}
void
operator
()(
const
BasicWriter
<
char
>
&
w
)
const
;
};
// Formats a string and prints it to stdout with the given color.
...
...
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