From a485a445252972c78b1296013f221f7f838c438b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 19 Apr 2020 09:34:18 +0000 Subject: Fix [7655f65ae7]: text positioning issues in entry widgets. This is a patch from Christopher Chavez, slightly modified, and addresses the bug for Windows, Linux and macOS. --- generic/tkEntry.c | 33 ++++++++++++++++++++++++--------- generic/ttk/ttkEntry.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 9c53769..27bcfe1 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -1727,18 +1727,14 @@ DisplayEntry( } } - /* - * Draw the text in two pieces: first the unselected portion, then the - * selected portion on top of it. - */ - - Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, - entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, - entryPtr->leftIndex, entryPtr->numChars); - if (showSelection && (entryPtr->state != STATE_DISABLED) && (entryPtr->selTextGC != entryPtr->textGC) && (entryPtr->selectFirst < entryPtr->selectLast)) { + + /* + * Draw the selected and unselected portions separately. + */ + int selFirst; if (entryPtr->selectFirst < entryPtr->leftIndex) { @@ -1746,9 +1742,28 @@ DisplayEntry( } else { selFirst = entryPtr->selectFirst; } + if (entryPtr->leftIndex < selFirst) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, selFirst); + } Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC, entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, selFirst, entryPtr->selectLast); + if (entryPtr->selectLast < entryPtr->numChars) { + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->selectLast, entryPtr->numChars); + } + } else { + + /* + * Draw the entire visible text + */ + + Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC, + entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY, + entryPtr->leftIndex, entryPtr->numChars); } if (entryPtr->type == TK_SPINBOX) { diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 96f3cf2..05b4c3b 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1274,16 +1274,27 @@ static void EntryDisplay(void *clientData, Drawable d) /* Draw the text: */ gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion); - Tk_DrawTextLayout( - Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, - entryPtr->entry.layoutX, entryPtr->entry.layoutY, - leftIndex, rightIndex); - XSetClipMask(Tk_Display(tkwin), gc, None); - Tk_FreeGC(Tk_Display(tkwin), gc); - - /* Overwrite the selected portion (if any) in the -selectforeground color: - */ if (showSelection) { + + /* Draw the selected and unselected portions separately. + */ + if (leftIndex < selFirst) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, selFirst); + } + if (selLast < rightIndex) { + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + selLast, rightIndex); + } + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); + + /* Draw the selected portion in the -selectforeground color: + */ gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion); Tk_DrawTextLayout( Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, @@ -1291,6 +1302,16 @@ static void EntryDisplay(void *clientData, Drawable d) selFirst, selLast); XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); + } else { + + /* Draw the entire visible text + */ + Tk_DrawTextLayout( + Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, + entryPtr->entry.layoutX, entryPtr->entry.layoutY, + leftIndex, rightIndex); + XSetClipMask(Tk_Display(tkwin), gc, None); + Tk_FreeGC(Tk_Display(tkwin), gc); } /* Drop the region. Note that we have to manually remove the reference to -- cgit v0.12 From 981e941cbfec9cdea31b3bde6666e9a5afc6ea85 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 19 Apr 2020 10:01:26 +0000 Subject: Apply another patch by Christopher Chavez that fixes the jerk of strings on aqua when selecting text (see the ticket). There is no functional change on Windows and Linux in this patch. --- generic/tkFont.c | 27 +++++++++++++++++++++++++++ generic/tkInt.h | 4 ++++ macosx/tkMacOSXFont.c | 20 ++++++++------------ macosx/tkMacOSXInt.h | 2 +- unix/tkUnixFont.c | 32 ++++++++++++++++++++++++++++++++ win/tkWinFont.c | 31 +++++++++++++++++++++++++++++++ 6 files changed, 103 insertions(+), 13 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 0ec79a6..3a06719 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2304,6 +2304,10 @@ Tk_DrawTextLayout( * draw from the given text item. A number < 0 * means to draw all characters. */ { +#if 0 + /* Use TkDrawAngledTextLayout() implementation */ + TkDrawAngledTextLayout(display, drawable, gc, layout, x, y, 0.0, firstChar, lastChar); +#else TextLayout *layoutPtr = (TextLayout *) layout; int i, numDisplayChars, drawX; const char *firstByte, *lastByte; @@ -2333,8 +2337,14 @@ Tk_DrawTextLayout( numDisplayChars = lastChar; } lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars); +#if TK_DRAW_IN_CONTEXT + TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont, + chunkPtr->start, chunkPtr->numBytes, firstChar, + numDisplayChars - firstChar, x+chunkPtr->x, y+chunkPtr->y); +#else /* !TK_DRAW_IN_CONTEXT */ Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y); +#endif /* TK_DRAW_IN_CONTEXT */ } firstChar -= chunkPtr->numChars; lastChar -= chunkPtr->numChars; @@ -2343,6 +2353,7 @@ Tk_DrawTextLayout( } chunkPtr++; } +#endif /* Use TkDrawAngledTextLayout() implementation */ } void @@ -2395,6 +2406,21 @@ TkDrawAngledTextLayout( numDisplayChars = lastChar; } lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars); +#if TK_DRAW_IN_CONTEXT + dx = cosA * (chunkPtr->x) + sinA * (chunkPtr->y); + dy = -sinA * (chunkPtr->x) + cosA * (chunkPtr->y); + if (angle == 0.0) { + TkpDrawCharsInContext(display, drawable, gc, + layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, + firstChar, numDisplayChars - firstChar, + (int)(x + dx), (int)(y + dy)); + } else { + TkpDrawAngledCharsInContext(display, drawable, gc, + layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, + firstChar, numDisplayChars - firstChar, + x+dx, y+dy, angle); + } +#else /* !TK_DRAW_IN_CONTEXT */ dx = cosA * (chunkPtr->x + drawX) + sinA * (chunkPtr->y); dy = -sinA * (chunkPtr->x + drawX) + cosA * (chunkPtr->y); if (angle == 0.0) { @@ -2405,6 +2431,7 @@ TkDrawAngledTextLayout( TkDrawAngledChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, x+dx, y+dy, angle); } +#endif /* TK_DRAW_IN_CONTEXT */ } firstChar -= chunkPtr->numChars; lastChar -= chunkPtr->numChars; diff --git a/generic/tkInt.h b/generic/tkInt.h index 8f958ab..2f9efe8 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1231,6 +1231,10 @@ MODULE_SCOPE void TkpDrawCharsInContext(Display * display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, int rangeStart, int rangeLength, int x, int y); +MODULE_SCOPE void TkpDrawAngledCharsInContext(Display * display, + Drawable drawable, GC gc, Tk_Font tkfont, + const char *source, int numBytes, int rangeStart, + int rangeLength, double x, double y, double angle); MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont, const char *source, int numBytes, int rangeStart, int rangeLength, int maxLength, int flags, diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 2d8168d..01e6d98 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -93,10 +93,6 @@ static void InitFont(NSFont *nsFont, static int CreateNamedSystemFont(Tcl_Interp *interp, Tk_Window tkwin, const char *name, TkFontAttributes *faPtr); -static void DrawCharsInContext(Display *display, Drawable drawable, - GC gc, Tk_Font tkfont, const char *source, - int numBytes, int rangeStart, int rangeLength, - int x, int y, double angle); #pragma mark - #pragma mark Font Helpers: @@ -1115,7 +1111,7 @@ done: * Draw a string of characters on the screen. * * With ATSUI we need the line context to do this right, so we have the - * actual implementation in TkpDrawCharsInContext(). + * actual implementation in TkpDrawAngledCharsInContext(). * * Results: * None. @@ -1144,7 +1140,7 @@ Tk_DrawChars( int x, int y) /* Coordinates at which to place origin of the * string when drawing. */ { - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, 0, numBytes, x, y, 0.0); } @@ -1167,7 +1163,7 @@ TkDrawAngledChars( * string when drawing. */ double angle) /* What angle to put text at, in degrees. */ { - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, 0, numBytes, x, y, angle); } @@ -1212,12 +1208,12 @@ TkpDrawCharsInContext( * whole (not just the range) string when * drawing. */ { - DrawCharsInContext(display, drawable, gc, tkfont, source, numBytes, + TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, rangeStart, rangeLength, x, y, 0.0); } -static void -DrawCharsInContext( +void +TkpDrawAngledCharsInContext( Display *display, /* Display on which to draw. */ Drawable drawable, /* Window or pixmap in which to draw. */ GC gc, /* Graphics context for drawing characters. */ @@ -1233,10 +1229,10 @@ DrawCharsInContext( int numBytes, /* Number of bytes in string. */ int rangeStart, /* Index of first byte to draw. */ int rangeLength, /* Length of range to draw in bytes. */ - int x, int y, /* Coordinates at which to place origin of the + double x, double y, /* Coordinates at which to place origin of the * whole (not just the range) string when * drawing. */ - double angle) + double angle) /* What angle to put text at, in degrees. */ { const MacFont *fontPtr = (const MacFont *) tkfont; NSString *string; diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 9cb75d2..b6b9cca 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -180,7 +180,7 @@ MODULE_SCOPE void TkpFreeGCCache(GC gc); #define TK_MACOSX_HANDLE_EVENT_IMMEDIATELY 1024 /* - * Defines for tkTextDisp.c + * Defines for tkTextDisp.c and tkFont.c */ #define TK_LAYOUT_WITH_BASE_CHUNKS 1 diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 6e7b4c3..a1b969e 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1413,6 +1413,38 @@ TkpDrawCharsInContext( rangeLength, x+widthUntilStart, y); } +/* UNTESTED */ +void +TkpDrawAngledCharsInContext( + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; must + * be the same as font used in GC. */ + const char * source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that is + * passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart, /* Index of first byte to draw. */ + int rangeLength, /* Length of range to draw in bytes. */ + double x, double y, /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ + double angle) /* What angle to put text at, in degrees. */ +{ + int widthUntilStart; + + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); + TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, + rangeLength, x+widthUntilStart, y, angle); +} + /* *------------------------------------------------------------------------- * diff --git a/win/tkWinFont.c b/win/tkWinFont.c index cef505a..39abda4 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1402,6 +1402,37 @@ TkpDrawCharsInContext( rangeLength, x+widthUntilStart, y); } +/* UNTESTED */ +void +TkpDrawAngledCharsInContext( + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; must + * be the same as font used in GC. */ + const char * source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that is + * passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart, /* Index of first byte to draw. */ + int rangeLength, /* Length of range to draw in bytes. */ + double x, double y, /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ + double angle) /* What angle to put text at, in degrees. */ +{ + int widthUntilStart; + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); + TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, + rangeLength, x+widthUntilStart, y, angle); +} + /* *------------------------------------------------------------------------- * -- cgit v0.12 From 5ed4790f7555c57fa47e3467c819aa111c632978 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 21 Apr 2020 06:57:35 +0000 Subject: Apply a third patch from Christopher Chavez. --- unix/tkUnixFont.c | 4 +-- unix/tkUnixRFont.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ win/tkWinFont.c | 4 +-- 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index a1b969e..c91da55 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1413,7 +1413,6 @@ TkpDrawCharsInContext( rangeLength, x+widthUntilStart, y); } -/* UNTESTED */ void TkpDrawAngledCharsInContext( Display *display, /* Display on which to draw. */ @@ -1437,12 +1436,13 @@ TkpDrawAngledCharsInContext( double angle) /* What angle to put text at, in degrees. */ { int widthUntilStart; + double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); (void) numBytes; /*unused*/ Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x+widthUntilStart, y, angle); + rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle); } /* diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 2c3d91f..069598f 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -1300,6 +1300,86 @@ TkDrawAngledChars( } } +/* + *--------------------------------------------------------------------------- + * + * TkpDrawCharsInContext -- + * + * Draw a string of characters on the screen like Tk_DrawChars(), but + * with access to all the characters on the line for context. On X11 this + * context isn't consulted, so we just call Tk_DrawChars(). + * + * Results: + * None. + * + * Side effects: + * Information gets drawn on the screen. + * + *--------------------------------------------------------------------------- + */ + +void +TkpDrawCharsInContext( + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; + * must be the same as font used in GC. */ + const char *source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that + * is passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart, /* Index of first byte to draw. */ + int rangeLength, /* Length of range to draw in bytes. */ + int x, int y) /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ +{ + int widthUntilStart; + + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); + Tk_DrawChars(display, drawable, gc, tkfont, source + rangeStart, + rangeLength, x+widthUntilStart, y); +} + +void +TkpDrawAngledCharsInContext( + Display *display, /* Display on which to draw. */ + Drawable drawable, /* Window or pixmap in which to draw. */ + GC gc, /* Graphics context for drawing characters. */ + Tk_Font tkfont, /* Font in which characters will be drawn; must + * be the same as font used in GC. */ + const char * source, /* UTF-8 string to be displayed. Need not be + * '\0' terminated. All Tk meta-characters + * (tabs, control characters, and newlines) + * should be stripped out of the string that is + * passed to this function. If they are not + * stripped out, they will be displayed as + * regular printing characters. */ + int numBytes, /* Number of bytes in string. */ + int rangeStart, /* Index of first byte to draw. */ + int rangeLength, /* Length of range to draw in bytes. */ + double x, double y, /* Coordinates at which to place origin of the + * whole (not just the range) string when + * drawing. */ + double angle) /* What angle to put text at, in degrees. */ +{ + int widthUntilStart; + double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); + + (void) numBytes; /*unused*/ + + Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); + TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, + rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle); +} + void TkUnixSetXftClipRegion( TkRegion clipRegion) /* The clipping region to install. */ diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 39abda4..91f8f14 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1402,7 +1402,6 @@ TkpDrawCharsInContext( rangeLength, x+widthUntilStart, y); } -/* UNTESTED */ void TkpDrawAngledCharsInContext( Display *display, /* Display on which to draw. */ @@ -1426,11 +1425,12 @@ TkpDrawAngledCharsInContext( double angle) /* What angle to put text at, in degrees. */ { int widthUntilStart; + double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0); (void) numBytes; /*unused*/ Tk_MeasureChars(tkfont, source, rangeStart, -1, 0, &widthUntilStart); TkDrawAngledChars(display, drawable, gc, tkfont, source + rangeStart, - rangeLength, x+widthUntilStart, y, angle); + rangeLength, x+cosA*widthUntilStart, y-sinA*widthUntilStart, angle); } /* -- cgit v0.12 From 885c5afec0135384958c33bab6774da2215f8bab Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Jul 2020 20:33:17 +0000 Subject: Fix [09abd739b5]: bind-13.14 fails on Debian 10. --- unix/tkUnixKey.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index f6478ef..668be15 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -367,8 +367,18 @@ TkpGetKeySym( index += 1; } - sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, - index); + if (eventPtr->xkey.keycode > 0xff) { + + /* + * X11 keycodes always lie in the inclusive range [8,255]. + */ + + sym = NoSymbol; + return sym; + } else { + sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, + index); + } /* * Special handling: if the key was shifted because of Lock, but lock is -- cgit v0.12 From 02c0e0f004c8958c75dc94c71943cd4b0f46350c Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Jul 2020 20:39:19 +0000 Subject: Same fix, code organized differently --- unix/tkUnixKey.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 668be15..757cb0f 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -320,6 +320,14 @@ TkpGetKeySym( TkKeyEvent* kePtr = (TkKeyEvent*) eventPtr; /* + * X11 keycodes always lie in the inclusive range [8,255]. + */ + + if (eventPtr->xkey.keycode > 0xff) { + return NoSymbol; + } + + /* * Refresh the mapping information if it's stale. This must happen before * we do any input method processing. [Bug 3599312] */ @@ -366,19 +374,9 @@ TkpGetKeySym( && (eventPtr->xkey.state & LockMask))) { index += 1; } - - if (eventPtr->xkey.keycode > 0xff) { - /* - * X11 keycodes always lie in the inclusive range [8,255]. - */ - - sym = NoSymbol; - return sym; - } else { - sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, - index); - } + sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, + index); /* * Special handling: if the key was shifted because of Lock, but lock is -- cgit v0.12 From 47116a3ec3ac7f6442f634b96a926dec2691285b Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 7 Jul 2020 20:41:31 +0000 Subject: Fix blank space --- unix/tkUnixKey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c index 757cb0f..4e150f7 100644 --- a/unix/tkUnixKey.c +++ b/unix/tkUnixKey.c @@ -374,9 +374,9 @@ TkpGetKeySym( && (eventPtr->xkey.state & LockMask))) { index += 1; } - + sym = TkKeycodeToKeysym(dispPtr, eventPtr->xkey.keycode, 0, - index); + index); /* * Special handling: if the key was shifted because of Lock, but lock is -- cgit v0.12 From 3018d78340026597655745f383e8f4c2e4e9505d Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 8 Jul 2020 20:36:06 +0000 Subject: Fix [34214bbdae]: typographical fixes in comments. Thanks to Christopher Chavez. --- generic/tkBind.c | 2 +- generic/tkCanvPs.c | 2 +- generic/tkEntry.c | 4 ++-- generic/tkInt.h | 2 +- generic/tkTextDisp.c | 4 ++-- generic/tkTextTag.c | 2 +- generic/ttk/ttkEntry.c | 2 +- macosx/tkMacOSXColor.c | 2 +- macosx/tkMacOSXDialog.c | 2 +- macosx/tkMacOSXKeyEvent.c | 2 +- macosx/tkMacOSXKeysyms.h | 2 +- macosx/tkMacOSXMenubutton.c | 2 +- macosx/tkMacOSXMouseEvent.c | 6 +++--- macosx/tkMacOSXNotify.c | 2 +- macosx/tkMacOSXSend.c | 2 +- macosx/tkMacOSXSubwindows.c | 8 ++++---- macosx/tkMacOSXWindowEvent.c | 18 +++++++++--------- macosx/tkMacOSXWm.c | 2 +- win/makefile.vc | 4 ++-- win/tkWinKey.c | 2 +- win/tkWinWm.c | 2 +- win/tkWinX.c | 2 +- win/ttkWinTheme.c | 2 +- xlib/X11/Xlib.h | 8 ++++---- xlib/X11/keysymdef.h | 2 +- 25 files changed, 44 insertions(+), 44 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index eacdf56..b3bddc9 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3506,7 +3506,7 @@ DeleteVirtualEventTable( * already defined, the new definition augments those that already exist. * * Results: - * The return value is TCL_ERROR if an error occured while creating the + * The return value is TCL_ERROR if an error occurred while creating the * virtual binding. In this case, an error message will be left in the * interp's result. If all went well then the return value is TCL_OK. * diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c index bcd1d13..1a8b3d3 100644 --- a/generic/tkCanvPs.c +++ b/generic/tkCanvPs.c @@ -1601,7 +1601,7 @@ Tk_PostscriptPhoto( /* * Generate data for image in monochrome mode. No attempt at * dithering is made--instead, just set a threshold. To handle - * transparecies we need to output two lines: one for the black + * transparencies we need to output two lines: one for the black * pixels, one for the white ones. */ diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 5fbff40..8141daf 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -3268,7 +3268,7 @@ EntryValidate( * * Results: * TCL_OK if the validatecommand accepts the new string, TCL_ERROR if any - * problems occured with validatecommand. + * problems occurred with validatecommand. * * Side effects: * The insertion/deletion may be aborted, and the validatecommand might @@ -3329,7 +3329,7 @@ EntryValidateChange( /* * If e->validate has become VALIDATE_NONE during the validation, or we * now have VALIDATE_VAR set (from EntrySetValue) and didn't before, it - * means that a loop condition almost occured. Do not allow this + * means that a loop condition almost occurred. Do not allow this * validation result to finish. */ diff --git a/generic/tkInt.h b/generic/tkInt.h index 3a8328f..22460fb 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -692,7 +692,7 @@ typedef struct TkWindow { Visual *visual; /* Visual to use for window. If not default, * MUST be set before X window is created. */ int depth; /* Number of bits/pixel. */ - Window window; /* X's id for window. NULL means window hasn't + Window window; /* X's id for window. None means window hasn't * actually been created yet, or it's been * deleted. */ struct TkWindow *childList; /* First in list of child windows, or NULL if diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 93b56aa..6d680f6 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -1367,7 +1367,7 @@ LayoutDLine( * expectations in the rest of the code, but we are able to skip * elided portions of the line quickly. * - * If current chunk is elided and last chunk was too, coalese. + * If current chunk is elided and last chunk was too, coalesce. * * This also means that each logical line which is entirely elided * still gets laid out into a DLine, but with zero height. This isn't @@ -5275,7 +5275,7 @@ TkTextRelayoutWindow( /* * Invalidate cached scrollbar positions, so that scrollbars sliders will - * be udpated. + * be updated. */ dInfoPtr->xScrollFirst = dInfoPtr->xScrollLast = -1; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 0d223fe..f7e4294 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -1440,7 +1440,7 @@ ChangeTagPriority( void TkTextBindProc( - ClientData clientData, /* Pointer to canvas structure. */ + ClientData clientData, /* Pointer to text widget structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkText *textPtr = clientData; diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 29f69a1..770d8ff 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -557,7 +557,7 @@ static int EntryNeedsValidation(VMODE vmode, VREASON reason) * Returns: * TCL_OK if the change is accepted * TCL_BREAK if the change is rejected - * TCL_ERROR if any errors occured + * TCL_ERROR if any errors occurred * * The change will be rejected if -validatecommand returns 0, * or if -validatecommand or -invalidcommand modifies the value. diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 5b59b58..a0eaa84 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -506,7 +506,7 @@ TkSetMacColor( * Results: * None resp. retained CGColorRef for CopyCachedColor() * - * Side effects:M + * Side effects: * None. * *---------------------------------------------------------------------- diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index ceaa2ac..026439f 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -1680,7 +1680,7 @@ enum FontchooserOption { * None. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index e0b0094..b0d91ad 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -771,7 +771,7 @@ TkMacOSXGetModalSession(void) * This enables correct placement of the popups used for character * selection by the NSTextInputClient. It gets called by text entry * widgets whenever the cursor is drawn. It does nothing if the widget's - * NSWindow is not the current KeyWindow. Otherwise it udpates the + * NSWindow is not the current KeyWindow. Otherwise it updates the * display's caret structure and records the caret geometry in static * variables for use by the NSTextInputClient implementation. Any * widget passed to this function will be marked as being able to input diff --git a/macosx/tkMacOSXKeysyms.h b/macosx/tkMacOSXKeysyms.h index d84d1b9..da364ea 100644 --- a/macosx/tkMacOSXKeysyms.h +++ b/macosx/tkMacOSXKeysyms.h @@ -91,7 +91,7 @@ static const KeyInfo keyArray[] = { {114, XK_Help, NSHelpFunctionKey}, {115, XK_Home, NSHomeFunctionKey}, /* Fn Left */ {116, XK_Page_Up, NSPageUpFunctionKey}, /* Fn Up */ - {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Deleete */ + {117, XK_Delete, NSDeleteFunctionKey}, /* Fn Delete */ {118, XK_F4, NSF4FunctionKey}, {119, XK_End, NSEndFunctionKey}, /* Fn Right */ {120, XK_F2, NSF2FunctionKey}, diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index b6603b2..d1f429e 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -362,7 +362,7 @@ TkpComputeMenuButtonGeometry(butPtr) * * DrawMenuButtonImageAndText -- * - * Draws the image and text associated witha button or label. + * Draws the image and text associated with a button or label. * * Results: * None. diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 4e0b644..f274a07 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -502,7 +502,7 @@ XQueryPointer( * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- @@ -540,7 +540,7 @@ TkGenerateButtonEventForXPointer( * True if event(s) are generated, false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- @@ -592,7 +592,7 @@ TkGenerateButtonEvent( * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. Grab state may + * Additional events may be placed on the Tk event queue. Grab state may * also change. * *---------------------------------------------------------------------- diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index 96c9a7a..6120ae5 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -302,7 +302,7 @@ TkMacOSXNotifyExitHandler( * TkMacOSXEventsSetupProc -- * * This procedure implements the setup part of the MacOSX event source. It - * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsProc to + * is invoked by Tcl_DoOneEvent before calling TkMacOSXEventsCheckProc to * process all queued NSEvents. In our case, all we need to do is to set * the Tcl MaxBlockTime to 0 before starting the loop to process all * queued NSEvents. diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index 8b65532..a651bcd 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -3,7 +3,7 @@ * * This file provides procedures that implement the "send" command, * allowing commands to be passed from interpreter to interpreter. This - * current implementation for the Mac has most functionality stubed out. + * current implementation for the Mac has most functionality stubbed out. * * The current plan, which we have not had time to implement, is for the * first Wish app to create a gestalt of type 'WIsH'. This gestalt will diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 6602564..b085ba4 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -38,7 +38,7 @@ static void NotifyVisibility(TkWindow *winPtr, XEvent *eventPtr); * * XDestroyWindow -- * - * Dealocates the given X Window. + * Deallocates the given X Window. * * Results: * The window id is returned. @@ -820,7 +820,7 @@ TkMacOSXUpdateClipRgn( /* * Clip away the area of any windows that may obscure this window. - * For a non-toplevel window, first, clip to the parents visible + * For a non-toplevel window, first, clip to the parent's visible * clip region. Second, clip away any siblings that are higher in * the stacking order. For an embedded toplevel, just clip to the * container's visible clip region. Remember, we only allow one @@ -1275,7 +1275,7 @@ TkMacOSXInvalClipRgns( * * TkMacOSXWinBounds -- * - * Given a Tk window this function determines the windows bounds in + * Given a Tk window this function determines the window's bounds in * relation to the Macintosh window's coordinate system. This is also the * same coordinate system as the Tk toplevel window in which this window * is contained. @@ -1307,7 +1307,7 @@ TkMacOSXWinBounds( * * TkMacOSXWinCGBounds -- * - * Given a Tk window this function determines the windows bounds in + * Given a Tk window this function determines the window's bounds in * relation to the Macintosh window's coordinate system. This is also the * same coordinate system as the Tk toplevel window in which this window * is contained. diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 61b647e..17f8585 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -424,16 +424,16 @@ TkpWillDrawWidget(Tk_Window tkwin) { * * GenerateUpdates -- * - * Given a Macintosh update region and a Tk window this function geneates + * Given a Macintosh update region and a Tk window this function generates * an X Expose event for the window if it meets the update region. The - * function will then recursivly have each damaged window generate Expose + * function will then recursively have each damaged window generate Expose * events for its child windows. * * Results: * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ @@ -458,7 +458,7 @@ GenerateUpdates( } /* - * Compute the bounding box of the area that the damage occured in. + * Compute the bounding box of the area that the damage occurred in. */ boundsRgn = HIShapeCreateWithRect(&bounds); @@ -532,7 +532,7 @@ GenerateUpdates( * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ @@ -560,7 +560,7 @@ GenerateActivateEvents( * None. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ @@ -584,7 +584,7 @@ DoWindowActivate( * True if event(s) are generated - false otherwise. * * Side effects: - * Additional events may be place on the Tk event queue. + * Additional events may be placed on the Tk event queue. * *---------------------------------------------------------------------- */ @@ -742,7 +742,7 @@ TkGenWMConfigureEvent( /* * Now set up the changes structure. Under X we wait for the - * ConfigureNotify to set these values. On the Mac we know imediatly that + * ConfigureNotify to set these values. On the Mac we know immediately that * this is what we want - so we just set them. However, we need to make * sure the windows clipping region is marked invalid so the change is * visible to the subwindow. @@ -934,7 +934,7 @@ RedisplayView( NSView *view = (NSView *) clientdata; /* - * Make sure that we are not trying to displaying a view that no longer + * Make sure that we are not trying to display a view that no longer * exists. Must call [NSApp windows] because [NSApp orderedWindows] excludes * floating/utility windows and other window panels. */ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d7df594..8e52278 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -4052,7 +4052,7 @@ TopLevelEventProc( TkMacOSXDbgMsg("TopLevelEventProc: %s deleted", winPtr->pathName); } } else if (eventPtr->type == ReparentNotify) { - Tcl_Panic("recieved unwanted reparent event"); + Tcl_Panic("received unwanted reparent event"); } } diff --git a/win/makefile.vc b/win/makefile.vc index fda0ff2..84c4e81 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -58,7 +58,7 @@ # 64-bit compiler, if your SDK has it. # # Examples: -# Assumign Tcl sources lie in ../../tcl +# Assuming Tcl sources lie in ../../tcl # c:\tcl_src\win\>nmake -f makefile.vc release # If Tcl sources are not in ../../tcl, use the TCLDIR macro to specify dir # c:\tcl_src\win\>nmake -f makefile.vc release TCLDIR=c:\src\tcl @@ -66,7 +66,7 @@ # c:\tcl_src\win\>nmake -f makefile.vc test # Install Tk in location specified by INSTALLDIR macro # c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl -# Build release with PDF files +# Build release with PDB files # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=pdbs # Build debug version # c:\tcl_src\win\>nmake -f makefile.vc release OPTS=symbols diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 4451296..0cd086c 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -110,7 +110,7 @@ TkpGetString( } else if (keyEv->send_event == -3) { /* - * Special case for WM_UNICHAR and win2000 multi-lingal IME input + * Special case for WM_UNICHAR and win2000 multilingual IME input */ len = TkUniCharToUtf(keyEv->keycode, buf); diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 9307503..f7ba611 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -2037,7 +2037,7 @@ UpdateWrapper( * Pick the decorative frame style. Override redirect windows get * created as undecorated popups if they have no transient parent, * otherwise they are children. This allows splash screens to operate - * as an independent window, while having dropdows (like for a + * as an independent window, while having dropdowns (like for a * combobox) not grab focus away from their parent. Transient windows * get a modal dialog frame. Neither override, nor transient windows * appear in the Windows taskbar. Note that a transient window does diff --git a/win/tkWinX.c b/win/tkWinX.c index f445fce..8616369 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -1354,7 +1354,7 @@ GenerateXEvent( * GetState -- * * This function constructs a state mask for the mouse buttons and - * modifier keys as they were before the event occured. + * modifier keys as they were before the event occurred. * * Results: * Returns a composite value of all the modifier and button state flags diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index 63e9704..b0468fd 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -7,7 +7,7 @@ #include -#ifndef DFCS_HOT /* Windows 98/Me, Windows 200/XP only */ +#ifndef DFCS_HOT /* Windows 98/Me, Windows 2000/XP only */ #define DFCS_HOT 0 #endif diff --git a/xlib/X11/Xlib.h b/xlib/X11/Xlib.h index 7969ff5..91aab57 100644 --- a/xlib/X11/Xlib.h +++ b/xlib/X11/Xlib.h @@ -541,7 +541,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -559,7 +559,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -577,7 +577,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ @@ -594,7 +594,7 @@ typedef struct { Bool send_event; /* true if this came from a SendEvent request */ Display *display; /* Display the event was read from */ Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occured on */ + Window root; /* root window that the event occurred on */ Window subwindow; /* child window */ Time time; /* milliseconds */ int x, y; /* pointer x, y coordinates in event window */ diff --git a/xlib/X11/keysymdef.h b/xlib/X11/keysymdef.h index 460c72d..d334cf2 100644 --- a/xlib/X11/keysymdef.h +++ b/xlib/X11/keysymdef.h @@ -30,7 +30,7 @@ SOFTWARE. /* * TTY Functions, cleverly chosen to map to ascii, for convenience of * programming, but could have been arbitrary (at the cost of lookup - * tables in client code. + * tables in client code). */ #define XK_BackSpace 0xFF08 /* back space, back char */ -- cgit v0.12 From 8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 10 Jul 2020 07:04:29 +0000 Subject: Minor bindings cleanup. Some removal of "expr" when we can do without it. Some KeyPress -> Key changes (which are synonymes). Some implicit specifications in stead of simply <1> (making clear this is not a binding to the "1" key). --- library/bgerror.tcl | 12 +++++----- library/demos/ctext.tcl | 14 +++++------ library/entry.tcl | 63 +++++++++++++++++++++---------------------------- library/tearoff.tcl | 10 ++++---- 4 files changed, 45 insertions(+), 54 deletions(-) diff --git a/library/bgerror.tcl b/library/bgerror.tcl index 8421924..fe8dfe0 100644 --- a/library/bgerror.tcl +++ b/library/bgerror.tcl @@ -41,7 +41,7 @@ proc ::tk::dialog::error::Details {} { set w .bgerrorDialog set caption [option get $w.function text {}] set command [option get $w.function command {}] - if { ($caption eq "") || ($command eq "") } { + if {($caption eq "") || ($command eq "")} { grid forget $w.function } lappend command [$w.top.info.text get 1.0 end-1c] @@ -50,7 +50,7 @@ proc ::tk::dialog::error::Details {} { } proc ::tk::dialog::error::SaveToLog {text} { - if { $::tcl_platform(platform) eq "windows" } { + if {$::tcl_platform(platform) eq "windows"} { set allFiles *.* } else { set allFiles * @@ -129,11 +129,11 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} { set lines 0 set maxLine 45 foreach line [split $err \n] { - if { [string length $line] > $maxLine } { - append displayedErr "[string range $line 0 [expr {$maxLine-3}]]..." + if {[string length $line] > $maxLine} { + append displayedErr "[string range $line 0 $maxLine-3]..." break } - if { $lines > 4 } { + if {$lines > 4} { append displayedErr "..." break } else { @@ -182,7 +182,7 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} { pack $W.text -side left -expand yes -fill both $W.text insert 0.0 "$err\n$info" $W.text mark set insert 0.0 - bind $W.text { focus %W } + bind $W.text {focus %W} $W.text configure -state disabled # 2. Fill the top part with bitmap and message diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index a3b4e8a..502c9d0 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -41,16 +41,16 @@ $c create rectangle 245 195 255 205 -outline black -fill red # First, create the text item and give it bindings so it can be edited. $c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left] -$c bind text <1> "textB1Press $c %x %y" +$c bind text "textB1Press $c %x %y" $c bind text "textB1Move $c %x %y" -$c bind text "$c select adjust current @%x,%y" +$c bind text "$c select adjust current @%x,%y" $c bind text "textB1Move $c %x %y" -$c bind text "textInsert $c %A" +$c bind text "textInsert $c %A" $c bind text "textInsert $c \\n" $c bind text "textBs $c" $c bind text "textBs $c" $c bind text "textDel $c" -$c bind text <2> "textPaste $c @%x,%y" +$c bind text "textPaste $c @%x,%y" # Next, create some items that allow the text's anchor position # to be edited. @@ -58,14 +58,14 @@ $c bind text <2> "textPaste $c @%x,%y" proc mkTextConfigBox {w x y option value color} { set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \ -outline black -fill $color -width 1] - $w bind $item <1> "$w itemconf text $option $value" + $w bind $item "$w itemconf text $option $value" $w addtag config withtag $item } proc mkTextConfigPie {w x y a option value color} { set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \ -start [expr {$a-15}] -extent 30 -outline black -fill $color \ -width 1] - $w bind $item <1> "$w itemconf text $option $value" + $w bind $item "$w itemconf text $option $value" $w addtag config withtag $item } @@ -84,7 +84,7 @@ mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color set item [$c create rect \ [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \ -outline black -fill red] -$c bind $item <1> "$c itemconf text -anchor center" +$c bind $item "$c itemconf text -anchor center" $c create text [expr {$x+45}] [expr {$y-5}] \ -text {Text Position} -anchor s -font {Times 20} -fill brown diff --git a/library/entry.tcl b/library/entry.tcl index da3f800..6539af7 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -58,7 +58,7 @@ bind Entry <> { } bind Entry <> { # ignore if there is no selection - catch { %W delete sel.first sel.last } + catch {%W delete sel.first sel.last} } bind Entry <> { if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] @@ -74,7 +74,7 @@ bind Entry <> { # Standard Motif bindings: -bind Entry <1> { +bind Entry { tk::EntryButton1 %W %x %W selection clear } @@ -82,25 +82,25 @@ bind Entry { set tk::Priv(x) %x tk::EntryMouseSelect %W %x } -bind Entry { +bind Entry { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry { +bind Entry { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry { +bind Entry { set tk::Priv(selectMode) char %W selection adjust @%x } -bind Entry { +bind Entry { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x } -bind Entry { +bind Entry { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x } @@ -114,22 +114,22 @@ bind Entry { bind Entry { tk::CancelRepeat } -bind Entry { +bind Entry { %W icursor @%x } bind Entry <> { - tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert]-1}] } bind Entry <> { - tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert]+1}] } bind Entry <> { - tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + tk::EntryKeySelect %W [expr {[%W index insert]-1}] tk::EntrySeeInsert %W } bind Entry <> { - tk::EntryKeySelect %W [expr {[%W index insert] + 1}] + tk::EntryKeySelect %W [expr {[%W index insert]+1}] tk::EntrySeeInsert %W } bind Entry <> { @@ -190,19 +190,19 @@ bind Entry <> { bind Entry <> { %W selection clear } -bind Entry { +bind Entry { tk::CancelRepeat tk::EntryInsert %W %A } # Ignore all Alt, Meta, and Control keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the -# class binding will also fire and insert the character, +# class binding will also fire and insert the character, # which is wrong. Ditto for Escape, Return, and Tab. -bind Entry {# nothing} -bind Entry {# nothing} -bind Entry {# nothing} +bind Entry {# nothing} +bind Entry {# nothing} +bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} @@ -210,7 +210,7 @@ bind Entry {# nothing} bind Entry {# nothing} bind Entry {# nothing} if {[tk windowingsystem] eq "aqua"} { - bind Entry {# nothing} + bind Entry {# nothing} } # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <> {# nothing} @@ -278,7 +278,7 @@ bind Entry <> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <> { - if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} { bell } else { %W selection range $mark insert @@ -294,7 +294,7 @@ bind Entry <> { # A few additional bindings of my own. if {[tk windowingsystem] ne "aqua"} { - bind Entry <2> { + bind Entry { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -305,7 +305,7 @@ if {[tk windowingsystem] ne "aqua"} { } } } else { - bind Entry <3> { + bind Entry { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -391,10 +391,10 @@ proc ::tk::EntryMouseSelect {w x} { word { if {$cur < $anchor} { set before [tcl_wordBreakBefore [$w get] $cur] - set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + set after [tcl_wordBreakAfter [$w get] $anchor-1] } elseif {$cur > $anchor} { set before [tcl_wordBreakBefore [$w get] $anchor] - set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + set after [tcl_wordBreakAfter [$w get] $cur-1] } else { if {[$w index @$Priv(pressX)] < $anchor} { incr anchor -1 @@ -520,7 +520,7 @@ proc ::tk::EntryBackspace w { } else { set x [$w index insert] if {$x > 0} { - $w delete [expr {$x - 1}] + $w delete [expr {$x-1}] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -580,7 +580,7 @@ proc ::tk::EntryTranspose w { } set first [expr {$i-2}] set data [$w get] - set new [string index $data [expr {$i-1}]][string index $data $first] + set new [string index $data $i-1][string index $data $first] $w delete $first $i $w insert insert $new EntrySeeInsert $w @@ -660,7 +660,7 @@ proc ::tk::EntryScanMark {w x} { proc ::tk::EntryScanDrag {w x} { # Make sure these exist, as some weird situations can trigger the # motion binding without the initial press. [Bug #220269] - if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x } + if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x} # allow for a delta if {abs($x-$::tk::Priv(x)) > 2} { set ::tk::Priv(mouseMoved) 1 @@ -677,19 +677,10 @@ proc ::tk::EntryScanDrag {w x} { proc ::tk::EntryGetSelection {w} { set entryString [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] if {[$w cget -show] ne ""} { return [string repeat [string index [$w cget -show] 0] \ [string length $entryString]] } return $entryString } - - - - - - - - - diff --git a/library/tearoff.tcl b/library/tearoff.tcl index c2d2d6b..4c8b404 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -39,7 +39,7 @@ proc ::tk::TearOffMenu {w {x 0} {y 0}} { # Shift by height of tearoff entry minus height of window titlebar catch {incr y [expr {[$w yposition 1] - 16}]} # Avoid the native menu bar which sits on top of everything. - if {$y < 22} { set y 22 } + if {$y < 22} {set y 22} } } @@ -155,9 +155,9 @@ proc ::tk::MenuDup {src dst type} { while {[set index [string first $src $tags]] != -1} { if {$index > 0} { - append x [string range $tags 0 [expr {$index - 1}]]$dst + append x [string range $tags 0 $index-1]$dst } - set tags [string range $tags [expr {$index + $srcLen}] end] + set tags [string range $tags $index+$srcLen end] } append x $tags @@ -172,10 +172,10 @@ proc ::tk::MenuDup {src dst type} { while {[set index [string first $event $script]] != -1} { if {$index > 0} { - append x [string range $script 0 [expr {$index - 1}]] + append x [string range $script 0 $index-1] } append x $dst - set script [string range $script [expr {$index + $eventLen}] end] + set script [string range $script $index+$eventLen end] } append x $script -- cgit v0.12 From 55208e8f833e1be79f085fa7cd1519b97fa9cb23 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 12 Jul 2020 09:25:49 +0000 Subject: Fix regression introduced by [f7f8ba2e3e]. Patch by Christopher Chavez. --- generic/tkFont.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index 3a06719..ee72d83 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2339,8 +2339,9 @@ Tk_DrawTextLayout( lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars); #if TK_DRAW_IN_CONTEXT TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont, - chunkPtr->start, chunkPtr->numBytes, firstChar, - numDisplayChars - firstChar, x+chunkPtr->x, y+chunkPtr->y); + chunkPtr->start, chunkPtr->numBytes, + firstByte - chunkPtr->start, lastByte - firstByte, + x+chunkPtr->x, y+chunkPtr->y); #else /* !TK_DRAW_IN_CONTEXT */ Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont, firstByte, lastByte - firstByte, x+chunkPtr->x+drawX, y+chunkPtr->y); @@ -2412,12 +2413,12 @@ TkDrawAngledTextLayout( if (angle == 0.0) { TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, - firstChar, numDisplayChars - firstChar, + firstByte - chunkPtr->start, lastByte - firstByte, (int)(x + dx), (int)(y + dy)); } else { TkpDrawAngledCharsInContext(display, drawable, gc, layoutPtr->tkfont, chunkPtr->start, chunkPtr->numBytes, - firstChar, numDisplayChars - firstChar, + firstByte - chunkPtr->start, lastByte - firstByte, x+dx, y+dy, angle); } #else /* !TK_DRAW_IN_CONTEXT */ -- cgit v0.12 From a0ad668fc8f8b2ec4dd82126ff7e60706abd0d0d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 12 Jul 2020 09:33:14 +0000 Subject: The draw-in-context functions on platforms for which TK_DRAW_IN_CONTEXT is not defined are unused. Add comments telling this and pointing to ticket [7655f65ae7]. --- generic/tkFont.c | 4 ++-- unix/tkUnixFont.c | 3 +++ unix/tkUnixRFont.c | 3 +++ win/tkWinFont.c | 5 ++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index ee72d83..bdaf971 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2298,7 +2298,7 @@ Tk_DrawTextLayout( int x, int y, /* Upper-left hand corner of rectangle in * which to draw (pixels). */ int firstChar, /* The index of the first character to draw - * from the given text item. 0 specfies the + * from the given text item. 0 specifies the * beginning. */ int lastChar) /* The index just after the last character to * draw from the given text item. A number < 0 @@ -2369,7 +2369,7 @@ TkDrawAngledTextLayout( * which to draw (pixels). */ double angle, int firstChar, /* The index of the first character to draw - * from the given text item. 0 specfies the + * from the given text item. 0 specifies the * beginning. */ int lastChar) /* The index just after the last character to * draw from the given text item. A number < 0 diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index 0963953..d524bfd 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -1374,6 +1374,9 @@ Tk_DrawChars( * with access to all the characters on the line for context. On X11 this * context isn't consulted, so we just call Tk_DrawChars(). * + * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this + * function is unused (and possibly unfinished). See [7655f65ae7]. + * * Results: * None. * diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 069598f..cac6f8e 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -1309,6 +1309,9 @@ TkDrawAngledChars( * with access to all the characters on the line for context. On X11 this * context isn't consulted, so we just call Tk_DrawChars(). * + * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this + * function is unused (and possibly unfinished). See [7655f65ae7]. + * * Results: * None. * diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 3d38ea4..7967a61 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -1363,7 +1363,10 @@ TkDrawAngledChars( * Draw a string of characters on the screen like Tk_DrawChars(), but * with access to all the characters on the line for context. On Windows * this context isn't consulted, so we just call Tk_DrawChars(). - * + * + * Note: TK_DRAW_IN_CONTEXT being currently defined only on macOS, this + * function is unused (and possibly unfinished). See [7655f65ae7]. +* * Results: * None. * -- cgit v0.12 From 4daf13d8e213797a97952c0147a165acdd260a29 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 12 Jul 2020 09:35:30 +0000 Subject: tkFont.c needs to include tkMacOSXInt.h on macOS, because this is where TK_DRAW_IN_CONTEXT is defined. --- generic/tkFont.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkFont.c b/generic/tkFont.c index 148ba20..c507371 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -13,6 +13,9 @@ #include "tkInt.h" #include "tkFont.h" +#if defined(MAC_OSX_TK) +#include "tkMacOSXInt.h" /* Defines TK_DRAW_IN_CONTEXT */ +#endif /* * The following structure is used to keep track of all the fonts that exist -- cgit v0.12 From 5075064d26591eac73ed4d1995af9a651a51657b Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 12 Jul 2020 10:17:57 +0000 Subject: Add yet another comment about the '#if 0' in tkFont.c --- generic/tkFont.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkFont.c b/generic/tkFont.c index c507371..cbe885a 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2306,7 +2306,7 @@ Tk_DrawTextLayout( * means to draw all characters. */ { #if 0 - /* Use TkDrawAngledTextLayout() implementation */ + /* Use TkDrawAngledTextLayout() implementation - testing purposes at this point */ TkDrawAngledTextLayout(display, drawable, gc, layout, x, y, 0.0, firstChar, lastChar); #else TextLayout *layoutPtr = (TextLayout *) layout; -- cgit v0.12 From c1b6abf51d0a94a1ef77c7119af5deddd62e1d16 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 12 Jul 2020 14:44:18 +0000 Subject: Fix [2442314]: Fontchooser - use message catalog for font style. --- library/fontchooser.tcl | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 5395acb..0510fb9 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -14,11 +14,11 @@ namespace eval ::tk::fontchooser { set S(W) .__tk__fontchooser set S(fonts) [lsort -dictionary [font families]] set S(styles) [list \ - [::msgcat::mc "Regular"] \ - [::msgcat::mc "Italic"] \ - [::msgcat::mc "Bold"] \ - [::msgcat::mc "Bold Italic"] \ - ] + [::msgcat::mc "Regular"] \ + [::msgcat::mc "Italic"] \ + [::msgcat::mc "Bold"] \ + [::msgcat::mc "Bold Italic"] \ + ] set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} set S(strike) 0 @@ -36,9 +36,9 @@ proc ::tk::fontchooser::Setup {} { # Canonical versions of font families, styles, etc. for easier searching set S(fonts,lcase) {} - foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]} + foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]} set S(styles,lcase) {} - foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style]} + foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]} set S(sizes,lcase) $S(sizes) ::ttk::style layout FontchooserFrame { @@ -145,10 +145,13 @@ proc ::tk::fontchooser::Create {} { wm title $S(W) $S(-title) wm transient $S(W) [winfo toplevel $S(-parent)] + set scaling [tk scaling] + set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}] + set outer [::ttk::frame $S(W).outer -padding {10 10}] ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"] ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"] - ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] + ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth ttk::entry $S(W).efont -width 18 \ -textvariable [namespace which -variable S](font) ttk::entry $S(W).estyle -width 10 \ @@ -199,7 +202,7 @@ proc ::tk::fontchooser::Create {} { set minsize(sizes) \ [expr {[font measure TkDefaultFont "-99"] + $scroll_width}] set min [expr {$minsize(gap) * 4}] - foreach {what width} [array get minsize] { incr min $width } + foreach {what width} [array get minsize] {incr min $width} wm minsize $S(W) $min 260 bind $S(W) [namespace code [list Done 1]] @@ -327,13 +330,13 @@ proc ::tk::fontchooser::Init {{defaultFont ""}} { set S(size) $F(-size) set S(strike) $F(-overstrike) set S(under) $F(-underline) - set S(style) "Regular" + set S(style) [::msgcat::mc "Regular"] if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} { - set S(style) "Bold Italic" + set S(style) [::msgcat::mc "Bold Italic"] } elseif {$F(-weight) eq "bold"} { - set S(style) "Bold" + set S(style) [::msgcat::mc "Bold"] } elseif {$F(-slant) eq "italic"} { - set S(style) "Italic" + set S(style) [::msgcat::mc "Italic"] } set S(first) 0 @@ -396,7 +399,7 @@ proc ::tk::fontchooser::Tracer {var1 var2 op} { } $S(W).l${var}s see $n } - if {!$bad} { Update } + if {!$bad} {Update} $S(W).ok configure -state $nstate } @@ -408,11 +411,11 @@ proc ::tk::fontchooser::Update {} { variable S set S(result) [list $S(font) $S(size)] - if {$S(style) eq "Bold"} { lappend S(result) bold } - if {$S(style) eq "Italic"} { lappend S(result) italic } - if {$S(style) eq "Bold Italic"} { lappend S(result) bold italic} - if {$S(strike)} { lappend S(result) overstrike} - if {$S(under)} { lappend S(result) underline} + if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold} + if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic} + if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic} + if {$S(strike)} {lappend S(result) overstrike} + if {$S(under)} {lappend S(result) underline} $S(sample) configure -font $S(result) } -- cgit v0.12 From ce1d35c813ae7774af4bbd3f1cc5d3a1f0c8cac6 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 12 Jul 2020 15:21:10 +0000 Subject: Spurious additional :: --- library/fontchooser.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 0510fb9..3e2b6df 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -280,7 +280,7 @@ proc ::tk::fontchooser::Create {} { # Arguments: # ok true if user pressed OK # -proc ::tk::::fontchooser::Done {ok} { +proc ::tk::fontchooser::Done {ok} { variable S if {! $ok} { -- cgit v0.12 From 451fa4203bff3f5e6a0ab5028f900823174b4c83 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 15 Jul 2020 14:33:41 +0000 Subject: Code simplifications: Don't bother the typedefs 'EventMask' and 'ModMask' for 'unsigned long', since Tk cannot handle more than 32 bits anyway. Simply use 'unsigned' everywhere. --- generic/tkBind.c | 59 +++++++++++++++++++++++------------------------------ generic/tkCanvas.c | 4 ++-- generic/tkEvent.c | 6 +++--- generic/tkInt.h | 2 +- generic/tkPointer.c | 5 +++-- 5 files changed, 35 insertions(+), 41 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index b3bddc9..bdc1f45 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -137,17 +137,10 @@ typedef struct { * this count considers the detail (keySym or button). */ } Event; -/* - * We need a structure providing a list of pattern sequences. - */ - -typedef unsigned EventMask; -typedef unsigned long ModMask; - struct PatSeq; /* forward declaration */ /* We need this array for bookkeeping the last matching modifier mask per pattern. */ -TK_ARRAY_DEFINE(PSModMaskArr, ModMask); +TK_ARRAY_DEFINE(PSModMaskArr, unsigned); typedef struct PSEntry { TK_DLIST_LINKS(PSEntry); /* Makes this struct a double linked list; must be first entry. */ @@ -203,7 +196,7 @@ typedef struct Tk_BindingTable_ { /* Containing the most recent event for every event type. */ PromArr *promArr; /* Contains the promoted pattern sequences. */ Event *curEvent; /* Pointing to most recent event. */ - ModMask curModMask; /* Containing the current modifier mask. */ + unsigned curModMask; /* Containing the current modifier mask. */ LookupTables lookupTables; /* Containing hash tables for fast lookup. */ Tcl_HashTable objectTable; /* Used to map from an object to a list of patterns associated with * that object. Keys are ClientData, values are (PatSeq *). */ @@ -265,7 +258,7 @@ typedef struct { typedef struct { unsigned eventType; /* Type of X event, e.g. ButtonPress. */ unsigned count; /* Multi-event count, e.g. double-clicks, triple-clicks, etc. */ - ModMask modMask; /* Mask of modifiers that must be present (zero means no modifiers + unsigned modMask; /* Mask of modifiers that must be present (zero means no modifiers * are required). */ Info info; /* Additional information that must match event. Normally this is zero, * meaning no additional information must match. For KeyPress and @@ -416,7 +409,7 @@ static Tcl_HashTable nameTable; /* keyArray hashed by keysym name. */ typedef struct { const char *name; /* Name of modifier. */ - ModMask mask; /* Button/modifier mask value, such as Button1Mask. */ + unsigned mask; /* Button/modifier mask value, such as Button1Mask. */ unsigned flags; /* Various flags; see below for definitions. */ } ModInfo; @@ -713,7 +706,7 @@ static void ExpandPercents(TkWindow *winPtr, const char *before, Event *eventPt unsigned scriptCount, Tcl_DString *dsPtr); static PatSeq * FindSequence(Tcl_Interp *interp, LookupTables *lookupTables, ClientData object, const char *eventString, int create, - int allowVirtual, EventMask *maskPtr); + int allowVirtual, unsigned *maskPtr); static void GetAllVirtualEvents(Tcl_Interp *interp, VirtualEventTable *vetPtr); static const char * GetField(const char *p, char *copy, unsigned size); static Tcl_Obj * GetPatternObj(const PatSeq *psPtr); @@ -729,7 +722,7 @@ static PatSeq * MatchPatterns(TkDisplay *dispPtr, Tk_BindingTable bindPtr, PSLi static int NameToWindow(Tcl_Interp *interp, Tk_Window main, Tcl_Obj *objPtr, Tk_Window *tkwinPtr); static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr, - TkPattern *patPtr, EventMask *eventMaskPtr); + TkPattern *patPtr, unsigned *eventMaskPtr); static void DoWarp(ClientData clientData); static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr, Tcl_Obj *object, int onlyConsiderDetailedEvents); @@ -761,8 +754,8 @@ static int TestNearbyCoords(int lhs, int rhs) { return Abs(lhs - rhs) <= NEARBY_ static int IsSubsetOf( - ModMask lhsMask, /* this is a subset */ - ModMask rhsMask) /* of this bit field? */ + unsigned lhsMask, /* this is a subset */ + unsigned rhsMask) /* of this bit field? */ { return (lhsMask & rhsMask) == lhsMask; } @@ -967,13 +960,13 @@ ResolveModifiers( if (dispPtr->metaModMask) { if (modMask & META_MASK) { - modMask &= ~(ModMask)META_MASK; + modMask &= ~META_MASK; modMask |= dispPtr->metaModMask; } } if (dispPtr->altModMask) { if (modMask & ALT_MASK) { - modMask &= ~(ModMask)ALT_MASK; + modMask &= ~ALT_MASK; modMask |= dispPtr->altModMask; } } @@ -1634,7 +1627,7 @@ Tk_CreateBinding( * existing binding will always be replaced. */ { PatSeq *psPtr; - EventMask eventMask; + unsigned eventMask; char *oldStr; char *newStr; @@ -2727,8 +2720,8 @@ static int CompareModMasks( const PSModMaskArr *fstModMaskArr, const PSModMaskArr *sndModMaskArr, - ModMask fstModMask, - ModMask sndModMask) + unsigned fstModMask, + unsigned sndModMask) { int fstCount = 0; int sndCount = 0; @@ -2752,8 +2745,8 @@ CompareModMasks( assert(PSModMaskArr_Size(fstModMaskArr) == PSModMaskArr_Size(sndModMaskArr)); for (i = PSModMaskArr_Size(fstModMaskArr) - 1; i >= 0; --i) { - ModMask fstModMask = *PSModMaskArr_Get(fstModMaskArr, i); - ModMask sndModMask = *PSModMaskArr_Get(sndModMaskArr, i); + unsigned fstModMask = *PSModMaskArr_Get(fstModMaskArr, i); + unsigned sndModMask = *PSModMaskArr_Get(sndModMaskArr, i); if (IsSubsetOf(fstModMask, sndModMask)) { ++sndCount; } if (IsSubsetOf(sndModMask, fstModMask)) { ++fstCount; } @@ -2786,7 +2779,7 @@ MatchPatterns( PSEntry *psEntry; PatSeq *bestPtr; PatSeq *bestPhysPtr; - ModMask bestModMask; + unsigned bestModMask; const PSModMaskArr *bestModMaskArr = NULL; int i, isModKeyOnly = 0; @@ -2853,8 +2846,8 @@ MatchPatterns( * cannot be done in ParseEventDescription, otherwise this function would * be the better place. */ - ModMask modMask = ResolveModifiers(dispPtr, patPtr->modMask); - ModMask curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); + unsigned modMask = ResolveModifiers(dispPtr, patPtr->modMask); + unsigned curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask); psEntry->expired = 1; /* remove it from promotion list */ psEntry->keepIt = 0; /* don't keep matching patterns */ @@ -3850,7 +3843,7 @@ HandleEventGenerate( Tk_Window tkwin; Tk_Window tkwin2; TkWindow *mainPtr; - EventMask eventMask; + unsigned eventMask; Tcl_Obj *userDataObj; int synch; int warp; @@ -4622,7 +4615,7 @@ FindSequence( * 1 means create. */ int allowVirtual, /* 0 means that virtual events are not allowed in the sequence. * 1 otherwise. */ - EventMask *maskPtr) /* *maskPtr is filled in with the event types on which this + unsigned *maskPtr) /* *maskPtr is filled in with the event types on which this * pattern sequence depends. */ { unsigned patsBufSize = 1; @@ -4636,8 +4629,8 @@ FindSequence( int isNew; unsigned count; unsigned maxCount = 0; - EventMask eventMask = 0; - ModMask modMask = 0; + unsigned eventMask = 0; + unsigned modMask = 0; PatternTableKey key; assert(lookupTables); @@ -4811,10 +4804,10 @@ ParseEventDescription( const char **eventStringPtr,/* On input, holds a pointer to start of event string. On exit, * gets pointer to rest of string after parsed event. */ TkPattern *patPtr, /* Filled with the pattern parsed from the event string. */ - EventMask *eventMaskPtr) /* Filled with event mask of matched event. */ + unsigned *eventMaskPtr) /* Filled with event mask of matched event. */ { const char *p; - EventMask eventMask = 0; + unsigned eventMask = 0; unsigned count = 1; assert(eventStringPtr); @@ -5127,7 +5120,7 @@ GetPatternObj( assert(patPtr->name); Tcl_AppendPrintfToObj(patternObj, "<<%s>>", patPtr->name); } else { - ModMask modMask; + unsigned modMask; const ModInfo *modPtr; /* @@ -5180,7 +5173,7 @@ GetPatternObj( break; #if PRINT_SHORT_MOTION_SYNTAX case MotionNotify: { - ModMask mask = patPtr->modMask; + unsigned mask = patPtr->modMask; while (mask & ALL_BUTTONS) { unsigned button = ButtonNumberFromState(mask); Tcl_AppendPrintfToObj(patternObj, "-%u", button); diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 9f661bc..50a88b4 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -4759,8 +4759,8 @@ CanvasBindProc( ClientData clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { - TkCanvas *canvasPtr = clientData; - unsigned long mask; + TkCanvas *canvasPtr = (TkCanvas *)clientData; + unsigned mask; Tcl_Preserve(canvasPtr); diff --git a/generic/tkEvent.c b/generic/tkEvent.c index a2fa293..0994a07 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -522,13 +522,13 @@ RefreshKeyboardMappingIfNeeded( *---------------------------------------------------------------------- */ -static const unsigned long buttonMasks[] = { +static const unsigned buttonMasks[] = { 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask }; -unsigned long +unsigned TkGetButtonMask( - unsigned int button) + unsigned button) { return (button > Button5) ? 0 : buttonMasks[button]; } diff --git a/generic/tkInt.h b/generic/tkInt.h index b60ab44..6f40078 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -966,7 +966,7 @@ typedef struct TkpClipMask { (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) -MODULE_SCOPE unsigned long TkGetButtonMask(unsigned int); +MODULE_SCOPE unsigned TkGetButtonMask(unsigned); /* * Object types not declared in tkObj.c need to be mentioned here so they can diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 06359a9..c17367a 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -225,8 +225,9 @@ Tk_UpdatePointer( TkWindow *targetWinPtr; XPoint pos; XEvent event; - int changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; - int type, b, mask; + unsigned changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; + int type, b; + unsigned mask; pos.x = x; pos.y = y; -- cgit v0.12