From 0958e055fa90248db8f8e05f58b8e9bb99adc053 Mon Sep 17 00:00:00 2001 From: Alexander Malmberg Date: Tue, 9 Nov 2004 21:14:36 +0000 Subject: [PATCH] 2004-11-09 22:08 Alexander Malmberg * Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): Implement NSLineBreakByClipping. Set outside_line_frag and dont_show attributes for every glyph. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20330 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++ Source/GSHorizontalTypesetter.m | 64 ++++++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce9d5b5b6..7f8f64c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-11-09 22:08 Alexander Malmberg + + * Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): + Implement NSLineBreakByClipping. Set outside_line_frag and dont_show + attributes for every glyph. + 2004-11-09 18:55 Alexander Malmberg * Source/NSPasteboard.m (+_pbs): Give gpbs a --GSStartupNotification diff --git a/Source/GSHorizontalTypesetter.m b/Source/GSHorizontalTypesetter.m index e9ac2e962..937fb8c34 100644 --- a/Source/GSHorizontalTypesetter.m +++ b/Source/GSHorizontalTypesetter.m @@ -969,11 +969,52 @@ restart: ; if (lf->last_glyph <= first_glyph) goto char_wrapping; break; + + case NSLineBreakByTruncatingHead: + case NSLineBreakByTruncatingMiddle: + case NSLineBreakByTruncatingTail: + /* Pretending that these are clipping is far from prefect, + but it's the closest we've got. */ + case NSLineBreakByClipping: + /* Scan forward to the next paragraph separator and mark + all the glyphs up to there as not visible. */ + g->outside_line_frag = YES; + while (1) + { + i++; + g++; + /* Update the cache. */ + if (i >= cache_length) + { + if (at_end) + { + newParagraph = NO; + i--; + break; + } + [self _cacheGlyphs: cache_length + CACHE_STEP]; + if (i >= cache_length) + { + newParagraph = NO; + i--; + break; + } + g = cache + i; + } + g->dont_show = YES; + g->pos = p; + if (g->g == NSControlGlyph + && [[curTextStorage string] + characterAtIndex: g->char_index] == 0xa) + break; + } + lf->last_glyph = i + 1; + break; } /* We force at least one glyph into each line frag rect. This ensures that typesetting will never get stuck (ie. if the text - container is to narrow to fit even a single glyph). */ + container is too narrow to fit even a single glyph). */ if (lf->last_glyph <= first_glyph) lf->last_glyph = i + 1; @@ -1062,21 +1103,20 @@ restart: ; forGlyphRange: NSMakeRange(cache_base + i, lf->last_glyph - i) usedRect: used_rect]; p = g->pos; - /* TODO: probably don't need to call unless the flags are YES */ - if (g->outside_line_frag) - { - [curLayoutManager setDrawsOutsideLineFragment: YES - forGlyphAtIndex: cache_base + i]; - } - if (g->dont_show) - { - [curLayoutManager setNotShownAttribute: YES - forGlyphAtIndex: cache_base + i]; - } p.y += baseline; j = i; while (i < lf->last_glyph) { + if (g->outside_line_frag) + { + [curLayoutManager setDrawsOutsideLineFragment: YES + forGlyphAtIndex: cache_base + i]; + } + if (g->dont_show) + { + [curLayoutManager setNotShownAttribute: YES + forGlyphAtIndex: cache_base + i]; + } if (!g->nominal && i != j) { [curLayoutManager setLocation: p