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

Introjucer: commands to move back/forwards through open docs.

This commit is contained in:
jules 2012-07-07 21:11:06 +01:00
parent 39c974194e
commit 0475cedff5
11 changed files with 325 additions and 123 deletions

View file

@ -29,12 +29,60 @@
#include "../Project/jucer_Project.h"
#include "../Application/jucer_DocumentEditorComponent.h"
//==============================================================================
class SourceCodeDocument : public OpenDocumentManager::Document
{
public:
//==============================================================================
SourceCodeDocument (Project* project_, const File& file_)
: modDetector (file_), project (project_)
{
reloadFromFile();
}
//==============================================================================
struct Type : public OpenDocumentManager::DocumentType
{
bool canOpenFile (const File& file) { return file.hasFileExtension ("cpp;h;hpp;mm;m;c;cc;cxx;txt;inc;tcc;xml;plist;rtf;html;htm;php;py;rb;cs"); }
Document* openFile (Project* project, const File& file) { return new SourceCodeDocument (project, file); }
};
//==============================================================================
bool loadedOk() const { return true; }
bool isForFile (const File& file) const { return getFile() == file; }
bool isForNode (const ValueTree& node) const { return false; }
bool refersToProject (Project& p) const { return project == &p; }
Project* getProject() const { return project; }
String getName() const { return getFile().getFileName(); }
String getType() const { return getFile().getFileExtension() + " file"; }
File getFile() const { return modDetector.getFile(); }
bool needsSaving() const { return codeDoc.hasChangedSinceSavePoint(); }
bool hasFileBeenModifiedExternally() { return modDetector.hasBeenModified(); }
void fileHasBeenRenamed (const File& newFile) { modDetector.fileHasBeenRenamed (newFile); }
void reloadFromFile();
bool save();
Component* createEditor();
Component* createViewer() { return createEditor(); }
void updateLastPosition (CodeEditorComponent& editor);
void applyLastPosition (CodeEditorComponent& editor) const;
protected:
FileModificationDetector modDetector;
CodeDocument codeDoc;
Project* project;
ScopedPointer<CodeEditorComponent::State> lastState;
};
//==============================================================================
class SourceCodeEditor : public DocumentEditorComponent,
private ValueTree::Listener
{
public:
SourceCodeEditor (OpenDocumentManager::Document* document, CodeDocument& codeDocument);
SourceCodeEditor (OpenDocumentManager::Document* document);
~SourceCodeEditor();
@ -43,9 +91,9 @@ public:
void highlightLine (int lineNum, int characterIndex);
private:
ScopedPointer<CodeEditorComponent> editor;
private:
void resized();
void valueTreePropertyChanged (ValueTree&, const Identifier&);