mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Many minor bug and behavior fixes to get the text system to work with several text containers attached to one layout manager.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15924 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f9fea1156d
commit
87a4e8d28d
4 changed files with 81 additions and 22 deletions
|
@ -1,3 +1,10 @@
|
|||
2003-02-10 15:09 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/GSLayoutManager.m, Source/NSLayoutManager.m,
|
||||
Source/NSTextView.m: Many minor bug and behavior fixes to get the
|
||||
text system to work with several text containers attached to one
|
||||
layout manager.
|
||||
|
||||
2003-02-09 21:08 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/GSLayoutManager.m: Clean up old debugging code, whitespace,
|
||||
|
|
|
@ -1304,15 +1304,16 @@ it should still be safe. might lose opportunities to merge runs, though.
|
|||
textcontainer_t *tc;
|
||||
unsigned int next;
|
||||
NSRect prev;
|
||||
BOOL delegate_responds;
|
||||
|
||||
next = 0;
|
||||
delegate_responds = [_delegate respondsToSelector:
|
||||
@selector(layoutManager:didCompleteLayoutForTextContainer:atEnd:)];
|
||||
|
||||
next = layout_glyph;
|
||||
for (i = 0, tc = textcontainers; i < num_textcontainers; i++, tc++)
|
||||
{
|
||||
if (tc->complete)
|
||||
{
|
||||
next = tc->pos + tc->length;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
@ -1330,8 +1331,25 @@ it should still be safe. might lose opportunities to merge runs, though.
|
|||
break;
|
||||
}
|
||||
tc->complete = YES;
|
||||
if (delegate_responds)
|
||||
{
|
||||
[_delegate layoutManager: self
|
||||
didCompleteLayoutForTextContainer: tc->textContainer
|
||||
atEnd: j == 2];
|
||||
/* The call might have resulted in more text containers being
|
||||
added, so 'textcontainers' might have moved. */
|
||||
tc = textcontainers + i;
|
||||
}
|
||||
if (j == 2)
|
||||
break;
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (i == num_textcontainers && delegate_responds)
|
||||
{
|
||||
[_delegate layoutManager: self
|
||||
didCompleteLayoutForTextContainer: nil
|
||||
atEnd: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1740,6 +1758,7 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
|||
if (effectiveRange)
|
||||
{
|
||||
[self _doLayoutToContainer: i];
|
||||
tc = textcontainers + i;
|
||||
*effectiveRange = NSMakeRange(tc->pos, tc->length);
|
||||
}
|
||||
return tc->textContainer;
|
||||
|
@ -1878,6 +1897,7 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
|||
}
|
||||
|
||||
[self _doLayoutToContainer: i];
|
||||
tc = textcontainers + i;
|
||||
used = NSZeroRect;
|
||||
for (i = 0, lf = tc->linefrags; i < tc->num_linefrags; i++, lf++)
|
||||
used = NSUnionRect(used, lf->used_rect);
|
||||
|
@ -1899,6 +1919,7 @@ forStartOfGlyphRange: (NSRange)glyphRange
|
|||
}
|
||||
|
||||
[self _doLayoutToContainer: i];
|
||||
tc = textcontainers + i;
|
||||
return NSMakeRange(tc->pos, tc->length);
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ container? necessary? */
|
|||
inTextContainer: (NSTextContainer *)container
|
||||
rectCount: (unsigned int *)rectCount
|
||||
{
|
||||
unsigned int last = glyphRange.location + glyphRange.length;
|
||||
unsigned int last;
|
||||
int i;
|
||||
textcontainer_t *tc;
|
||||
linefrag_t *lf;
|
||||
|
@ -138,31 +138,45 @@ container? necessary? */
|
|||
NSRect r;
|
||||
|
||||
|
||||
*rectCount = 0;
|
||||
|
||||
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
|
||||
if (tc->textContainer == container)
|
||||
break;
|
||||
//printf("container %i %@, %i+%i\n",i,tc->textContainer,tc->pos,tc->length);
|
||||
[self _doLayoutToGlyph: last - 1];
|
||||
[self _doLayoutToGlyph: NSMaxRange(glyphRange) - 1];
|
||||
//printf(" now %i+%i\n",tc->pos,tc->length);
|
||||
if (i == num_textcontainers ||
|
||||
tc->pos + tc->length < last ||
|
||||
tc->pos > glyphRange.location)
|
||||
if (i == num_textcontainers)
|
||||
{
|
||||
if (i == num_textcontainers)
|
||||
NSLog(@"%s: invalid text container", __PRETTY_FUNCTION__);
|
||||
else
|
||||
[NSException raise: NSRangeException
|
||||
format: @"%s invalid glyph range", __PRETTY_FUNCTION__];
|
||||
*rectCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Silently clamp range to the text container.
|
||||
TODO: is this good? */
|
||||
if (tc->pos > glyphRange.location)
|
||||
{
|
||||
if (tc->pos > NSMaxRange(glyphRange))
|
||||
return NULL;
|
||||
glyphRange.length = NSMaxRange(glyphRange) - tc->pos;
|
||||
glyphRange.location = tc->pos;
|
||||
}
|
||||
|
||||
if (tc->pos + tc->length < NSMaxRange(glyphRange))
|
||||
{
|
||||
if (tc->pos + tc->length < glyphRange.location)
|
||||
return NULL;
|
||||
glyphRange.length = tc->pos + tc->length - glyphRange.location;
|
||||
}
|
||||
|
||||
if (!glyphRange.length)
|
||||
{
|
||||
*rectCount = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
last = NSMaxRange(glyphRange);
|
||||
|
||||
num_rects = 0;
|
||||
|
||||
for (lf = tc->linefrags, i = 0; i < tc->num_linefrags; i++, lf++)
|
||||
|
@ -332,6 +346,8 @@ line frag rect. */
|
|||
[self _doLayoutToContainer: i
|
||||
point: NSMakePoint(NSMaxX(bounds),NSMaxY(bounds))];
|
||||
|
||||
tc = textcontainers + i;
|
||||
|
||||
if (!tc->num_linefrags)
|
||||
return NSMakeRange(0, 0);
|
||||
|
||||
|
@ -472,6 +488,8 @@ anything visible
|
|||
|
||||
[self _doLayoutToContainer: i point: point];
|
||||
|
||||
tc = textcontainers + i;
|
||||
|
||||
for (i = 0, lf = tc->linefrags; i < tc->num_linefrags; i++, lf++)
|
||||
{
|
||||
if (NSPointInRect(point, lf->rect))
|
||||
|
@ -629,10 +647,10 @@ has the same y origin and height as the line frag rect it is in.
|
|||
return NSMakeRect(1,1,1,13);
|
||||
}
|
||||
|
||||
[self _doLayoutToGlyph: glyph_index];
|
||||
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
|
||||
if (tc->pos + tc->length > glyph_index)
|
||||
break;
|
||||
[self _doLayoutToGlyph: glyph_index];
|
||||
if (i == num_textcontainers)
|
||||
{
|
||||
*textContainer = -1;
|
||||
|
@ -824,6 +842,7 @@ has the same y origin and height as the line frag rect it is in.
|
|||
{
|
||||
[self _doLayoutToContainer: from_tc
|
||||
point: NSMakePoint(target, distance + NSMaxY(from_rect))];
|
||||
tc = textcontainers + from_tc;
|
||||
/* Find the target line. Move at least (should be up to?)
|
||||
distance, and at least one line. */
|
||||
for (; i < tc->num_linefrags; i++, lf++)
|
||||
|
@ -970,8 +989,12 @@ container */
|
|||
first_char_pos = char_pos;
|
||||
while (1)
|
||||
{
|
||||
rects = [self rectArrayForGlyphRange:
|
||||
NSMakeRange(glyph_pos + i, glyph_run->head.glyph_length - i)
|
||||
NSRange r = NSMakeRange(glyph_pos + i, glyph_run->head.glyph_length - i);
|
||||
|
||||
if (NSMaxRange(r) > NSMaxRange(range))
|
||||
r.length = NSMaxRange(range) - r.location;
|
||||
|
||||
rects = [self rectArrayForGlyphRange: r
|
||||
withinSelectedGlyphRange: NSMakeRange(NSNotFound, 0)
|
||||
inTextContainer: textContainer
|
||||
rectCount: &count];
|
||||
|
@ -1023,15 +1046,17 @@ container */
|
|||
|
||||
if (r.location < range.location)
|
||||
{
|
||||
if (range.location - r.location > r.length)
|
||||
return;
|
||||
r.length -= range.location - r.location;
|
||||
r.location = range.location;
|
||||
}
|
||||
if (r.location + r.length > range.location + range.length)
|
||||
{
|
||||
if (r.location > range.location + range.length)
|
||||
return;
|
||||
r.length = range.location + range.length - r.location;
|
||||
}
|
||||
if (r.length <= 0)
|
||||
return;
|
||||
|
||||
/* TODO: use the text view's selected text attributes */
|
||||
color = [NSColor selectedTextBackgroundColor];
|
||||
|
|
|
@ -1336,6 +1336,11 @@ incorrectly. */
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
TODO: There is code in TextEdit that implies that the minimum size is
|
||||
mostly ignored, and that the size of the containing clip view is always
|
||||
used instead. Should test on OS to find out what the proper behavior is.
|
||||
*/
|
||||
-(void) setConstrainedFrameSize: (NSSize)desiredSize
|
||||
{
|
||||
NSSize newSize;
|
||||
|
@ -2866,7 +2871,8 @@ Figure out how the additional layout stuff is supposed to work.
|
|||
}
|
||||
|
||||
if (_layoutManager->_selected_range.length > 0 ||
|
||||
_layoutManager->_selected_range.location == NSNotFound)
|
||||
_layoutManager->_selected_range.location == NSNotFound ||
|
||||
!restartFlag)
|
||||
{
|
||||
new = NSZeroRect;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue