From 5e7cd0b1ceda5c0cefd03d13595713d9c00cf8d3 Mon Sep 17 00:00:00 2001 From: "donal.k.fellows@manchester.ac.uk" Date: Thu, 11 Mar 2010 09:43:19 +0000 Subject: Removed lame reliance on the leading letters of the names of segment types when dumping a text widget. Entailed expanding the scope of the declarations of the types of embedded images and windows. --- ChangeLog | 3 +++ generic/tkText.c | 10 ++++++---- generic/tkText.h | 4 +++- generic/tkTextImage.c | 4 ++-- generic/tkTextWind.c | 4 ++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9991e29..8c32167 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ there can be unnamed marks present during a dump. Ignore them as they will just be for the peers' insert and current marks, which aren't very important. + (DumpLine): Removed lame reliance on the leading letters of the names + of segment types. Entailed expanding the scope of the declarations of + the types of embedded images and windows. 2010-03-08 Don Porter diff --git a/generic/tkText.c b/generic/tkText.c index 49cfae0..3010d6e 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.98 2010/03/11 09:24:07 dkf Exp $ + * RCS: @(#) $Id: tkText.c,v 1.99 2010/03/11 09:43:19 dkf Exp $ */ #include "default.h" @@ -4708,7 +4708,9 @@ DumpLine( segPtr->body.chars + first, command, &index, what); } } else if ((offset >= startByte)) { - if ((what & TK_DUMP_MARK) && (segPtr->typePtr->name[0] == 'm')) { + if ((what & TK_DUMP_MARK) + && (segPtr->typePtr == &tkTextLeftMarkType + || segPtr->typePtr == &tkTextRightMarkType)) { const char *name; TkTextMark *markPtr = (TkTextMark *) &segPtr->body; @@ -4744,7 +4746,7 @@ DumpLine( segPtr->body.toggle.tagPtr->name, command, &index, what); } else if ((what & TK_DUMP_IMG) && - (segPtr->typePtr->name[0] == 'i')) { + (segPtr->typePtr == &tkTextEmbImageType)) { TkTextEmbImage *eiPtr = (TkTextEmbImage *)&segPtr->body; const char *name = (eiPtr->name == NULL) ? "" : eiPtr->name; @@ -4753,7 +4755,7 @@ DumpLine( lineChanged = DumpSegment(textPtr, interp, "image", name, command, &index, what); } else if ((what & TK_DUMP_WIN) && - (segPtr->typePtr->name[0] == 'w')) { + (segPtr->typePtr == &tkTextEmbWindowType)) { TkTextEmbWindow *ewPtr = (TkTextEmbWindow *)&segPtr->body; const char *pathname; diff --git a/generic/tkText.h b/generic/tkText.h index 6957120..a819752 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.h,v 1.37 2009/10/22 21:36:24 dkf Exp $ + * RCS: @(#) $Id: tkText.h,v 1.38 2010/03/11 09:43:19 dkf Exp $ */ #ifndef _TKTEXT @@ -964,6 +964,8 @@ MODULE_SCOPE const Tk_SegType tkTextLeftMarkType; MODULE_SCOPE const Tk_SegType tkTextRightMarkType; MODULE_SCOPE const Tk_SegType tkTextToggleOnType; MODULE_SCOPE const Tk_SegType tkTextToggleOffType; +MODULE_SCOPE const Tk_SegType tkTextEmbWindowType; +MODULE_SCOPE const Tk_SegType tkTextEmbImageType; /* * Convenience macros for use by B-tree clients which want to access pixel diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index c394196..7f1ce25 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextImage.c,v 1.28 2010/01/18 20:43:38 nijtmans Exp $ + * RCS: @(#) $Id: tkTextImage.c,v 1.29 2010/03/11 09:43:19 dkf Exp $ */ #include "tkPort.h" @@ -56,7 +56,7 @@ static void EmbImageProc(ClientData clientData, int x, int y, * The following structure declares the "embedded image" segment type. */ -static const Tk_SegType tkTextEmbImageType = { +const Tk_SegType tkTextEmbImageType = { "image", /* name */ 0, /* leftGravity */ NULL, /* splitProc */ diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c index fa42b05..8c032c6 100644 --- a/generic/tkTextWind.c +++ b/generic/tkTextWind.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextWind.c,v 1.29 2010/02/21 12:14:16 dkf Exp $ + * RCS: @(#) $Id: tkTextWind.c,v 1.30 2010/03/11 09:43:19 dkf Exp $ */ #include "tkPort.h" @@ -72,7 +72,7 @@ static TkTextEmbWindowClient *EmbWinGetClient(const TkText *textPtr, * The following structure declares the "embedded window" segment type. */ -static const Tk_SegType tkTextEmbWindowType = { +const Tk_SegType tkTextEmbWindowType = { "window", /* name */ 0, /* leftGravity */ NULL, /* splitProc */ -- cgit v0.12