Tk Source Code

Check-in [1a6d9912]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Realization of global default value for tag option -undo (bug report [5a670c16ba]).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | revised_text-aside
Files: files | file ages | folders
SHA3-256: 1a6d99122ac9c040e2eaf56a66ba4e4425b2c455ca6c7583b5ae3f99ea974cf0
User & Date: gcramer 2019-01-01 15:00:43
References
2019-01-01
15:07 Ticket [5a670c16] Revised text: -undo tag option default should be changed status still Open with 3 other changes artifact: e1fd84d7 user: gcramer
Context
2019-01-03
21:45
Realization of global default value for tag option -undo (bug report [5a670c16ba]). check-in: a263e6c9 user: jan.nijtmans tags: revised_text, tip-466
19:38
Make the sync command generate a <<WidgetViewSync>> event after updating all line metrics. Merge the modified 11a-* tests from the legacy widget. Closed-Leaf check-in: 4aca5dbe user: culler tags: revised_text-aside
2019-01-01
15:00
Realization of global default value for tag option -undo (bug report [5a670c16ba]). check-in: 1a6d9912 user: gcramer tags: revised_text-aside
2018-12-31
16:32
Fix gcc warning: tkText.c:5159:55: warning: division ‘sizeof (TkTextPosition * {aka struct TkTextPosition *}) / sizeof (TkTextPosition {aka struct TkTextPosition})’ does not compute the number of array elements [-Wsizeof-pointer-div] which turns out to be an actual - but harmless - bug check-in: 1b803cf9 user: jan.nijtmans tags: revised_text-aside
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to doc/text.n.

483
484
485
486
487
488
489





490
491
492
493
494
495
496
....
1112
1113
1114
1115
1116
1117
1118
1119

1120
1121
1122
1123
1124
1125
1126
1127
mode), but only if a preceding character exists in this line. This mode is
commonly used in some text editors.
.IP "\fBnone\fR"
The new text will not receive any tags from surrounded text.
.RE
.OP \-undo undo Undo
Specifies a boolean that says whether the undo mechanism is active or not.





.OP \-width width Width
Specifies the desired width for the window in units of characters in the font
given by the \fB\-font\fR option. If the font does not have a uniform width
then the width of the character
.QW 0
is used in translating from character units to screen units.
.OP \-useunibreak useUniBreak UseUniBreak
................................................................................
may be removed in a future version.
See equivalent tag option \fB\-underlinecolor\fR for a description.
.TP
\fB\-undo \fIboolean\fR
.
Specifies whether adding/removing this tag to/from text will be undone with
\fBundo\fR operation. If this flag is \fIfalse\fR, then changes of tag
associations will not be undone for this tag. The default is \fItrue\fR, except

for the special selection flag \fBsel\fR, the default for this tag is \fIfalse\fR.
.TP
\fB\-wrap \fImode\fR
.
\fIMode\fR specifies how to handle lines that are wider than the text's
window. This option only applies to a display line if it applies to the
first non-elided character on that display line. It has the same legal
values as the \fB\-wrap\fR option for the text widget: \fBnone\fR,






>
>
>
>
>







 







|
>
|







483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
....
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
mode), but only if a preceding character exists in this line. This mode is
commonly used in some text editors.
.IP "\fBnone\fR"
The new text will not receive any tags from surrounded text.
.RE
.OP \-undo undo Undo
Specifies a boolean that says whether the undo mechanism is active or not.
.OP \-undotagging undoTagging UndoTagging
This boolean value specifies the setup value for \fB-undo\fR option when
creating tags. Per default the setup value is \fItrue\fR. Note that this
value will not be used for the special tag \fBsel\fR. See description of
tag option \fB-undo\fR for more information.
.OP \-width width Width
Specifies the desired width for the window in units of characters in the font
given by the \fB\-font\fR option. If the font does not have a uniform width
then the width of the character
.QW 0
is used in translating from character units to screen units.
.OP \-useunibreak useUniBreak UseUniBreak
................................................................................
may be removed in a future version.
See equivalent tag option \fB\-underlinecolor\fR for a description.
.TP
\fB\-undo \fIboolean\fR
.
Specifies whether adding/removing this tag to/from text will be undone with
\fBundo\fR operation. If this flag is \fIfalse\fR, then changes of tag
associations will not be undone for this tag. The default is given with
text option \fB-undotagging\fR (normally \fItrue\fR), except for the special
selection flag \fBsel\fR, the default for this tag is always \fIfalse\fR.
.TP
\fB\-wrap \fImode\fR
.
\fIMode\fR specifies how to handle lines that are wider than the text's
window. This option only applies to a display line if it applies to the
first non-elided character on that display line. It has the same legal
values as the \fB\-wrap\fR option for the text widget: \fBnone\fR,

