Skip to content

Instantly share code, notes, and snippets.

@njlr
Last active August 21, 2017 15:25
Show Gist options
  • Save njlr/8fbc7161b939e14887ddd56521ff57be to your computer and use it in GitHub Desktop.
Save njlr/8fbc7161b939e14887ddd56521ff57be to your computer and use it in GitHub Desktop.
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) 
  MaxWidth(20, Progress(i * 0.01)),
  }; 
};
for (int i = 0; i < 101; ++i) {
  Component const app = StackLayout<>({
  fancyCounter(0, 100, i)
  });
 
 vt = renderToTerm(vt, TerminalWidth, app); // Render to terminal
  std::this_thread::sleep_for(200ms);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment