Tk Source Code

Check-in [ef7364ed]
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:Aligned GenerateModifiedEvent() on GenerateUndoStackEvent() regarding generation of the event for each peer
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tip-446-canundo
Files: files | file ages | folders
SHA1: ef7364ed74b99bb76753d6223c54fb07112191be
User & Date: fvogel 2016-05-12 21:42:49
Context
2016-05-12
22:21
Unified branched tip-446-undodepth and tip-446-canundo to become branch tip-446 check-in: 2bfc04af user: fvogel tags: tip-446
21:42
Aligned GenerateModifiedEvent() on GenerateUndoStackEvent() regarding generation of the event for each peer Closed-Leaf check-in: ef7364ed user: fvogel tags: tip-446-canundo
21:35
Added test for the <<UndoStack>> event check-in: efe4cb36 user: fvogel tags: tip-446-canundo
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkText.c.

5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
....
5387
5388
5389
5390
5391
5392
5393

5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407


5408
5409

5410
5411
5412
5413
5414
5415
5416
....
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
....
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
	/*
	 * Only issue the <<Modified>> event if the flag actually changed.
	 * However, degree of modified-ness doesn't matter. [Bug 1799782]
	 */

	if ((!oldModified) != (!setModified)) {
            for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL;
                    textPtr = textPtr->next) {
                GenerateModifiedEvent(textPtr);
            }
	}
	break;
    case EDIT_REDO:
        if (objc != 3) {
	    Tcl_WrongNumArgs(interp, 3, objv, NULL);
	    return TCL_ERROR;
	}
................................................................................
/*
 *----------------------------------------------------------------------
 *
 * GenerateModifiedEvent --
 *
 *	Send an event that the text was modified. This is equivalent to:
 *	   event generate $textWidget <<Modified>>

 *
 * Results:
 *	None
 *
 * Side effects:
 *	May force the text window into existence.
 *
 *----------------------------------------------------------------------
 */

static void
GenerateModifiedEvent(
    TkText *textPtr)	/* Information about text widget. */
{


    Tk_MakeWindowExist(textPtr->tkwin);
    TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL);

}
 
/*
 *----------------------------------------------------------------------
 *
 * GenerateUndoStackEvent --
 *
................................................................................
 */

static void
UpdateDirtyFlag(
    TkSharedText *sharedTextPtr)/* Information about text widget. */
{
    int oldDirtyFlag;
    TkText *textPtr;

    /*
     * If we've been forced to be dirty, we stay dirty (until explicitly
     * reset, of course).
     */

    if (sharedTextPtr->dirtyMode == TK_TEXT_DIRTY_FIXED) {
................................................................................
    if (sharedTextPtr->dirtyMode == TK_TEXT_DIRTY_UNDO) {
	sharedTextPtr->isDirty--;
    } else {
	sharedTextPtr->isDirty++;
    }

    if (sharedTextPtr->isDirty == 0 || oldDirtyFlag == 0) {
	for (textPtr = sharedTextPtr->peers; textPtr != NULL;
		textPtr = textPtr->next) {
	    GenerateModifiedEvent(textPtr);
	}
    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * RunAfterSyncCmd --






<
<
|
<







 







>
|













>
>
|
|
>







 







<







 







<
<
|
<







5237
5238
5239
5240
5241
5242
5243


5244

5245
5246
5247
5248
5249
5250
5251
....
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
....
5457
5458
5459
5460
5461
5462
5463

5464
5465
5466
5467
5468
5469
5470
....
5487
5488
5489
5490
5491
5492
5493


5494

5495
5496
5497
5498
5499
5500
5501
	/*
	 * Only issue the <<Modified>> event if the flag actually changed.
	 * However, degree of modified-ness doesn't matter. [Bug 1799782]
	 */

	if ((!oldModified) != (!setModified)) {


            GenerateModifiedEvent(textPtr);

	}
	break;
    case EDIT_REDO:
        if (objc != 3) {
	    Tcl_WrongNumArgs(interp, 3, objv, NULL);
	    return TCL_ERROR;
	}
................................................................................
/*
 *----------------------------------------------------------------------
 *
 * GenerateModifiedEvent --
 *
 *	Send an event that the text was modified. This is equivalent to:
 *	   event generate $textWidget <<Modified>>
  *	for all peers of $textWidget.
*
 * Results:
 *	None
 *
 * Side effects:
 *	May force the text window into existence.
 *
 *----------------------------------------------------------------------
 */

static void
GenerateModifiedEvent(
    TkText *textPtr)	/* Information about text widget. */
{
    for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL;
            textPtr = textPtr->next) {
        Tk_MakeWindowExist(textPtr->tkwin);
        TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL);
    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * GenerateUndoStackEvent --
 *
................................................................................
 */

static void
UpdateDirtyFlag(
    TkSharedText *sharedTextPtr)/* Information about text widget. */
{
    int oldDirtyFlag;


    /*
     * If we've been forced to be dirty, we stay dirty (until explicitly
     * reset, of course).
     */

    if (sharedTextPtr->dirtyMode == TK_TEXT_DIRTY_FIXED) {
................................................................................
    if (sharedTextPtr->dirtyMode == TK_TEXT_DIRTY_UNDO) {
	sharedTextPtr->isDirty--;
    } else {
	sharedTextPtr->isDirty++;
    }

    if (sharedTextPtr->isDirty == 0 || oldDirtyFlag == 0) {


        GenerateModifiedEvent(sharedTextPtr->peers);

    }
}
 
/*
 *----------------------------------------------------------------------
 *
 * RunAfterSyncCmd --