Browse Source

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

tags/2021-05-28
jules 9 years ago
parent
commit
2877653cc3
3 changed files with 17 additions and 1 deletions
  1. +1
    -1
      extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp
  2. +14
    -0
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp
  3. +2
    -0
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h

+ 1
- 1
extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp 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);
}


+ 14
- 0
extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp 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)


+ 2
- 0
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h 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);


Loading…
Cancel
Save