diff options
author | dgp <dgp@users.sourceforge.net> | 2015-11-30 21:21:48 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-11-30 21:21:48 (GMT) |
commit | a24fdcc2b9295b493a9cd9e7632be98c5ddb3f6a (patch) | |
tree | 24ccb2318d04412685b1a4262df7c33df0864d34 /generic | |
parent | ddb9e825e0b85f216d172f8b537257c8d58b0de9 (diff) | |
parent | b8bfd3505b511a3cc94297df7f04c55505d6df2c (diff) | |
download | tk-a24fdcc2b9295b493a9cd9e7632be98c5ddb3f6a.zip tk-a24fdcc2b9295b493a9cd9e7632be98c5ddb3f6a.tar.gz tk-a24fdcc2b9295b493a9cd9e7632be98c5ddb3f6a.tar.bz2 |
merge 8.5
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkFont.c | 4 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 6 | ||||
-rw-r--r-- | generic/tkMenu.c | 7 | ||||
-rw-r--r-- | generic/tkOption.c | 13 | ||||
-rw-r--r-- | generic/tkText.c | 20 | ||||
-rw-r--r-- | generic/tkTextBTree.c | 2 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 73 |
7 files changed, 85 insertions, 40 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c index 5d2ad43..7ff1ae9 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2069,14 +2069,14 @@ Tk_ComputeTextLayout( NewChunk(&layoutPtr, &maxChunks, start, 1, curX, newX, baseline)->numDisplayChars = -1; start++; + curX = newX; + flags &= ~TK_AT_LEAST_ONE; if ((start < end) && ((wrapLength <= 0) || (newX <= wrapLength))) { /* * More chars can still fit on this line. */ - curX = newX; - flags &= ~TK_AT_LEAST_ONE; continue; } } else { diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 780b0c2..47aa523 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -2454,7 +2454,11 @@ ImgPhotoGet( } XFree((char *) visInfoPtr); - sprintf(buf, ((mono) ? "%d": "%d/%d/%d"), nRed, nGreen, nBlue); + if (mono) { + sprintf(buf, "%d", nRed); + } else { + sprintf(buf, "%d/%d/%d", nRed, nGreen, nBlue); + } instancePtr->defaultPalette = Tk_GetUid(buf); /* diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 49b5935..b35be24 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -934,9 +934,14 @@ MenuWidgetObjCmd( * Tearoff menus are posted differently on Mac and Windows than * non-tearoffs. TkpPostMenu does not actually map the menu's window * on those platforms, and popup menus have to be handled specially. + * Also, menubar menues are not intended to be posted (bug 1567681, + * 2160206). */ - if (menuPtr->menuType != TEAROFF_MENU) { + if (menuPtr->menuType == MENUBAR) { + Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); + return TCL_ERROR; + } else if (menuPtr->menuType != TEAROFF_MENU) { result = TkpPostMenu(interp, menuPtr, x, y); } else { result = TkPostTearoffMenu(interp, menuPtr, x, y); diff --git a/generic/tkOption.c b/generic/tkOption.c index 91a6cc0..bff799b 100644 --- a/generic/tkOption.c +++ b/generic/tkOption.c @@ -1086,7 +1086,7 @@ ReadOptionFile( char *buffer; int result, bufferSize; Tcl_Channel chan; - Tcl_DString newName; + Tcl_DString newName, optString; /* * Prevent file system access in a safe interpreter. @@ -1136,7 +1136,16 @@ ReadOptionFile( } Tcl_Close(NULL, chan); buffer[bufferSize] = 0; - result = AddFromString(interp, tkwin, buffer, priority); + if ((bufferSize>2) && !memcmp(buffer, "\357\273\277", 3)) { + /* File starts with UTF-8 BOM */ + result = AddFromString(interp, tkwin, buffer+3, priority); + } else { + Tcl_DStringInit(&optString); + Tcl_ExternalToUtfDString(NULL, buffer, bufferSize, &optString); + result = AddFromString(interp, tkwin, Tcl_DStringValue(&optString), + priority); + Tcl_DStringFree(&optString); + } ckfree(buffer); return result; } diff --git a/generic/tkText.c b/generic/tkText.c index cb89218..6e982b0 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -566,14 +566,6 @@ CreateWidget( textPtr->end = NULL; } - /* - * Register with the B-tree. In some sense it would be best if we could do - * this later (after configuration options), so that any changes to - * start,end do not require a total recalculation. - */ - - TkBTreeAddClient(sharedPtr->tree, textPtr, textPtr->charHeight); - textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; textPtr->cursor = None; @@ -584,6 +576,14 @@ CreateWidget( textPtr->prevHeight = Tk_Height(newWin); /* + * Register with the B-tree. In some sense it would be best if we could do + * this later (after configuration options), so that any changes to + * start,end do not require a total recalculation. + */ + + TkBTreeAddClient(sharedPtr->tree, textPtr, textPtr->charHeight); + + /* * This will add refCounts to textPtr. */ @@ -2319,6 +2319,7 @@ TextWorldChanged( { Tk_FontMetrics fm; int border; + int oldCharHeight = textPtr->charHeight; textPtr->charWidth = Tk_TextWidth(textPtr->tkfont, "0", 1); if (textPtr->charWidth <= 0) { @@ -2330,6 +2331,9 @@ TextWorldChanged( if (textPtr->charHeight <= 0) { textPtr->charHeight = 1; } + if (textPtr->charHeight != oldCharHeight) { + TkBTreeClientRangeChanged(textPtr, textPtr->charHeight); + } border = textPtr->borderWidth + textPtr->highlightWidth; Tk_GeometryRequest(textPtr->tkwin, textPtr->width * textPtr->charWidth + 2*textPtr->padX + 2*border, diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 36f0ef3..58fc645 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -1117,7 +1117,7 @@ TkBTreeInsertChars( /* * I don't believe it's possible for either of the two lines passed to * this function to be the last line of text, but the function is robust - * to that case anyway. (We must never re-calculated the line height of + * to that case anyway. (We must never re-calculate the line height of * the last line). */ diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index fc7b46b..cfe6e7a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -2225,7 +2225,7 @@ UpdateDisplayInfo( * Here's a problem: see the tests textDisp-29.2.1-4 * * If the widget is being created, but has not yet been configured it will - * have a maxY of 1 above, and we we won't have examined all the lines + * have a maxY of 1 above, and we won't have examined all the lines * (just the first line, in fact), and so maxOffset will not be a true * reflection of the widget's lines. Therefore we must not overwrite the * original newXPixelOffset in this case. @@ -2540,7 +2540,7 @@ DisplayLineBackground( * current x coordinate? */ int matchRight; /* Does line's style match its neighbor just * to the right of the current x-coord? */ - int minX, maxX, xOffset; + int minX, maxX, xOffset, bw; StyleValues *sValuePtr; Display *display; #ifndef TK_NO_DOUBLE_BUFFERING @@ -2611,16 +2611,25 @@ DisplayLineBackground( rightX = leftX + 32767; } + /* + * Prevent the borders from leaking on adjacent characters, + * which would happen for too large border width. + */ + + bw = sValuePtr->borderWidth; + if (leftX + sValuePtr->borderWidth > rightX) { + bw = rightX - leftX; + } + XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC, leftX + xOffset, y, (unsigned int) (rightX - leftX), (unsigned int) dlPtr->height); if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset, y, sValuePtr->borderWidth, - dlPtr->height, 1, sValuePtr->relief); + leftX + xOffset, y, bw, dlPtr->height, 1, + sValuePtr->relief); Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX - sValuePtr->borderWidth + xOffset, - y, sValuePtr->borderWidth, dlPtr->height, 0, + rightX - bw + xOffset, y, bw, dlPtr->height, 0, sValuePtr->relief); } } @@ -2717,22 +2726,29 @@ DisplayLineBackground( matchRight = (nextPtr2 != NULL) && SAME_BACKGROUND(nextPtr2->stylePtr, chunkPtr->stylePtr); if (matchLeft && !matchRight) { + bw = sValuePtr->borderWidth; + if (rightX2 - sValuePtr->borderWidth < leftX) { + bw = rightX2 - leftX; + } if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 - sValuePtr->borderWidth + xOffset, y, - sValuePtr->borderWidth, sValuePtr->borderWidth, 0, - sValuePtr->relief); + rightX2 - bw + xOffset, y, bw, + sValuePtr->borderWidth, 0, sValuePtr->relief); } - leftX = rightX2 - sValuePtr->borderWidth; + leftX = rightX2 - bw; leftXIn = 0; } else if (!matchLeft && matchRight && (sValuePtr->relief != TK_RELIEF_FLAT)) { + bw = sValuePtr->borderWidth; + if (rightX2 + sValuePtr->borderWidth > rightX) { + bw = rightX - rightX2; + } Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 + xOffset, y, sValuePtr->borderWidth, - sValuePtr->borderWidth, 1, sValuePtr->relief); + rightX2 + xOffset, y, bw, sValuePtr->borderWidth, + 1, sValuePtr->relief); Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset, y, rightX2 + sValuePtr->borderWidth - - leftX, sValuePtr->borderWidth, leftXIn, 0, 1, + leftX + xOffset, y, rightX2 + bw - leftX, + sValuePtr->borderWidth, leftXIn, 0, 1, sValuePtr->relief); } @@ -2764,7 +2780,7 @@ DisplayLineBackground( chunkPtr2 = NULL; if (dlPtr->nextPtr != NULL && dlPtr->nextPtr->chunkPtr != NULL) { /* - * Find the chunk in the previous line that covers leftX. + * Find the chunk in the next line that covers leftX. */ nextPtr2 = dlPtr->nextPtr->chunkPtr; @@ -2820,26 +2836,33 @@ DisplayLineBackground( matchRight = (nextPtr2 != NULL) && SAME_BACKGROUND(nextPtr2->stylePtr, chunkPtr->stylePtr); if (matchLeft && !matchRight) { + bw = sValuePtr->borderWidth; + if (rightX2 - sValuePtr->borderWidth < leftX) { + bw = rightX2 - leftX; + } if (sValuePtr->relief != TK_RELIEF_FLAT) { Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 - sValuePtr->borderWidth + xOffset, + rightX2 - bw + xOffset, y + dlPtr->height - sValuePtr->borderWidth, - sValuePtr->borderWidth, sValuePtr->borderWidth, 0, - sValuePtr->relief); + bw, sValuePtr->borderWidth, 0, sValuePtr->relief); } - leftX = rightX2 - sValuePtr->borderWidth; + leftX = rightX2 - bw; leftXIn = 1; } else if (!matchLeft && matchRight && (sValuePtr->relief != TK_RELIEF_FLAT)) { + bw = sValuePtr->borderWidth; + if (rightX2 + sValuePtr->borderWidth > rightX) { + bw = rightX - rightX2; + } Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - rightX2 + xOffset, y + dlPtr->height - - sValuePtr->borderWidth, sValuePtr->borderWidth, + rightX2 + xOffset, + y + dlPtr->height - sValuePtr->borderWidth, bw, sValuePtr->borderWidth, 1, sValuePtr->relief); Tk_3DHorizontalBevel(textPtr->tkwin, pixmap, sValuePtr->border, - leftX + xOffset, y + dlPtr->height - - sValuePtr->borderWidth, rightX2 + sValuePtr->borderWidth - - leftX, sValuePtr->borderWidth, leftXIn, 1, 0, - sValuePtr->relief); + leftX + xOffset, + y + dlPtr->height - sValuePtr->borderWidth, + rightX2 + bw - leftX, sValuePtr->borderWidth, leftXIn, + 1, 0, sValuePtr->relief); } nextChunk2b: |