mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
Introjucer: popup menu for code editor.
This commit is contained in:
parent
9fde239d9c
commit
1cd7660f10
2 changed files with 31 additions and 4 deletions
|
|
@ -115,7 +115,7 @@ SourceCodeEditor::~SourceCodeEditor()
|
|||
void SourceCodeEditor::createEditor (CodeDocument& codeDocument)
|
||||
{
|
||||
if (document->getFile().hasFileExtension (sourceOrHeaderFileExtensions))
|
||||
setEditor (new CppCodeEditorComponent (codeDocument));
|
||||
setEditor (new CppCodeEditorComponent (document->getFile(), codeDocument));
|
||||
else
|
||||
setEditor (new CodeEditorComponent (codeDocument, nullptr));
|
||||
}
|
||||
|
|
@ -161,8 +161,8 @@ void SourceCodeEditor::valueTreeRedirected (ValueTree&)
|
|||
//==============================================================================
|
||||
static CPlusPlusCodeTokeniser cppTokeniser;
|
||||
|
||||
CppCodeEditorComponent::CppCodeEditorComponent (CodeDocument& codeDocument)
|
||||
: CodeEditorComponent (codeDocument, &cppTokeniser)
|
||||
CppCodeEditorComponent::CppCodeEditorComponent (const File& f, CodeDocument& codeDocument)
|
||||
: CodeEditorComponent (codeDocument, &cppTokeniser), file (f)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -226,3 +226,26 @@ void CppCodeEditorComponent::insertTextAtCaret (const String& newText)
|
|||
|
||||
CodeEditorComponent::insertTextAtCaret (newText);
|
||||
}
|
||||
|
||||
enum { showInFinderID = 0x2fe821e3 };
|
||||
|
||||
void CppCodeEditorComponent::addPopupMenuItems (PopupMenu& menu, const MouseEvent* e)
|
||||
{
|
||||
menu.addItem (showInFinderID,
|
||||
#if JUCE_MAC
|
||||
"Reveal " + file.getFileName() + " in Finder");
|
||||
#else
|
||||
"Reveal " + file.getFileName() + " in Explorer");
|
||||
#endif
|
||||
menu.addSeparator();
|
||||
|
||||
CodeEditorComponent::addPopupMenuItems (menu, e);
|
||||
}
|
||||
|
||||
void CppCodeEditorComponent::performPopupMenuAction (int menuItemID)
|
||||
{
|
||||
if (menuItemID == showInFinderID)
|
||||
file.revealToUser();
|
||||
else
|
||||
CodeEditorComponent::performPopupMenuAction (menuItemID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,12 +156,16 @@ private:
|
|||
class CppCodeEditorComponent : public CodeEditorComponent
|
||||
{
|
||||
public:
|
||||
CppCodeEditorComponent (CodeDocument& codeDocument);
|
||||
CppCodeEditorComponent (const File& file, CodeDocument& codeDocument);
|
||||
|
||||
void handleReturnKey();
|
||||
void insertTextAtCaret (const String& newText);
|
||||
|
||||
void addPopupMenuItems (PopupMenu&, const MouseEvent*);
|
||||
void performPopupMenuAction (int menuItemID);
|
||||
|
||||
private:
|
||||
File file;
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CppCodeEditorComponent);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue