Path: utzoo!attcan!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!quagga!ucthpx!uctcs!gram From: gram@uctcs.uucp (Graham Wheeler) Newsgroups: comp.windows.x Subject: Re: AsciiDiskWidget Message-ID: <801@ucthpx.UUCP> Date: 4 Oct 90 06:35:17 GMT References: <9010011257.AA09735@pcs.cnc.edu..cnc.edu> Sender: news@ucthpx.UUCP Lines: 81 The AsciiText widget is fairly easy to use. Obviously you should include AsciiText.h. If you want to cheat and access private data (like I needed to do), you will want to use: #define ASCII_DISK #define ASCII_STRING #include #include #include Note that the reason I needed to do this is that the XawAsciiSourceChanged routine returns the value of a flag which is cleared ONLY in calls to XawAsciiSave (contrary to what the manual says). The code I use to access this flag myself is: void XawClearAsciiSrcChangedFlag(w) Widget w; { ((AsciiSrcObject)w)->ascii_src.changes = False; } but I digress.... To invoke a function manually (for example, the Search popup), you can use: void PopupSearch() { char *tmp="forward"; XtCallActionProc(AsciiTxtW, "search", NULL, &tmp, 1); } and similarly for other action functions. To load up a new file, whose name is in the string 'fname', use: Arg arg; XtSetArg(arg,"string",fname); XtSetValues(AsciiTxtW, &arg, 1); You may want to call the flag clearing routine I gave earlier as well. If you want to read the source, you can use: XawTextBlock TxtBlk; char *TxtBlk; int pos, Xtpos, avail; int NextChar() { if (avail==0) { pos = 0; avail = XawTextSourceRead(AsciiTxtW, XtPos, &TxtBlk, 80) - XtPos; TxtBuf = TxtBlk.ptr; XtPos += avail; } if (avail==0) return '\0'; /* End of file */ else { avail--; return TxtBuf[pos++]; } } Finally, before you create the widget, you may want to set some of the following arguments (this is by no means an exhaustive list): "string" The name of the file "type" XawAsciiFile for disk files "editType" if you want to be able to edit the text "scrollHorizontal" "scrollVertical" if you want scroll bars Hope this information is of assistance. 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>