diff --git a/TextEditor.cpp b/TextEditor.cpp index 02966f0b..6152a1c9 100644 --- a/TextEditor.cpp +++ b/TextEditor.cpp @@ -41,13 +41,13 @@ TextEditor::TextEditor() , mColorRangeMin(0) , mColorRangeMax(0) , mSelectionMode(SelectionMode::Normal) - , mCheckComments(true) - , mLastClick(-1.0f) - , mHandleKeyboardInputs(true) + , mHandleKeyboardInputs(true) , mHandleMouseInputs(true) , mIgnoreImGuiChild(false) , mShowWhitespaces(true) + , mCheckComments(true) , mStartTime(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()) + , mLastClick(-1.0f) { SetPalette(GetDarkPalette()); SetLanguageDefinition(LanguageDefinition::HLSL()); @@ -84,7 +84,7 @@ std::string TextEditor::GetText(const Coordinates & aStart, const Coordinates & auto iend = GetCharacterIndex(aEnd); size_t s = 0; - for (size_t i = lstart; i < lend; i++) + for (size_t i = lstart; (int)i < lend; i++) s += mLines[i].size(); result.reserve(s + s / 8); @@ -459,7 +459,7 @@ TextEditor::Coordinates TextEditor::FindNextWord(const Coordinates & aFrom) cons while (!isword || skip) { - if (at.mLine >= mLines.size()) + if (at.mLine >= (int)mLines.size()) { auto l = std::max(0, (int) mLines.size() - 1); return Coordinates(l, GetLineMaxColumn(l)); @@ -492,12 +492,12 @@ TextEditor::Coordinates TextEditor::FindNextWord(const Coordinates & aFrom) cons int TextEditor::GetCharacterIndex(const Coordinates& aCoordinates) const { - if (aCoordinates.mLine >= mLines.size()) + if (aCoordinates.mLine >= (int)mLines.size()) return -1; auto& line = mLines[aCoordinates.mLine]; int c = 0; int i = 0; - for (; i < line.size() && c < aCoordinates.mColumn;) + for (; i < (int)line.size() && c < aCoordinates.mColumn;) { if (line[i].mChar == '\t') c = (c / mTabSize) * mTabSize + mTabSize; @@ -510,7 +510,7 @@ int TextEditor::GetCharacterIndex(const Coordinates& aCoordinates) const int TextEditor::GetCharacterColumn(int aLine, int aIndex) const { - if (aLine >= mLines.size()) + if (aLine >= (int)mLines.size()) return 0; auto& line = mLines[aLine]; int col = 0; @@ -529,7 +529,7 @@ int TextEditor::GetCharacterColumn(int aLine, int aIndex) const int TextEditor::GetLineCharacterCount(int aLine) const { - if (aLine >= mLines.size()) + if (aLine >= (int)mLines.size()) return 0; auto& line = mLines[aLine]; int c = 0; @@ -540,7 +540,7 @@ int TextEditor::GetLineCharacterCount(int aLine) const int TextEditor::GetLineMaxColumn(int aLine) const { - if (aLine >= mLines.size()) + if (aLine >= (int)mLines.size()) return 0; auto& line = mLines[aLine]; int col = 0; @@ -1013,7 +1013,7 @@ void TextEditor::Render() auto prevColor = line.empty() ? mPalette[(int)PaletteIndex::Default] : GetGlyphColor(line[0]); ImVec2 bufferOffset; - for (int i = 0; i < line.size();) + for (int i = 0; i < (int)line.size();) { auto& glyph = line[i]; auto color = GetGlyphColor(glyph); @@ -1625,7 +1625,7 @@ void TextEditor::MoveRight(int aAmount, bool aSelect, bool aWordMode) { auto oldPos = mState.mCursorPosition; - if (mLines.empty() || oldPos.mLine >= mLines.size()) + if (mLines.empty() || oldPos.mLine >= (int)mLines.size()) return; auto cindex = GetCharacterIndex(mState.mCursorPosition); @@ -1634,9 +1634,9 @@ void TextEditor::MoveRight(int aAmount, bool aSelect, bool aWordMode) auto lindex = mState.mCursorPosition.mLine; auto& line = mLines[lindex]; - if (cindex >= line.size()) + if (cindex >= (int)line.size()) { - if (mState.mCursorPosition.mLine < mLines.size() - 1) + if (mState.mCursorPosition.mLine < (int)mLines.size() - 1) { mState.mCursorPosition.mLine = std::max(0, std::min((int)mLines.size() - 1, mState.mCursorPosition.mLine + 1)); mState.mCursorPosition.mColumn = 0; @@ -1874,7 +1874,7 @@ void TextEditor::Backspace() --u.mRemovedStart.mColumn; --mState.mCursorPosition.mColumn; - while (cindex < line.size() && cend-- > cindex) + while (cindex < (int)line.size() && cend-- > cindex) { u.mRemoved += line[cindex].mChar; line.erase(line.begin() + cindex); @@ -2007,7 +2007,7 @@ const TextEditor::Palette & TextEditor::GetDarkPalette() { const static Palette p = { { 0xff7f7f7f, // Default - 0xffd69c56, // Keyword + 0xffd69c56, // Keyword 0xff00ff00, // Number 0xff7070e0, // String 0xff70a0e0, // Char literal @@ -2035,7 +2035,7 @@ const TextEditor::Palette & TextEditor::GetLightPalette() { const static Palette p = { { 0xff7f7f7f, // None - 0xffff0c06, // Keyword + 0xffff0c06, // Keyword 0xff008000, // Number 0xff2020a0, // String 0xff304070, // Char literal @@ -2063,7 +2063,7 @@ const TextEditor::Palette & TextEditor::GetRetroBluePalette() { const static Palette p = { { 0xff00ffff, // None - 0xffffff00, // Keyword + 0xffffff00, // Keyword 0xff00ff00, // Number 0xff808000, // String 0xff808000, // Char literal @@ -2264,7 +2264,7 @@ void TextEditor::ColorizeInternal() auto concatenate = false; // '\' on the very end of the line auto currentLine = 0; auto currentIndex = 0; - while (currentLine < endLine || currentIndex < endIndex) + while (currentLine < (int)endLine || currentIndex < endIndex) { auto& line = mLines[currentLine]; @@ -2288,7 +2288,7 @@ void TextEditor::ColorizeInternal() if (currentIndex == (int)line.size() - 1 && line[line.size() - 1].mChar == '\\') concatenate = true; - bool inComment = (commentStartLine < currentLine || (commentStartLine == currentLine && commentStartIndex <= currentIndex)); + bool inComment = ((int)commentStartLine < currentLine || ((int)commentStartLine == currentLine && commentStartIndex <= currentIndex)); if (withinString) { @@ -2342,7 +2342,7 @@ void TextEditor::ColorizeInternal() commentStartIndex = currentIndex; } - inComment = inComment = (commentStartLine < currentLine || (commentStartLine == currentLine && commentStartIndex <= currentIndex)); + inComment = ((int)commentStartLine < currentLine || ((int)commentStartLine == currentLine && commentStartIndex <= currentIndex)); line[currentIndex].mMultiLineComment = inComment; line[currentIndex].mComment = withinSingleLineComment; @@ -2395,7 +2395,7 @@ float TextEditor::TextDistanceToLineStart(const Coordinates& aFrom) const float distance = 0.0f; float spaceSize = ImGui::GetFont()->CalcTextSizeA(ImGui::GetFontSize(), FLT_MAX, -1.0f, " ", nullptr, nullptr).x; int colIndex = GetCharacterIndex(aFrom); - for (size_t it = 0u; it < line.size() && it < colIndex; ) + for (size_t it = 0u; it < line.size() && (int)it < colIndex; ) { if (line[it].mChar == '\t') { @@ -2407,7 +2407,7 @@ float TextEditor::TextDistanceToLineStart(const Coordinates& aFrom) const auto d = UTF8CharLength(line[it].mChar); char tempCString[7]; int i = 0; - for (; i < 6 && d-- > 0 && it < (int)line.size(); i++, it++) + for (; i < 6 && d-- > 0 && it < line.size(); i++, it++) tempCString[i] = line[it].mChar; tempCString[i] = '\0';