@@ -120,7 +120,7 @@ SourceCodeEditor::SourceCodeEditor (OpenDocumentManager::Document* doc, CodeDocu | |||||
GenericCodeEditorComponent* ed = nullptr; | GenericCodeEditorComponent* ed = nullptr; | ||||
const File file (document->getFile()); | const File file (document->getFile()); | ||||
if (file.hasFileExtension (sourceOrHeaderFileExtensions)) | |||||
if (fileNeedsCppSyntaxHighlighting (file)) | |||||
{ | { | ||||
ed = new CppCodeEditorComponent (file, codeDocument); | ed = new CppCodeEditorComponent (file, codeDocument); | ||||
} | } | ||||
@@ -243,6 +243,20 @@ int indexOfLineStartingWith (const StringArray& lines, const String& text, int i | |||||
return -1; | return -1; | ||||
} | } | ||||
//============================================================================== | |||||
bool fileNeedsCppSyntaxHighlighting (const File& file) | |||||
{ | |||||
if (file.hasFileExtension (sourceOrHeaderFileExtensions)) | |||||
return true; | |||||
// This is a bit of a bodge to deal with libc++ headers with no extension.. | |||||
char fileStart[64] = { 0 }; | |||||
FileInputStream fin (file); | |||||
fin.read (fileStart, sizeof (fileStart) - 4); | |||||
return String (fileStart).trimStart().startsWith ("// -*- C++ -*-"); | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
RolloverHelpComp::RolloverHelpComp() | RolloverHelpComp::RolloverHelpComp() | ||||
: lastComp (nullptr) | : lastComp (nullptr) | ||||
@@ -50,6 +50,8 @@ void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& va | |||||
void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, bool value); | void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, bool value); | ||||
void addPlistDictionaryKeyInt (XmlElement* xml, const String& key, int value); | void addPlistDictionaryKeyInt (XmlElement* xml, const String& key, int value); | ||||
bool fileNeedsCppSyntaxHighlighting (const File& file); | |||||
//============================================================================== | //============================================================================== | ||||
int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex); | int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex); | ||||