Changes to generic/tkText.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391


392
393
394
395
396
397
398
....
1046
1047
1048
1049
1050
1051
1052

1053
1054
1055
1056
1057
1058
1059
....
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184

1185
1186
1187
1188
1189
1190
1191
....
3875
3876
3877
3878
3879
3880
3881

3882
3883
3884

3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
....
4063
4064
4065
4066
4067
4068
4069









4070
4071
4072
4073
4074
4075
4076
....
4129
4130
4131
4132
4133
4134
4135

4136
4137
4138
4139
4140
4141
4142
 *	editable text widgets for Tk. Among other things, it provides the Tcl
 *	command interfaces to text widgets. The B-tree representation of text
 *	and its actual display are implemented elsewhere.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
 * Copyright (c) 1999 by Scriptics Corporation.
 * Copyright (c) 2015-2017 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"
#include "tkText.h"
................................................................................
    {TK_OPTION_CUSTOM, "-startline", NULL, NULL,
	 NULL, -1, Tk_Offset(TkText, startLine), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE},
#endif
    {TK_OPTION_STRING_TABLE, "-state", "state", "State",
	DEF_TEXT_STATE, -1, Tk_Offset(TkText, state), 0, stateStrings, 0},
    {TK_OPTION_BOOLEAN, "-steadymarks", "steadyMarks", "SteadyMarks",
	"0", -1, Tk_Offset(TkText, steadyMarks), TK_OPTION_DONT_SET_DEFAULT, 0, 0},
    {TK_OPTION_INT, "-synctime", "syncTime", "SyncTime", "150", -1, Tk_Offset(TkText, syncTime),
	0, 0, TK_TEXT_SYNCHRONIZE},
    {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, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING_TABLE, "-tagging", "tagging", "Tagging",
	"within", -1, Tk_Offset(TkText, tagging), 0, taggingStrings, 0},
    {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
	DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
	DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo), TK_OPTION_DONT_SET_DEFAULT, 0 ,0},


    {TK_OPTION_BOOLEAN, "-useunibreak", "useUniBreak", "UseUniBreak",
	"0", -1, Tk_Offset(TkText, useUniBreak), 0, 0, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_INT, "-width", "width", "Width",
	DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
	DEF_TEXT_WRAP, -1, Tk_Offset(TkText, wrapMode), 0, wrapStrings, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
................................................................................
	sharedTextPtr->affectGeometryTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->affectGeometryNonSelTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->affectLineHeightTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->tagLookup = malloc(TK_TEXT_SET_MAX_BIT_SIZE*sizeof(TkTextTag *));
	sharedTextPtr->emptyTagInfoPtr = TkTextTagSetResize(NULL, 0);
	sharedTextPtr->maxRedoDepth = -1;
	sharedTextPtr->autoSeparators = true;

	sharedTextPtr->lastEditMode = TK_TEXT_EDIT_OTHER;
	sharedTextPtr->lastUndoTokenType = -1;
	sharedTextPtr->startMarker = TkTextMakeStartEndMark(NULL, &tkTextLeftMarkType);
	sharedTextPtr->endMarker = TkTextMakeStartEndMark(NULL, &tkTextRightMarkType);
	sharedTextPtr->protectionMark[0] = TkTextMakeMark(NULL, NULL);
	sharedTextPtr->protectionMark[1] = TkTextMakeMark(NULL, NULL);
	sharedTextPtr->protectionMark[0]->typePtr = &tkTextProtectionMarkType;
................................................................................
     */

    TkTextCreateDInfo(textPtr);
    TkTextIndexSetupToStartOfText(&startIndex, textPtr, sharedTextPtr->tree);
    TkTextSetYView(textPtr, &startIndex, 0);
    textPtr->exportSelection = true;
    textPtr->pickEvent.type = LeaveNotify;
    textPtr->steadyMarks = textPtr->sharedTextPtr->steadyMarks;
    textPtr->undo = textPtr->sharedTextPtr->undo;
    textPtr->maxUndoDepth = textPtr->sharedTextPtr->maxUndoDepth;
    textPtr->maxRedoDepth = textPtr->sharedTextPtr->maxRedoDepth;
    textPtr->maxUndoSize = textPtr->sharedTextPtr->maxUndoSize;
    textPtr->autoSeparators = textPtr->sharedTextPtr->autoSeparators;


    /*
     * Create the "sel" tag and the "current" and "insert" marks.
     * Note: it is important that textPtr->selTagPtr is NULL before this
     * initial call.
     */

................................................................................
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    Tk_SavedOptions savedOptions;
    TkTextIndex start, end, current;
    TkSizeT currentEpoch;
    TkSharedText *sharedTextPtr = textPtr->sharedTextPtr;
    TkTextBTree tree = sharedTextPtr->tree;

    bool oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp));
    bool oldTextDebug = tkTextDebug;
    bool didHyphenate = textPtr->hyphenate;

    int oldHyphenRules = textPtr->hyphenRules;
    int mask = 0;
    bool copyDownFlags = false;

    tkTextDebug = false; /* debugging is not useful here */

