Beispiel #1
0
// Try to guess if a *.h file is C or C++, return FALSE if file is not *.h, TRUE otherwise.
bool SciDoc::SetLanguageForHeader(const FXString &fn)
{
  if (FXPath::extension(fn)=="h") {
    FXString fnbase=FXPath::stripExtension(fn);
    // Check for matching source file and set language accordingly if found...
    if (FXStat::exists(fnbase+".c")) {
      setLanguage("c");
    } else if (FXStat::exists(fnbase+".cpp")||FXStat::exists(fnbase+".cxx")||FXStat::exists(fnbase+".cc")) {
      setLanguage("cpp");
    } else {
      // Take a wild guess - if the file contains the word "class" it's probably  C++
      const char *content=(const char*)(sendMessage(SCI_GETCHARACTERPOINTER,0,0));
#ifdef FOX_1_7_50_OR_NEWER
      if (FXRex("\\<class\\>").search(content,strlen(content),0,strlen(content))>=0) {
#else
      if (FXRex("\\<class\\>").match(content)) {
#endif
        setLanguage("cpp");
      } else {
        setLanguage("c");
      }
    }
    return true;
  } else {
    return false;
Beispiel #2
0
// Match contents against regular expression
FXbool FXSyntax::matchContents(const FXString& text) const {
  return FXRex(contents).match(text);
  }