Add text cursor setting to always render caret (disable blinking)

Add flag to temporarily cause the caret to not blink, so the caret can be rendered without blinking after it has been moved, which greatly improves usability.
This commit is contained in:
Robert Müller 2023-04-14 15:05:34 +02:00
parent 08b0a03ca4
commit f77af29094
2 changed files with 9 additions and 2 deletions

View file

@ -167,6 +167,7 @@ struct STextContainer
unsigned m_RenderFlags;
bool m_HasCursor;
bool m_ForceCursorRendering;
bool m_HasSelection;
bool m_SingleTimeUse;
@ -193,6 +194,7 @@ struct STextContainer
m_HasCursor = false;
m_HasSelection = false;
m_ForceCursorRendering = false;
m_SingleTimeUse = false;
@ -809,6 +811,7 @@ public:
pCursor->m_SelectionEnd = 0;
pCursor->m_CursorMode = TEXT_CURSOR_CURSOR_MODE_NONE;
pCursor->m_ForceCursorRendering = false;
pCursor->m_CursorCharacter = -1;
}
@ -1505,6 +1508,7 @@ public:
TextContainer.m_HasCursor = HasCursor;
TextContainer.m_HasSelection = HasSelection;
TextContainer.m_ForceCursorRendering = pCursor->m_ForceCursorRendering;
if(HasSelection)
{
@ -1660,14 +1664,16 @@ public:
const auto CurTime = time_get_nanoseconds();
Graphics()->TextureClear();
if((CurTime - m_CursorRenderTime) > 500ms)
if(TextContainer.m_ForceCursorRendering || (CurTime - m_CursorRenderTime) > 500ms)
{
Graphics()->SetColor(TextOutlineColor);
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 0, 1, 0, 0);
Graphics()->SetColor(TextColor);
Graphics()->RenderQuadContainerEx(TextContainer.m_StringInfo.m_SelectionQuadContainerIndex, 1, 1, 0, 0);
}
if((CurTime - m_CursorRenderTime) > 1s)
if(TextContainer.m_ForceCursorRendering)
m_CursorRenderTime = CurTime - 501ms;
else if((CurTime - m_CursorRenderTime) > 1s)
m_CursorRenderTime = time_get_nanoseconds();
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
}

View file

@ -198,6 +198,7 @@ public:
int m_SelectionEnd;
ETextCursorCursorMode m_CursorMode;
bool m_ForceCursorRendering;
// note this is the decoded character offset
int m_CursorCharacter;