Browse Source

Reverted CodeDocument::replaceAllContent, and added an applyChanges() method.

tags/2021-05-28
jules 13 years ago
parent
commit
9a89d815cc
3 changed files with 13 additions and 2 deletions
  1. +1
    -1
      extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp
  2. +7
    -1
      modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp
  3. +5
    -0
      modules/juce_gui_extra/code_editor/juce_CodeDocument.h

+ 1
- 1
extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.cpp View File

@@ -62,7 +62,7 @@ void SourceCodeDocument::reloadInternal()
{
jassert (codeDoc != nullptr);
modDetector.updateHash();
codeDoc->replaceAllContent (modDetector.getFile().loadFileAsString());
codeDoc->applyChanges (modDetector.getFile().loadFileAsString());
codeDoc->setSavePoint();
}


+ 7
- 1
modules/juce_gui_extra/code_editor/juce_CodeDocument.cpp View File

@@ -574,7 +574,7 @@ void CodeDocument::replaceSection (const int start, const int end, const String&
deleteSection (start + newTextLen, end + newTextLen);
}
void CodeDocument::replaceAllContent (const String& newContent)
void CodeDocument::applyChanges (const String& newContent)
{
TextDiff diff (getAllContent(), newContent);
@@ -589,6 +589,12 @@ void CodeDocument::replaceAllContent (const String& newContent)
}
}
void CodeDocument::replaceAllContent (const String& newContent)
{
remove (0, getNumCharacters(), true);
insert (newContent, 0, true);
}
bool CodeDocument::loadFromStream (InputStream& stream)
{
remove (0, getNumCharacters(), false);


+ 5
- 0
modules/juce_gui_extra/code_editor/juce_CodeDocument.h View File

@@ -234,6 +234,11 @@ public:
*/
void replaceAllContent (const String& newContent);
/** Analyses the changes between the current content and some new text, and applies
those changes.
*/
void applyChanges (const String& newContent);
/** Replaces the editor's contents with the contents of a stream.
This will also reset the undo history and save point marker.
*/


Loading…
Cancel
Save