diff --git a/rawterm/color.cpp b/rawterm/color.cpp index 87efc1c..99457a7 100644 --- a/rawterm/color.cpp +++ b/rawterm/color.cpp @@ -19,9 +19,9 @@ namespace rawterm { throw std::invalid_argument("Hex code must be 7 characters long including the #"); } - red = std::stoi(hex.substr(1, 2), nullptr, 16); - green = std::stoi(hex.substr(3, 2), nullptr, 16); - blue = std::stoi(hex.substr(5, 2), nullptr, 16); + red = static_cast(std::stoi(hex.substr(1, 2), nullptr, 16)); + green = static_cast(std::stoi(hex.substr(3, 2), nullptr, 16)); + blue = static_cast(std::stoi(hex.substr(5, 2), nullptr, 16)); } const std::string Color::to_hex() { diff --git a/rawterm/core.cpp b/rawterm/core.cpp index f1a34b1..4f382c1 100644 --- a/rawterm/core.cpp +++ b/rawterm/core.cpp @@ -61,10 +61,10 @@ namespace rawterm { std::atexit(rawterm::disable_raw_mode); termios raw = rawterm::detail::orig; - raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - raw.c_oflag &= ~(OPOST); + raw.c_iflag &= ~static_cast(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + raw.c_oflag &= ~static_cast(OPOST); // raw.c_lflag |= ~(CS8); // Disable to allow term_size reading - raw.c_lflag &= ~(ECHO | IEXTEN | ICANON | ISIG); + raw.c_lflag &= ~static_cast(ECHO | IEXTEN | ICANON | ISIG); if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) { std::perror("tcsetattr"); diff --git a/rawterm/extras/extras.cpp b/rawterm/extras/extras.cpp index 2d890b3..8270bef 100644 --- a/rawterm/extras/extras.cpp +++ b/rawterm/extras/extras.cpp @@ -7,7 +7,8 @@ namespace rawterm { const std::string set_header(const std::string& title) { rawterm::Pos term_size = rawterm::get_term_size(); - int half_screen_len = (term_size.horizontal / 2) - (title.size() / 2); + std::size_t half_screen_len = + static_cast(term_size.horizontal / 2) - (title.size() / 2); bool odd = term_size.horizontal % 2; auto c = rawterm::Cursor(); diff --git a/rawterm/text.cpp b/rawterm/text.cpp index 63df4c2..4adc438 100644 --- a/rawterm/text.cpp +++ b/rawterm/text.cpp @@ -56,7 +56,7 @@ namespace rawterm { std::regex ansi_escape_code("\x1b\\[[0-9;]*[A-Za-z]"); std::smatch match; int visible_index = 0; - std::size_t pos = 0; + unsigned int pos = 0; while (pos < str.length()) { // Check if there's an ANSI escape code at the current position @@ -85,7 +85,7 @@ namespace rawterm { return cleaned_str; } - [[nodiscard]] int raw_size(const std::string& str) { + [[nodiscard]] std::size_t raw_size(const std::string& str) { std::regex ansi_escape_code("\x1b\\[[0-9;]*[A-Za-z]"); std::string cleaned_str = std::regex_replace(str, ansi_escape_code, ""); return cleaned_str.length(); diff --git a/rawterm/text.h b/rawterm/text.h index 0a31c9d..3e08100 100644 --- a/rawterm/text.h +++ b/rawterm/text.h @@ -27,7 +27,7 @@ namespace rawterm { [[nodiscard]] char raw_at(const std::string&, const int); [[nodiscard]] std::string raw_str(std::string); - [[nodiscard]] int raw_size(const std::string&); + [[nodiscard]] std::size_t raw_size(const std::string&); } // namespace rawterm #endif // RAWTERM_TEXT_H