Check-in [85ea46a8c7]
Not logged in

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

Overview
Comment:improve block cursor in text widget
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 85ea46a8c74b8f6f6eed2174ddf37665f236963e
User & Date: chw 2025-04-03 21:17:13.924
Context
2025-04-04
05:11
update nagelfar to version 1.3.5 check-in: 13478202b9 user: chw tags: trunk
2025-04-03
21:20
merge with trunk check-in: 1c46e1f9b6 user: chw tags: wtf-8-experiment
21:17
improve block cursor in text widget check-in: 85ea46a8c7 user: chw tags: trunk
05:15
follow-up to check-in [b8894bb579] check-in: 664489d230 user: chw tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to jni/sdl2tk/generic/tkTextDisp.c.
2556
2557
2558
2559
2560
2561
2562
2563

2564
2565
2566
2567
2568
2569
2570
2571
2572







2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
		    (chunkPtr->nextPtr->numBytes > 0)) {
		/*
		 * Make a temporary chunk for displaying the text
		 * within the block cursor later on.
		 */
		XGCValues gcValues;
		unsigned long mask;
		Tcl_UniChar ch;

#ifdef TK_LAYOUT_WITH_BASE_CHUNKS
		CharInfo *ciPtr;
		BaseCharInfo *bciPtr;
		int chnum;
		char buf[16];
#endif

		otherChunkPtr = &tmpChunk;
		*otherChunkPtr = *(chunkPtr->nextPtr);







		otherChunkPtr->undisplayProc = NULL;
		tmpStyle = *otherChunkPtr->stylePtr;
		otherChunkPtr->stylePtr = &tmpStyle;
		tmpStyle.bgGC = None;
		mask = GCFont;
		gcValues.font = Tk_FontId(tmpStyle.sValuePtr->tkfont);
		mask |= GCForeground;
		borderPtr = (TkBorder *) textPtr->border;
		gcValues.foreground = borderPtr->bgColorPtr->pixel;
		tmpStyle.fgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues);
#ifdef TK_LAYOUT_WITH_BASE_CHUNKS
		ciPtr = (CharInfo *) otherChunkPtr->clientData;
		chnum = ciPtr->baseOffset;
		bciPtr = (BaseCharInfo *) ciPtr->baseChunkPtr->clientData;
		bci.ci = *ciPtr;
		Tcl_DStringInit(&bci.baseChars);
		bci.width = -1;
		bci.ci.baseOffset = 0;
		Tcl_UtfToUniChar(Tcl_DStringValue(&bciPtr->baseChars) + chnum,
			&ch);
		chnum = Tcl_UniCharToUtf(ch, buf);
		Tcl_DStringAppend(&bci.baseChars, buf, chnum);
		bci.ci.numBytes = Tcl_DStringLength(&bci.baseChars);
		bci.ci.chars = Tcl_DStringValue(&bci.baseChars);
		bci.ci.baseChunkPtr = otherChunkPtr;
		otherChunkPtr->clientData = (ClientData) &bci;
		otherChunkPtr->numBytes = bci.ci.numBytes;
#else
		ci = *((CharInfo *) (otherChunkPtr->clientData));
		otherChunkPtr->clientData = (ClientData) &ci;
		ci.numBytes = Tcl_UtfToUniChar(ci.chars, &ch);
		otherChunkPtr->numBytes = ci.numBytes;
		if ((ci.chars[0] == '\n') ||
			(ci.chars[0] == ' ') || (ci.chars[0] == '\t')) {
		    /*
		     * Ignore newline and other whitespace.
		     */

		    if (otherChunkPtr->stylePtr->fgGC != NULL) {
			Tk_FreeGC(textPtr->display,
				otherChunkPtr->stylePtr->fgGC);
		    }
		    otherChunkPtr = NULL;
		}
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
	    }
	    continue;
	}

	/*
	 * Don't call if elide. This tax OK since not very many visible DLines
	 * in an area, but potentially many elide ones.







|
>



<
<




>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|

|
<
|
|
|
|
|
|
<
|
|
|
|
|
|
|

|
|
|
|
<
<
<
<
<
|
<
<
<
|


<







2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567


2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590

2591
2592
2593
2594
2595
2596

2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608





2609



2610
2611
2612

2613
2614
2615
2616
2617
2618
2619
		    (chunkPtr->nextPtr->numBytes > 0)) {
		/*
		 * Make a temporary chunk for displaying the text
		 * within the block cursor later on.
		 */
		XGCValues gcValues;
		unsigned long mask;
		int endX, numBytes, ix, iy, iw, ih, charWidth = 0;
		TkTextIndex index;
#ifdef TK_LAYOUT_WITH_BASE_CHUNKS
		CharInfo *ciPtr;
		BaseCharInfo *bciPtr;


#endif

		otherChunkPtr = &tmpChunk;
		*otherChunkPtr = *(chunkPtr->nextPtr);
		TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
		TkTextIndexBbox(textPtr, &index, &ix, &iy, &iw, &ih,
			&charWidth);
		numBytes = CharChunkMeasureChars(otherChunkPtr, NULL, 0,
				0, -1, otherChunkPtr->x,
				otherChunkPtr->x + charWidth, 0, &endX);
		if (numBytes > 0) {
		    otherChunkPtr->undisplayProc = NULL;
		    tmpStyle = *otherChunkPtr->stylePtr;
		    otherChunkPtr->stylePtr = &tmpStyle;
		    tmpStyle.bgGC = None;
		    mask = GCFont;
		    gcValues.font = Tk_FontId(tmpStyle.sValuePtr->tkfont);
		    mask |= GCForeground;
		    borderPtr = (TkBorder *) textPtr->border;
		    gcValues.foreground = borderPtr->bgColorPtr->pixel;
		    tmpStyle.fgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues);
#ifdef TK_LAYOUT_WITH_BASE_CHUNKS
		    ciPtr = (CharInfo *) otherChunkPtr->clientData;

		    bciPtr = (BaseCharInfo *) ciPtr->baseChunkPtr->clientData;
		    bci.ci = *ciPtr;
		    Tcl_DStringInit(&bci.baseChars);
		    bci.width = -1;
		    Tcl_DStringAppend(&bci.baseChars,
			    Tcl_DStringValue(&bciPtr->baseChars) +

			    bci.ci.baseOffset, numBytes);
		    bci.ci.baseOffset = 0;
		    bci.ci.numBytes = Tcl_DStringLength(&bci.baseChars);
		    bci.ci.chars = Tcl_DStringValue(&bci.baseChars);
		    bci.ci.baseChunkPtr = otherChunkPtr;
		    otherChunkPtr->clientData = (ClientData) &bci;
		    otherChunkPtr->numBytes = bci.ci.numBytes;
#else
		    ci = *((CharInfo *) (otherChunkPtr->clientData));
		    otherChunkPtr->clientData = (ClientData) &ci;
		    ci.numBytes = numBytes;
		    otherChunkPtr->numBytes = ci.numBytes;





#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */



		} else {
		    otherChunkPtr = NULL;
		}

	    }
	    continue;
	}

	/*
	 * Don't call if elide. This tax OK since not very many visible DLines
	 * in an area, but potentially many elide ones.