Tk Source Code

Artifact [feadd43e46]
Login

Artifact feadd43e46ae4bf9fa32a43c63a2d43ae7638940:

Attachment "tabs85.patch" to ticket [1247835fff] added by vincentdarley 2005-08-31 06:22:02.
? tabs85.patch
? library/v_menu.tcl
Index: doc/text.n
===================================================================
RCS file: /cvsroot/tktoolkit/tk/doc/text.n,v
retrieving revision 1.38
diff -b -u -r1.38 text.n
--- doc/text.n	9 Aug 2005 09:46:02 -0000	1.38
+++ doc/text.n	30 Aug 2005 22:40:10 -0000
@@ -117,10 +117,7 @@
 right-justified at the tab position.
 For example, \fB\-tabs {2c left 4c 6c center}\fR creates three
 tab stops at two-centimeter intervals;  the first two use left
-justification and the third uses center justification.  Note that
-tabs are interpreted as they are encountered in the text.  Any tab
-character being laid out will use (and be defined by) the first tab stop 
-to the right of the preceding characters already laid out on that line.
+justification and the third uses center justification.  
 If the list of tab stops does not have enough elements to cover all
 of the tabs in a text line, then Tk extrapolates new tab stops using
 the spacing and alignment from the last tab stop in the list.  Tab
@@ -133,6 +130,19 @@
 (average size) characters.  To achieve a different standard spacing,
 for example every 4 characters, simply configure the widget with 
 \fB\-tabs "[expr {4 * [font measure $font 0]}] left"\fR.
+.OP \-tabstyle tabStyle TabStyle
+Specifies how to interpret the relationship between tab stops on a line
+and tabs in the text of that line.  The value must be \fBtabular\fR (the
+default) or \fBwordprocessor\fR. Note that tabs are interpreted as they
+are encountered in the text.  If the tab style is \fBtabular\fR then the
+n'th tab character in the line's text will be associated with the n'th
+tab stop defined for that line.  If the tab character's x coordinate
+falls to the right of the n'th tab stop, then a gap of a single space
+will be inserted as a fallback.  If the tab style is \fBwordprocessor\fR
+then any tab character being laid out will use (and be defined by) the
+first tab stop to the right of the preceding characters already laid out
+on that line.  The value of the \fBtabstyle\fR option may be overridden
+by \fB\-tabstyle\fR options in tags.
 .OP \-undo undo Undo
 Specifies a boolean that says whether the undo mechanism is active or
 not.
@@ -586,6 +596,14 @@
 default 8-character tabs as described for the \fBtags\fR
 widget option.
 .TP
+\fB\-tabstyle \fIstyle\fR
+\fIStyle\fR specifies either the \fItabular\fR or 
+\fIwordprocessor\fR style of tabbing to use for the text widget.
+This option only applies to a display line if it applies to the
+first character on that display line.
+If this option is specified as an empty string, it cancels
+the option, leaving it unspecified for the tag (the default).
+.TP
 \fB\-underline \fIboolean\fR
 \fIBoolean\fR specifies whether or not to draw an underline underneath
 characters.
@@ -1553,6 +1571,15 @@
 An error will be thrown if this switch is used without \fB\-all\fR.
 .VE 8.5
 .TP
+\fB\-strictlimits\fR 
+.VS 8.5
+When performing any search, the normal behaviour is that
+the start and stop limits are checked with respect to the
+start of the matching text.  With the \fB\-strictlimits\fR flag,
+the entire matching range must lie inside the start and stop
+limits specified for the match to be valid.
+.VE 8.5
+.TP
 \fB\-elide\fR
 Find elided (hidden) text as well. By default only displayed text is
 searched.
