-
Notifications
You must be signed in to change notification settings - Fork 0
/
symbol_cycler.hpp
134 lines (110 loc) · 4.16 KB
/
symbol_cycler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#pragma once
#include <string>
#include <vector>
namespace cli_widgets {
/**
* \brief symbol_spinner is a circular
*
*
* \note to future self and anyone else: don't do silly things which could make both passed iterators
* swap places like sorting the list etc which likely could cause havoc. Should be fine otherwise _/\Ö/\_
*/
class symbol_cycler : public std::vector<std::string>::const_iterator {
std::vector<std::string>::const_iterator begin, end;
public:
/**
* \brief symbol spinner to (ring-)iterate over a collection of symbols
* Symbols can be stored in a const std::vector<std::string> whose begin() and end() itterators
* must be passed to this class during construction.
*
* Each iterator incrementation (or next() call) will get you access to the next symbol of
* your favourite ASCII spinner.
*/
symbol_cycler(std::vector<std::string>::const_iterator b, std::vector<std::string>::const_iterator e)
: std::vector<std::string>::const_iterator(b)
, begin(b)
, end(e) {}
/**
* \brief symbol spinner to (ring-)iterate over a collection of symbols
* Using the full range of provided symbols by accessing the begin() and end() operators
*
* For reduced range look at the other constructor overloads
*/
symbol_cycler(const std::vector<std::string> &vector)
: std::vector<std::string>::const_iterator(vector.begin())
, begin(vector.begin())
, end(vector.end()) {}
symbol_cycler &operator++(void) {
std::vector<std::string>::const_iterator::operator++();
if (*this == end)
std::vector<std::string>::const_iterator::operator=(begin);
return *this;
}
const symbol_cycler operator++(int) {
const auto oldValue = *this;
this->operator++();
return oldValue;
};
const std::string& next() {
return *(this->operator++());
}
symbol_cycler &operator--(void) = delete;
const symbol_cycler operator--(int) = delete;
};
}
namespace cli_widgets::spinner_symbols {
/**
* \brief ← ↖ ↑ ↗ → ↘ ↓ ↙
*/
const std::vector<std::string> symbols_arrows { "←", "↖", "↑", "↗", "→", "↘", "↓", "↙" };
/**
* \brief ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁
*/
const std::vector<std::string> symbols_bars_vertical { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▁" };
/**
* \brief ▉▊▋▌▍▎▏▎▍▌▋▊▉
*/
const std::vector<std::string> symbols_bars_horizontal { "▉", "▊", "▋", "▌", "▍", "▎", "▏", "▎", "▍", "▌", "▋", "▊", "▉" };
/**
* \brief ▖ ▘ ▝ ▗
*/
const std::vector<std::string> symbols_sqares { "▖", "▘", "▝", "▗" };
/**
* \brief ┤ ┘ ┴ └ ├ ┌ ┬ ┐
*
* /!\ this one is actually code page 850 safe
*/
const std::vector<std::string> symbols_angles { "┤", "┘", "┴", "└", "├", "┌", "┬", "┐" };
/**
* \brief ◢ ◣ ◤ ◥
*/
const std::vector<std::string> symbols_triangles {"◢", "◣", "◤", "◥" };
/**
* \brief ◰ ◳ ◲ ◱
*/
const std::vector<std::string> symbols_blocks { "◰", "◳", "◲", "◱" };
/**
* \brief ◴ ◷ ◶ ◵
*/
const std::vector<std::string> symbols_quarters { "◴", "◷", "◶", "◵" };
/**
* \brief ◐ ◓ ◑ ◒
*/
const std::vector<std::string> symbols_halves { "◐", "◓", "◑", "◒" };
/**
* \brief ◡◡ ⊙⊙ ◠◠
*/
const std::vector<std::string> symbols_circles { "◡", "◡", "⊙", "⊙", "◠", "◠" };
/**
* \brief ⠁⠂⠄⡀⢀⠠⠐⠈
*/
const std::vector<std::string> symbols_braille { "⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈" };
/**
* \brief ⣾⣽⣻⢿⡿⣟⣯⣷
*/
const std::vector<std::string> symbols_braille_inverted { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" };
/**
* \brief 🕛 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚
*/
const std::vector<std::string> symbols_clocks { "🕛", "🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚" };
}