Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
629e06d6
Unverified
Commit
629e06d6
authored
Mar 05, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write uncoloured text
parent
51ccb921
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
36 deletions
+8
-36
include/cif++/utilities.hpp
+8
-36
No files found.
include/cif++/utilities.hpp
View file @
629e06d6
...
@@ -113,16 +113,12 @@ namespace colour
...
@@ -113,16 +113,12 @@ namespace colour
/**
/**
* @brief Struct for delimited strings.
* @brief Struct for delimited strings.
*/
*/
template
<
typename
StringType
>
struct
coloured_string_t
struct
coloured_string_t
{
{
static_assert
(
std
::
is_reference_v
<
StringType
>
or
std
::
is_pointer_v
<
StringType
>
,
"String type must be pointer or reference"
);
/**
/**
* @brief Construct a new coloured string t object
* @brief Construct a new coloured string t object
*/
*/
coloured_string_t
(
StringType
s
,
colour_type
fc
,
colour_type
bc
,
style_type
st
)
coloured_string_t
(
std
::
string_view
s
,
colour_type
fc
,
colour_type
bc
,
style_type
st
)
:
m_str
(
s
)
:
m_str
(
s
)
,
m_fore_colour
(
static_cast
<
int
>
(
fc
)
+
30
)
,
m_fore_colour
(
static_cast
<
int
>
(
fc
)
+
30
)
,
m_back_colour
(
static_cast
<
int
>
(
bc
)
+
40
)
,
m_back_colour
(
static_cast
<
int
>
(
bc
)
+
40
)
...
@@ -152,12 +148,14 @@ namespace colour
...
@@ -152,12 +148,14 @@ namespace colour
<<
cs
.
m_str
<<
cs
.
m_str
<<
"
\033
[0m"
;
<<
"
\033
[0m"
;
}
}
else
os
<<
cs
.
m_str
;
return
os
;
return
os
;
}
}
/// @cond
/// @cond
StringType
m_str
;
std
::
string_view
m_str
;
int
m_fore_colour
,
m_back_colour
;
int
m_fore_colour
,
m_back_colour
;
int
m_style
;
int
m_style
;
/// @endcond
/// @endcond
...
@@ -191,39 +189,13 @@ namespace colour
...
@@ -191,39 +189,13 @@ namespace colour
* @param st Text style to use
* @param st Text style to use
*/
*/
template
<
typename
char_type
>
template
<
typename
T
>
inline
auto
coloured
(
const
char_type
*
str
,
requires
std
::
is_assignable_v
<
std
::
string_view
,
T
>
colour
::
colour_type
fg
,
colour
::
colour_type
bg
=
colour
::
colour_type
::
none
,
inline
auto
coloured
(
T
str
,
colour
::
style_type
st
=
colour
::
style_type
::
regular
)
{
return
colour
::
detail
::
coloured_string_t
<
const
char_type
*>
(
str
,
fg
,
bg
,
st
);
}
/// @brief Manipulator for coloured strings.
template
<
typename
char_type
,
typename
traits_type
,
typename
allocator_type
>
inline
auto
coloured
(
const
std
::
basic_string
<
char_type
,
traits_type
,
allocator_type
>
&
str
,
colour
::
colour_type
fg
,
colour
::
colour_type
bg
=
colour
::
colour_type
::
none
,
colour
::
style_type
st
=
colour
::
style_type
::
regular
)
{
return
colour
::
detail
::
coloured_string_t
<
const
std
::
basic_string
<
char_type
,
traits_type
,
allocator_type
>
&>
(
str
,
fg
,
bg
,
st
);
}
/// @brief Manipulator for coloured strings.
template
<
typename
char_type
,
typename
traits_type
,
typename
allocator_type
>
inline
auto
coloured
(
std
::
basic_string
<
char_type
,
traits_type
,
allocator_type
>
&
str
,
colour
::
colour_type
fg
,
colour
::
colour_type
bg
=
colour
::
colour_type
::
none
,
colour
::
style_type
st
=
colour
::
style_type
::
regular
)
{
return
colour
::
detail
::
coloured_string_t
<
std
::
basic_string
<
char_type
,
traits_type
,
allocator_type
>
&>
(
str
,
fg
,
bg
,
st
);
}
/// @brief Manipulator for coloured strings.
template
<
typename
char_type
,
typename
traits_type
>
inline
auto
coloured
(
std
::
basic_string_view
<
char_type
,
traits_type
>
&
str
,
colour
::
colour_type
fg
,
colour
::
colour_type
bg
=
colour
::
colour_type
::
none
,
colour
::
colour_type
fg
,
colour
::
colour_type
bg
=
colour
::
colour_type
::
none
,
colour
::
style_type
st
=
colour
::
style_type
::
regular
)
colour
::
style_type
st
=
colour
::
style_type
::
regular
)
{
{
return
colour
::
detail
::
coloured_string_t
<
std
::
basic_string_view
<
char_type
,
traits_type
>
&>
(
str
,
fg
,
bg
,
st
);
return
colour
::
detail
::
coloured_string_t
(
str
,
fg
,
bg
,
st
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
...
...
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