Made cursor control/movement functions static inline #58

This commit is contained in:
Pranav Srinivas Kumar
2020-05-23 12:40:09 -05:00
parent a5fb2bbcaf
commit 27f4ad1f59
3 changed files with 22 additions and 22 deletions

View File

@@ -14,7 +14,7 @@ namespace indicators {
#if defined(_MSC_VER)
void show_console_cursor(bool const show) {
static inline void show_console_cursor(bool const show) {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
@@ -26,7 +26,7 @@ void show_console_cursor(bool const show) {
#else
void show_console_cursor(bool const show) {
static inline void show_console_cursor(bool const show) {
std::fputs(show ? "\e[?25h" : "\e[?25l", stdout);
}

View File

@@ -14,7 +14,7 @@ namespace indicators {
#ifdef _MSC_VER
void move(int x, int y) {
static inline void move(int x, int y) {
auto hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (!hStdout)
return;
@@ -29,17 +29,17 @@ void move(int x, int y) {
SetConsoleCursorPosition(hStdout, cursor);
}
void move_up(int lines) { move(0, -lines); }
void move_down(int lines) { move(0, -lines); }
void move_right(int cols) { move(cols, 0); }
void move_left(int cols) { move(-cols, 0); }
static inline void move_up(int lines) { move(0, -lines); }
static inline void move_down(int lines) { move(0, -lines); }
static inline void move_right(int cols) { move(cols, 0); }
static inline void move_left(int cols) { move(-cols, 0); }
#else
void move_up(int lines) { std::cout << "\033[" << lines << "A"; }
void move_down(int lines) { std::cout << "\033[" << lines << "B"; }
void move_right(int cols) { std::cout << "\033[" << cols << "C"; }
void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
static inline void move_up(int lines) { std::cout << "\033[" << lines << "A"; }
static inline void move_down(int lines) { std::cout << "\033[" << lines << "B"; }
static inline void move_right(int cols) { std::cout << "\033[" << cols << "C"; }
static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif

View File

@@ -1176,7 +1176,7 @@ namespace indicators {
#if defined(_MSC_VER)
void show_console_cursor(bool const show) {
static inline void show_console_cursor(bool const show) {
HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursorInfo;
@@ -1188,7 +1188,7 @@ void show_console_cursor(bool const show) {
#else
void show_console_cursor(bool const show) {
static inline void show_console_cursor(bool const show) {
std::fputs(show ? "\e[?25h" : "\e[?25l", stdout);
}
@@ -1210,7 +1210,7 @@ namespace indicators {
#ifdef _MSC_VER
void move(int x, int y) {
static inline void move(int x, int y) {
auto hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (!hStdout)
return;
@@ -1225,17 +1225,17 @@ void move(int x, int y) {
SetConsoleCursorPosition(hStdout, cursor);
}
void move_up(int lines) { move(0, -lines); }
void move_down(int lines) { move(0, -lines); }
void move_right(int cols) { move(cols, 0); }
void move_left(int cols) { move(-cols, 0); }
static inline void move_up(int lines) { move(0, -lines); }
static inline void move_down(int lines) { move(0, -lines); }
static inline void move_right(int cols) { move(cols, 0); }
static inline void move_left(int cols) { move(-cols, 0); }
#else
void move_up(int lines) { std::cout << "\033[" << lines << "A"; }
void move_down(int lines) { std::cout << "\033[" << lines << "B"; }
void move_right(int cols) { std::cout << "\033[" << cols << "C"; }
void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
static inline void move_up(int lines) { std::cout << "\033[" << lines << "A"; }
static inline void move_down(int lines) { std::cout << "\033[" << lines << "B"; }
static inline void move_right(int cols) { std::cout << "\033[" << cols << "C"; }
static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif