Skip to content

Commit

Permalink
Update TextEditor to commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad
Browse files Browse the repository at this point in the history
  • Loading branch information
mortennobel committed Mar 17, 2018
1 parent 574d9a4 commit 54f9d91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/TextEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "imgui.h"

/**
* https://github.com/BalazsJako/ImGuiColorTextEdit
* https://github.com/BalazsJako/ImGuiColorTextEdit (commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad)
*
* MIT License
*
Expand Down
14 changes: 9 additions & 5 deletions src/imgui/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "TextEditor.h"

/**
* https://github.com/BalazsJako/ImGuiColorTextEdit
* https://github.com/BalazsJako/ImGuiColorTextEdit (commit 6c69c306da0afb6c0b7ea51ec504aa0aae348aad)
*/

static const int cTextStart = 7;
Expand Down Expand Up @@ -104,7 +104,7 @@ TextEditor::Coordinates TextEditor::SanitizeCoordinates(const Coordinates & aVal
auto line = aValue.mLine;
auto column = aValue.mColumn;

if (line >= mLines.size())
if (line >= (int)mLines.size())
{
line = (int)mLines.size() - 1;
column = mLines.empty() ? 0 : (int)mLines[line].size();
Expand Down Expand Up @@ -657,7 +657,8 @@ void TextEditor::Render(const char* aTitle, const ImVec2& aSize, bool aBorder)
}
}

snprintf(buf, 16, "%6d", lineNo + 1);
auto chars = snprintf(buf, 16, "%6d", lineNo + 1);
assert(chars >= 0 && chars < 16);
drawList->AddText(ImVec2(lineStartScreenPos.x /*+ mCharAdvance.x * 1*/, lineStartScreenPos.y), mPalette[(int)PaletteIndex::LineNumber], buf);

if (mState.mCursorPosition.mLine == lineNo)
Expand Down Expand Up @@ -1027,8 +1028,11 @@ void TextEditor::MoveRight(int aAmount, bool aSelect, bool aWordMode)
auto& line = mLines[mState.mCursorPosition.mLine];
if (mState.mCursorPosition.mColumn >= (int)line.size())
{
mState.mCursorPosition.mLine = std::max(0, std::min((int)mLines.size() - 1, mState.mCursorPosition.mLine + 1));
mState.mCursorPosition.mColumn = 0;
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;
}
}
else
{
Expand Down

0 comments on commit 54f9d91

Please sign in to comment.