forked from arvidn/libtorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.hpp
56 lines (38 loc) · 1.24 KB
/
print.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
#ifndef PRINT_HPP_
#define PRINT_HPP_
#include <string>
#include <cstdio> // for snprintf
#include <cinttypes> // for PRId64 et.al.
#include "libtorrent/bitfield.hpp"
#include "libtorrent/span.hpp"
enum color_code
{
col_none = -1,
col_black = 0,
col_red = 1,
col_green = 2,
col_yellow = 3,
col_blue = 4,
col_magenta = 5,
col_cyan = 6,
col_white = 7
};
char const* esc(char const* code);
std::string to_string(int v, int width);
std::string add_suffix_float(double val, char const* suffix);
template<class T> std::string add_suffix(T val, char const* suffix = nullptr) {
return add_suffix_float(double(val), suffix);
}
std::string color(std::string const& s, color_code c);
enum { progress_invert = 1};
std::string const& progress_bar(int progress, int width, color_code c = col_green
, char fill = '#', char bg = '-', std::string caption = "", int flags = 0);
std::string const& piece_bar(lt::bitfield const& p, int width);
std::string avail_bar(lt::span<int> avail, int const width, int& pos);
void set_cursor_pos(int x, int y);
void clear_screen();
void clear_rows(int y1, int y2);
std::pair<int, int> terminal_size();
std::string piece_matrix(lt::bitfield const& p, int width, int* height);
void print(char const* str);
#endif // PRINT_HPP_