Skip to content

Commit 82e9f28

Browse files
committed
minor
1 parent c736d37 commit 82e9f28

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

demos/bars_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace {
4545
, m_bar_width(bar_width)
4646
, m_screen(m_bar_start_column + bar_width, 1, 1, line, L'')
4747
{
48-
m_screen.write_into(description+L": ", 0, 0, oof::cell_format{.m_fg_color=oof::color{255, 100, 100}});
48+
m_screen.write_into(description+L": ", 0, 0, oof::cell_format{.m_fg_color={255, 100, 100}});
4949
}
5050

5151
auto print() const -> void

demos/fireworks_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ auto fireworks_demo() -> void
246246
const s9w::ivec2 new_dim = get_screen_cell_dimensions();
247247
if (new_dim != dim) {
248248
fast_print(std::string(oof::clear_screen()));
249-
canvas = oof::pixel_screen(new_dim[0], 2 * new_dim[1], 0, 0, oof::color{});
249+
canvas = oof::pixel_screen(new_dim[0], 2 * new_dim[1]);
250250
dim = new_dim;
251251
glitter.clear();
252252
}

demos/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ auto my_error_function(
2121
auto print_choice(const char* desc)
2222
{
2323
static int choice = 0;
24-
std::cout << choice << ": " << oof::fg_color(oof::color{ 255, 100, 100 }) << desc << oof::reset_formatting() << "\n";
24+
std::cout << choice << ": " << oof::fg_color({ 255, 100, 100 }) << desc << oof::reset_formatting() << "\n";
2525
++choice;
2626
}
2727

@@ -31,9 +31,9 @@ int main()
3131
enable_vt_mode();
3232
std::cout << oof::cursor_visibility(false) << oof::reset_formatting() << oof::clear_screen();
3333

34-
//std::cout << oof::fg_color(oof::color{ 255, 100, 100 }) << "This is red\n";
35-
//std::cout << "Still the same - state was changed!\n";
36-
//std::cout << oof::reset_formatting() << oof::hposition(10) << "All back to normal\n";
34+
std::cout << oof::fg_color({ 255, 100, 100 }) << "This is red\n";
35+
std::cout << "Still the same - state was changed!\n";
36+
std::cout << oof::reset_formatting() << oof::hposition(10) << "All back to normal\n";
3737

3838
// oof::screen scr(10, 3, 0, 0, ' ');
3939
// for(uint64_t i=0; ; ++i){

demos/radar_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ auto radar_demo() -> void
5959
const s9w::dvec2 rel_pos = s9w::dvec2{ x, y } - center + half_pixel_offset;
6060
const double pixel_phi = nonstupid_atan2(rel_pos[1], rel_pos[0]);
6161
if(s9w::equal(pixel_phi, radar_phi, 0.05) && s9w::get_length(rel_pos) < radar_radius)
62-
px.get_color(x, y) = oof::color{ 255, 0, 0 };
62+
px.get_color(x, y) = { 255, 0, 0 };
6363
}
6464
}
6565

oof.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ namespace oof
247247
[[nodiscard]] auto get_pixel_background(const color& fill_color) -> cell<std::wstring>;
248248

249249
template<oof::std_string_type string_type>
250-
[[nodiscard]] auto write_sequence_string_no_reserve(const std::vector<sequence_variant_type>& sequences, string_type& target) -> void;
250+
auto write_sequence_string_no_reserve(const std::vector<sequence_variant_type>& sequences, string_type& target) -> void;
251251

