Implement basic handling of tabs.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15950 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-12 23:53:29 +00:00
parent a273e6156a
commit 77950b1e66
2 changed files with 46 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2003-02-13 00:52 Alexander Malmberg <alexander@malmberg.org>
* Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:):
Implement basic handling of tabs.
2003-02-12 Fred Kiefer <FredKiefer@gmx.de> 2003-02-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSSlideView.h * Source/GSSlideView.h

View file

@ -28,10 +28,11 @@
#include "AppKit/GSLayoutManager.h" #include "AppKit/GSLayoutManager.h"
#include <Foundation/NSDebug.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSGeometry.h>
#include <Foundation/NSLock.h> #include <Foundation/NSLock.h>
#include <Foundation/NSValue.h> #include <Foundation/NSValue.h>
#include <Foundation/NSGeometry.h>
#include "AppKit/NSTextStorage.h" #include "AppKit/NSTextStorage.h"
#include "AppKit/NSParagraphStyle.h" #include "AppKit/NSParagraphStyle.h"
@ -504,19 +505,20 @@ restart:
line_frag_t *lf = line_frags; line_frag_t *lf = line_frags;
int lfi = 0; int lfi = 0;
BOOL prev_was_attachment; BOOL prev_had_non_nominal_width;
last_p = p = NSMakePoint(0,0); last_p = p = NSMakePoint(0,0);
g = cache; g = cache;
first_glyph = 0; first_glyph = 0;
prev_was_attachment = NO; prev_had_non_nominal_width = NO;
/* /*
Main glyph layout loop. Main glyph layout loop.
*/ */
while (1) while (1)
{ {
// printf("at %3i+%3i\n",cache_base,i);
/*printf("at %3i+%2i, glyph %08x, char %04x (%i)\n", /*printf("at %3i+%2i, glyph %08x, char %04x (%i)\n",
cache_base,i, cache_base,i,
g->g, g->g,
@ -588,16 +590,46 @@ restart:
g->pos = p; g->pos = p;
g->size.width = 0; g->size.width = 0;
g->dont_show = YES; g->dont_show = YES;
g->nominal = !prev_was_attachment; g->nominal = !prev_had_non_nominal_width;
i++; i++;
g++; g++;
last_glyph = NSNullGlyph; last_glyph = NSNullGlyph;
prev_was_attachment = NO; prev_had_non_nominal_width = NO;
if (ch == 0xa) if (ch == 0xa)
break; break;
if (ch == 0x9)
{
/*
Handle tabs. This is a very basic and stupid implementation.
TODO: implement properly
*/
NSArray *tabs = [curParagraphStyle tabStops];
NSTextTab *tab = nil;
int i, c = [tabs count];
/* Find first tab beyond our current position. */
for (i = 0; i < c; i++)
{
tab = [tabs objectAtIndex: i];
if ([tab location] >= p.x + lf->rect.origin.x)
break;
}
if (i == c)
{
/* TODO: we're already past all the tab stops. what
should we do? */
continue;
}
prev_had_non_nominal_width = YES;
p.x = [tab location] - lf->rect.origin.x;
continue;
}
NSDebugLLog(@"GSHorizontalTypesetter",
@"ignoring unknown control character %04x\n", ch);
continue; continue;
} }
@ -609,7 +641,7 @@ restart:
Currently, the attributes of the attachment character (eg. font) Currently, the attributes of the attachment character (eg. font)
affect the layout. Think hard about this. affect the layout. Think hard about this.
*/ */
g->nominal = !prev_was_attachment; g->nominal = !prev_had_non_nominal_width;
if (g->attributes.explicit_kern && if (g->attributes.explicit_kern &&
g->attributes.kern != 0) g->attributes.kern != 0)
@ -757,7 +789,7 @@ restart:
line frag rect (see above). */ line frag rect (see above). */
lf->last_used = g[-1].pos.x + g[-1].size.width; lf->last_used = g[-1].pos.x + g[-1].size.width;
last_glyph = NSNullGlyph; last_glyph = NSNullGlyph;
prev_was_attachment = NO; prev_had_non_nominal_width = NO;
lf++; lf++;
lfi++; lfi++;
@ -772,11 +804,11 @@ restart:
if (last_glyph == GSAttachmentGlyph) if (last_glyph == GSAttachmentGlyph)
{ {
last_glyph = NSNullGlyph; last_glyph = NSNullGlyph;
prev_was_attachment = YES; prev_had_non_nominal_width = YES;
} }
else else
{ {
prev_was_attachment = NO; prev_had_non_nominal_width = NO;
} }
i++; i++;
g++; g++;