This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counting from 1 to 10: i=1 [#_________] | |
counting from 1 to 10: i=2 [##________] | |
counting from 1 to 10: i=3 [###_______] | |
counting from 1 to 10: i=4 [####______] | |
counting from 1 to 10: i=5 [#####_____] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned const terminalWidth = 80; | |
int main() { | |
VirtualTerminal vt; | |
auto const fancyCounter = [](auto start, auto end, auto i) -> FlowLayout<> { | |
return { | |
Text("counting from "), Text({ Font::Bold }, start), | |
Text(" to "), Text({ Font::Bold }, end), | |
Text(": i="), Text({ FgColor::Red, Font::Underline }, i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() { | |
std::cout << "\e[31m" << "Hello" << "\e[0m" << World" << std::endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class Color { /* ... */ }; | |
enum class Font { /* ... */ }; | |
struct Style { | |
Color bg; | |
Color fg; | |
Font font; | |
}; | |
struct Pixel { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Renderable { | |
virtual Image render(unsigned const width) const = 0; | |
virtual ~Renderable() {} | |
}; | |
template<class T> | |
struct Model : Renderable { | |
T data; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Text { | |
Style style; | |
std::string text; | |
Image render() const { | |
std::vector<Pixel> pixels(text.size(), Pixel{ style }); | |
for (int i = 0; i < text.size(); ++i) { | |
pixels[i].c = text[i]; | |
} | |
return Image{ width, height, pixels }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running task: download | |
progress(50%): [xxxxxx ] | |
Tasks Done: 1/5: [x ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running task: download | |
progress(75%): [xxxxxxxxx ] | |
Tasks Done: 1/5: [x ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pseudo-code | |
struct VirtualTerminal { | |
string buffer; // Currently visible output | |
string computeTransition(string const& prev, string const& next) { | |
const string deleteLine = "\e[2K\r\e[1A"; | |
return repeat(count("\n", prev), deleteLine()) + next; | |
} | |
VirtualTerminal flip(std::string const& str) const { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int f() { | |
Foo foo = new Foo(); | |
return foo.bar(); | |
} |