Fix updating of glyph counts in some rare cases. Minor cleanups.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16408 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2003-04-10 00:08:26 +00:00
parent f0b3c9c911
commit 77261b37c3
4 changed files with 32 additions and 24 deletions

View file

@ -1,3 +1,8 @@
2003-04-10 01:53 Alexander Malmberg <alexander@malmberg.org>
* Source/GSLayoutManager.m (-_generateGlyphs_char_r::::::): Fix
updating of glyph counts in some rare cases. Minor cleanups.
2003-04-09 Richard Frith-Macdonald <rfm@gnu.org> 2003-04-09 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/gnustep/gui/GSServicesManager.h: Expost file open methods. * Headers/gnustep/gui/GSServicesManager.h: Expost file open methods.

View file

@ -654,11 +654,6 @@ restart:
while (1) while (1)
{ {
// printf("at %3i+%3i\n",cache_base,i); // printf("at %3i+%3i\n",cache_base,i);
/*printf("at %3i+%2i, glyph %08x, char %04x (%i)\n",
cache_base,i,
g->g,
[[curTextStorage string] characterAtIndex: g->char_index],g->char_index);*/
/* Update the cache. */ /* Update the cache. */
if (i >= cache_length) if (i >= cache_length)
{ {
@ -676,6 +671,11 @@ restart:
g = cache + i; g = cache + i;
} }
/*printf("at %3i+%2i, glyph %08x, char %04x (%i)\n",
cache_base,i,
g->g,
[[curTextStorage string] characterAtIndex: g->char_index],g->char_index);*/
/* /*
At this point: At this point:

View file

@ -153,6 +153,7 @@ Private method used internally by GSLayoutManager for sanity checking.
printf("--- dumping runs\n"); printf("--- dumping runs\n");
{ {
glyph_run_t *h; glyph_run_t *h;
unsigned int cpos = 0;
h = (glyph_run_t *)(glyphs + SKIP_LIST_DEPTH - 1)->next; h = (glyph_run_t *)(glyphs + SKIP_LIST_DEPTH - 1)->next;
for (; h; h = (glyph_run_t *)h->head.next) for (; h; h = (glyph_run_t *)h->head.next)
{ {
@ -160,14 +161,17 @@ Private method used internally by GSLayoutManager for sanity checking.
(int)h, h->head.char_length, h->head.glyph_length, h->head.complete, (int)h, h->head.char_length, h->head.glyph_length, h->head.complete,
(int)h->prev, (int)h->head.next); (int)h->prev, (int)h->head.next);
printf(" level %i, continued %i\n", h->level, h->continued); printf(" level %i, continued %i\n", h->level, h->continued);
/* if (h->head.complete) if (h->head.complete)
{ {
int i; int i;
printf("glyphs:\n"); printf("glyphs:\n");
for (i = 0;i < h->head.glyph_length;i++) for (i = 0;i < h->head.glyph_length;i++)
printf("%5i %04x ",h->glyphs[i].char_offset,h->glyphs[i].g); printf("%5i %04x u%04x ",
h->glyphs[i].char_offset,h->glyphs[i].g,
[[_textStorage string] characterAtIndex: cpos+h->glyphs[i].char_offset]);
printf("\n"); printf("\n");
}*/ }
cpos += h->head.char_length;
} }
} }
printf("- structure\n"); printf("- structure\n");
@ -516,23 +520,24 @@ static glyph_run_t *run_insert(glyph_run_head_t **context)
} }
/* returns number of new glyphs generated */ /*
Returns number of valid glyphs under h after generating up to last (sortof,
not completely accurate).
*/
-(unsigned int) _generateGlyphs_char_r: (unsigned int)last : (unsigned int)pos -(unsigned int) _generateGlyphs_char_r: (unsigned int)last : (unsigned int)pos
: (int)level : (int)level
: (glyph_run_head_t *)h : (glyph_run_head_t *)stop : (glyph_run_head_t *)h : (glyph_run_head_t *)stop
: (BOOL *)all_complete : (BOOL *)all_complete
{ {
int total_new = 0, new; int total = 0, sub_total;
BOOL c, seen_incomplete; BOOL c;
*all_complete = YES; *all_complete = YES;
seen_incomplete = NO;
while (h != stop && (pos <= last || *all_complete)) while (h != stop && (pos <= last || *all_complete))
{ {
if (h->complete) if (h->complete)
{ {
if (seen_incomplete) total += h->glyph_length;
total_new += h->glyph_length;
pos += h->char_length; pos += h->char_length;
h = h->next; h = h->next;
continue; continue;
@ -541,32 +546,31 @@ static glyph_run_t *run_insert(glyph_run_head_t **context)
if (pos > last) if (pos > last)
break; break;
seen_incomplete = YES;
if (level) if (level)
{ {
if (h->next) if (h->next)
new = [self _generateGlyphs_char_r: last : pos : level - 1: h + 1: h->next + 1: &c]; sub_total = [self _generateGlyphs_char_r: last : pos : level - 1: h + 1: h->next + 1: &c];
else else
new = [self _generateGlyphs_char_r: last : pos : level - 1: h + 1: NULL : &c]; sub_total = [self _generateGlyphs_char_r: last : pos : level - 1: h + 1: NULL : &c];
if (!c) if (!c)
*all_complete = NO; *all_complete = NO;
else else
h->complete = 1; h->complete = 1;
h->glyph_length += new; h->glyph_length = sub_total;
total_new += new; total += sub_total;
} }
else else
{ {
[self _generateGlyphsForRun: (glyph_run_t *)h at: pos]; [self _generateGlyphsForRun: (glyph_run_t *)h at: pos];
h->complete = 1; h->complete = 1;
total_new += h->glyph_length; total += h->glyph_length;
} }
pos += h->char_length; pos += h->char_length;
h = h->next; h = h->next;
} }
if (h != stop) if (h != stop)
*all_complete = NO; *all_complete = NO;
return total_new; return total;
} }
-(void) _generateGlyphsUpToCharacter: (unsigned int)last -(void) _generateGlyphsUpToCharacter: (unsigned int)last
@ -602,7 +606,7 @@ static glyph_run_t *run_insert(glyph_run_head_t **context)
if (glyphs->char_length <= last) if (glyphs->char_length <= last)
[self _generateRunsToCharacter: last]; [self _generateRunsToCharacter: last];
// [self _glyphDumpRuns]; // [self _glyphDumpRuns];
if ([self _generateGlyphs_char_r: last : 0 : SKIP_LIST_DEPTH - 1: glyphs : NULL : &dummy]) if ([self _generateGlyphs_char_r: last : 0 : SKIP_LIST_DEPTH - 1: glyphs : NULL : &dummy])
/*[self _glyphDumpRuns]*/; /*[self _glyphDumpRuns]*/;
} }
@ -1023,7 +1027,7 @@ places where we switch.
// [self _glyphDumpRuns]; // [self _glyphDumpRuns];
/* Switch to before-incides. */ /* Switch to before-indices. */
range.length -= lengthChange; range.length -= lengthChange;
// printf("invalidate %i+%i=%i\n", range.location, range.length, range.location+range.length); // printf("invalidate %i+%i=%i\n", range.location, range.length, range.location+range.length);

View file

@ -2061,7 +2061,6 @@ no_soft_invalidation:
[self _didInvalidateLayout]; [self _didInvalidateLayout];
if ((mask & NSTextStorageEditedCharacters) && lengthChange) if ((mask & NSTextStorageEditedCharacters) && lengthChange)
{ {
/* /*