Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!ogicse!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!quagga!ucthpx!uctcs.uucp!gram From: gram@uctcs.uucp (Graham Wheeler) Newsgroups: comp.windows.x Subject: Error in Athena widget documentation Message-ID: <788@ucthpx.UUCP> Date: 2 Oct 90 12:01:35 GMT Sender: news@ucthpx.UUCP Reply-To: gram@uctcs.uucp (Graham Wheeler) Organization: Dept. of Computer Science, University of Cape Town Lines: 91 I have solved one of my two previous errors (reading text from the widget itself). The other problem is still bugging me 8-). The Athena Widget docs are also incorrect, it seems. THe problem I am refering to is clearing the internal 'changes' flag of the AsciiSrc widget. I quote from the docs: (p83) *************************************************************************** 5.6.2.3 Seeing if the Source has Changed To find out if the text buffer in an AsciiSrc object has changed since the last time it was saved with XawAsciiSave or queried use XawAsciiSourceChanged. Boolean XawAsciiSourceChanged(w) Widget w; w Specifies the AsciiSrc object This function will return True if the source has changed since the last time it was saved OR QUERIED. The internal change flag is reset whenever the string is queried via XtGetValues or the buffer is saved via XawAsciiSave. *************************************************************************** This is not true - the only time the flag is cleared is in calls to XawAsciiSave. This means that if you load up a different file into a AsciiText widget, and you modified but did not save the previous file, the change flag will still be set - not very desirable behaviour. As the changes flag is internal, I decided to try to hack this one, and wrote the following function: #include #include #include void XawClearAsciiSrcFlag(w) Widget w; { printf("Flag was %s\n",((AsciiSrcObject)w)->ascii_src.changes ? "TRUE" : "FALSE"); ((AsciiSrcObject)w)->ascii_src.changes = FALSE; printf("Flag is now %s\n",((AsciiSrcObject)w)->ascii_src.changes ? "TRUE" : "FALSE"); } I then called this function from my editor program as follows: /* Clear the Source-modified flag */ printf("Before call: %s\n",FileChanged() ? "true" : "false"); XawClearAsciiSrcFlag(EdSrcWidget); printf("After call: %s\n",FileChanged() ? "true" : "false"); The FileChanged routine is: Boolean FileChanged() { return (Boolean)XawAsciiSourceChanged(EdSrcWidget); } The EdSrcWidget is extracted from the AsciiText widget on an earlier occasion. Now the going really gets weird! The stdout output that results when I run this code is: Before call: true Flag was FALSE Flag is now FALSE After call: true If you consider that the XawAsciiSourceChanged routine simply returns the value of the flag (something like: Boolean XawAsciiSourceChanged(w) Widget w; { return ((AsciiSrcObject)w)->ascii_src.changes; } ) then the behaviour of this code seems inexplicable (to me, anyway). In each case I pass the same widget through, but the Xaw routine sees the flag as false whereas my hack sees it as true. SOMEBODY OUT THERE, PLEASE HELP ME! Should I have myself committed? Graham Wheeler | "Don't bother me, Data Network Architectures Lab| I'm reading a `Crisis'!" Dept. of Computer Science | Internet: University of Cape Town | BANG: <...uunet!ddsw1!olsa99!uctcs!gram>