mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add code to adjust the selected range after every change.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15752 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
eaec5ebcea
commit
36c596fdf6
2 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-01-28 22:54 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSLayoutManager.m (-textStorage:edited:range:changeInLength:
|
||||
invalidatedRange:): Add code to adjust the selected range after each
|
||||
change.
|
||||
|
||||
2003-01-28 22:20 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSTextView.m (-initWithFrame:textContainer:): Make the
|
||||
|
|
|
@ -1042,6 +1042,30 @@ TODO: not really clear what these should do
|
|||
changeInLength: lengthChange
|
||||
invalidatedRange: invalidatedRange];
|
||||
|
||||
if ((mask & NSTextStorageEditedCharacters) && lengthChange)
|
||||
{
|
||||
/*
|
||||
Adjust the selected range so it's still valid. We don't try to
|
||||
be smart here (smart adjustments will have to be done by whoever
|
||||
made the change), we just want to keep it in range to avoid crashes.
|
||||
|
||||
TODO: It feels slightly ugly to be doing this here, but there aren't
|
||||
many other places that can do this, and it gives reasonable behavior
|
||||
for select-only text views.
|
||||
|
||||
One option is to only adjust when absolutely necessary to keep the
|
||||
selected range valid.
|
||||
*/
|
||||
if (_selected_range.location >= range.location + range.length - lengthChange)
|
||||
{
|
||||
_selected_range.location += lengthChange;
|
||||
}
|
||||
else if (_selected_range.location + _selected_range.length >= range.location)
|
||||
{
|
||||
_selected_range.length += lengthChange;
|
||||
}
|
||||
}
|
||||
|
||||
/* Invalidate display from the first glyph not laid out (which will
|
||||
generally be the first glyph to have been invalidated). */
|
||||
g = layout_glyph;
|
||||
|
|
Loading…
Reference in a new issue