#if SUPPORT_DEPRECATED_STARTLINE_ENDLINE

    /*
     * We want also to support the "-start", and "-end" abbreviations. The thing that
................................................................................
	    goto error;
	}
    }

    /*
     * Copy up shared flags.
     */










    /* This flag cannot alter if we have peers. */
    sharedTextPtr->steadyMarks = textPtr->steadyMarks;

    if (sharedTextPtr->autoSeparators != textPtr->autoSeparators) {
	sharedTextPtr->autoSeparators = textPtr->autoSeparators;
	copyDownFlags = true;
................................................................................

	for (tPtr = sharedTextPtr->peers; tPtr; tPtr = tPtr->next) {
	    tPtr->autoSeparators = sharedTextPtr->autoSeparators;
	    tPtr->maxUndoDepth = sharedTextPtr->maxUndoDepth;
	    tPtr->maxRedoDepth = sharedTextPtr->maxRedoDepth;
	    tPtr->maxUndoSize = sharedTextPtr->maxUndoSize;
	    tPtr->undo = sharedTextPtr->undo;

	}
    }

    /*
     * Check soft hyphen support.
     */







|







 







|
|










>
>







 







>







 







|
|
|
|
|
|
>







 







>



>


<







 







>
>
>
>
>
>
>
>
>







 







>







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
....
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
....
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
....
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892

3893
3894
3895
3896
3897
3898
3899
....
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
....
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
 *	editable text widgets for Tk. Among other things, it provides the Tcl
 *	command interfaces to text widgets. The B-tree representation of text
 *	and its actual display are implemented elsewhere.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
 * Copyright (c) 1999 by Scriptics Corporation.
 * Copyright (c) 2015-2018 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"
#include "tkText.h"
................................................................................
    {TK_OPTION_CUSTOM, "-startline", NULL, NULL,
	 NULL, -1, Tk_Offset(TkText, startLine), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE},