Index: generic/tkText.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkText.c,v
retrieving revision 1.59
diff -b -u -r1.59 tkText.c
--- generic/tkText.c	11 Aug 2005 01:55:04 -0000	1.59
+++ generic/tkText.c	30 Aug 2005 22:40:27 -0000
@@ -66,6 +66,16 @@
 };
 
 /*
+ * The 'TkTextTabStyle' enum in tkText.h is used to define a type for
+ * the -tabstyle option of the Text widget.  These values are used as
+ * indices into the string table below.
+ */
+
+static char *tabStyleStrings[] = {
+    "tabular", "wordprocessor", (char *) NULL
+};
+
+/*
  * The following functions and custom option type are used to define the
  * "line" option type, and thereby handle the text widget '-startline',
  * '-endline' configuration options which are of that type.
@@ -214,6 +224,9 @@
     {TK_OPTION_STRING, "-tabs", "tabs", "Tabs",
 	DEF_TEXT_TABS, Tk_Offset(TkText, tabOptionPtr), -1,
 	TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY},
+    {TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle",
+	DEF_TEXT_TABSTYLE, -1, Tk_Offset(TkText, tabStyle),
+	0, (ClientData) tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
     {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
 	DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus),
 	TK_OPTION_NULL_OK, 0, 0},
@@ -4253,7 +4266,8 @@
     tabArrayPtr->numTabs = 0;
     prevStop = 0.0;
     lastStop = 0.0;
-    for (i = 0, tabPtr = &tabArrayPtr->tabs[0]; i < objc; i++, tabPtr++) {
+    for (i = 0, tabPtr = &tabArrayPtr->tabs[0]; i < objc;
+      i++, tabPtr++) {
 	int index;
 
 	/*
@@ -6309,11 +6323,3 @@
     Tcl_GetStringFromObj(objPtr, &length);
     return (length == 0);
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: generic/tkText.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkText.h,v
retrieving revision 1.26
diff -b -u -r1.26 tkText.h
--- generic/tkText.h	14 Feb 2005 23:00:44 -0000	1.26
+++ generic/tkText.h	30 Aug 2005 22:40:32 -0000
@@ -421,6 +421,8 @@
     struct TkTextTabArray *tabArrayPtr;
 				/* Info about tabs for tag (malloc-ed)
 				 * or NULL.  Corresponds to tabString. */
+    int tabStyle;               /* One of TABULAR or WORDPROCESSOR or
+                                 * NONE (if not specified). */
     char *underlineString;	/* -underline option string (malloc-ed).
 				 * NULL means option not specified. */
     int underline;		/* Non-zero means draw underline underneath
@@ -493,6 +495,17 @@
 
 typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign;
 
+/*
+ * The following are the supported styles of tabbing, used for the
+ * -tabstyle option of the text widget.  The last element is only
+ * used for tag options.
+ */
+typedef enum {
+    TK_TEXT_TABSTYLE_TABULAR, 
+    TK_TEXT_TABSTYLE_WORDPROCESSOR, 
+    TK_TEXT_TABSTYLE_NONE
+} TkTextTabStyle;
+
 typedef struct TkTextTab {
     int location;			/* Offset in pixels of this tab stop
 					 * from the left margin (lmargin2) of
@@ -695,6 +708,7 @@
 				/* Information about tab stops (malloc'ed).
 				 * NULL means perform default tabbing
 				 * behavior. */
+    int tabStyle;               /* One of TABULAR or WORDPROCESSOR. */
 
     /*
      * Additional information used for displaying:
Index: generic/tkTextBTree.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextBTree.c,v
retrieving revision 1.18
diff -b -u -r1.18 tkTextBTree.c
--- generic/tkTextBTree.c	29 Jul 2005 13:43:43 -0000	1.18
+++ generic/tkTextBTree.c	30 Aug 2005 22:40:42 -0000
@@ -4832,11 +4832,3 @@
 	}
     }
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: generic/tkTextDisp.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextDisp.c,v
retrieving revision 1.52
diff -b -u -r1.52 tkTextDisp.c
--- generic/tkTextDisp.c	28 Jul 2005 17:20:41 -0000	1.52
+++ generic/tkTextDisp.c	30 Aug 2005 22:41:02 -0000
@@ -100,6 +100,7 @@
     int spacing3;		/* Spacing below last dline in text line. */
     TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be
 				 * NULL). */
+    int tabStyle;               /* One of TABULAR or WORDPROCESSOR. */
     int underline;		/* Non-zero means draw underline underneath
 				 * text. */
     int elide;			/* Zero means draw text, otherwise not */
@@ -482,8 +483,8 @@
 static void		YScrollByPixels _ANSI_ARGS_((TkText *textPtr,
 			    int offset));
 static int		SizeOfTab _ANSI_ARGS_((TkText *textPtr,
-			    TkTextTabArray *tabArrayPtr, int *indexPtr,
-			    int x, int maxX));
+			    int tabStyle, TkTextTabArray *tabArrayPtr, 
+			    int *indexPtr, int x, int maxX));
 static void		TextChanged _ANSI_ARGS_((TkText *textPtr,
 			    CONST TkTextIndex *index1Ptr,
 			    CONST TkTextIndex *index2Ptr));
