1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-23 01:44:22 +00:00

Introjucer: added hack to enable c++ syntax highlighting in the editor for extensionless libc++ header files.

This commit is contained in:
jules 2015-09-14 19:52:37 +01:00
parent 3af553e34f
commit 2877653cc3
3 changed files with 17 additions and 1 deletions

View file

@ -120,7 +120,7 @@ SourceCodeEditor::SourceCodeEditor (OpenDocumentManager::Document* doc, CodeDocu
GenericCodeEditorComponent* ed = nullptr;
const File file (document->getFile());
if (file.hasFileExtension (sourceOrHeaderFileExtensions))
if (fileNeedsCppSyntaxHighlighting (file))
{
ed = new CppCodeEditorComponent (file, codeDocument);
}

View file

@ -243,6 +243,20 @@ int indexOfLineStartingWith (const StringArray& lines, const String& text, int i
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()
: lastComp (nullptr)

View file

@ -50,6 +50,8 @@ void addPlistDictionaryKey (XmlElement* xml, const String& key, const String& va
void addPlistDictionaryKeyBool (XmlElement* xml, const String& key, bool 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);