Path: utzoo!attcan!uunet!lll-winken!ames!pasteur!ucbvax!tut.cis.ohio-state.edu!bloom-beacon!earth.cray.COM!jlf From: jlf@earth.cray.COM (John Freeman) Newsgroups: comp.windows.x Subject: Re: AsciiDiskWidgets Message-ID: <8902171611.AA17093@thelake.cray.com> Date: 17 Feb 89 16:11:11 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 31 > ok, I give up. Does anyone have an example of how to > use XtDiskSourceCreate, XtStringSourceCreate, et. al. > for a textWidget? I want to be able to change the displayed > file in a asciiDiskWidget at will (can be a readonly file) > and send strings to an asciiStringWidget. Here is a fragment of code from a program of mine that does what you ask for, hopefully complete enough. --------------------------------------------------------------- Widget source_box; XtTextSource xtsp = NULL; Arg file_arg[] = {XtNfile,(XtArgVal) source_filename}; /* * If XtDiskSourceCreate can't open source_filename, the whole * program will exit, so check first. */ ret = open(source_filename, O_RDONLY); if (ret < 0) { sprintf(carray, "Can't open source file %s\n", source_filename); return; } if (xtsp) { /* close old */ XtDiskSourceDestroy(xtsp); } /* Change file in source_box */ xtsp = XtDiskSourceCreate(source_box, file_arg, XtNumber(file_arg)); XtTextSetSource(source_box, xtsp, 0);