@@ -685,7 +686,7 @@
     int underlinePrio, elidePrio, justifyPrio, offsetPrio;
     int lMargin1Prio, lMargin2Prio, rMarginPrio;
     int spacing1Prio, spacing2Prio, spacing3Prio;
-    int overstrikePrio, tabPrio, wrapPrio;
+    int overstrikePrio, tabPrio, tabStylePrio, wrapPrio;
 
     /*
      * Find out what tags are present for the character, then compute a
@@ -699,7 +700,7 @@
     underlinePrio = elidePrio = justifyPrio = offsetPrio = -1;
     lMargin1Prio = lMargin2Prio = rMarginPrio = -1;
     spacing1Prio = spacing2Prio = spacing3Prio = -1;
-    overstrikePrio = tabPrio = wrapPrio = -1;
+    overstrikePrio = tabPrio = tabStylePrio = wrapPrio = -1;
     memset((VOID *) &styleValues, 0, sizeof(StyleValues));
     styleValues.relief = TK_RELIEF_FLAT;
     styleValues.fgColor = textPtr->fgColor;
@@ -709,6 +710,7 @@
     styleValues.spacing2 = textPtr->spacing2;
     styleValues.spacing3 = textPtr->spacing3;
     styleValues.tabArrayPtr = textPtr->tabArrayPtr;
+    styleValues.tabStyle = textPtr->tabStyle;
     styleValues.wrapMode = textPtr->wrapMode;
     styleValues.elide = 0;
 
@@ -817,6 +819,11 @@
 	    styleValues.tabArrayPtr = tagPtr->tabArrayPtr;
 	    tabPrio = tagPtr->priority;
 	}
+	if ((tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE)
+		&& (tagPtr->priority > tabStylePrio)) {
+	    styleValues.tabStyle = tagPtr->tabStyle;
+	    tabStylePrio = tagPtr->priority;
+	}
 	if ((tagPtr->underlineString != NULL)
 		&& (tagPtr->priority > underlinePrio)) {
 	    styleValues.underline = tagPtr->underline;
@@ -1001,6 +1008,7 @@
     TkTextTabArray *tabArrayPtr;	/* Tab stops for line; taken from
 					 * style for the first character on
 					 * line. */
+    int tabStyle;                       /* One of TABULAR or WORDPROCESSOR. */
     int tabSize;			/* Number of pixels consumed by
 					 * current tab stop. */
     TkTextDispChunk *lastCharChunkPtr;	/* Pointer to last chunk in display
@@ -1141,6 +1149,7 @@
     tabIndex = -1;
     tabChunkPtr = NULL;
     tabArrayPtr = NULL;
+    tabStyle = TK_TEXT_TABSTYLE_TABULAR;
     rMargin = 0;
     wrapMode = TEXT_WRAPMODE_CHAR;
     tabSize = 0;
@@ -1264,6 +1273,7 @@
 
 	if (noCharsYet) {
 	    tabArrayPtr = chunkPtr->stylePtr->sValuePtr->tabArrayPtr;
+	    tabStyle = chunkPtr->stylePtr->sValuePtr->tabStyle;
 	    justify = chunkPtr->stylePtr->sValuePtr->justify;
 	    rMargin = chunkPtr->stylePtr->sValuePtr->rMargin;
 	    wrapMode = chunkPtr->stylePtr->sValuePtr->wrapMode;
@@ -1382,7 +1392,8 @@
 		x = chunkPtr->x + chunkPtr->width;
 	    }
 	    tabChunkPtr = chunkPtr;
-	    tabSize = SizeOfTab(textPtr, tabArrayPtr, &tabIndex, x, maxX);
+	    tabSize = SizeOfTab(textPtr, tabStyle, tabArrayPtr, 
+				&tabIndex, x, maxX);
 	    if ((maxX >= 0) && (tabSize >= maxX - x)) {
 		break;
 	    }
@@ -7248,19 +7259,31 @@
 	return;
     }
 
+    x = chunkPtr->nextPtr->x;
+
     /*
-     * If no tab information has been given, do the usual thing: round up to
-     * the next boundary of 8 average-sized characters.
+     * If no tab information has been given, assuming tab stops are
+     * at 8 average-sized characters.  Still ensure we respect the
+     * tabular versus wordprocessor tab style.
      */
 
