-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.cpp
32 lines (26 loc) · 1.14 KB
/
example.cpp
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
#include <iostream>
#include "ansipipe.h"
// needed for MSVC
#include <string>
/*
* This source demonstrates how to use ANSI|pipe in a console-based C++ project.
* Under Windows, if the binary is run through the ANSI|pipe launcher, UTF-8
* and ANSI escape sequences will shown correctly; if the binary is run on its
* own, ANSI and UTF-8 will not be parsed.
* This source also compiles and runs on Unix without the need to make changes.
*/
int main()
{
if (ansipipe_init() != 0)
std::cout << "Not connected to ANSI|pipe. Output will be gibberish.\n";
std::cout << "\x1b]2;ANSI|pipe demo\x07";
// From helloworldcollection.de. Lucida Sans doesn't support Asian scripts, but this all works:
std::cout << "\n\n\n\x1b[2AHello, \x1b[1A\x1b[91mWorld!\x1b[2B\x1b[0m ";
std::cout << "Здравствуй, \x1b[1A\x1b[92mмир!\x1b[0m\x1b[2B ";
std::cout << "Γεια σου \x1b[1A\x1b[94mκόσμε!\x1b[2B\x1b[0m\n";
std::cout << "Type something: ";
std::string input;
std::getline(std::cin, input);
std::cout << "You typed \x1b[45;1m" << input << "\x1b[0m.\n";
return 0;
}