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
6 changes: 3 additions & 3 deletions rawterm/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(std::stoi(hex.substr(1, 2), nullptr, 16));
green = static_cast<unsigned int>(std::stoi(hex.substr(3, 2), nullptr, 16));
blue = static_cast<unsigned int>(std::stoi(hex.substr(5, 2), nullptr, 16));
}

const std::string Color::to_hex() {
Expand Down
6 changes: 3 additions & 3 deletions rawterm/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<tcflag_t>(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
raw.c_oflag &= ~static_cast<tcflag_t>(OPOST);
// raw.c_lflag |= ~(CS8); // Disable to allow term_size reading
raw.c_lflag &= ~(ECHO | IEXTEN | ICANON | ISIG);
raw.c_lflag &= ~static_cast<tcflag_t>(ECHO | IEXTEN | ICANON | ISIG);

if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw) == -1) {
std::perror("tcsetattr");
Expand Down
3 changes: 2 additions & 1 deletion rawterm/extras/extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(term_size.horizontal / 2) - (title.size() / 2);
bool odd = term_size.horizontal % 2;

auto c = rawterm::Cursor();
Expand Down
4 changes: 2 additions & 2 deletions rawterm/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion rawterm/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading