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
9368b6a4
Commit
9368b6a4
authored
Feb 08, 2015
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error handling in print_colored
parent
7004d1ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
format.cc
format.cc
+4
-4
No files found.
format.cc
View file @
9368b6a4
...
@@ -1114,17 +1114,17 @@ FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) {
...
@@ -1114,17 +1114,17 @@ FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) {
#ifdef _WIN32
#ifdef _WIN32
HANDLE
handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
HANDLE
handle
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
if
(
handle
==
INVALID_HANDLE_VALUE
)
FMT_THROW
(
GetLastError
(),
"cannot get output handle"
);
FMT_THROW
(
WindowsError
(
GetLastError
(),
"cannot get output handle"
)
);
CONSOLE_SCREEN_BUFFER_INFO
info_con
;
CONSOLE_SCREEN_BUFFER_INFO
info_con
;
if
(
!
GetConsoleScreenBufferInfo
(
handle
,
&
info_con
))
if
(
!
GetConsoleScreenBufferInfo
(
handle
,
&
info_con
))
FMT_THROW
(
GetLastError
(),
"cannot get console information"
);
FMT_THROW
(
WindowsError
(
GetLastError
(),
"cannot get console information"
)
);
WORD
reset_color
=
info_con
.
wAttributes
;
WORD
reset_color
=
info_con
.
wAttributes
;
WORD
color
=
static_cast
<
int
>
(
c
)
>=
ARRAYSIZE
(
WIN32_COLORS
)
?
reset_color
:
WIN32_COLORS
[
c
];
WORD
color
=
static_cast
<
int
>
(
c
)
>=
ARRAYSIZE
(
WIN32_COLORS
)
?
reset_color
:
WIN32_COLORS
[
c
];
if
(
!
SetConsoleTextAttribute
(
handle
,
color
))
if
(
!
SetConsoleTextAttribute
(
handle
,
color
))
FMT_THROW
(
GetLastError
(),
"cannot set console color"
);
FMT_THROW
(
WindowsError
(
GetLastError
(),
"cannot set console color"
)
);
print
(
format
,
args
);
print
(
format
,
args
);
if
(
!
SetConsoleTextAttribute
(
handle
,
reset_color
))
if
(
!
SetConsoleTextAttribute
(
handle
,
reset_color
))
FMT_THROW
(
GetLastError
(),
"cannot set console color"
);
FMT_THROW
(
WindowsError
(
GetLastError
(),
"cannot set console color"
)
);
#else
#else
char
escape
[]
=
"
\x1b
[30m"
;
char
escape
[]
=
"
\x1b
[30m"
;
escape
[
3
]
=
'0'
+
static_cast
<
char
>
(
c
);
escape
[
3
]
=
'0'
+
static_cast
<
char
>
(
c
);
...
...
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