mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Refactored some TreeView key handling. Introjucer: now restores the last set of open documents for a project.
This commit is contained in:
parent
3d72789127
commit
25e7361f2c
13 changed files with 309 additions and 123 deletions
|
|
@ -40,7 +40,7 @@ SourceCodeEditor::~SourceCodeEditor()
|
|||
SourceCodeDocument* doc = dynamic_cast <SourceCodeDocument*> (getDocument());
|
||||
|
||||
if (doc != nullptr)
|
||||
doc->updateLastPosition (*editor);
|
||||
doc->updateLastState (*editor);
|
||||
}
|
||||
|
||||
void SourceCodeEditor::createEditor (CodeDocument& codeDocument)
|
||||
|
|
@ -97,22 +97,45 @@ void SourceCodeEditor::valueTreeParentChanged (ValueTree&)
|
|||
void SourceCodeEditor::valueTreeRedirected (ValueTree&) { updateColourScheme(); }
|
||||
|
||||
//==============================================================================
|
||||
SourceCodeDocument::SourceCodeDocument (Project* project_, const File& file_)
|
||||
: modDetector (file_), project (project_)
|
||||
{
|
||||
}
|
||||
|
||||
CodeDocument& SourceCodeDocument::getCodeDocument()
|
||||
{
|
||||
if (codeDoc == nullptr)
|
||||
{
|
||||
codeDoc = new CodeDocument();
|
||||
reloadInternal();
|
||||
}
|
||||
|
||||
return *codeDoc;
|
||||
}
|
||||
|
||||
Component* SourceCodeDocument::createEditor()
|
||||
{
|
||||
SourceCodeEditor* e = new SourceCodeEditor (this);
|
||||
e->createEditor (codeDoc);
|
||||
applyLastPosition (*(e->editor));
|
||||
e->createEditor (getCodeDocument());
|
||||
applyLastState (*(e->editor));
|
||||
return e;
|
||||
}
|
||||
|
||||
void SourceCodeDocument::reloadFromFile()
|
||||
{
|
||||
getCodeDocument();
|
||||
reloadInternal();
|
||||
}
|
||||
|
||||
void SourceCodeDocument::reloadInternal()
|
||||
{
|
||||
jassert (codeDoc != nullptr);
|
||||
modDetector.updateHash();
|
||||
|
||||
ScopedPointer <InputStream> in (modDetector.getFile().createInputStream());
|
||||
|
||||
if (in != nullptr)
|
||||
codeDoc.loadFromStream (*in);
|
||||
codeDoc->loadFromStream (*in);
|
||||
}
|
||||
|
||||
bool SourceCodeDocument::save()
|
||||
|
|
@ -122,24 +145,24 @@ bool SourceCodeDocument::save()
|
|||
{
|
||||
FileOutputStream fo (temp.getFile());
|
||||
|
||||
if (! (fo.openedOk() && codeDoc.writeToStream (fo)))
|
||||
if (! (fo.openedOk() && getCodeDocument().writeToStream (fo)))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! temp.overwriteTargetFileWithTemporary())
|
||||
return false;
|
||||
|
||||
codeDoc.setSavePoint();
|
||||
getCodeDocument().setSavePoint();
|
||||
modDetector.updateHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceCodeDocument::updateLastPosition (CodeEditorComponent& editor)
|
||||
void SourceCodeDocument::updateLastState (CodeEditorComponent& editor)
|
||||
{
|
||||
lastState = new CodeEditorComponent::State (editor);
|
||||
}
|
||||
|
||||
void SourceCodeDocument::applyLastPosition (CodeEditorComponent& editor) const
|
||||
void SourceCodeDocument::applyLastState (CodeEditorComponent& editor) const
|
||||
{
|
||||
if (lastState != nullptr)
|
||||
lastState->restoreState (editor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue