diff --git a/src/console_output.cc b/src/console_output.cc index d51f8c4..91d89ae 100644 --- a/src/console_output.cc +++ b/src/console_output.cc @@ -29,36 +29,36 @@ console_output::console_output(std::ostream &cout): out{cout} {} X Y are numbers from above */ -std::string console_output::get_code(const int attr) { - if (attr < 255) +std::string console_output::get_code(const int attrs) { + if (attrs < 255) return "\033[0m"; std::string result = "\033[0m\033["; - if (attr & A_BOLD) + if (attrs & A_BOLD) result += "1;"; - if (attr & A_UNDERLINE) + if (attrs & A_UNDERLINE) result += "4;"; - if (attr & A_STANDOUT) + if (attrs & A_STANDOUT) result += "7;"; - if ((attr & COLOR_PAIR(COLOR_WHITE)) == COLOR_PAIR(COLOR_WHITE)) + if ((attrs & COLOR_PAIR(COLOR_WHITE)) == COLOR_PAIR(COLOR_WHITE)) result += "37;"; - else if ((attr & COLOR_PAIR(COLOR_CYAN)) == COLOR_PAIR(COLOR_CYAN)) + else if ((attrs & COLOR_PAIR(COLOR_CYAN)) == COLOR_PAIR(COLOR_CYAN)) result += "36;"; - else if ((attr & COLOR_PAIR(COLOR_MAGENTA)) == COLOR_PAIR(COLOR_MAGENTA)) + else if ((attrs & COLOR_PAIR(COLOR_MAGENTA)) == COLOR_PAIR(COLOR_MAGENTA)) result += "35;"; - else if ((attr & COLOR_PAIR(COLOR_BLUE)) == COLOR_PAIR(COLOR_BLUE)) + else if ((attrs & COLOR_PAIR(COLOR_BLUE)) == COLOR_PAIR(COLOR_BLUE)) result += "34;"; - else if ((attr & COLOR_PAIR(COLOR_YELLOW)) == COLOR_PAIR(COLOR_YELLOW)) + else if ((attrs & COLOR_PAIR(COLOR_YELLOW)) == COLOR_PAIR(COLOR_YELLOW)) result += "33;"; - else if ((attr & COLOR_PAIR(COLOR_RED)) == COLOR_PAIR(COLOR_RED)) + else if ((attrs & COLOR_PAIR(COLOR_RED)) == COLOR_PAIR(COLOR_RED)) result += "31;"; - else if ((attr & COLOR_PAIR(COLOR_GREEN)) == COLOR_PAIR(COLOR_GREEN)) + else if ((attrs & COLOR_PAIR(COLOR_GREEN)) == COLOR_PAIR(COLOR_GREEN)) result += "32;"; - else if ((attr & COLOR_PAIR(COLOR_BLACK_ON_WHITE)) == COLOR_BLACK_ON_WHITE) + else if ((attrs & COLOR_PAIR(COLOR_BLACK_ON_WHITE)) == COLOR_BLACK_ON_WHITE) result += "30;47;"; result[result.length() - 1] = 'm'; @@ -80,20 +80,20 @@ void console_output::render() { } void console_output::print_char(const position &pos, const char ch, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; - contents[pos.y * DISPLAY_WIDTH + pos.x] = attr | ch; + contents[pos.y * DISPLAY_WIDTH + pos.x] = attrs | ch; } void console_output::print_str(const position &pos, const std::string &str, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; int head = pos.y * DISPLAY_WIDTH + pos.x; for (std::size_t i = 0; i < str.length(); ++i) - contents[i + head] = attr | str[i]; + contents[i + head] = attrs | str[i]; } diff --git a/src/console_output.h b/src/console_output.h index 4315e46..677d40b 100644 --- a/src/console_output.h +++ b/src/console_output.h @@ -7,15 +7,15 @@ class console_output final : public display { private: std::ostream &out; - std::string get_code(const int attr); + std::string get_code(const int attrs); public: console_output(std::ostream &cout); void render() override; void print_char(const position &pos, - const char ch, const int attr) override; + const char ch, const int attrs) override; void print_str(const position &pos, - const std::string &str, const int attr) override; + const std::string &str, const int attrs) override; }; #endif diff --git a/src/curses_output.cc b/src/curses_output.cc index a587343..27fd4a3 100644 --- a/src/curses_output.cc +++ b/src/curses_output.cc @@ -12,22 +12,22 @@ void curses_output::clear() { } void curses_output::print_char(const position &pos, const char ch, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; - curse->print_char(pos, ch, attr); + curse->print_char(pos, ch, attrs); } void curses_output::print_str(const position &pos, const std::string &str, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; position tmp = pos; for (std::size_t i = 0; i < str.length(); ++i) { - curse->print_char(tmp, str[i], attr); + curse->print_char(tmp, str[i], attrs); tmp += {1, 0}; if (tmp.x >= DISPLAY_WIDTH) diff --git a/src/curses_output.h b/src/curses_output.h index 0bc88c8..f4b5f3f 100644 --- a/src/curses_output.h +++ b/src/curses_output.h @@ -15,9 +15,9 @@ public: void render() override; void clear() override; void print_char(const position &pos, - const char ch, const int attr) override; + const char ch, const int attrs) override; void print_str(const position &pos, - const std::string &str, const int attr) override; + const std::string &str, const int attrs) override; }; #endif diff --git a/src/display.h b/src/display.h index b7f57b6..1e1ad1d 100644 --- a/src/display.h +++ b/src/display.h @@ -24,10 +24,10 @@ public: virtual void clear(); virtual void print_char(const position &pos, const char ch, - const int attr = + const int attrs = A_NORMAL | COLOR_PAIR(COLOR_WHITE)) = 0; virtual void print_str(const position &pos, const std::string &str, - const int attr = + const int attrs = A_NORMAL | COLOR_PAIR(COLOR_WHITE)) = 0; // default arguments are to be set in the base class's declaration }; diff --git a/src/file_output.cc b/src/file_output.cc index 4606005..2dfce06 100644 --- a/src/file_output.cc +++ b/src/file_output.cc @@ -17,7 +17,7 @@ void file_output::render() { } void file_output::print_char(const position &pos, const char ch, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; @@ -25,7 +25,7 @@ void file_output::print_char(const position &pos, const char ch, } void file_output::print_str(const position &pos, const std::string &str, - const int attr) { + const int attrs) { if (pos.x >= DISPLAY_WIDTH || pos.y >= DISPLAY_HEIGHT) return; diff --git a/src/file_output.h b/src/file_output.h index c0754b3..a6ef81e 100644 --- a/src/file_output.h +++ b/src/file_output.h @@ -12,9 +12,9 @@ public: void render() override; void print_char(const position &pos, - const char ch, const int attr) override; + const char ch, const int attrs) override; void print_str(const position &pos, - const std::string &str, const int attr) override; + const std::string &str, const int attrs) override; }; #endif