From 27f4ad1f59ff3e92cb5ad6904ff07eb584a00fef Mon Sep 17 00:00:00 2001 From: Pranav Srinivas Kumar Date: Sat, 23 May 2020 12:40:09 -0500 Subject: [PATCH] Made cursor control/movement functions static inline #58 --- include/indicators/cursor_control.hpp | 4 ++-- include/indicators/cursor_movement.hpp | 18 +++++++++--------- single_include/indicators/indicators.hpp | 22 +++++++++++----------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/indicators/cursor_control.hpp b/include/indicators/cursor_control.hpp index 1d79726..5aaa658 100755 --- a/include/indicators/cursor_control.hpp +++ b/include/indicators/cursor_control.hpp @@ -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); } diff --git a/include/indicators/cursor_movement.hpp b/include/indicators/cursor_movement.hpp index 0a93d32..99a3645 100755 --- a/include/indicators/cursor_movement.hpp +++ b/include/indicators/cursor_movement.hpp @@ -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 diff --git a/single_include/indicators/indicators.hpp b/single_include/indicators/indicators.hpp index b6641a6..b78d959 100644 --- a/single_include/indicators/indicators.hpp +++ b/single_include/indicators/indicators.hpp @@ -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