Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
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
spdlog
Commits
adcfb7fb
Unverified
Commit
adcfb7fb
authored
Dec 20, 2020
by
Gabi Melman
Committed by
GitHub
Dec 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1768 from dominicpoeschko/colorterminal_detection
Changed is_color_terminal to be more generic.
parents
55bfa8dd
cec36588
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
include/spdlog/details/os-inl.h
include/spdlog/details/os-inl.h
+18
-9
No files found.
include/spdlog/details/os-inl.h
View file @
adcfb7fb
...
...
@@ -397,17 +397,26 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
#ifdef _WIN32
return
true
;
#else
static
constexpr
std
::
array
<
const
char
*
,
14
>
terms
=
{
{
"ansi"
,
"color"
,
"console"
,
"cygwin"
,
"gnome"
,
"konsole"
,
"kterm"
,
"linux"
,
"msys"
,
"putty"
,
"rxvt"
,
"screen"
,
"vt100"
,
"xterm"
}};
const
char
*
env_p
=
std
::
getenv
(
"TERM"
);
if
(
env_p
==
nullptr
)
{
return
false
;
}
static
const
bool
result
=
[]()
{
const
char
*
env_colorterm_p
=
std
::
getenv
(
"COLORTERM"
);
if
(
env_colorterm_p
!=
nullptr
)
{
return
true
;
}
static
constexpr
std
::
array
<
const
char
*
,
15
>
terms
=
{{
"ansi"
,
"color"
,
"console"
,
"cygwin"
,
"gnome"
,
"konsole"
,
"kterm"
,
"linux"
,
"msys"
,
"putty"
,
"rxvt"
,
"screen"
,
"vt100"
,
"xterm"
,
"alacritty"
}};
const
char
*
env_term_p
=
std
::
getenv
(
"TERM"
);
if
(
env_term_p
==
nullptr
)
{
return
false
;
}
return
std
::
any_of
(
terms
.
begin
(),
terms
.
end
(),
[
&
](
const
char
*
term
)
{
return
std
::
strstr
(
env_term_p
,
term
)
!=
nullptr
;
});
}();
static
const
bool
result
=
std
::
any_of
(
terms
.
begin
(),
terms
.
end
(),
[
&
](
const
char
*
term
)
{
return
std
::
strstr
(
env_p
,
term
)
!=
nullptr
;
});
return
result
;
#endif
}
...
...
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