From bf716a59d27051e7fac11aa157f3b9eef6bf08bd Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 14 Feb 2003 16:59:38 +0000 Subject: [PATCH] Fix an edge case in tab handling. Also, if tabs occure and the paragraph style has no more tab stops, act as if there were tabs every 100 points. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15957 72102866-910b-0410-8b05-ffd578937521 --- Source/GSHorizontalTypesetter.m | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/GSHorizontalTypesetter.m b/Source/GSHorizontalTypesetter.m index 65f519a37..5ee2ae27f 100644 --- a/Source/GSHorizontalTypesetter.m +++ b/Source/GSHorizontalTypesetter.m @@ -26,7 +26,7 @@ #include "AppKit/GSHorizontalTypesetter.h" -#include "AppKit/GSLayoutManager.h" +#include #include #include @@ -34,10 +34,12 @@ #include #include -#include "AppKit/NSTextStorage.h" #include "AppKit/NSParagraphStyle.h" -#include "AppKit/NSTextContainer.h" #include "AppKit/NSTextAttachment.h" +#include "AppKit/NSTextContainer.h" +#include "AppKit/NSTextStorage.h" +#include "AppKit/GSLayoutManager.h" + /* @@ -613,17 +615,31 @@ restart: for (i = 0; i < c; i++) { tab = [tabs objectAtIndex: i]; - if ([tab location] >= p.x + lf->rect.origin.x) + /* + We cannot use a tab at our exact location; we must + use one beyond it. The reason is that several tabs in + a row would get very odd behavior. Eg. given "\t\t", + the first tab would move (exactly) to the next tab + stop, and the next tab stop would move to the same + tab, thus having no effect. + */ + 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; + should we do? + + Pretend that we have tabs every 100 points. + */ + p.x = (floor(p.x / 100.0) + 1.0) * 100.0; + } + else + { + p.x = [tab location] - lf->rect.origin.x; } prev_had_non_nominal_width = YES; - p.x = [tab location] - lf->rect.origin.x; continue; }