Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/raw_escapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>(ret); ++i) {
std::stringstream ss;
ss << std::hex << "\\x" << static_cast<unsigned char>(seq[i]);
ss << std::hex << "\\x" << static_cast<unsigned char>(seq.at(i));
code += ss.str();
}

Expand Down
9 changes: 5 additions & 4 deletions rawterm/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<long>(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<std::size_t>(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;
Expand Down
Loading