changed naming scheme

This commit is contained in:
2024-07-07 20:10:31 -04:00
parent d85f375fbe
commit 6f998d8523
7 changed files with 32 additions and 32 deletions

View File

@ -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];
}

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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
};

View File

@ -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;

View File

@ -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