summaryrefslogtreecommitdiffstats
path: root/generic/tkTextWind.c
diff options
context:
space:
mode:
authorgcramer <remarcg@gmx.net>2017-04-26 19:20:29 (GMT)
committergcramer <remarcg@gmx.net>2017-04-26 19:20:29 (GMT)
commitc1349889286e3274a78d007e905d6421669a695c (patch)
tree2af9c6b682e398a432277e941983bc3e4bbbe433 /generic/tkTextWind.c
parent44db3e40fa2bf080b2d316652f28decca8542174 (diff)
downloadtk-c1349889286e3274a78d007e905d6421669a695c.zip
tk-c1349889286e3274a78d007e905d6421669a695c.tar.gz
tk-c1349889286e3274a78d007e905d6421669a695c.tar.bz2
(1) Watch command now triggers changes in image or window.
(2) Handling of the watch command a bit simplified. (3) Update of manual. (4) Minor fix in text-27.26.
Diffstat (limited to 'generic/tkTextWind.c')
-rw-r--r--generic/tkTextWind.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index 09ac090..59d4c50 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -751,6 +751,25 @@ IsPreservedWindow(
return client && !client->hPtr;
}
+static void
+TriggerWatchCmd(
+ TkText *textPtr,
+ TkTextSegment *ewPtr,
+ Tk_Window tkwin,
+ const char *arg1,
+ const char *arg2)
+{
+ if (!(textPtr->flags & DESTROYED)) {
+ TkTextIndex index;
+ char buf[TK_POS_CHARS];
+
+ TkTextIndexClear(&index, textPtr);
+ TkTextIndexSetSegment(&index, ewPtr);
+ TkTextPrintIndex(textPtr, &index, buf);
+ TkTextTriggerWatchCmd(textPtr, "window", buf, buf, Tk_PathName(tkwin), arg1, arg2, false);
+ }
+}
+
static int
EmbWinConfigure(
TkText *textPtr, /* Information about text widget that contains
@@ -800,6 +819,13 @@ EmbWinConfigure(
} else {
Tk_UnmapWindow(oldWindow);
}
+ if (textPtr->watchCmd) {
+ textPtr->refCount += 1;
+ TriggerWatchCmd(textPtr, ewPtr, oldWindow, NULL, NULL);
+ if (TkTextDecrRefCountAndTestIfDestroyed(textPtr)) {
+ return TCL_OK;
+ }
+ }
}
if (client) {
client->tkwin = NULL;
@@ -905,16 +931,18 @@ EmbWinStructureProc(
{
TkTextEmbWindowClient *client = clientData;
TkTextSegment *ewPtr;
+ Tk_Window tkwin;
if (eventPtr->type != DestroyNotify || !client->hPtr) {
return;
}
ewPtr = client->parent;
+ tkwin = client->tkwin;
assert(ewPtr->typePtr);
assert(client->hPtr == Tcl_FindHashEntry(&ewPtr->body.ew.sharedTextPtr->windowTable,
- Tk_PathName(client->tkwin)));
+ Tk_PathName(tkwin)));
/*
* This may not exist if the entire widget is being deleted.
@@ -926,6 +954,10 @@ EmbWinStructureProc(
client->tkwin = NULL;
client->hPtr = NULL;
EmbWinRequestProc(client, NULL);
+
+ if (client->textPtr->watchCmd) {
+ TriggerWatchCmd(client->textPtr, ewPtr, tkwin, NULL, NULL);
+ }
}
/*
@@ -1028,6 +1060,10 @@ EmbWinLostSlaveProc(
TkTextIndexClear(&index, textPtr);
TkTextIndexSetSegment(&index, ewPtr);
TextChanged(&index);
+
+ if (textPtr->watchCmd) {
+ TriggerWatchCmd(textPtr, ewPtr, tkwin, NULL, NULL);
+ }
}
/*
@@ -1618,9 +1654,22 @@ EmbWinDisplayProc(
|| Tk_ReqWidth(tkwin) != Tk_Width(tkwin)
|| height != Tk_Height(tkwin)) {
Tk_MoveResizeWindow(tkwin, windowX, windowY, width, height);
+
+ if (textPtr->watchCmd && Tk_IsMapped(tkwin)) {
+ char w[100], h[100];
+
+ snprintf(h, sizeof(h), "%d", Tk_Height(tkwin));
+ snprintf(w, sizeof(w), "%d", Tk_Width(tkwin));
+
+ TriggerWatchCmd(textPtr, ewPtr, tkwin, w, h);
+ }
}
- if (!client->displayed) {
+ if (!Tk_IsMapped(tkwin)) {
Tk_MapWindow(tkwin);
+
+ if (textPtr->watchCmd) {
+ TriggerWatchCmd(textPtr, ewPtr, tkwin, NULL, NULL);
+ }
}
} else {
Tk_MaintainGeometry(tkwin, textPtr->tkwin, windowX, windowY, width, height);
@@ -1770,6 +1819,12 @@ EmbWinDelayedUnmap(
} else {
Tk_UnmapWindow(client->tkwin);
}
+
+ assert(client->textPtr);
+
+ if (client->textPtr->watchCmd) {
+ TriggerWatchCmd(client->textPtr, client->parent, client->tkwin, NULL, NULL);
+ }
}
}