-    x = chunkPtr->nextPtr->x;
     if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) {
 	/*
 	 * No tab information has been given, so use the default
 	 * interpretation of tabs.
 	 */
 
+	if (textPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) {
+	    int tabWidth = Tk_TextWidth(textPtr->tkfont, "0", 1) * 8;
+	    if (tabWidth == 0) {
+		tabWidth = 1;
+	    }
+
+	    desired = tabWidth * (index + 1);
+	} else {
 	desired = NextTabStop(textPtr->tkfont, x, 0);
+	}
+	
 	goto update;
     }
 
@@ -7399,9 +7422,11 @@
  */
 
 static int
-SizeOfTab(textPtr, tabArrayPtr, indexPtr, x, maxX)
+SizeOfTab(textPtr, tabStyle, tabArrayPtr, indexPtr, x, maxX)
     TkText *textPtr;		/* Information about the text widget as a
 				 * whole. */
+    int tabStyle;               /* One of TK_TEXT_TABSTYLE_TABULAR 
+                                 * or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
     TkTextTabArray *tabArrayPtr;/* Information about the tab stops that apply
 				 * to this line. NULL means use default
 				 * tabbing (every 8 chars.) */
@@ -7412,20 +7437,19 @@
     int maxX;			/* X-location of pixel just past the right
 				 * edge of the line. */
 {
-    int tabX, result, index, spaceWidth;
+    int tabX, result, index, spaceWidth, tabWidth;
     TkTextTabAlign alignment;
 
     index = *indexPtr;
 
     if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) {
-	tabX = NextTabStop(textPtr->tkfont, x, 0);
-
-	/*
-	 * We used up one tab stop.
-	 */
-
-	*indexPtr = index+1;
-	return tabX - x;
+	/* We're using a default tab spacing of 8 characters */
+	tabWidth = Tk_TextWidth(textPtr->tkfont, "0", 1) * 8;
+	if (tabWidth == 0) {
+	    tabWidth = 1;
+	}
+    } else {
+	tabWidth = 0; /* Avoid compiler error */
     }
 
     do {
@@ -7434,7 +7458,12 @@
 	 */
 
 	index++;
-	if (index < tabArrayPtr->numTabs) {
+	
+	if ((tabArrayPtr == NULL) || (tabArrayPtr->numTabs == 0)) {
+	    /* We're using a default tab spacing calculated above */
+	    tabX = tabWidth * (index + 1);
+	    alignment = LEFT;
+	} else if (index < tabArrayPtr->numTabs) {
 	    tabX = tabArrayPtr->tabs[index].location;
 	    alignment = tabArrayPtr->tabs[index].alignment;
 	} else {
@@ -7449,10 +7478,16 @@
 	}
 
 	/*
-	 * If this tab stop is before the current x position, then we must
-	 * obviously continue until we reach the text tab stop.
+	 * If this tab stop is before the current x position, then we
+	 * have two cases:
+	 * 
+	 * With 'wordprocessor' style tabs, we must obviously continue
+	 * until we reach the text tab stop.
+	 * 
+	 * With 'tabular' style tabs, we always use the index'th tab
+	 * stop.
 	 */
-    } while (tabX < x);
+    } while (tabX < x && (tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR));
 
     /*
      * Inform our caller of how many tab stops we've used up.
@@ -7506,7 +7541,8 @@
  *	Given the current position, determine where the next default tab stop
  *	would be located. This function is called when the current chunk in
  *	the text has no tabs defined and so the default tab spacing for the
- *	font should be used.
+ *	font should be used, provided we are using wordprocessor 
+ *	style tabs.
  *
  * Results:
  *	The location in pixels of the next tab stop.
@@ -7733,11 +7769,3 @@
 	    "\": must be moveto or scroll", (char *) NULL);
     return TKTEXT_SCROLL_ERROR;
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: generic/tkTextImage.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextImage.c,v
retrieving revision 1.15
diff -b -u -r1.15 tkTextImage.c
--- generic/tkTextImage.c	10 Aug 2005 22:02:22 -0000	1.15
+++ generic/tkTextImage.c	30 Aug 2005 22:41:05 -0000
@@ -834,11 +834,3 @@
     TkTextInvalidateLineMetrics(eiPtr->body.ei.sharedTextPtr, NULL,
 	    index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY);
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: generic/tkTextIndex.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextIndex.c,v
retrieving revision 1.22
diff -b -u -r1.22 tkTextIndex.c
--- generic/tkTextIndex.c	10 Aug 2005 22:02:22 -0000	1.22
+++ generic/tkTextIndex.c	30 Aug 2005 22:41:09 -0000
@@ -2303,11 +2303,3 @@
   done:
     return p;
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: generic/tkTextTag.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkTextTag.c,v
retrieving revision 1.20
diff -b -u -r1.20 tkTextTag.c
--- generic/tkTextTag.c	10 Aug 2005 22:02:22 -0000	1.20
+++ generic/tkTextTag.c	30 Aug 2005 22:41:13 -0000
@@ -30,6 +30,17 @@
     "char", "none", "word", "", (char *) NULL
 };
 
+/*
+ * The 'TkTextTabStyle' enum in tkText.h is used to define a type for
+ * the -tabstyle option of the Text widget.  These values are used as
+ * indices into the string table below.  Tags are allowed an empty wrap
+ * value, but the widget as a whole is not.
+ */
+
+static char *tabStyleStrings[] = {
+    "tabular", "wordprocessor", "", (char *) NULL
+};
+
 static Tk_OptionSpec tagOptionSpecs[] = {
     {TK_OPTION_BORDER, "-background", (char *) NULL, (char *) NULL,
 	NULL, -1, Tk_Offset(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
@@ -70,6 +81,9 @@
 	NULL, -1, Tk_Offset(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
     {TK_OPTION_STRING, "-tabs", (char *) NULL, (char *) NULL,
 	NULL, Tk_Offset(TkTextTag, tabStringPtr), -1, TK_OPTION_NULL_OK, 0, 0},
+    {TK_OPTION_STRING_TABLE, "-tabstyle", (char *) NULL, (char *) NULL,
+	(char *) NULL, -1, Tk_Offset(TkTextTag, tabStyle),
+	TK_OPTION_NULL_OK, (ClientData) tabStyleStrings, 0},
     {TK_OPTION_STRING, "-underline", (char *) NULL, (char *) NULL,
 	(char *) NULL, -1, Tk_Offset(TkTextTag, underlineString),
 	TK_OPTION_NULL_OK, 0, 0},
@@ -483,6 +497,7 @@
 		    || (tagPtr->spacing2String != NULL)
 		    || (tagPtr->spacing3String != NULL)
 		    || (tagPtr->tabStringPtr != NULL)
+		    || (tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE)
 		    || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) {
 		tagPtr->affectsDisplay = 1;
 		tagPtr->affectsDisplayGeometry = 1;
@@ -996,6 +1011,7 @@
     tagPtr->spacing3 = 0;
     tagPtr->tabStringPtr = NULL;
     tagPtr->tabArrayPtr = NULL;
+    tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE;
     tagPtr->underlineString = NULL;
     tagPtr->underline = 0;
     tagPtr->elideString = NULL;
@@ -1723,11 +1739,3 @@
 	ckfree((char*)nameArrPtr);
     }
 }
-
-/*
- * Local Variables:
- * mode: c
- * c-basic-offset: 4
- * fill-column: 78
- * End:
- */
Index: macosx/tkMacOSXDefault.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXDefault.h,v
retrieving revision 1.8
diff -b -u -r1.8 tkMacOSXDefault.h
--- macosx/tkMacOSXDefault.h	23 Jun 2005 20:17:57 -0000	1.8
+++ macosx/tkMacOSXDefault.h	30 Aug 2005 22:41:15 -0000
@@ -524,6 +524,7 @@
 #define DEF_TEXT_SPACING3		"0"
 #define DEF_TEXT_STATE			"normal"
 #define DEF_TEXT_TABS			""
+#define DEF_TEXT_TABSTYLE		"tabular"
 #define DEF_TEXT_TAKE_FOCUS		(char *) NULL
 #define DEF_TEXT_UNDO    		"0"
 #define DEF_TEXT_WIDTH			"80"
Index: tests/text.test
===================================================================
RCS file: /cvsroot/tktoolkit/tk/tests/text.test,v
retrieving revision 1.39
diff -b -u -r1.39 text.test
--- tests/text.test	23 Aug 2005 23:04:42 -0000	1.39
+++ tests/text.test	30 Aug 2005 22:41:21 -0000
@@ -86,6 +86,7 @@
     {-spacing3 -10 0 bogus}
     {-state d disabled foo}
     {-tabs {1i 2i 3i 4i} {1i 2i 3i 4i} bad_tabs}
+    {-tabstyle wordprocessor wordprocessor garbage}
     {-undo 1 1 eh}
     {-width 73 73 2.4}
     {-wrap w word bad_wrap}
@@ -115,7 +116,7 @@
 	lappend result [lindex $i 4]
     }
     set result
-} {1 blue {} {} 0 7 watch {} 0 {} fixed #012 5 #123 #234 0 #ffff01234567 green 45 100 47 2 5 3 82 raised #ffff01234567 21 yellow 0 0 0 0 {} disabled {1i 2i 3i 4i} {any old thing} 1 73 word {x scroll command} {test command}}
+} {1 blue {} {} 0 7 watch {} 0 {} fixed #012 5 #123 #234 0 #ffff01234567 green 45 100 47 2 5 3 82 raised #ffff01234567 21 yellow 0 0 0 0 {} disabled {1i 2i 3i 4i} wordprocessor {any old thing} 1 73 word {x scroll command} {test command}}
 
 test text-2.1 {Tk_TextCmd procedure} {
     list [catch {text} msg] $msg
Index: tests/textDisp.test
===================================================================
RCS file: /cvsroot/tktoolkit/tk/tests/textDisp.test,v
retrieving revision 1.37
diff -b -u -r1.37 textDisp.test
--- tests/textDisp.test	10 May 2005 22:26:16 -0000	1.37
+++ tests/textDisp.test	30 Aug 2005 22:41:28 -0000
@@ -2992,6 +2992,15 @@
     .t insert 1.0 a\tbcdefghij\tc\td
     list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
 	    [lindex [.t bbox 1.14] 0]
+} [list 56 126 168]
+test textDisp-26.1.2 {AdjustForTab procedure, no tabs} {textfonts} {
+    .t delete 1.0 end
+    .t insert 1.0 a\tbcdefghij\tc\td
+    .t configure -tabstyle wordprocessor
+    set res [list [lindex [.t bbox 1.2] 0] [lindex [.t bbox 1.12] 0] \
+      [lindex [.t bbox 1.14] 0]]
+    .t configure -tabstyle tabular
+    set res
 } [list 56 168 224]
 test textDisp-26.2 {AdjustForTab procedure, not enough tabs specified} {
     .t delete 1.0 end
@@ -3111,6 +3120,17 @@
     .t tag add x 1.0 end
     list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
 	    [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]
+} [list 28 56 84 120]
+test textDisp-26.13.2 {AdjustForTab procedure, not enough space} {textfonts} {
+    .t delete 1.0 end
+    .t insert 1.0 "abc\txyz\tqrs\txyz\t0"
+    .t tag delete x
+    .t tag configure x -tabs {10 30 center 50 right 120} -tabstyle wordprocessor
+    .t tag add x 1.0 end
+    set res [list [lindex [.t bbox 1.4] 0] [lindex [.t bbox 1.8] 0] \
+      [lindex [.t bbox 1.12] 0] [lindex [.t bbox 1.16] 0]]
+    .t tag configure x -tabstyle tabular
+    set res
 } [list 28 56 120 190]
 test textDisp-26.14 {AdjustForTab procedure, not enough space} {textfonts} {
     .t delete 1.0 end
@@ -3120,6 +3140,18 @@
     .t insert end "Watch the \tX and the \t\t\tY\n" moop
     list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
 	    [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]
+} [list 77 224 77 224]
+test textDisp-26.14.2 {AdjustForTab procedure, not enough space} {textfonts} {
+    .t delete 1.0 end
+    .t configure -tabstyle wordprocessor
+    .t insert end "a \tb \tc \td \te \tf \tg\n"
+    .t insert end "Watch the \tX and the \t\t\tY\n"
+    .t tag configure moop -tabs [expr {8*$fixedWidth}]
+    .t insert end "Watch the \tX and the \t\t\tY\n" moop
+    set res [list [lindex [.t bbox 2.11] 0] [lindex [.t bbox 2.24] 0] \
+      [lindex [.t bbox 3.11] 0] [lindex [.t bbox 3.24] 0]]
+    .t configure -tabstyle tabular
+    set res
 } [list 112 56 112 56]
 
 .t configure -width 20 -bd 2 -highlightthickness 2 -relief sunken -tabs {} \
@@ -3129,6 +3161,14 @@
     .t delete 1.0 end
     .t insert 1.0 a\tbcdefghij\tc\td
     list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]
