diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 587aeafc4b..114052a7c1 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -33505,7 +33505,7 @@ bool VSTPluginInstance::saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSiz MemoryBlock chunk; getChunkData (chunk, false, maxSizeMB); - const int totalLen = sizeof (fxChunkSet) + chunk.getSize() - 8; + const size_t totalLen = sizeof (fxChunkSet) + chunk.getSize() - 8; dest.setSize (totalLen, true); fxChunkSet* const set = (fxChunkSet*) dest.getData(); @@ -33516,7 +33516,7 @@ bool VSTPluginInstance::saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSiz set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap (chunk.getSize()); + set->chunkSize = vst_swap ((long) chunk.getSize()); chunk.copyTo (set->chunk, 0, chunk.getSize()); } @@ -33525,7 +33525,7 @@ bool VSTPluginInstance::saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSiz MemoryBlock chunk; getChunkData (chunk, true, maxSizeMB); - const int totalLen = sizeof (fxProgramSet) + chunk.getSize() - 8; + const size_t totalLen = sizeof (fxProgramSet) + chunk.getSize() - 8; dest.setSize (totalLen, true); fxProgramSet* const set = (fxProgramSet*) dest.getData(); @@ -33536,7 +33536,7 @@ bool VSTPluginInstance::saveToFXBFile (MemoryBlock& dest, bool isFXB, int maxSiz set->fxID = vst_swap (getUID()); set->fxVersion = vst_swap (getVersionNumber()); set->numPrograms = vst_swap (numPrograms); - set->chunkSize = vst_swap (chunk.getSize()); + set->chunkSize = vst_swap ((long) chunk.getSize()); getCurrentProgramName().copyToBuffer (set->name, sizeof (set->name) - 1); chunk.copyTo (set->chunk, 0, chunk.getSize()); @@ -43806,18 +43806,18 @@ BEGIN_JUCE_NAMESPACE class CodeDocumentLine { public: - CodeDocumentLine (const String& line_, + CodeDocumentLine (const tchar* const line_, const int lineLength_, const int numNewLineChars, const int lineStartInFile_) - : line (line_), + : line (line_, lineLength_), lineStartInFile (lineStartInFile_), lineLength (lineLength_), lineLengthWithoutNewLines (lineLength_ - numNewLineChars) { } - ~CodeDocumentLine() throw() + ~CodeDocumentLine() { } @@ -43857,9 +43857,8 @@ public: ++pos; } - newLines.add (new CodeDocumentLine (String (t + startOfLine, pos - startOfLine), - pos - startOfLine, numNewLineChars, - startOfLine)); + newLines.add (new CodeDocumentLine (t + startOfLine, pos - startOfLine, + numNewLineChars, startOfLine)); } jassert (pos == text.length()); @@ -44934,6 +44933,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& document_, linesOnScreen (0), columnsOnScreen (0), scrollbarThickness (16), + columnToTryToMaintain (-1), useSpacesForTabs (false), xOffset (0), codeTokeniser (codeTokeniser_) @@ -44996,6 +44996,7 @@ void CodeEditorComponent::codeDocumentChanged (const CodeDocument::Position& aff triggerAsyncUpdate(); ((CaretComponent*) caret)->updatePosition (*this); + columnToTryToMaintain = -1; if (affectedTextEnd.getPosition() >= selectionStart.getPosition() && affectedTextStart.getPosition() <= selectionEnd.getPosition()) @@ -45109,6 +45110,7 @@ void CodeEditorComponent::rebuildLineTokens() void CodeEditorComponent::moveCaretTo (const CodeDocument::Position& newPos, const bool highlighting) { caretPos = newPos; + columnToTryToMaintain = -1; if (highlighting) { @@ -45336,6 +45338,21 @@ void CodeEditorComponent::cursorRight (const bool moveInWholeWordSteps, const bo moveCaretTo (caretPos.movedBy (1), selecting); } +void CodeEditorComponent::moveLineDelta (const int delta, const bool selecting) +{ + CodeDocument::Position pos (caretPos); + const int newLineNum = pos.getLineNumber() + delta; + + if (columnToTryToMaintain < 0) + columnToTryToMaintain = indexToColumn (pos.getLineNumber(), pos.getIndexInLine()); + + pos.setLineAndIndex (newLineNum, columnToIndex (newLineNum, columnToTryToMaintain)); + + const int colToMaintain = columnToTryToMaintain; + moveCaretTo (pos, selecting); + columnToTryToMaintain = colToMaintain; +} + void CodeEditorComponent::cursorDown (const bool selecting) { newTransaction(); @@ -45343,7 +45360,7 @@ void CodeEditorComponent::cursorDown (const bool selecting) if (caretPos.getLineNumber() == document.getNumLines() - 1) moveCaretTo (CodeDocument::Position (&document, std::numeric_limits::max(), std::numeric_limits::max()), selecting); else - moveCaretTo (caretPos.movedByLines (1), selecting); + moveLineDelta (1, selecting); } void CodeEditorComponent::cursorUp (const bool selecting) @@ -45353,7 +45370,7 @@ void CodeEditorComponent::cursorUp (const bool selecting) if (caretPos.getLineNumber() == 0) moveCaretTo (CodeDocument::Position (&document, 0, 0), selecting); else - moveCaretTo (caretPos.movedByLines (-1), selecting); + moveLineDelta (-1, selecting); } void CodeEditorComponent::pageDown (const bool selecting) @@ -45361,7 +45378,7 @@ void CodeEditorComponent::pageDown (const bool selecting) newTransaction(); scrollBy (jlimit (0, linesOnScreen, 1 + document.getNumLines() - firstLineOnScreen - linesOnScreen)); - moveCaretTo (caretPos.movedByLines (linesOnScreen), selecting); + moveLineDelta (linesOnScreen, selecting); } void CodeEditorComponent::pageUp (const bool selecting) @@ -45369,7 +45386,7 @@ void CodeEditorComponent::pageUp (const bool selecting) newTransaction(); scrollBy (-linesOnScreen); - moveCaretTo (caretPos.movedByLines (-linesOnScreen), selecting); + moveLineDelta (-linesOnScreen, selecting); } void CodeEditorComponent::scrollUp() @@ -45378,7 +45395,7 @@ void CodeEditorComponent::scrollUp() scrollBy (1); if (caretPos.getLineNumber() < firstLineOnScreen) - moveCaretTo (caretPos.movedByLines (1), false); + moveLineDelta (1, false); } void CodeEditorComponent::scrollDown() @@ -45387,7 +45404,7 @@ void CodeEditorComponent::scrollDown() scrollBy (-1); if (caretPos.getLineNumber() >= firstLineOnScreen + linesOnScreen) - moveCaretTo (caretPos.movedByLines (-1), false); + moveLineDelta (-1, false); } void CodeEditorComponent::goToStartOfDocument (const bool selecting) @@ -79990,7 +80007,7 @@ void EdgeTable::clipEdgeTableLineToRange (int* dest, const int x1, const int x2) while (lastItem[0] > x1) lastItem -= 2; - const int itemsRemoved = (lastItem - (dest + 1)) / 2; + const int itemsRemoved = (int) (lastItem - (dest + 1)) / 2; if (itemsRemoved > 0) { diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 4ae4bb23c8..c4aaaa8946 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -20305,7 +20305,7 @@ private: int firstLineOnScreen, gutter, spacesPerTab; float charWidth; int lineHeight, linesOnScreen, columnsOnScreen; - int scrollbarThickness; + int scrollbarThickness, columnToTryToMaintain; bool useSpacesForTabs; double xOffset; @@ -20335,6 +20335,7 @@ private: void clearCachedIterators (const int firstLineToBeInvalid) throw(); void updateCachedIterators (int maxLineNum); void getIteratorForPosition (int position, CodeDocument::Iterator& result); + void moveLineDelta (const int delta, const bool selecting); void updateScrollBars(); void scrollToLineInternal (int line);