summaryrefslogtreecommitdiffstats
path: root/generic/tkTextDisp.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2015-11-14 13:05:04 (GMT)
committerfvogel <fvogelnew1@free.fr>2015-11-14 13:05:04 (GMT)
commit026e3c1a89685f0cc95502bfb70e6132128c1c58 (patch)
tree5c35c0b4b63b4fa1aa3ed3ad8e68c2cb62db23f2 /generic/tkTextDisp.c
parent4fe451bdce628ec817ecdebadbcd7f46dc967b41 (diff)
parentb965bde49f462725f54d29e9e8b8008f79fe43b9 (diff)
downloadtk-026e3c1a89685f0cc95502bfb70e6132128c1c58.zip
tk-026e3c1a89685f0cc95502bfb70e6132128c1c58.tar.gz
tk-026e3c1a89685f0cc95502bfb70e6132128c1c58.tar.bz2
TIP #438 - <<TextLineHeightsInvalid>> event added, with corresponding new tests
Diffstat (limited to 'generic/tkTextDisp.c')
-rw-r--r--generic/tkTextDisp.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index d740181..ff90520 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -590,6 +590,7 @@ static int TextGetScrollInfoObj(Tcl_Interp *interp,
Tcl_Obj *CONST objv[], double *dblPtr,
int *intPtr);
static void AsyncUpdateLineMetrics(ClientData clientData);
+static void GenerateTextLineHeightsInvalidEvent(TkText *textPtr);
static void AsyncUpdateYScrollbar(ClientData clientData);
static int IsStartOfNotMergedLine(TkText *textPtr,
CONST TkTextIndex *indexPtr);
@@ -2929,6 +2930,8 @@ AsyncUpdateLineMetrics(
LOG("tk_textInvalidateLine", buffer);
}
+ GenerateTextLineHeightsInvalidEvent(textPtr);
+
/*
* If we're not in the middle of a long-line calculation (metricEpoch==-1)
* and we've reached the last line, then we're done.
@@ -2961,6 +2964,43 @@ AsyncUpdateLineMetrics(
/*
*----------------------------------------------------------------------
*
+ * GenerateTextLineHeightsInvalidEvent --
+ *
+ * Send the <<TextLineHeightsInvalid>> event related to the text widget
+ * line metrics asynchronous update.
+ * This is equivalent to:
+ * event generate $textWidget <<TextLineHeightsInvalid>> -detail $N
+ * where $N is the number of lines for which the height is outdated.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * If corresponding bindings are present, they will trigger.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+GenerateTextLineHeightsInvalidEvent(
+ TkText *textPtr) /* Information about text widget. */
+{
+ union {XEvent general; XVirtualEvent virtual;} event;
+
+ memset(&event, 0, sizeof(event));
+ event.general.xany.type = VirtualEvent;
+ event.general.xany.serial = NextRequest(Tk_Display(textPtr->tkwin));
+ event.general.xany.send_event = False;
+ event.general.xany.window = Tk_WindowId(textPtr->tkwin);
+ event.general.xany.display = Tk_Display(textPtr->tkwin);
+ event.virtual.name = Tk_GetUid("TextLineHeightsInvalid");
+ event.virtual.user_data = Tcl_NewIntObj(TkTextPendingyupdate(textPtr));
+ Tk_HandleEvent(&event.general);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkTextUpdateLineMetrics --
*
* This function updates the pixel height calculations of a range of