mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-16 04:18:51 +08:00
Made cursor control/movement functions static inline #58
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user