Skip to content

Commit

Permalink
#6 Refactor some function on TextBox
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Nov 19, 2020
1 parent 2abd8e5 commit af6393a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions Projects/Editor/Source/GUI/Controls/CTextContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ namespace Skylicht

for (CText *line : m_lines)
{
// draw selection
if (fromLine != toLine || from != to)
{
if (lineID >= fromLine && lineID <= toLine)
Expand Down Expand Up @@ -351,7 +350,7 @@ namespace Skylicht
m_caretBeginLine = line;
m_caretBeginPosition = c;

m_caretBegin = getCaretBeginAt();
m_caretBegin = getCaretBegin();
}

void CTextContainer::setCaretEnd(u32 line, u32 c)
Expand All @@ -362,7 +361,7 @@ namespace Skylicht
m_caretEndLine = line;
m_caretEndPosition = c;

m_caretEnd = getCaretEndAt();
m_caretEnd = getCaretEnd();
}

bool CTextContainer::updateCaretPosition()
Expand Down Expand Up @@ -399,7 +398,7 @@ namespace Skylicht
return foundBegin && foundEnd;
}

u32 CTextContainer::getCharacterPositionAt(u32 line, u32 pos)
u32 CTextContainer::getCharacterPosition(u32 line, u32 pos)
{
u32 ret = 0;
u32 lineID = 0;
Expand All @@ -420,14 +419,14 @@ namespace Skylicht
return ret;
}

u32 CTextContainer::getCaretBeginAt()
u32 CTextContainer::getCaretBegin()
{
return getCharacterPositionAt(m_caretBeginLine, m_caretBeginPosition);
return getCharacterPosition(m_caretBeginLine, m_caretBeginPosition);
}

u32 CTextContainer::getCaretEndAt()
u32 CTextContainer::getCaretEnd()
{
return getCharacterPositionAt(m_caretEndLine, m_caretEndPosition);
return getCharacterPosition(m_caretEndLine, m_caretEndPosition);
}

u32 CTextContainer::getClosestCharacter(const SPoint& point, u32& outLine, u32& outChar)
Expand Down
6 changes: 3 additions & 3 deletions Projects/Editor/Source/GUI/Controls/CTextContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ namespace Skylicht

void setCaretEnd(u32 line, u32 c);

u32 getCaretBeginAt();
u32 getCaretBegin();

u32 getCaretEndAt();
u32 getCaretEnd();

inline void resetCaretBlink()
{
Expand Down Expand Up @@ -164,7 +164,7 @@ namespace Skylicht

void drawSelection(CText *line, u32 from, u32 to);

u32 getCharacterPositionAt(u32 line, u32 pos);
u32 getCharacterPosition(u32 line, u32 pos);

bool updateCaretPosition();

Expand Down

0 comments on commit af6393a

Please sign in to comment.