+} [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 130 5 7 $fixedHeight]]
+test textDisp-27.1.1 {SizeOfTab procedure, old-style tabs} {textfonts} {
+    .t delete 1.0 end
+    .t insert 1.0 a\tbcdefghij\tc\td
+    .t configure -tabstyle wordprocessor
+    set res [list [.t bbox 1.2] [.t bbox 1.10] [.t bbox 1.12]]
+    .t configure -tabstyle tabular
+    set res
 } [list [list 60 5 7 $fixedHeight] [list 116 5 7 $fixedHeight] [list 4 [expr {$fixedDiff + 18}] 7 $fixedHeight]]
 test textDisp-27.2 {SizeOfTab procedure, choosing tabX and alignment} {textfonts} {
     .t delete 1.0 end
@@ -3189,8 +3229,30 @@
     set res [.t bbox 2.23]
     lset res 0 [expr {[lindex $res 0] - $tab}]
     set res
+} [list -28 [expr {$fixedDiff + 18}] 7 $fixedHeight]
+test textDisp-27.7.1 {SizeOfTab procedure, center alignment, wrap -none (potential numerical problems)} {textfonts} {
+    .t delete 1.0 end
+    .t configure -tabstyle wordprocessor
+    set cm [winfo fpixels .t 1c]
+    .t configure -tabs {1c 2c center 3c 4c 5c 6c 7c 8c} -wrap none -width 40
+    .t insert 1.0 a\tb\tc\td\te\n012345678934567890a\tbb\tcc\tdd
+    set width [expr {$fixedWidth * 19}]
+    set tab $cm
+    while {$tab < $width} {
+	set tab [expr {$tab + $cm}]
+    }
+    # Now we've calculated to the end of the tab after 'a', add one
+    # more for 'bb\t' and we're there, with 4 for the border.  Since
+    # Tk_GetPixelsFromObj uses the standard 'int(0.5 + float)' rounding,
+    # so must we.
+    set tab [expr {4 + int(0.5 + $tab + $cm)}]
+    update
+    set res [.t bbox 2.23]
+    .t configure -tabstyle tabular
+    lset res 0 [expr {[lindex $res 0] - $tab}]
+    set res
 } [list 0 [expr {$fixedDiff + 18}] 7 $fixedHeight]
