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:
parent
3af553e34f
commit
2877653cc3
3 changed files with 17 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue