Tk Source Code

Check-in [b5d2bf70]
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:Show cursor in any case, even if padx=0.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | revised_text | tip-466
Files: files | file ages | folders
SHA3-256: b5d2bf70cd864f05a9e0a877d16f99db4d3fb8e535b3cc00802a459330a79e45
User & Date: gcramer 2018-11-02 18:43:18
References
2018-11-02
18:45 Ticket [6e16952a] revised_text insertion cursor and -padx issues status still Open with 3 other changes artifact: 0969c0a8 user: gcramer
Context
2018-11-04
13:43
Now -insertwidth will be honored, and the visibility of the cursor at very right side will be ensured. check-in: 8317b198 user: gcramer tags: revised_text, tip-466
2018-11-02
18:43
Show cursor in any case, even if padx=0. check-in: b5d2bf70 user: gcramer tags: revised_text, tip-466
2018-10-30
13:51
Bugfix [6e16952a49]: Issue (1) fixed. check-in: 6523c540 user: gcramer tags: revised_text, tip-466
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkTextDisp.c.

6279
6280
6281
6282
6283
6284
6285







6286
6287
6288
6289
6290
6291
6292
6293
6294
....
6548
6549
6550
6551
6552
6553
6554

6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
....
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
{
    /*
     * TODO: is it possible to set the extents to zero when state=READONLY.
     * We have to test whether the cursor artefacts (in padding area) are
     * already eliminated, otherwise we cannot do this optimization.
     */








    *extent1 = MIN(textPtr->padX, textPtr->insertWidth/2);
    *extent2 = MIN(textPtr->padX, (textPtr->insertWidth + 1)/2);
}


static void
DisplayDLine(
    TkText *textPtr,	/* Text widget in which to draw line. */
    DLine *dlPtr,	/* Information about line to draw. */
................................................................................
     *
     * Another special trick: consider the padding area left/right of the line;
     * this is because the insertion cursor sometimes overflows onto that area
     * and we want to get as much of the cursor as possible.
     */

    ComputeCursorExtents(textPtr, &extent1, &extent2);

    XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC,
	    dInfoPtr->x - extent1, yOffs, dInfoPtr->maxX - dInfoPtr->x + extent1 + extent2, lineHeight,
	    dInfoPtr->x - extent1, dlPtr->y + yOffs);

    DEBUG(stats.linesRedrawn += 1);
}
 
/*
 *--------------------------------------------------------------
 *
................................................................................

	/*
	 * Now scroll the lines. This may generate damage which we handle by
	 * calling TextInvalidateRegion to mark the display blocks as stale.
	 */

	damageRgn = TkCreateRegion();
	if (TkScrollWindow(textPtr->tkwin, dInfoPtr->scrollGC, dInfoPtr->x - extent1, oldY,
		dInfoPtr->maxX - dInfoPtr->x + extent1 + extent2, height, 0, y - oldY, damageRgn)) {
	    TextInvalidateRegion(textPtr, damageRgn);
	}
	DEBUG(stats.numCopies += 1);
	TkDestroyRegion(damageRgn);
    }







>
>
>
>
>
>
>
|
|







 







>

|
|







 







|







6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
....
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
....
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
{
    /*
     * TODO: is it possible to set the extents to zero when state=READONLY.
     * We have to test whether the cursor artefacts (in padding area) are
     * already eliminated, otherwise we cannot do this optimization.
     */

    /*
     * NOTE:
     * The cursor disappears (when not using at least value 1 for the extents) if it's at the
     * very left of the first character of display line. But we prefer that the cursor is always
     * visible, thus we allow to overlap the first character in this special case.
     */

    *extent1 = MAX(1, MIN(textPtr->padX, textPtr->insertWidth/2));
    *extent2 = MAX(1, MIN(textPtr->padX, (textPtr->insertWidth + 1)/2));
}


static void
DisplayDLine(
    TkText *textPtr,	/* Text widget in which to draw line. */
    DLine *dlPtr,	/* Information about line to draw. */
................................................................................
     *
     * Another special trick: consider the padding area left/right of the line;
     * this is because the insertion cursor sometimes overflows onto that area
     * and we want to get as much of the cursor as possible.
     */

    ComputeCursorExtents(textPtr, &extent1, &extent2);
    xOffs = MAX(0, dInfoPtr->x - extent1);
    XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC,
	    xOffs, yOffs, dInfoPtr->maxX - dInfoPtr->x + extent1 + extent2, lineHeight,
	    xOffs, dlPtr->y + yOffs);

    DEBUG(stats.linesRedrawn += 1);
}
 
/*
 *--------------------------------------------------------------
 *
................................................................................

	/*
	 * Now scroll the lines. This may generate damage which we handle by
	 * calling TextInvalidateRegion to mark the display blocks as stale.
	 */

	damageRgn = TkCreateRegion();
	if (TkScrollWindow(textPtr->tkwin, dInfoPtr->scrollGC, MAX(0, dInfoPtr->x - extent1), oldY,
		dInfoPtr->maxX - dInfoPtr->x + extent1 + extent2, height, 0, y - oldY, damageRgn)) {
	    TextInvalidateRegion(textPtr, damageRgn);
	}
	DEBUG(stats.numCopies += 1);
	TkDestroyRegion(damageRgn);
    }

Changes to generic/tkTextMark.c.

2744
2745
2746
2747
2748
2749
2750





2751
2752
2753
2754
2755
2756
2757
2758
	 * The insertion cursor is off-screen. Indicate caret at 0,0 and return.
	 */

	Tk_SetCaretPos(textPtr->tkwin, 0, 0, height);
	return;
    }






    x -= halfWidth;

    Tk_SetCaretPos(textPtr->tkwin, x, screenY, height);

    if (POINTER_IS_MARKED(chunkPtr)) {
	/*
	 * HACK: We are drawing into a tailored pixmap, because Tk has no clipping;
	 * see DisplayDLine().






>
>
>
>
>
|







2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
	 * The insertion cursor is off-screen. Indicate caret at 0,0 and return.
	 */

	Tk_SetCaretPos(textPtr->tkwin, 0, 0, height);
	return;
    }

    /*
     * Always show insert cursor, so don't allow negative x position.
     * See also function ComputeCursorExtents() in file tkTextDisp.c.
     */

    x = MAX(0, x - halfWidth);

    Tk_SetCaretPos(textPtr->tkwin, x, screenY, height);

    if (POINTER_IS_MARKED(chunkPtr)) {
	/*
	 * HACK: We are drawing into a tailored pixmap, because Tk has no clipping;
	 * see DisplayDLine().