-test textDisp-27.7.1 {SizeOfTab procedure, fractional tab interpolation problem} {
+test textDisp-27.7.2 {SizeOfTab procedure, fractional tab interpolation problem} {
     .t delete 1.0 end
     set interpolatetab {1c 2c}
     set precisetab {}
Index: unix/tkUnixDefault.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixDefault.h,v
retrieving revision 1.21
diff -b -u -r1.21 tkUnixDefault.h
--- unix/tkUnixDefault.h	24 Oct 2004 17:22:55 -0000	1.21
+++ unix/tkUnixDefault.h	30 Aug 2005 22:41:29 -0000
@@ -515,6 +515,7 @@
 #define DEF_TEXT_SPACING3		"0"
 #define DEF_TEXT_STATE			"normal"
 #define DEF_TEXT_TABS			""
+#define DEF_TEXT_TABSTYLE		"tabular"
 #define DEF_TEXT_TAKE_FOCUS		(char *) NULL
 #define DEF_TEXT_UNDO    		"0"
 #define DEF_TEXT_WIDTH			"80"
Index: win/tkWinDefault.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/win/tkWinDefault.h,v
retrieving revision 1.19
diff -b -u -r1.19 tkWinDefault.h
--- win/tkWinDefault.h	24 Oct 2004 17:22:55 -0000	1.19
+++ win/tkWinDefault.h	30 Aug 2005 22:41:29 -0000
@@ -502,6 +502,7 @@
 #define DEF_TEXT_SPACING3		"0"
 #define DEF_TEXT_STATE			"normal"
 #define DEF_TEXT_TABS			""
+#define DEF_TEXT_TABSTYLE		"tabular"
 #define DEF_TEXT_TAKE_FOCUS		(char *) NULL
 #define DEF_TEXT_UNDO    		"0"
 #define DEF_TEXT_WIDTH			"80"