|
@@ -49,7 +49,7 @@ struct TextAtom |
|
|
return atomText.substring (0, numChars);
|
|
|
return atomText.substring (0, numChars);
|
|
|
|
|
|
|
|
|
if (isNewLine())
|
|
|
if (isNewLine())
|
|
|
return String::empty;
|
|
|
|
|
|
|
|
|
return String();
|
|
|
|
|
|
|
|
|
return String::repeatedString (String::charToString (passwordCharacter), numChars);
|
|
|
return String::repeatedString (String::charToString (passwordCharacter), numChars);
|
|
|
}
|
|
|
}
|
|
@@ -111,7 +111,7 @@ public: |
|
|
|
|
|
|
|
|
UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar)
|
|
|
UniformTextSection* split (const int indexToBreakAt, const juce_wchar passwordChar)
|
|
|
{
|
|
|
{
|
|
|
UniformTextSection* const section2 = new UniformTextSection (String::empty, font, colour, passwordChar);
|
|
|
|
|
|
|
|
|
UniformTextSection* const section2 = new UniformTextSection (String(), font, colour, passwordChar);
|
|
|
int index = 0;
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
for (int i = 0; i < atoms.size(); ++i)
|
|
|
for (int i = 0; i < atoms.size(); ++i)
|
|
@@ -902,6 +902,7 @@ TextEditor::TextEditor (const String& name, |
|
|
: Component (name),
|
|
|
: Component (name),
|
|
|
borderSize (1, 1, 1, 3),
|
|
|
borderSize (1, 1, 1, 3),
|
|
|
readOnly (false),
|
|
|
readOnly (false),
|
|
|
|
|
|
caretVisible (true),
|
|
|
multiline (false),
|
|
|
multiline (false),
|
|
|
wordWrap (false),
|
|
|
wordWrap (false),
|
|
|
returnKeyStartsNewLine (false),
|
|
|
returnKeyStartsNewLine (false),
|
|
@@ -933,7 +934,7 @@ TextEditor::TextEditor (const String& name, |
|
|
viewport->setScrollBarsShown (false, false);
|
|
|
viewport->setScrollBarsShown (false, false);
|
|
|
|
|
|
|
|
|
setWantsKeyboardFocus (true);
|
|
|
setWantsKeyboardFocus (true);
|
|
|
setCaretVisible (true);
|
|
|
|
|
|
|
|
|
recreateCaret();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
TextEditor::~TextEditor()
|
|
|
TextEditor::~TextEditor()
|
|
@@ -1020,7 +1021,7 @@ void TextEditor::setReadOnly (const bool shouldBeReadOnly) |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
bool TextEditor::isReadOnly() const
|
|
|
|
|
|
|
|
|
bool TextEditor::isReadOnly() const noexcept
|
|
|
{
|
|
|
{
|
|
|
return readOnly || ! isEnabled();
|
|
|
return readOnly || ! isEnabled();
|
|
|
}
|
|
|
}
|
|
@@ -1084,20 +1085,27 @@ void TextEditor::colourChanged() |
|
|
void TextEditor::lookAndFeelChanged()
|
|
|
void TextEditor::lookAndFeelChanged()
|
|
|
{
|
|
|
{
|
|
|
recreateCaret();
|
|
|
recreateCaret();
|
|
|
|
|
|
repaint();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void TextEditor::recreateCaret()
|
|
|
|
|
|
|
|
|
void TextEditor::enablementChanged()
|
|
|
{
|
|
|
{
|
|
|
if (isCaretVisible())
|
|
|
|
|
|
|
|
|
recreateCaret();
|
|
|
|
|
|
repaint();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (caretVisible != shouldCaretBeVisible)
|
|
|
{
|
|
|
{
|
|
|
setCaretVisible (false);
|
|
|
|
|
|
setCaretVisible (true);
|
|
|
|
|
|
|
|
|
caretVisible = shouldCaretBeVisible;
|
|
|
|
|
|
recreateCaret();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void TextEditor::setCaretVisible (const bool shouldCaretBeVisible)
|
|
|
|
|
|
|
|
|
void TextEditor::recreateCaret()
|
|
|
{
|
|
|
{
|
|
|
if (shouldCaretBeVisible && ! isReadOnly())
|
|
|
|
|
|
|
|
|
if (isCaretVisible())
|
|
|
{
|
|
|
{
|
|
|
if (caret == nullptr)
|
|
|
if (caret == nullptr)
|
|
|
{
|
|
|
{
|
|
@@ -1139,8 +1147,7 @@ void TextEditor::setInputFilter (InputFilter* newFilter, bool takeOwnership) |
|
|
inputFilter.set (newFilter, takeOwnership);
|
|
|
inputFilter.set (newFilter, takeOwnership);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void TextEditor::setInputRestrictions (const int maxLen,
|
|
|
|
|
|
const String& chars)
|
|
|
|
|
|
|
|
|
void TextEditor::setInputRestrictions (const int maxLen, const String& chars)
|
|
|
{
|
|
|
{
|
|
|
setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true);
|
|
|
setInputFilter (new LengthAndCharacterRestriction (maxLen, chars), true);
|
|
|
}
|
|
|
}
|
|
@@ -1570,7 +1577,7 @@ void TextEditor::cut() |
|
|
if (! isReadOnly())
|
|
|
if (! isReadOnly())
|
|
|
{
|
|
|
{
|
|
|
moveCaret (selection.getEnd());
|
|
|
moveCaret (selection.getEnd());
|
|
|
insertTextAtCaret (String::empty);
|
|
|
|
|
|
|
|
|
insertTextAtCaret (String());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2131,12 +2138,6 @@ void TextEditor::handleCommandMessage (const int commandId) |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void TextEditor::enablementChanged()
|
|
|
|
|
|
{
|
|
|
|
|
|
recreateCaret();
|
|
|
|
|
|
repaint();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections)
|
|
|
void TextEditor::setTemporaryUnderlining (const Array<Range<int> >& newUnderlinedSections)
|
|
|
{
|
|
|
{
|
|
|
underlinedSections = newUnderlinedSections;
|
|
|
underlinedSections = newUnderlinedSections;
|
|
@@ -2361,7 +2362,7 @@ String TextEditor::getText() const |
|
|
String TextEditor::getTextInRange (const Range<int>& range) const
|
|
|
String TextEditor::getTextInRange (const Range<int>& range) const
|
|
|
{
|
|
|
{
|
|
|
if (range.isEmpty())
|
|
|
if (range.isEmpty())
|
|
|
return String::empty;
|
|
|
|
|
|
|
|
|
return String();
|
|
|
|
|
|
|
|
|
MemoryOutputStream mo;
|
|
|
MemoryOutputStream mo;
|
|
|
mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength()));
|
|
|
mo.preallocate ((size_t) jmin (getTotalNumChars(), range.getLength()));
|
|
|