Skip to content

Commit a68eb72

Browse files
committed
Add terminal and color escape sequences
- style, foreground and background color enumerators - true color (24-bit) types - generation of escape strings via to_string function
1 parent 8e0d8dd commit a68eb72

8 files changed

+599
-0
lines changed

doc/specs/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ This is and index/directory of the specifications (specs) for each new module/fe
3333
- [string\_type](./stdlib_string_type.html) - Basic string support
3434
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
3535
- [strings](./stdlib_strings.html) - String handling and manipulation routines
36+
- [stringlist_type](./stdlib_stringlist_type.html) - 1-Dimensional list of strings
37+
- [terminal_colors](./stdlib_terminal_colors.html) - Terminal color and style escape sequences
3638
- [version](./stdlib_version.html) - Version information
3739

3840
## Released/Stable Features & Modules

doc/specs/stdlib_terminal_color.md

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
---
2+
title: terminal colors
3+
...
4+
5+
6+
# The `stdlib_terminal_colors` module
7+
8+
[TOC]
9+
10+
## Introduction
11+
12+
Support terminal escape sequences to produce styled and colored terminal output.
13+
14+
15+
## Derived types provided
16+
17+
18+
### ``fg_color24`` type
19+
20+
The ``fg_color24`` type represent a true color (24-bit) foreground color.
21+
It contains the members ``red``, ``blue`` and ``green`` as default integer types.
22+
23+
#### Status
24+
25+
Experimental
26+
27+
28+
### ``bg_color24`` type
29+
30+
The ``bg_color24`` type represent a true color (24-bit) background color.
31+
It contains the members ``red``, ``blue`` and ``green`` as default integer types.
32+
33+
#### Status
34+
35+
Experimental
36+
37+
38+
## Constants provided
39+
40+
### ``style_reset``
41+
42+
Style enumerator representing a reset escape code.
43+
44+
45+
### ``style_bold``
46+
47+
Style enumerator representing a bold escape code.
48+
49+
50+
### ``style_dim``
51+
52+
Style enumerator representing a dim escape code.
53+
54+
55+
56+
### ``style_italic``
57+
58+
Style enumerator representing an italic escape code.
59+
60+
61+
62+
### ``style_underline``
63+
64+
Style enumerator representing an underline escape code.
65+
66+
67+
### ``style_blink``
68+
69+
Style enumerator representing a blink escape code.
70+
71+
72+
### ``style_blink_fast``
73+
74+
Style enumerator representing a (fast) blink escape code.
75+
76+
77+
### ``style_reverse``
78+
79+
Style enumerator representing a reverse escape code.
80+
81+
82+
### ``style_hidden``
83+
84+
Style enumerator representing a hidden escape code.
85+
86+
87+
### ``style_strikethrough``
88+
89+
Style enumerator representing a strike-through escape code.
90+
91+
92+
### ``fg_color_black``
93+
94+
Foreground color enumerator representing a foreground black color escape code.
95+
96+
97+
### ``fg_color_red``
98+
99+
Foreground color enumerator representing a foreground red color escape code.
100+
101+
102+
### ``fg_color_green``
103+
104+
Foreground color enumerator representing a foreground green color escape code.
105+
106+
107+
### ``fg_color_yellow``
108+
109+
Foreground color enumerator representing a foreground yellow color escape code.
110+
111+
112+
### ``fg_color_blue``
113+
114+
Foreground color enumerator representing a foreground blue color escape code.
115+
116+
117+
### ``fg_color_magenta``
118+
119+
Foreground color enumerator representing a foreground magenta color escape code.
120+
121+
122+
### ``fg_color_cyan``
123+
124+
Foreground color enumerator representing a foreground cyan color escape code.
125+
126+
127+
### ``fg_color_white``
128+
129+
Foreground color enumerator representing a foreground white color escape code.
130+
131+
132+
### ``fg_color_default``
133+
134+
Foreground color enumerator representing a foreground default color escape code.
135+
136+
137+
### ``bg_color_black``
138+
139+
Background color enumerator representing a background black color escape code.
140+
141+
142+
### ``bg_color_red``
143+
144+
Background color enumerator representing a background red color escape code.
145+
146+
147+
### ``bg_color_green``
148+
149+
Background color enumerator representing a background green color escape code.
150+
151+
152+
### ``bg_color_yellow``
153+
154+
Background color enumerator representing a background yellow color escape code.
155+
156+
157+
### ``bg_color_blue``
158+
159+
Background color enumerator representing a background blue color escape code.
160+
161+
162+
### ``bg_color_magenta``
163+
164+
Background color enumerator representing a background magenta color escape code.
165+
166+
167+
### ``bg_color_cyan``
168+
169+
Background color enumerator representing a background cyan color escape code.
170+
171+
172+
### ``bg_color_white``
173+
174+
Background color enumerator representing a background white color escape code.
175+
176+
177+
### ``bg_color_default``
178+
179+
Background color enumerator representing a background default color escape code.
180+
181+
182+
## Procedures and methods provided
183+
184+
### ``to_string``
185+
186+
Generic interface to turn a style, foreground or background enumerator into an actual escape code string for printout.
187+
188+
#### Syntax
189+
190+
`string = [[stdlib_string_colors(module):to_string(interface)]] (enum)`
191+
192+
#### Class
193+
194+
Pure function.
195+
196+
#### Argument
197+
198+
``enum``: Style, foreground or background enumerator, this argument is ``intent(in)``.
199+
200+
#### Result value
201+
202+
The result is a default character string.
203+
204+
#### Status
205+
206+
Experimental
207+
208+
209+
### ``to_string``
210+
211+
Generic interface to turn a foreground or background true color type into an actual escape code string for printout.
212+
213+
#### Syntax
214+
215+
`string = [[stdlib_string_colors(module):to_string(interface)]] (color24)`
216+
217+
#### Class
218+
219+
Pure function.
220+
221+
#### Argument
222+
223+
``color24``: Foreground or background true color instance, this argument is ``intent(in)``.
224+
225+
#### Result value
226+
227+
The result is a default character string.
228+
229+
#### Status
230+
231+
Experimental

src/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ set(SRC
8787
stdlib_system.F90
8888
stdlib_specialfunctions.f90
8989
stdlib_specialfunctions_legendre.f90
90+
stdlib_terminal_colors.f90
91+
stdlib_terminal_colors_to_string.f90
9092
stdlib_quadrature_gauss.f90
9193
stdlib_stringlist_type.f90
9294
${outFiles}

0 commit comments

Comments
 (0)