Tk Source Code

Check-in [882be869]
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:Add support for an 'M' binding substitution that is replaced with the number of script-based binding patterns matched so far for the event.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bindScriptCount
Files: files | file ages | folders
SHA1: 882be869bbc7f283390b79ab3ea166c80906b147
User & Date: mistachkin 2012-11-16 21:21:54
Context
2012-11-16
22:09
Add docs and tests. check-in: 055ab275 user: mistachkin tags: bindScriptCount
21:21
Add support for an 'M' binding substitution that is replaced with the number of script-based binding patterns matched so far for the event. check-in: 882be869 user: mistachkin tags: bindScriptCount
2012-11-15
09:21
merge-mark check-in: a6c854e4 user: jan.nijtmans tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.







1
2
3
4
5
6
7





2012-11-13  Jan Nijtmans  <[email protected]>

	* win/tkWinTest.c: [Bug 3585396]: winDialog.test requires user
	* tests/winDialog.test: interaction. Renumber test-cases as in
	Tk 8.6, and convert various to tcltest-2 style.

2012-11-09  Don Porter  <[email protected]>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2012-11-16  Joe Mistachkin  <[email protected]>

	* generic/tkBind.c: Add support for an 'M' binding substitution
	that is replaced with the number of script-based binding patterns
	matched so far for the event.

2012-11-13  Jan Nijtmans  <[email protected]>

	* win/tkWinTest.c: [Bug 3585396]: winDialog.test requires user
	* tests/winDialog.test: interaction. Renumber test-cases as in
	Tk 8.6, and convert various to tcltest-2 style.

2012-11-09  Don Porter  <[email protected]>

Changes to generic/tkBind.c.

656
657
658
659
660
661
662
663

664
665
666
667
668
669
670
....
1411
1412
1413
1414
1415
1416
1417

1418
1419
1420
1421
1422
1423
1424
....
1567
1568
1569
1570
1571
1572
1573

1574
1575
1576
1577
1578
1579
1580
....
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
....
2255
2256
2257
2258
2259
2260
2261


2262
2263
2264
2265
2266
2267
2268
....
2536
2537
2538
2539
2540
2541
2542



2543
2544
2545
2546
2547
2548
2549
			    VirtualEventTable *vetPtr, char *virtString,
			    char *eventString);
static int		DeleteVirtualEvent(Tcl_Interp *interp,
			    VirtualEventTable *vetPtr, char *virtString,
			    char *eventString);
static void		DeleteVirtualEventTable(VirtualEventTable *vetPtr);
static void		ExpandPercents(TkWindow *winPtr, const char *before,
			    XEvent *eventPtr,KeySym keySym,Tcl_DString *dsPtr);

static void		FreeTclBinding(ClientData clientData);
static PatSeq *		FindSequence(Tcl_Interp *interp,
			    Tcl_HashTable *patternTablePtr, ClientData object,
			    const char *eventString, int create,
			    int allowVirtual, unsigned long *maskPtr);
static void		GetAllVirtualEvents(Tcl_Interp *interp,
			    VirtualEventTable *vetPtr);
................................................................................
    ScreenInfo *screenPtr;
    BindInfo *bindInfoPtr;
    TkDisplay *oldDispPtr;
    XEvent *ringPtr;
    PatSeq *vMatchDetailList, *vMatchNoDetailList;
    int flags, oldScreen, i, deferModal;
    unsigned int matchCount, matchSpace;

    Tcl_Interp *interp;
    Tcl_DString scripts, savedResult;
    Detail detail;
    char *p, *end;
    PendingBinding staticPending, *pendingPtr;
    TkWindow *winPtr = (TkWindow *) tkwin;
    PatternTableKey key;
................................................................................
     * expanded, to "scripts", with null characters separating the scripts for
     * each object. Append all the callbacks to the array of pending
     * callbacks.
     */

    pendingPtr = &staticPending;
    matchCount = 0;

    matchSpace = sizeof(staticPending.matchArray) / sizeof(PatSeq *);
    Tcl_DStringInit(&scripts);

    for ( ; numObjects > 0; numObjects--, objectPtr++) {
	PatSeq *matchPtr = NULL, *sourcePtr = NULL;
	Tcl_HashEntry *hPtr;

................................................................................

	if (matchPtr != NULL) {
	    if (sourcePtr->eventProc == NULL) {
		Tcl_Panic("Tk_BindEvent: missing command");
	    }
	    if (sourcePtr->eventProc == EvalTclBinding) {
		ExpandPercents(winPtr, (char *) sourcePtr->clientData,
			eventPtr, detail.keySym, &scripts);
	    } else {
		if (matchCount >= matchSpace) {
		    PendingBinding *newPtr;
		    unsigned int oldSize, newSize;

		    oldSize = sizeof(staticPending)
			    - sizeof(staticPending.matchArray)
................................................................................
				 * input context. */
    const char *before,		/* Command containing percent expressions to
				 * be replaced. */
    XEvent *eventPtr,		/* X event containing information to be used
				 * in % replacements. */
    KeySym keySym,		/* KeySym: only relevant for KeyPress and
				 * KeyRelease events). */


    Tcl_DString *dsPtr)		/* Dynamic string in which to append new
				 * command. */
{
    int spaceNeeded, cvtFlags;	/* Used to substitute string as proper Tcl
				 * list element. */
    int number, flags, length;
#define NUM_SIZE 40
................................................................................
		char *name = TkKeysymToString(keySym);

		if (name != NULL) {
		    string = name;
		}
	    }
	    goto doString;



	case 'N':
	    if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
		number = (int) keySym;
		goto doNumber;
	    }
	    goto doString;
	case 'P':






|
>







 







>







 







>







 







|







 







>
>







 







>
>
>







656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
....
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
....
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
....
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
....
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
....
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
			    VirtualEventTable *vetPtr, char *virtString,
			    char *eventString);
static int		DeleteVirtualEvent(Tcl_Interp *interp,
			    VirtualEventTable *vetPtr, char *virtString,
			    char *eventString);
static void		DeleteVirtualEventTable(VirtualEventTable *vetPtr);
static void		ExpandPercents(TkWindow *winPtr, const char *before,
			    XEvent *eventPtr,KeySym keySym,
			    unsigned int scriptCount, Tcl_DString *dsPtr);
static void		FreeTclBinding(ClientData clientData);
static PatSeq *		FindSequence(Tcl_Interp *interp,
			    Tcl_HashTable *patternTablePtr, ClientData object,
			    const char *eventString, int create,
			    int allowVirtual, unsigned long *maskPtr);
static void		GetAllVirtualEvents(Tcl_Interp *interp,
			    VirtualEventTable *vetPtr);
................................................................................
    ScreenInfo *screenPtr;
    BindInfo *bindInfoPtr;
    TkDisplay *oldDispPtr;
    XEvent *ringPtr;
    PatSeq *vMatchDetailList, *vMatchNoDetailList;
    int flags, oldScreen, i, deferModal;
    unsigned int matchCount, matchSpace;
    unsigned int scriptCount;
    Tcl_Interp *interp;
    Tcl_DString scripts, savedResult;
    Detail detail;
    char *p, *end;
    PendingBinding staticPending, *pendingPtr;
    TkWindow *winPtr = (TkWindow *) tkwin;
    PatternTableKey key;
................................................................................
     * expanded, to "scripts", with null characters separating the scripts for
     * each object. Append all the callbacks to the array of pending
     * callbacks.
     */

    pendingPtr = &staticPending;
    matchCount = 0;
    scriptCount = 0;
    matchSpace = sizeof(staticPending.matchArray) / sizeof(PatSeq *);
    Tcl_DStringInit(&scripts);

    for ( ; numObjects > 0; numObjects--, objectPtr++) {
	PatSeq *matchPtr = NULL, *sourcePtr = NULL;
	Tcl_HashEntry *hPtr;

................................................................................

	if (matchPtr != NULL) {
	    if (sourcePtr->eventProc == NULL) {
		Tcl_Panic("Tk_BindEvent: missing command");
	    }
	    if (sourcePtr->eventProc == EvalTclBinding) {
		ExpandPercents(winPtr, (char *) sourcePtr->clientData,
			eventPtr, detail.keySym, scriptCount++, &scripts);
	    } else {
		if (matchCount >= matchSpace) {
		    PendingBinding *newPtr;
		    unsigned int oldSize, newSize;

		    oldSize = sizeof(staticPending)
			    - sizeof(staticPending.matchArray)
................................................................................
				 * input context. */
    const char *before,		/* Command containing percent expressions to
				 * be replaced. */
    XEvent *eventPtr,		/* X event containing information to be used
				 * in % replacements. */
    KeySym keySym,		/* KeySym: only relevant for KeyPress and
				 * KeyRelease events). */
    unsigned int scriptCount,	/* The number of script-based binding patterns
				 * matched so far for this event. */
    Tcl_DString *dsPtr)		/* Dynamic string in which to append new
				 * command. */
{
    int spaceNeeded, cvtFlags;	/* Used to substitute string as proper Tcl
				 * list element. */
    int number, flags, length;
#define NUM_SIZE 40
................................................................................
		char *name = TkKeysymToString(keySym);

		if (name != NULL) {
		    string = name;
		}
	    }
	    goto doString;
	case 'M':
	    number = scriptCount;
	    goto doNumber;
	case 'N':
	    if ((flags & KEY) && (eventPtr->type != MouseWheelEvent)) {
		number = (int) keySym;
		goto doNumber;
	    }
	    goto doString;
	case 'P':