Tk Source Code

Check-in [c2bbf946]
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:(1) Compile problem eliminated in unix/tkUnixRFont.c. (2) Problem with -wrap=none fixed, tabbing didn't work properly in this case because of a lost bugfix, see [1c8aad0efa].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | revised_text | tip-466
Files: files | file ages | folders
SHA3-256: c2bbf9464d692c24298d0409b6f5b151164a89185b0378e6354758785b802047
User & Date: gcramer 2018-10-22 12:59:10
References
2018-10-22
13:50 Ticket [1c8aad0e] Tab justifications other than "left" don't work with -wrap none status still Open with 3 other changes artifact: f0a3c455 user: gcramer
Context
2018-10-22
20:53
merge trunk check-in: 58aefded user: jan.nijtmans tags: revised_text, tip-466
12:59
(1) Compile problem eliminated in unix/tkUnixRFont.c. (2) Problem with -wrap=none fixed, tabbing didn't work properly in this case because of a lost bugfix, see [1c8aad0efa]. check-in: c2bbf946 user: gcramer tags: revised_text, tip-466
2018-10-19
22:20
Two more warnings, back with compiling against Tcl 8.7 check-in: fd92f39c user: jan.nijtmans tags: revised_text, tip-466
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkTextDisp.c.

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
....
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
....
2421
2422
2423
2424
2425
2426
2427

2428
2429
2430
2431
2432
2433
2434
....
2436
2437
2438
2439
2440
2441
2442

2443
2444
2445
2446
2447
2448
2449
....
3296
3297
3298
3299
3300
3301
3302

3303
3304
3305
3306
3307
3308
3309
....
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
.....
11993
11994
11995
11996
11997
11998
11999


12000
12001
12002
12003
12004
12005
12006
.....
12877
12878
12879
12880
12881
12882
12883

12884



12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896

12897



12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908

12909



12910
12911
12912
12913
12914
12915
12916
 *	This module provides facilities to display text widgets. It is the
 *	only place where information is kept about the screen layout of text
 *	widgets. (Well, strictly, each TkTextLine and B-tree node caches its
 *	last observed pixel height, but that information originates here).
 *
 * 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.
 */

#if defined(_MSC_VER ) && _MSC_VER < 1500
/* suppress wrong warnings to support ancient compilers */
................................................................................
/* Version 8.5 has forgotten to define this constant. */
# ifndef TK_DO_NOT_DRAW
#  define TK_DO_NOT_DRAW 0x80
# endif
# ifndef DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED
#  define DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED "1"
# endif
#else /* for partability to 8.5/6 */
# ifndef DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED
#  define DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED "0"
# endif
#endif

#include <stdlib.h>
#include <assert.h>
................................................................................
		&& (haveFocus
		    /*
		     * If this is the selection tag, and selAttrs.inactiveBorder is NULL
		     * (the default on Windows), then we need to skip it if we don't have
		     * the focus.
		     */
		    || (textPtr->selAttrs.inactiveBorder
		    /*
		     * Don't show inactive selection in readonly widgets.
		     */
		    && !(textPtr->state != TK_TEXT_STATE_NORMAL
			&& *DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED == '1')))) {
	    borderPrio = FillStyle(tagPtr, &styleValues, haveFocus, containsSelection);

	    if (borderPrio == -1) {
		if (textPtr->selAttrs.border)  { styleValues.border = textPtr->selAttrs.border; }
		if (textPtr->selAttrs.fgColor) { styleValues.fgColor = textPtr->selAttrs.fgColor; }
	    
		if (!haveFocus) {
................................................................................
 *----------------------------------------------------------------------
 */

static TkTextSegment *
LayoutGetNextSegment(
    TkTextSegment *segPtr)
{

    while ((segPtr = segPtr->nextPtr)) {
	if (segPtr->typePtr == &tkTextCharType) {
	    return segPtr;
	}
	if (segPtr->typePtr == &tkTextBranchType) {
	    segPtr = segPtr->body.branch.nextPtr;
	}
................................................................................
    return NULL;
}

static TkTextDispChunk *
LayoutGetNextCharChunk(
    TkTextDispChunk *chunkPtr)
{

    while ((chunkPtr = chunkPtr->nextPtr)) {
	switch (chunkPtr->layoutProcs->type) {
	case TEXT_DISP_CHAR:	return chunkPtr;
	case TEXT_DISP_WINDOW:	/* fallthru */
	case TEXT_DISP_IMAGE:	return NULL;
	case TEXT_DISP_HYPHEN:	/* fallthru */
	case TEXT_DISP_ELIDED:	/* fallthru */
................................................................................
}

static bool
AtEndOfLine(
    TkTextSegment *segPtr,
    int offset)
{

    if (offset < segPtr->size) {
	return false;
    }
    while ((segPtr = segPtr->nextPtr)) {
	switch (segPtr->typePtr->group) {
	case SEG_GROUP_CHAR:
	case SEG_GROUP_HYPHEN:
................................................................................
		if (dInfoPtr->dLinesInvalidated) {
		    Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap);
		    goto doScrollbars;
		}
		dlPtr->oldY = dlPtr->y;
		dlPtr->flags &= ~(NEW_LAYOUT | OLD_Y_INVALID);
#ifdef MAC_OSX_TK
	    } else if (dInfoPtr->countWindows > 0 && dlPtr->chunkPtr != NULL) {
		/*
		 * On macOS we need to redisplay all embedded windows which
		 * were moved by the call to TkScrollWindows above.  This is
		 * not necessary on Unix or Windows because XScrollWindow will
		 * have included the bounding rectangles of all of these
		 * windows in the damage region.  The macosx implementation of
		 * TkScrollWindow does not do this.  It simply generates a
................................................................................
 *----------------------------------------------------------------------
 */

static TkTextDispChunk *
FindNextTagInfoChunk(
    TkTextDispChunk *chunkPtr)
{


    for ( ; chunkPtr->nextPtr; chunkPtr = chunkPtr->nextPtr) {
	switch (chunkPtr->layoutProcs->type) {
	case TEXT_DISP_CHAR:   /* fallthru */
	case TEXT_DISP_HYPHEN: /* fallthru */
	case TEXT_DISP_IMAGE:  /* fallthru */
	case TEXT_DISP_WINDOW: return chunkPtr;
	case TEXT_DISP_ELIDED: /* fallthru */
................................................................................
	     * it to pick a desired location.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }

	    desired = MIN(tabX, data->maxX) - width/2;



	    break;

	case RIGHT:
	    /*
	     * Compute the width of all the information in the tab group, then use
	     * it to pick a desired location.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }

	    desired = MIN(tabX, data->maxX - data->tabOverhang) - width;



	    break;

	case NUMERIC:
	    /*
	     * Right justify before decimal point.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr && !chPtr->integralPart; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }

	    desired = MIN(tabX, data->maxX - data->tabOverhang) - width;



	    data->tabApplied = false;
	    break;
	}
    }

    desired += data->tabShift;







|







 







|







 







|
|
|
|
|







 







>







 







>







 







>







 







|







 







>
>







 







>
|
>
>
>












>
|
>
>
>











>
|
>
>
>







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
..
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
....
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
....
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
....
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
....
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
....
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
.....
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
.....
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
 *	This module provides facilities to display text widgets. It is the
 *	only place where information is kept about the screen layout of text
 *	widgets. (Well, strictly, each TkTextLine and B-tree node caches its
 *	last observed pixel height, but that information originates here).
 *
 * 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.
 */

#if defined(_MSC_VER ) && _MSC_VER < 1500
/* suppress wrong warnings to support ancient compilers */
................................................................................
/* Version 8.5 has forgotten to define this constant. */
# ifndef TK_DO_NOT_DRAW
#  define TK_DO_NOT_DRAW 0x80
# endif
# ifndef DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED
#  define DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED "1"
# endif
#else /* for portability to 8.5/6 */
# ifndef DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED
#  define DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED "0"
# endif
#endif

#include <stdlib.h>
#include <assert.h>
................................................................................
		&& (haveFocus
		    /*
		     * If this is the selection tag, and selAttrs.inactiveBorder is NULL
		     * (the default on Windows), then we need to skip it if we don't have
		     * the focus.
		     */
		    || (textPtr->selAttrs.inactiveBorder
			/*
			 * Don't show inactive selection in readonly widgets.
			 */
			&& (textPtr->state == TK_TEXT_STATE_NORMAL
			    || *DEF_TEXT_INACTIVE_SELECT_COLOR_DISABLED == '0')))) {
	    borderPrio = FillStyle(tagPtr, &styleValues, haveFocus, containsSelection);

	    if (borderPrio == -1) {
		if (textPtr->selAttrs.border)  { styleValues.border = textPtr->selAttrs.border; }
		if (textPtr->selAttrs.fgColor) { styleValues.fgColor = textPtr->selAttrs.fgColor; }
	    
		if (!haveFocus) {
................................................................................
 *----------------------------------------------------------------------
 */

static TkTextSegment *
LayoutGetNextSegment(
    TkTextSegment *segPtr)
{
    assert(segPtr);
    while ((segPtr = segPtr->nextPtr)) {
	if (segPtr->typePtr == &tkTextCharType) {
	    return segPtr;
	}
	if (segPtr->typePtr == &tkTextBranchType) {
	    segPtr = segPtr->body.branch.nextPtr;
	}
................................................................................
    return NULL;
}

static TkTextDispChunk *
LayoutGetNextCharChunk(
    TkTextDispChunk *chunkPtr)
{
    assert(chunkPtr);
    while ((chunkPtr = chunkPtr->nextPtr)) {
	switch (chunkPtr->layoutProcs->type) {
	case TEXT_DISP_CHAR:	return chunkPtr;
	case TEXT_DISP_WINDOW:	/* fallthru */
	case TEXT_DISP_IMAGE:	return NULL;
	case TEXT_DISP_HYPHEN:	/* fallthru */
	case TEXT_DISP_ELIDED:	/* fallthru */
................................................................................
}

static bool
AtEndOfLine(
    TkTextSegment *segPtr,
    int offset)
{
    assert(segPtr);
    if (offset < segPtr->size) {
	return false;
    }
    while ((segPtr = segPtr->nextPtr)) {
	switch (segPtr->typePtr->group) {
	case SEG_GROUP_CHAR:
	case SEG_GROUP_HYPHEN:
................................................................................
		if (dInfoPtr->dLinesInvalidated) {
		    Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap);
		    goto doScrollbars;
		}
		dlPtr->oldY = dlPtr->y;
		dlPtr->flags &= ~(NEW_LAYOUT | OLD_Y_INVALID);
#ifdef MAC_OSX_TK
	    } else if (dInfoPtr->countWindows > 0 && dlPtr->chunkPtr) {
		/*
		 * On macOS we need to redisplay all embedded windows which
		 * were moved by the call to TkScrollWindows above.  This is
		 * not necessary on Unix or Windows because XScrollWindow will
		 * have included the bounding rectangles of all of these
		 * windows in the damage region.  The macosx implementation of
		 * TkScrollWindow does not do this.  It simply generates a
................................................................................
 *----------------------------------------------------------------------
 */

static TkTextDispChunk *
FindNextTagInfoChunk(
    TkTextDispChunk *chunkPtr)
{
    assert(chunkPtr);

    for ( ; chunkPtr->nextPtr; chunkPtr = chunkPtr->nextPtr) {
	switch (chunkPtr->layoutProcs->type) {
	case TEXT_DISP_CHAR:   /* fallthru */
	case TEXT_DISP_HYPHEN: /* fallthru */
	case TEXT_DISP_IMAGE:  /* fallthru */
	case TEXT_DISP_WINDOW: return chunkPtr;
	case TEXT_DISP_ELIDED: /* fallthru */
................................................................................
	     * it to pick a desired location.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }
	    if (data->maxX >= 0) {
		desired = MIN(tabX, data->maxX) - width/2;
	    } else {
		desired = tabX - width/2;
	    }
	    break;

	case RIGHT:
	    /*
	     * Compute the width of all the information in the tab group, then use
	     * it to pick a desired location.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }
	    if (data->maxX - data->tabOverhang >= 0) {
		desired = MIN(tabX, data->maxX - data->tabOverhang) - width;
	    } else {
		desired = tabX - width;
	    }
	    break;

	case NUMERIC:
	    /*
	     * Right justify before decimal point.
	     */

	    width = 0;
	    for (chPtr = nextChunkPtr; chPtr && !chPtr->integralPart; chPtr = chPtr->nextPtr) {
		width += chPtr->width;
	    }
	    if (data->maxX - data->tabOverhang >= 0) {
		desired = MIN(tabX, data->maxX - data->tabOverhang) - width;
	    } else {
		desired = data->maxX - data->tabOverhang - width;
	    }
	    data->tabApplied = false;
	    break;
	}
    }

    desired += data->tabShift;

Changes to unix/tkUnixRFont.c.

618
619
620
621
622
623
624













625
626
627
628
629
630
631
 *
 *	Retrieve the font attributes of the actual font used to render a given
 *	character.
 *
 *----------------------------------------------------------------------
 */














void
TkpGetFontAttrsForChar(
    Tk_Window tkwin,		/* Window on the font's display */
    Tk_Font tkfont,		/* Font to query */
    int c,			/* Character of interest */
    TkFontAttributes *faPtr)	/* Output: Font attributes */
{






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







618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
 *
 *	Retrieve the font attributes of the actual font used to render a given
 *	character.
 *
 *----------------------------------------------------------------------
 */

/* we need backward compatibility */
#if TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7
# define UNICHAR Tcl_UniChar
# define TkUtfToUniChar Tcl_UtfToUniChar
#else /* if !(TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7) */
# define UNICHAR int
# if TCL_UTF_MAX > 4
#  define TkUtfToUniChar Tcl_UtfToUniChar
# else /* if TCL_UTF_MAX <= 4 */
/*extern int TkUtfToUniChar(const char *src, int *chPtr);*/
# endif /* TCL_UTF_MAX > 4 */
#endif /* TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 7 */

void
TkpGetFontAttrsForChar(
    Tk_Window tkwin,		/* Window on the font's display */
    Tk_Font tkfont,		/* Font to query */
    int c,			/* Character of interest */
    TkFontAttributes *faPtr)	/* Output: Font attributes */
{