コード例 #1
0
void LuaScriptEditorView::CheckSyntax()
{
   CStringA text;
   GetText(text);

   int indicatorNumber = INDIC_CONTAINER;

   AnnotationClearAll();

   Lua::State state;
   std::vector<CString> errorMessages;
   if (state.CheckSyntax(CString(text), errorMessages))
   {
      IndicSetStyle(indicatorNumber, INDIC_HIDDEN);
      AnnotationSetVisible(ANNOTATION_HIDDEN);
      return;
   }

   IndicSetStyle(indicatorNumber, INDIC_SQUIGGLE);
   IndicSetFore(indicatorNumber, RGB(255, 0, 0)); // red

   SetIndicatorCurrent(indicatorNumber);

   for (size_t index = 0, maxIndex = errorMessages.size(); index < maxIndex; index++)
   {
      CString errorMessage = errorMessages[0];

      int pos = errorMessage.Find(_T("]:"));
      int pos2 = errorMessage.Find(_T(':'), pos + 2);

      int lineNumber = _ttoi(errorMessage.Mid(pos + 2, pos2 - (pos + 2)));
      CString error = errorMessage.Mid(pos2 + 1).Trim();

      SetIndicatorValue(index);

      int textStart = static_cast<int>(PositionFromLine(lineNumber - 1));
      int textEnd = GetLineEndPosition(lineNumber - 1);

      IndicatorFillRange(textStart, textEnd - textStart);

      AnnotationSetText(lineNumber - 1, CStringA(error).GetString());
      AnnotationSetVisible(ANNOTATION_BOXED);
   }
}
コード例 #2
0
ファイル: edit.cpp プロジェクト: jfiguinha/Regards
void Edit::OnAnnotationClear(wxCommandEvent& WXUNUSED(event))
{
    AnnotationClearAll();
}