#endif
    {TK_OPTION_STRING_TABLE, "-state", "state", "State",
	DEF_TEXT_STATE, -1, Tk_Offset(TkText, state), 0, stateStrings, 0},
    {TK_OPTION_BOOLEAN, "-steadymarks", "steadyMarks", "SteadyMarks",
	"0", -1, Tk_Offset(TkText, steadyMarks), TK_OPTION_DONT_SET_DEFAULT, 0, 0},
    {TK_OPTION_INT, "-synctime", "syncTime", "SyncTime",
	"150", -1, Tk_Offset(TkText, syncTime), 0, 0, TK_TEXT_SYNCHRONIZE},
    {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, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING_TABLE, "-tagging", "tagging", "Tagging",
	"within", -1, Tk_Offset(TkText, tagging), 0, taggingStrings, 0},
    {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
	DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus), TK_OPTION_NULL_OK, 0, 0},
    {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
	DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo), TK_OPTION_DONT_SET_DEFAULT, 0 ,0},
    {TK_OPTION_BOOLEAN, "-undotagging", "undoTagging", "UndoTagging",
	"1", -1, Tk_Offset(TkText, undoTagging), 0, 0 ,0},
    {TK_OPTION_BOOLEAN, "-useunibreak", "useUniBreak", "UseUniBreak",
	"0", -1, Tk_Offset(TkText, useUniBreak), 0, 0, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_INT, "-width", "width", "Width",
	DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
	DEF_TEXT_WRAP, -1, Tk_Offset(TkText, wrapMode), 0, wrapStrings, TK_TEXT_LINE_GEOMETRY},
    {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
................................................................................
	sharedTextPtr->affectGeometryTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->affectGeometryNonSelTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->affectLineHeightTags = TkBitResize(NULL, TK_TEXT_SET_MAX_BIT_SIZE);
	sharedTextPtr->tagLookup = malloc(TK_TEXT_SET_MAX_BIT_SIZE*sizeof(TkTextTag *));
	sharedTextPtr->emptyTagInfoPtr = TkTextTagSetResize(NULL, 0);
	sharedTextPtr->maxRedoDepth = -1;
	sharedTextPtr->autoSeparators = true;
	sharedTextPtr->undoTagging = true;
	sharedTextPtr->lastEditMode = TK_TEXT_EDIT_OTHER;
	sharedTextPtr->lastUndoTokenType = -1;
	sharedTextPtr->startMarker = TkTextMakeStartEndMark(NULL, &tkTextLeftMarkType);
	sharedTextPtr->endMarker = TkTextMakeStartEndMark(NULL, &tkTextRightMarkType);
	sharedTextPtr->protectionMark[0] = TkTextMakeMark(NULL, NULL);
	sharedTextPtr->protectionMark[1] = TkTextMakeMark(NULL, NULL);
	sharedTextPtr->protectionMark[0]->typePtr = &tkTextProtectionMarkType;
................................................................................
     */

    TkTextCreateDInfo(textPtr);
    TkTextIndexSetupToStartOfText(&startIndex, textPtr, sharedTextPtr->tree);
    TkTextSetYView(textPtr, &startIndex, 0);
    textPtr->exportSelection = true;
    textPtr->pickEvent.type = LeaveNotify;
    textPtr->steadyMarks = sharedTextPtr->steadyMarks;
    textPtr->undo = sharedTextPtr->undo;
    textPtr->maxUndoDepth = sharedTextPtr->maxUndoDepth;
    textPtr->maxRedoDepth = sharedTextPtr->maxRedoDepth;
    textPtr->maxUndoSize = sharedTextPtr->maxUndoSize;
    textPtr->autoSeparators = sharedTextPtr->autoSeparators;
    textPtr->undoTagging = sharedTextPtr->undoTagging;

    /*
     * Create the "sel" tag and the "current" and "insert" marks.
     * Note: it is important that textPtr->selTagPtr is NULL before this
     * initial call.
     */

................................................................................
    Tcl_Obj *const objv[])	/* Argument objects. */
{
    Tk_SavedOptions savedOptions;
    TkTextIndex start, end, current;
    TkSizeT currentEpoch;
    TkSharedText *sharedTextPtr = textPtr->sharedTextPtr;
    TkTextBTree tree = sharedTextPtr->tree;
    bool copyDownFlags = false;
    bool oldExport = (textPtr->exportSelection) && (!Tcl_IsSafe(textPtr->interp));
    bool oldTextDebug = tkTextDebug;
    bool didHyphenate = textPtr->hyphenate;
    bool oldUndoTagging = textPtr->undoTagging;
    int oldHyphenRules = textPtr->hyphenRules;
    int mask = 0;


    tkTextDebug = false; /* debugging is not useful here */

#if SUPPORT_DEPRECATED_STARTLINE_ENDLINE

    /*
     * We want also to support the "-start", and "-end" abbreviations. The thing that
................................................................................
	    goto error;
	}
    }

    /*
     * Copy up shared flags.
     */

    /*
     * Update default value for undoing tag operations.
     */

    if (oldUndoTagging != textPtr->undoTagging) {
	sharedTextPtr->undoTagging = textPtr->undoTagging;
	copyDownFlags = true;
    }

    /* This flag cannot alter if we have peers. */
    sharedTextPtr->steadyMarks = textPtr->steadyMarks;

    if (sharedTextPtr->autoSeparators != textPtr->autoSeparators) {
	sharedTextPtr->autoSeparators = textPtr->autoSeparators;
	copyDownFlags = true;
................................................................................

	for (tPtr = sharedTextPtr->peers; tPtr; tPtr = tPtr->next) {
	    tPtr->autoSeparators = sharedTextPtr->autoSeparators;
	    tPtr->maxUndoDepth = sharedTextPtr->maxUndoDepth;
	    tPtr->maxRedoDepth = sharedTextPtr->maxRedoDepth;
	    tPtr->maxUndoSize = sharedTextPtr->maxUndoSize;
	    tPtr->undo = sharedTextPtr->undo;
	    tPtr->undoTagging = sharedTextPtr->undoTagging;
	}
    }

    /*
     * Check soft hyphen support.
     */

Changes to generic/tkText.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
....
1198
1199
1200
1201
1202
1203
1204

1205
1206
1207
1208
1209
1210
1211
....
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502

1503
1504
1505
1506
1507
1508
1509
/*
 * tkText.h --
 *
 *	Declarations shared among the files that implement text widgets.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1995 Sun Microsystems, Inc.
 * Copyright (c) 2015-2017 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#ifndef _TKTEXT
#define _TKTEXT
................................................................................
				 * be cleared, or the user is clearing. */
    bool userHasSetModifiedFlag;/* Flag indicating if the user has set the 'modified' flag.
    				 * Value 'true' is superseding the computed value, but value
				 * 'false' is only clearing to the initial state of this flag. */
    bool undoStackEvent;	/* Flag indicating whether <<UndoStack>> is already triggered. */
    bool pushSeparator;		/* Flag indicating whether a separator has to be pushed before next
    				 * insert/delete item. */

    unsigned undoLevel;		/* The undo level which corresponds to the unmodified state. */
    TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode was. */
    int lastUndoTokenType;	/* Type of newest undo token on stack. */
    TkTextTag **undoTagList;	/* Array of tags, prepared for undo stack. */
    TkTextMarkChange *undoMarkList;
    				/* Array of mark changes, prepared for undo stack. */
    uint32_t undoTagListCount;	/* Number of entries in array 'undoTagList'. */
................................................................................
     * Copies of information from the shared section relating to the editor control mode:
     */

    int steadyMarks;		/* false = behavior of original implementation,
    				 * true  = new editor control mode. */

    /*
     * Copies of information from the shared section relating to the undo/redo functonality:
     */

    int undo;			/* Non-zero means the undo/redo behaviour is enabled. */
    int maxUndoDepth;		/* The maximum depth of the undo stack expressed as the
    				 * maximum number of compound statements. */
    int maxRedoDepth;		/* The maximum depth of the redo stack expressed as the
    				 * maximum number of compound statements. */
    int maxUndoSize;		/* The maximum number of bytes kept on the undo stack. */
    int autoSeparators;		/* Non-zero means the separators will be inserted automatically. */


    /*
     * Support of sync command:
     */

    Tcl_Obj *afterSyncCmd;	/* Commands to be executed when lines are up to date */







|







 







>







 







|









>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
....
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
....
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
/*
 * tkText.h --
 *
 *	Declarations shared among the files that implement text widgets.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1995 Sun Microsystems, Inc.
 * Copyright (c) 2015-2018 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#ifndef _TKTEXT
#define _TKTEXT
................................................................................
				 * be cleared, or the user is clearing. */
    bool userHasSetModifiedFlag;/* Flag indicating if the user has set the 'modified' flag.
    				 * Value 'true' is superseding the computed value, but value
				 * 'false' is only clearing to the initial state of this flag. */
    bool undoStackEvent;	/* Flag indicating whether <<UndoStack>> is already triggered. */
    bool pushSeparator;		/* Flag indicating whether a separator has to be pushed before next
    				 * insert/delete item. */
    bool undoTagging;		/* Global default value for TkTextTag::undo. */
    unsigned undoLevel;		/* The undo level which corresponds to the unmodified state. */
    TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode was. */
    int lastUndoTokenType;	/* Type of newest undo token on stack. */
    TkTextTag **undoTagList;	/* Array of tags, prepared for undo stack. */
    TkTextMarkChange *undoMarkList;
    				/* Array of mark changes, prepared for undo stack. */
    uint32_t undoTagListCount;	/* Number of entries in array 'undoTagList'. */
................................................................................
     * Copies of information from the shared section relating to the editor control mode:
     */

    int steadyMarks;		/* false = behavior of original implementation,
    				 * true  = new editor control mode. */

    /*
     * Copies of information from the shared section relating to the undo/redo functionality:
     */

    int undo;			/* Non-zero means the undo/redo behaviour is enabled. */
    int maxUndoDepth;		/* The maximum depth of the undo stack expressed as the
    				 * maximum number of compound statements. */
    int maxRedoDepth;		/* The maximum depth of the redo stack expressed as the
    				 * maximum number of compound statements. */
    int maxUndoSize;		/* The maximum number of bytes kept on the undo stack. */
    int autoSeparators;		/* Non-zero means the separators will be inserted automatically. */
    bool undoTagging;		/* Global default value for TkTextTag::undo. */

    /*
     * Support of sync command:
     */

    Tcl_Obj *afterSyncCmd;	/* Commands to be executed when lines are up to date */

Changes to generic/tkTextTag.c.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
 *
 *	This module implements the "tag" subcommand of the widget command for
 *	text widgets, plus most of the other high-level functions related to
 *	tags.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 2015-2017 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"
#include "tkText.h"
................................................................................
     * No existing entry. Create a new one, initialize it, and add a pointer
     * to it to the hash table entry.
     */

    tagPtr = calloc(1, sizeof(TkTextTag));
    tagPtr->name = name;
    tagPtr->index = index;
    tagPtr->priority = textPtr->sharedTextPtr->numEnabledTags;
    tagPtr->isSelTag = isSelTag;
    tagPtr->bgStipple = 0;
    tagPtr->fgStipple = 0;
    tagPtr->justify = TK_TEXT_JUSTIFY_LEFT;
    tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE;
    tagPtr->wrapMode = TEXT_WRAPMODE_NULL;
    tagPtr->undo = !isSelTag;
    tagPtr->sharedTextPtr = sharedTextPtr;
    tagPtr->undoTagListIndex = -1;
    tagPtr->refCount = 1;
    tagPtr->tagEpoch = ++sharedTextPtr->tagEpoch;
    DEBUG_ALLOC(tkTextCountNewTag++);

    tagPtr->optionTable = Tk_CreateOptionTable(textPtr->interp, tagOptionSpecs);
    assert(!tagPtr->reliefPtr);

    textPtr->sharedTextPtr->numTags += 1;
    textPtr->sharedTextPtr->numEnabledTags += 1;

    if (isSelTag) {
	tagPtr->textPtr = textPtr;
	textPtr->refCount += 1;
	TkBitSet(sharedTextPtr->selectionTags, index);
	TkBitSet(sharedTextPtr->dontUndoTags, index);
    } else {






|







 







|






|









|
|







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
....
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
 *
 *	This module implements the "tag" subcommand of the widget command for
 *	text widgets, plus most of the other high-level functions related to
 *	tags.
 *
 * Copyright (c) 1992-1994 The Regents of the University of California.
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 * Copyright (c) 2015-2018 Gregor Cramer
 *
 * See the file "license.terms" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */

#include "tkInt.h"
#include "tkText.h"
................................................................................
     * No existing entry. Create a new one, initialize it, and add a pointer
     * to it to the hash table entry.
     */

    tagPtr = calloc(1, sizeof(TkTextTag));
    tagPtr->name = name;
    tagPtr->index = index;
    tagPtr->priority = sharedTextPtr->numEnabledTags;
    tagPtr->isSelTag = isSelTag;
    tagPtr->bgStipple = 0;
    tagPtr->fgStipple = 0;
    tagPtr->justify = TK_TEXT_JUSTIFY_LEFT;
    tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE;
    tagPtr->wrapMode = TEXT_WRAPMODE_NULL;
    tagPtr->undo = sharedTextPtr->undoTagging && !isSelTag;
    tagPtr->sharedTextPtr = sharedTextPtr;
    tagPtr->undoTagListIndex = -1;
    tagPtr->refCount = 1;
    tagPtr->tagEpoch = ++sharedTextPtr->tagEpoch;
    DEBUG_ALLOC(tkTextCountNewTag++);

    tagPtr->optionTable = Tk_CreateOptionTable(textPtr->interp, tagOptionSpecs);
    assert(!tagPtr->reliefPtr);

    sharedTextPtr->numTags += 1;
    sharedTextPtr->numEnabledTags += 1;

    if (isSelTag) {
	tagPtr->textPtr = textPtr;
	textPtr->refCount += 1;
	TkBitSet(sharedTextPtr->selectionTags, index);
	TkBitSet(sharedTextPtr->dontUndoTags, index);
    } else {

Changes to tests/text.test.

1080
1081
1082
1083
1084
1085
1086

















1087
1088
1089
1090
1091
1092
1093
test text-1.108 {configuration option: "useunibreak"} -setup {
    text .t
    pack .t
    update
} -body {
    .t configure -useunibreak eh
} -cleanup {

















    destroy .t
} -match glob -returnCodes {error} -result {*}


test text-2.1 {Tk_TextCmd procedure} -body {
    text
} -returnCodes {error} -result {wrong # args: should be "text pathName ?-option value ...?"}






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
test text-1.108 {configuration option: "useunibreak"} -setup {
    text .t
    pack .t
    update
} -body {
    .t configure -useunibreak eh
} -cleanup {
    destroy .t
} -match glob -returnCodes {error} -result {*}
test text-1.109 {configuration option: "undotagging"} -setup {
    text .t
    update
} -body {
    .t configure -undotagging 0
    .t cget -undotagging
} -cleanup {
    destroy .t
} -result {0}
test text-1.110 {configuration option: "undotagging"} -setup {
    text .t
    update
} -body {
    .t configure -undotagging eh
} -cleanup {
    destroy .t
} -match glob -returnCodes {error} -result {*}


test text-2.1 {Tk_TextCmd procedure} -body {
    text
} -returnCodes {error} -result {wrong # args: should be "text pathName ?-option value ...?"}

Changes to tests/textTag.test.

307
308
309
310
311
312
313



















314
315
316
317
318
319
320
    .t tag configure x -underlinecolor [lindex [.t tag configure x -underlinecolor] 3]
} -result {red}
test textTag-1.37 {configuration options} -body {
    .t tag configure x -underlinecolor stupid
} -cleanup {
    .t tag configure x -underlinecolor [lindex [.t tag configure x -underlinecolor] 3]
} -returnCodes error -result {unknown color name "stupid"}





















test textTag-2.1 {TkTextTagCmd - "add" option} -body {
    .t tag
} -returnCodes error -result {wrong # args: should be ".t tag option ?arg arg ...?"}
test textTag-2.2 {TkTextTagCmd - "add" option} -body {
    .t tag gorp






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
    .t tag configure x -underlinecolor [lindex [.t tag configure x -underlinecolor] 3]
} -result {red}
test textTag-1.37 {configuration options} -body {
    .t tag configure x -underlinecolor stupid
} -cleanup {
    .t tag configure x -underlinecolor [lindex [.t tag configure x -underlinecolor] 3]
} -returnCodes error -result {unknown color name "stupid"}
test textTag-1.38 {configuration options} -body {
    .t tag configure x -undo eh
} -cleanup {
    .t tag configure x -undo 1
} -returnCodes error -result {expected boolean value but got "eh"}
test textTag-1.39 {configuration options} -setup {
    .t tag configure x -underline [lindex [.t tag configure x -underline] 3]
} -body {
    .t tag cget x -undo
} -result {1}
test textTag-1.40 {configuration options} -setup {
    text .u
} -body {
    .u configure -undotagging 0
    .u tag configure x -underline 0
    .u tag cget x -undo
} -cleanup {
    destroy .u
} -result {0}


test textTag-2.1 {TkTextTagCmd - "add" option} -body {
    .t tag
} -returnCodes error -result {wrong # args: should be ".t tag option ?arg arg ...?"}
test textTag-2.2 {TkTextTagCmd - "add" option} -body {
    .t tag gorp