vijay@cs.arizona.edu (Vijay Anand) (09/01/90)
This might be a trivial question here but I seem to be stuck with a problem. I am using the Athena Text widget, and in one of my application functions I would like to set my insertPosition resource to the end of text. There seems to be no widget callbacks that can do this. Of course I can keep track of the insert point in a variable and then set the insertPosition resource, but I would like to know if there is any direct way of doing this. There is a cursor movement action end-of-file(). How would I be able to use this in my code. Pl. email me your answers. Thanks for your interest and if this question seems too trivial I apologize for the misuse of bandwidth. Vijay o o \_/ Computer Science University of Arizona. !! GO !! WILDCATS !! Internet: vijay@cs.arizona.edu CSnet : vijay%cs.arizona.edu@relay.cs.net UUCP : ...!{allegra,noao,uunet}!arizona!vijay
thoth@reef.cis.ufl.edu (Gilligan) (09/01/90)
There is no way I know of to discover the end of the text widget without using procedures private to the AsciiSource. Scanning for a null in XtNstring will NOT do the job. What if someone inserts a nul into the text,? it's legal and possibly desirable. There is a procedure in the AsciiSrc class rec that you can access with asciiSrcClassRec.text_src_class.Scan. It points to the procedure /* Function Name: Scan * Description: Scans the text source for the number and type * of item specified. * Arguments: w - the AsciiSource widget. * position - the position to start scanning. * type - type of thing to scan for. * dir - direction to scan. * count - which occurance if this thing to search for. * include - whether or not to include the character found in * the position that is returned. * Returns: the position of the item found. * * Note: While there are only 'n' characters in the file there are n+1 * possible cursor positions (one before the first character and * one after the last character. */ static XawTextPosition Scan (w, position, type, dir, count, include) Widget w; XawTextPosition position; XawTextScanType type; XawTextScanDirection dir; int count; Boolean include; { And I usually call it like this. length = (asciiSrcClassRec.text_src_class.Scan)(source, 0, XawstAll, XawsdRight, 1, True); The problem with this is that it is completely undocumented and probably unsupported. You have to #include <X11/Xaw/AsciiSrcP.h> to get the structure definitions and #defines. Is there a better way? -- /-------------------- "a window is a terrible thing to paste" -me ( My name's not really Gilligan, It's Robert Forsman, without an `e' ) --------------------/