Skip to content

Commit

Permalink
Fix warning for sign-compare (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee authored Apr 25, 2024
1 parent 2c76f6b commit ef7bdfa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions library/lib/platforms/glfw/glfw_ime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void GLFWImeManager::char_callback(GLFWwindow* window, unsigned int codepoint)
{
if (!showIME)
return;
if (cursor < 0 || cursor > textBuffer.size())
if (cursor < 0 || cursor > (int)textBuffer.size())
cursor = textBuffer.size();
textBuffer.insert(textBuffer.begin() + cursor, (wchar_t)codepoint);
cursor++;
Expand Down Expand Up @@ -204,7 +204,7 @@ void GLFWImeManager::openInputDialog(std::function<void(std::string)> cb, std::s
return ;
}
isEditing = true;
if (cursor < 0 || cursor > textBuffer.size()) cursor = textBuffer.size();
if (cursor < 0 || cursor > (int)textBuffer.size()) cursor = textBuffer.size();
auto left = std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(textBuffer.substr(0, cursor));
auto right = std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(textBuffer.substr(cursor, textBuffer.size()));
dialog->setText(left + preeditTextBuffer + right);
Expand All @@ -215,8 +215,8 @@ void GLFWImeManager::openInputDialog(std::function<void(std::string)> cb, std::s
dialog->getBackspaceEvent()->subscribe([dialog](...)
{
if(textBuffer.empty()) return true;
if (cursor < 0 || cursor > textBuffer.size()) cursor = textBuffer.size();
if (cursor > 0 && cursor <= textBuffer.size()) {
if (cursor < 0 || cursor > (int)textBuffer.size()) cursor = textBuffer.size();
if (cursor > 0 && cursor <= (int)textBuffer.size()) {
textBuffer.erase(cursor - 1, 1);
cursor--;
dialog->setCursor(cursor);
Expand All @@ -239,7 +239,7 @@ void GLFWImeManager::openInputDialog(std::function<void(std::string)> cb, std::s
{
if (isEditing) return true;
if (cursor >= (int)CursorPosition::START) {
if (cursor < textBuffer.size()) {
if (cursor < (int)textBuffer.size()) {
cursor++;
dialog->setCursor(cursor);
}
Expand Down
2 changes: 1 addition & 1 deletion library/lib/platforms/glfw/glfw_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ GLFWVideoContext::GLFWVideoContext(const std::string& windowTitle, uint32_t wind
// Set window position
if (!VideoContext::FULLSCREEN)
{
if (mode->width >= windowWidth && mode->height >= windowHeight)
if (mode->width >= (int)windowWidth && mode->height >= (int)windowHeight)
{
if (!isnan(windowX) && !isnan(windowY))
{
Expand Down

0 comments on commit ef7bdfa

Please sign in to comment.