Code: Select all
const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Code: Select all
m_lastTyped = (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()).time_since_epoch().count() * 0.001);
size_t curPos = m_stc->GetCurrentPos();
if (m_endTyping)
{
m_typedMinPos = curPos;
m_typedMaxPos = curPos;
}
m_endTyping = false;
if (m_typedMinPos > curPos)
m_typedMinPos = curPos;
if (m_typedMaxPos < curPos)
m_typedMaxPos = curPos;
CallAfter(&cScriptEditor::UpdateStatusText, m_stc);
event.Skip();
Code: Select all
//from here
int line = m_stc->GetCurrentLine();
int start = m_stc->PositionFromLine(line);
int end = m_stc->GetLineEndPosition(line);
m_stc->StartStyling(start);
m_stc->SetStyling(m_stc->LineLength(line), 0); //Clear old style
FindAndHighlightAllVars(m_stc, start, end);
VerifyCurLineLenght(m_stc);
//to here is just styling. The next code is for the spell
double now = (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()).time_since_epoch().count() * 0.001);
double elapsed = now - m_lastTyped;
if (elapsed > 500 && !m_endTyping)
{
m_endTyping = true;
DoSpelling(m_stc, m_stc->WordStartPosition(m_typedMinPos, false), m_stc->WordEndPosition(m_typedMaxPos, false));
}
event.Skip();
Code: Select all
std::string s = stc->GetTextRange(start, end).ToStdString();
size_t npos = std::string::npos;
m_stc->IndicatorClearRange(start, end - start);
for (size_t first = s.find_first_of(letters, 0); first != npos; first = s.find_first_of(letters, first))
{
size_t last = s.find_first_not_of(letters, first);
std::string word = s.substr(first, last != npos ? last - first : s.size() - first);
bool isGood = m_hunspell->spell(s);
if (!isGood)
m_stc->IndicatorFillRange(start + first, last != npos ? last - first : s.size() - first);
first = last;
}