252252
template<oof::sequence_c sequence_type>
253253
[[nodiscard]] constexpr auto get_sequence_string_size(const sequence_type& sequence) -> size_t;
@@ -397,7 +397,7 @@ constexpr auto oof::detail::get_sequence_string_size(const sequence_type& sequen
397397
constexpr auto get_int_param_str_length = [](const int param) -> int {
398398
if (param < 10) return 1;
399399
if (param < 100) return 2;
400-
else return 3;
400+
return 3;
401401
};
402402

403403
if constexpr (is_any_of<sequence_type, char_sequence, wchar_sequence>) {
@@ -735,7 +735,7 @@ oof::screen<string_type>::screen(
735735
const int width, const int height,
736736
const char_type fill_char
737737
)
738-
: screen(width, height, 0, 0, cell<string_type>{fill_char})
738+
: screen(width, height, 0, 0, fill_char)
739739
{
740740

741741
}

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Oof (omnipotent output friend)
2-
It's common for C++ programs to write output to the console. But consoles are far more capable than what they are usually used for. The magic lies in the so-called [Virtual Terminal sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) (sometimes also confusingly called ["escape codes"](https://en.wikipedia.org/wiki/ANSI_escape_code)): These cryptic character sequences allow complete control over position, color and other properties of written characters. *Oof* is a single C++20 header that wraps these in a convenient way
2+
It's common for C++ programs to write output to the console. But consoles are far more capable than what they are usually used for. The magic lies in the so-called [Virtual Terminal sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) (sometimes also confusingly called ["escape codes"](https://en.wikipedia.org/wiki/ANSI_escape_code)): These cryptic character sequences allow complete control over position, color and other properties of written characters. *Oof* is a single C++20 header that wraps these in a convenient way.
33

4-
On top of that, *oof* provides two special interfaces that heavily optimizes the resulting stream of VT sequences, so that real-time outputs like those below are possible. Note that everything in these videos are letters in a console window:
4+
On top of that, *oof* provides two special interfaces that heavily optimize the resulting stream of VT sequences, so that real-time outputs like those below are possible. Everything in these videos are letters in a console window:
55

66
https://user-images.githubusercontent.com/6044318/142469815-ce680909-9151-4322-85aa-01dc9ba29c1d.mp4
77

@@ -63,7 +63,7 @@ Index colors are simply colors refered to by an index. The colors behind the ind
6363
6464
All these functions return a magic type that can `operator<<` into `std::cout` and `std::wcout`. Example:
6565
```c++
66-
std::cout << oof::fg_color(oof::color{ 255, 100, 100 }) << "This is red\n";
66+
std::cout << oof::fg_color({ 255, 100, 100 }) << "This is red\n";
6767
std::cout << "Still the same - state was changed!\n";
6868
std::cout << oof::reset_formatting() << oof::hposition(10) << "All back to normal\n";
6969
```
@@ -79,7 +79,7 @@ Each printing command (regardless of wether it's `printf`, `std::cout` or someth
7979

8080
If you want real-time output, ie continuously changing what's on the screen, there's even more potential: By keeping track of the current screen state, *oof* avoids writing to cells that haven't changed. And: Changing the console cursor state (even without printing anything) is expensive. Avoiding unnecessary state changes is key. Both of these optimizations are implemented in the `screen` and `pixel_screen` classes.
8181

82-
`oof::screen` lets you define a rectangle in your console window, and set the state of every single cell. Its `get_string()` and `write_string(string_type&)` methods then output an optimized string to achieve the desired state. This assumes that the user didn't interfere - so don't. The difference between `get_string()` and `write_string(string_type&)` is that the passed string will be used to avoid allocating a new string. So it'll avoid memory waste. Almost always, the cost of building up the string is tiny vs the cost of printing, so don't worry about this too much.
82+
With `oof::screen` you define a rectangle in your console window and set the state of every single cell. Its `get_string()` and `write_string(string_type&)` methods then output an optimized string to achieve the desired state. This assumes that the user didn't interfere - so don't. The difference between `get_string()` and `write_string(string_type&)` is that the passed string will be reused to avoid allocating a new string. Almost always, the time to build up the string is tiny vs the time it takes to print, so don't worry about this too much.
8383

8484
Example for `oof::screen` usage:
8585
```c++
@@ -121,7 +121,7 @@ while(true){
121121
```
122122
![pixel_screen_example](https://user-images.githubusercontent.com/6044318/142581841-66a235d1-d1e8-4f02-b7e7-2c9889a321e6.gif)
123123

124-
The source code from the demo videos at the beginning is in this repo under /demos. That code uses a not-included and yet unreleased helper library (`s9w::`) for colors and math. But those aren't crucial if you just want to have a look.
124+
The source code from the demo videos at the beginning is in this repo under [demos/](demos). That code uses a not-included and yet unreleased helper library (`s9w::`) for colors and math. But those aren't crucial if you just want to have a look.
125125

126126
## Notes
127127
Consoles display text. Text is displayed via fonts. If you use letters that aren't included in your console font, that will result in visual artifacts - duh. This especially important for the `pixel_display` type, as it uses the mildly special [Block element](https://en.wikipedia.org/wiki/Block_Elements) '▀'. Some fonts may not have them included. Others do, but have them poorly aligned or sized - breaking up the even pixel grid.

0 commit comments

Comments
 (0)