1994689c1Smrg<sect1 id="Ascii_Source_Object_and_Multi_Source_Object"> 2994689c1Smrg<title>Ascii Source Object and Multi Source Object</title> 3994689c1Smrg<para> 4994689c1Smrg<!-- .LP --> 5994689c1Smrg<!-- .XS --> 6994689c1Smrg<!-- AsciiSrc Object --> 7994689c1Smrg<!-- .XE --> 85ec34c4cSmrg<indexterm significance="preferred"><primary>AsciiSrc object</primary></indexterm> 9994689c1Smrg</para> 10994689c1Smrg<para> 11994689c1Smrg<!-- .LP --> 12994689c1Smrg<literallayout class="monospaced"> 13994689c1Smrg<!-- .TA 2.0i --> 14994689c1Smrg<!-- .ta 2.0i --> 15994689c1SmrgApplication Header file <X11/Xaw/AsciiSrc.h> or <X11/Xaw/MultiSrc.h> 165ec34c4cSmrg<indexterm><primary>AsciiSrc.h</primary></indexterm> 17994689c1SmrgClass Header file <X11/Xaw/AsciiSrcP.h> or <X11/Xaw/MultiSrcP.h> 185ec34c4cSmrg<indexterm><primary>AsciiSrcP.h</primary></indexterm> 19994689c1SmrgClass asciiSrcObjectClass or multiSrcObjectClass 205ec34c4cSmrg<indexterm><primary>asciiSrcObjectClass</primary></indexterm> 21994689c1SmrgClass Name AsciiSrc or MultiSrc 225ec34c4cSmrg<indexterm><primary>AsciiSrc object</primary><secondary>class name</secondary></indexterm> 23994689c1SmrgSuperclass TextSource 24994689c1Smrg</literallayout> 25994689c1Smrg</para> 26994689c1Smrg<para> 27994689c1Smrg<!-- .LP --> 28994689c1SmrgThe AsciiSrc or MultiSrc object is used by a text widget to read the text from a 29994689c1Smrgfile or string in memory. Depending on its <function>international</function> resource, an 30994689c1SmrgAsciiText widget will create one or the other of these when the AsciiText 31994689c1Smrgitself is created. Both types are nearly identical; the following discussion 32994689c1Smrgapplies to both, with MultiSrc differences noted only as they occur. 33994689c1Smrg</para> 34994689c1Smrg<para> 35994689c1Smrg<!-- .LP --> 365ec34c4cSmrgThe AsciiSrc understands all Latin1 characters plus Tab and Carriage Return. 375ec34c4cSmrg<emphasis remap='I'>The MultiSrc understands any set of character sets that 385ec34c4cSmrgthe underlying X implementation's internationalization handles.</emphasis> 39994689c1Smrg</para> 40994689c1Smrg<para> 41994689c1Smrg<!-- .LP --> 42994689c1SmrgThe AsciiSrc can be either of two types: <function>XawAsciiFile</function> 43994689c1Smrgor <function>XawAsciiString</function>. 44994689c1Smrg</para> 45994689c1Smrg<para> 46994689c1Smrg<!-- .LP --> 47994689c1SmrgAsciiSrc objects of type <function>XawAsciiFile</function> read the text from a file and 48994689c1Smrgstore it 49994689c1Smrginto an internal buffer. This buffer may then be modified, provided the 50994689c1Smrgtext widget is in the correct edit mode, just as if it were a source of 51994689c1Smrgtype <function>XawAsciiString</function>. Unlike R3 and earlier versions of the AsciiSrc, 52994689c1Smrgit is now possible to specify an editable disk source. The file is not 53421c997bSmrgupdated, however, until a call to <xref linkend='XawAsciiSave' xrefstyle='select: title'/> is made. When the 54994689c1Smrgsource is in this mode the <function>useStringInPlace</function> resource is ignored. 55994689c1Smrg</para> 56994689c1Smrg<para> 57994689c1Smrg<!-- .LP --> 58994689c1SmrgAsciiSrc objects of type <function>XawAsciiString</function> have the text buffer 59994689c1Smrgimplemented as a string. 605ec34c4cSmrg<emphasis remap='I'>MultiSrc objects of type <function>XawAsciiString</function> 615ec34c4cSmrghave the text buffer implemented as a wide character string.</emphasis> 62994689c1SmrgThe string owner is responsible for allocating and managing storage for the 63994689c1Smrgstring. 64994689c1Smrg</para> 65994689c1Smrg<para> 66994689c1Smrg<!-- .LP --> 67994689c1SmrgIn the default case for AsciiSrc objects of type <function>XawAsciiString</function>, 68994689c1Smrgthe resource <function>useStringInPlace</function> is false, 69994689c1Smrgand the widget owns the string. The initial value of the 70994689c1Smrgstring resource, and any update made by the application 71421c997bSmrgprogrammer to the string resource with <xref linkend='XtSetValues' xrefstyle='select: title'/>, is copied 72994689c1Smrginto memory private to the widget, and managed internally by the widget. 73994689c1SmrgThe application writer 74994689c1Smrgdoes not need to worry about running out of buffer space 75994689c1Smrg(subject to the total memory available to the application). 76994689c1SmrgThe performance does not decay linearly as the buffer grows 77994689c1Smrglarge, as is necessarily the case when the text buffer is used 78421c997bSmrgin place. The application writer must use <xref linkend='XtGetValues' xrefstyle='select: title'/> to 79994689c1Smrgdetermine the contents of the text buffer, which will return 80994689c1Smrga copy of the widget's text buffer as 81421c997bSmrgit existed at the time of the <xref linkend='XtGetValues' xrefstyle='select: title'/> call. This copy 82994689c1Smrgis not affected by subsequent updates to the text buffer, i.e., 83994689c1Smrgit is not updated as the user types input into the text buffer. 84994689c1SmrgThis copy is freed upon the next call to XtGetValues to 85994689c1Smrgretrieve the string resource; however, to conserve memory, 86421c997bSmrgthere is a convenience routine, <xref linkend='XawAsciiSourceFreeString' xrefstyle='select: title'/>, allowing the 87994689c1Smrgapplication programmer to direct the widget to free the copy. 88994689c1Smrg</para> 89994689c1Smrg<para> 90994689c1Smrg<!-- .LP --> 91994689c1SmrgWhen the resource <function>useStringInPlace</function> is true and the AsciiSrc object 92994689c1Smrgis of type <function>XawAsciiString</function>, the application 93994689c1Smrgis the string owner. The widget will take the value 94994689c1Smrgof the string resource as its own text buffer, and the <function>length</function> 95994689c1Smrgresource indicates the buffer size. In this case 96994689c1Smrgthe buffer contents change as the user types at the widget; 97421c997bSmrgit is not necessary to call <xref linkend='XtGetValues' xrefstyle='select: title'/> on the string 98994689c1Smrgresource to determine the contents of the buffer-it will 99994689c1Smrgsimply return the address of the application's implementation 100994689c1Smrgof the text buffer. 101994689c1Smrg</para> 102421c997bSmrg<sect2 id='AsciiSource::Resources'> 103994689c1Smrg<title>Resources</title> 104994689c1Smrg<para> 105994689c1Smrg<!-- .LP --> 106994689c1SmrgWhen creating an AsciiSrc object instance, the following resources are 107994689c1Smrgretrieved from the argument list or from the resource database: 108994689c1Smrg</para> 109994689c1Smrg<para> 110994689c1Smrg<!-- .LP --> 1115ec34c4cSmrg<indexterm><primary>AsciiSrc object</primary><secondary>resources</secondary></indexterm> 112994689c1Smrg<informaltable> 113994689c1Smrg <tgroup cols='5' align='center'> 114994689c1Smrg <colspec colname='c1'/> 115994689c1Smrg <colspec colname='c2'/> 116994689c1Smrg <colspec colname='c3'/> 117994689c1Smrg <colspec colname='c4'/> 118994689c1Smrg <colspec colname='c5'/> 119994689c1Smrg <thead> 120994689c1Smrg <row> 121994689c1Smrg <entry>Name</entry> 122994689c1Smrg <entry>Class</entry> 123994689c1Smrg <entry>Type</entry> 124994689c1Smrg <entry>Notes</entry> 125994689c1Smrg <entry>Default Value</entry> 126994689c1Smrg </row> 127994689c1Smrg </thead> 128994689c1Smrg <tbody> 129994689c1Smrg <row> 130994689c1Smrg <entry>callback</entry> 131994689c1Smrg <entry>Callback</entry> 132994689c1Smrg <entry>XtCallbackList</entry> 133994689c1Smrg <entry></entry> 134994689c1Smrg <entry>NULL</entry> 135994689c1Smrg </row> 136994689c1Smrg <row> 137994689c1Smrg <entry>dataCompression</entry> 138994689c1Smrg <entry>DataCompression</entry> 139994689c1Smrg <entry>Boolean</entry> 140994689c1Smrg <entry></entry> 141994689c1Smrg <entry>True</entry> 142994689c1Smrg </row> 143994689c1Smrg <row> 144994689c1Smrg <entry>destroyCallback</entry> 145994689c1Smrg <entry>Callback</entry> 146994689c1Smrg <entry>Callback</entry> 147994689c1Smrg <entry></entry> 148994689c1Smrg <entry>NULL</entry> 149994689c1Smrg </row> 150994689c1Smrg <row> 151994689c1Smrg <entry>editType</entry> 152994689c1Smrg <entry>EditType</entry> 153994689c1Smrg <entry>EditMode</entry> 154994689c1Smrg <entry></entry> 155994689c1Smrg <entry>XawtextRead</entry> 156994689c1Smrg </row> 157994689c1Smrg <row> 158994689c1Smrg <entry>length</entry> 159994689c1Smrg <entry>Length</entry> 160994689c1Smrg <entry>Int</entry> 161994689c1Smrg <entry>A</entry> 162994689c1Smrg <entry>length of <function>string</function></entry> 163994689c1Smrg </row> 164994689c1Smrg <row> 165994689c1Smrg <entry>pieceSize</entry> 166994689c1Smrg <entry>PieceSize</entry> 167994689c1Smrg <entry>Int</entry> 168994689c1Smrg <entry></entry> 169994689c1Smrg <entry>BUFSIZ</entry> 170994689c1Smrg </row> 171994689c1Smrg <row> 172994689c1Smrg <entry>string</entry> 173994689c1Smrg <entry>String</entry> 174994689c1Smrg <entry>String</entry> 175994689c1Smrg <entry></entry> 176994689c1Smrg <entry>NULL</entry> 177994689c1Smrg </row> 178994689c1Smrg <row> 179994689c1Smrg <entry>type</entry> 180994689c1Smrg <entry>Type</entry> 181994689c1Smrg <entry>AsciiType</entry> 182994689c1Smrg <entry></entry> 183994689c1Smrg <entry>XawAsciiString</entry> 184994689c1Smrg </row> 185994689c1Smrg <row> 186994689c1Smrg <entry>useStringInPlace</entry> 187994689c1Smrg <entry>UseStringInPlace</entry> 188994689c1Smrg <entry>Boolean</entry> 189994689c1Smrg <entry></entry> 190994689c1Smrg <entry>False</entry> 191994689c1Smrg </row> 192994689c1Smrg <row> 193994689c1Smrg <entry>_</entry> 194994689c1Smrg </row> 195994689c1Smrg </tbody> 196994689c1Smrg </tgroup> 197994689c1Smrg</informaltable> 198994689c1Smrg<!-- .Oc Bold --> 199994689c1Smrg<!-- .Dc --> 200994689c1Smrg<!-- .Od Bold --> 201994689c1Smrg<!-- .Oe --> 202994689c1Smrg<!-- .Ol Bold --> 203994689c1Smrg<!-- .Op Bold --> 204994689c1Smrg<!-- .Os Bold --> 205994689c1Smrg<!-- .Ot Bold --> 206994689c1Smrg<!-- .Ou Bold --> 207994689c1Smrg</para> 208994689c1Smrg</sect2> 209421c997bSmrg<sect2 id='AsciiSource::Convenience_Routines'> 210994689c1Smrg<title>Convenience Routines</title> 211994689c1Smrg<para> 212994689c1Smrg<!-- .LP --> 213994689c1SmrgThe AsciiSrc has a few convenience routines that allow the 214994689c1Smrgapplication programmer quicker or easier access to some of the 215994689c1Smrgcommonly used functionality of the AsciiSrc. 216994689c1Smrg</para> 217994689c1Smrg<sect3 id="Conserving_Memory"> 218994689c1Smrg<title>Conserving Memory</title> 219994689c1Smrg<para> 220994689c1Smrg<!-- .LP --> 221994689c1SmrgWhen the AsciiSrc widget is not in <function>useStringInPlace</function> mode 222994689c1Smrgspace must be allocated whenever the file is saved, or the string is 223421c997bSmrgrequested with a call to <xref linkend='XtGetValues' xrefstyle='select: title'/>. This memory is allocated on the 224994689c1Smrgfly, and remains valid until the next time a string needs to be allocated. 225994689c1SmrgYou may save memory by freeing this string as soon as you are done 226421c997bSmrgwith it by calling <xref linkend='XawAsciiSourceFreeString' xrefstyle='select: title'/>. 227421c997bSmrg<funcsynopsis id='XawAsciiSourceFreeString'> 228994689c1Smrg<funcprototype> 229994689c1Smrg <funcdef>void<function> XawAsciiSourceFreeString</function></funcdef> 230994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 231994689c1Smrg</funcprototype> 232994689c1Smrg</funcsynopsis> 233994689c1Smrg<!-- .FN --> 234994689c1Smrg<variablelist> 235994689c1Smrg <varlistentry> 236994689c1Smrg <term> 237994689c1Smrg <emphasis remap='I'>w</emphasis> 238994689c1Smrg </term> 239994689c1Smrg <listitem> 240994689c1Smrg <para> 241994689c1SmrgSpecifies the AsciiSrc object. 242994689c1Smrg </para> 243994689c1Smrg </listitem> 244994689c1Smrg </varlistentry> 245994689c1Smrg</variablelist> 246994689c1Smrg</para> 247994689c1Smrg<para> 248994689c1Smrg<!-- .LP --> 249994689c1SmrgThis function will free the memory that contains the string pointer returned 250421c997bSmrgby <xref linkend='XtGetValues' xrefstyle='select: title'/>. This will normally happen automatically when 251421c997bSmrgthe next call to <xref linkend='XtGetValues' xrefstyle='select: title'/> occurs, or when the widget is destroyed. 252994689c1Smrg</para> 253994689c1Smrg</sect3> 254994689c1Smrg<sect3 id="Saving_Files"> 255994689c1Smrg<title>Saving Files</title> 256994689c1Smrg<para> 257994689c1Smrg<!-- .LP --> 258994689c1SmrgTo save the changes made in the current text source into a file use 259421c997bSmrg<xref linkend='XawAsciiSave' xrefstyle='select: title'/>. 260421c997bSmrg<funcsynopsis id='XawAsciiSave'> 261994689c1Smrg<funcprototype> 262994689c1Smrg <funcdef>Boolean<function> XawAsciiSave</function></funcdef> 263994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 264994689c1Smrg</funcprototype> 265994689c1Smrg</funcsynopsis> 266994689c1Smrg<!-- .FN --> 267994689c1Smrg<variablelist> 268994689c1Smrg <varlistentry> 269994689c1Smrg <term> 270994689c1Smrg <emphasis remap='I'>w</emphasis> 271994689c1Smrg </term> 272994689c1Smrg <listitem> 273994689c1Smrg <para> 274994689c1SmrgSpecifies the AsciiSrc object. 275994689c1Smrg </para> 276994689c1Smrg </listitem> 277994689c1Smrg </varlistentry> 278994689c1Smrg</variablelist> 279994689c1Smrg</para> 280994689c1Smrg<para> 281994689c1Smrg<!-- .LP --> 282421c997bSmrg<xref linkend='XawAsciiSave' xrefstyle='select: title'/> returns <function>True</function> if the save was successful. 283994689c1SmrgIt will update the file named in the <function>string</function> resource. 284994689c1SmrgIf the buffer has not been changed, no action will be taken. This function 285994689c1Smrgonly works on an AsciiSrc of type <function>XawAsciiFile</function>. 286994689c1Smrg</para> 287994689c1Smrg<para> 288994689c1Smrg<!-- .LP --> 289994689c1Smrg<!-- .sp 1 --> 290994689c1SmrgTo save the contents of the current text buffer into a named file use 291421c997bSmrg<xref linkend='XawAsciiSaveAsFile' xrefstyle='select: title'/>. 292421c997bSmrg<funcsynopsis id='XawAsciiSaveAsFile'> 293994689c1Smrg<funcprototype> 294994689c1Smrg <funcdef>Boolean<function> XawAsciiSaveAsFile</function></funcdef> 295994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 296994689c1Smrg <paramdef>String<parameter> name</parameter></paramdef> 297994689c1Smrg</funcprototype> 298994689c1Smrg</funcsynopsis> 299994689c1Smrg<!-- .FN --> 300994689c1Smrg<variablelist> 301994689c1Smrg <varlistentry> 302994689c1Smrg <term> 303994689c1Smrg <emphasis remap='I'>w</emphasis> 304994689c1Smrg </term> 305994689c1Smrg <listitem> 306994689c1Smrg <para> 307994689c1SmrgSpecifies the AsciiSrc object. 308994689c1Smrg </para> 309994689c1Smrg </listitem> 310994689c1Smrg </varlistentry> 311994689c1Smrg <varlistentry> 312994689c1Smrg <term> 313994689c1Smrg <emphasis remap='I'>name</emphasis> 314994689c1Smrg </term> 315994689c1Smrg <listitem> 316994689c1Smrg <para> 317994689c1SmrgThe name of the file to save the current buffer into. 318994689c1Smrg </para> 319994689c1Smrg </listitem> 320994689c1Smrg </varlistentry> 321994689c1Smrg</variablelist> 322994689c1Smrg</para> 323994689c1Smrg<para> 324994689c1Smrg<!-- .LP --> 325994689c1SmrgThis function returns <function>True</function> if the save was successful. 326421c997bSmrg<xref linkend='XawAsciiSaveAsFile' xrefstyle='select: title'/> will work with a buffer of either type 327994689c1Smrg<function>XawAsciiString</function> or type <function>XawAsciiFile</function>. 328994689c1Smrg</para> 329994689c1Smrg</sect3> 330994689c1Smrg<sect3 id="Seeing_if_the_Source_has_Changed"> 331994689c1Smrg<title>Seeing if the Source has Changed</title> 332994689c1Smrg<para> 333994689c1Smrg<!-- .LP --> 334994689c1SmrgTo find out if the text buffer in an AsciiSrc object has changed 335421c997bSmrgsince the last time it was saved with <xref linkend='XawAsciiSave' xrefstyle='select: title'/> or queried 3365ec34c4cSmrg<indexterm><primary>XawAsciiSave</primary></indexterm> 337421c997bSmrguse <xref linkend='XawAsciiSourceChanged' xrefstyle='select: title'/>. 338421c997bSmrg<funcsynopsis id='XawAsciiSourceChanged'> 339994689c1Smrg<funcprototype> 340994689c1Smrg <funcdef>Boolean<function> XawAsciiSourceChanged</function></funcdef> 341994689c1Smrg <paramdef>Widget<parameter> w</parameter></paramdef> 342994689c1Smrg</funcprototype> 343994689c1Smrg</funcsynopsis> 344994689c1Smrg<!-- .FN --> 345994689c1Smrg<variablelist> 346994689c1Smrg <varlistentry> 347994689c1Smrg <term> 348994689c1Smrg <emphasis remap='I'>w</emphasis> 349994689c1Smrg </term> 350994689c1Smrg <listitem> 351994689c1Smrg <para> 352994689c1SmrgSpecifies the AsciiSrc object. 353994689c1Smrg </para> 354994689c1Smrg </listitem> 355994689c1Smrg </varlistentry> 356994689c1Smrg</variablelist> 357994689c1Smrg</para> 358994689c1Smrg<para> 359994689c1Smrg<!-- .LP --> 360994689c1SmrgThis function will return <function>True</function> if the source has changed since 361994689c1Smrgthe last time it was saved or queried. The internal change flag is 362421c997bSmrgreset whenever the string is queried via <xref linkend='XtGetValues' xrefstyle='select: title'/> or the 363421c997bSmrgbuffer is saved via <xref linkend='XawAsciiSave' xrefstyle='select: title'/>. 364994689c1Smrg 365994689c1Smrg</para> 366994689c1Smrg</sect3> 367994689c1Smrg</sect2> 368994689c1Smrg</sect1> 369