diff --git a/examples/raw_escapes.cpp b/examples/raw_escapes.cpp index 5ae8406..4dd035d 100644 --- a/examples/raw_escapes.cpp +++ b/examples/raw_escapes.cpp @@ -24,9 +24,9 @@ int main() { } std::string code; - for (int i = 0; i < ret; ++i) { + for (std::size_t i = 0; i < static_cast(ret); ++i) { std::stringstream ss; - ss << std::hex << "\\x" << static_cast(seq[i]); + ss << std::hex << "\\x" << static_cast(seq.at(i)); code += ss.str(); } diff --git a/rawterm/text.cpp b/rawterm/text.cpp index 4adc438..cded778 100644 --- a/rawterm/text.cpp +++ b/rawterm/text.cpp @@ -56,19 +56,20 @@ namespace rawterm { std::regex ansi_escape_code("\x1b\\[[0-9;]*[A-Za-z]"); std::smatch match; int visible_index = 0; - unsigned int pos = 0; + std::size_t pos = 0; while (pos < str.length()) { // Check if there's an ANSI escape code at the current position - if (std::regex_search(str.begin() + pos, str.end(), match, ansi_escape_code) && + long longPos = static_cast(pos); + if (std::regex_search(str.begin() + longPos, str.end(), match, ansi_escape_code) && match.position() == 0) { // Move position past the ANSI escape code - pos += match.length(); + pos += static_cast(match.length()); } else { // If the current visible index matches the target index, return the // character if (visible_index == index) { - return str[pos]; + return str.at(pos); } // Move to the next character ++visible_index;