mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CTextLogger: Skip newline characters when advancing cursor
Skip newline characters to avoid having to issue a move left/right command twice before seeing the cursor move.
This commit is contained in:
parent
dbf3b5b91d
commit
381f09b1d7
18
r5dev/thirdparty/imgui/misc/imgui_logger.cpp
vendored
18
r5dev/thirdparty/imgui/misc/imgui_logger.cpp
vendored
@ -1213,7 +1213,13 @@ void CTextLogger::MoveLeft(int aAmount, bool aSelect, bool aWordMode)
|
||||
{
|
||||
if (static_cast<int>(m_Lines.size()) > line)
|
||||
{
|
||||
while (cindex > 0 && IsUTFSequence(m_Lines[line][cindex].m_Char))
|
||||
const Line &lineData = m_Lines[line];
|
||||
|
||||
while (cindex > 0 && IsUTFSequence(lineData[cindex].m_Char))
|
||||
--cindex;
|
||||
|
||||
// Skip the newline character.
|
||||
if (cindex > 0 && lineData[cindex].m_Char == '\n')
|
||||
--cindex;
|
||||
}
|
||||
}
|
||||
@ -1262,7 +1268,15 @@ void CTextLogger::MoveRight(int aAmount, bool aSelect, bool aWordMode)
|
||||
int lindex = m_State.m_CursorPosition.m_nLine;
|
||||
const Line& line = m_Lines[lindex];
|
||||
|
||||
if (cindex >= static_cast<int>(line.size()))
|
||||
bool isNewLine = false;
|
||||
const bool isLastChar = (cindex >= static_cast<int>(line.size())-1);
|
||||
|
||||
// If the cursor is at the last character before the newline character,
|
||||
// we want to skip the newline character and move to the next line.
|
||||
if (isLastChar && !line.empty())
|
||||
isNewLine = line.back().m_Char == '\n';
|
||||
|
||||
if (cindex >= static_cast<int>(line.size()) || isNewLine)
|
||||
{
|
||||
if (m_State.m_CursorPosition.m_nLine < static_cast<int>(m_Lines.size()) - 1)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user