home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / xconf / part04 < prev    next >
Encoding:
Internet Message Format  |  1993-05-04  |  55.3 KB

  1. From: argv@island.uu.net (Dan Heller)
  2. Newsgroups: comp.sources.x
  3. Subject: v04i085: xconf -- X-based conferencing tool, Part04/05
  4. Message-ID: <936@island.uu.net>
  5. Date: 25 Jul 89 08:11:01 GMT
  6. Approved: island!argv@sun.com
  7.  
  8. Submitted-by: Jon Crowcroft <J.Crowcroft@Cs.Ucl.AC.UK>
  9. Posting-number: Volume 4, Issue 85
  10. Archive-name: xconf/part04
  11.  
  12.  
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # If this archive is complete, you will see the following message at the end:
  21. #        "End of archive 4 (of 5)."
  22. # Contents:  xconf/AsciiText.c xconf/Dialog.c xconf/DiskSrc.c
  23. #   xconf/Imakefile xconf/StringSrc.c xconf/Text.h xconf/TextP.h
  24. # Wrapped by argv@sumatra on Tue Jul 25 01:01:07 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'xconf/AsciiText.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'xconf/AsciiText.c'\"
  28. else
  29. echo shar: Extracting \"'xconf/AsciiText.c'\" \(9259 characters\)
  30. sed "s/^X//" >'xconf/AsciiText.c' <<'END_OF_FILE'
  31. X#ifndef lint
  32. Xstatic char Xrcsid[] = "$XConsortium: AsciiText.c,v 1.18 88/10/18 12:28:26 swick Exp $";
  33. X#endif lint
  34. X
  35. X
  36. X/***********************************************************
  37. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  38. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  39. X
  40. X                        All Rights Reserved
  41. X
  42. XPermission to use, copy, modify, and distribute this software and its 
  43. Xdocumentation for any purpose and without fee is hereby granted, 
  44. Xprovided that the above copyright notice appear in all copies and that
  45. Xboth that copyright notice and this permission notice appear in 
  46. Xsupporting documentation, and that the names of Digital or MIT not be
  47. Xused in advertising or publicity pertaining to distribution of the
  48. Xsoftware without specific, written prior permission.  
  49. X
  50. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  51. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  52. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  53. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  54. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  55. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  56. XSOFTWARE.
  57. X
  58. X******************************************************************/
  59. X
  60. X#include <X11/copyright.h>
  61. X#include <X11/IntrinsicP.h>
  62. X#include <X11/StringDefs.h>
  63. X#ifdef JON
  64. X#include "AsciiTextP.h"
  65. X#else JON
  66. X#include <X11/AsciiTextP.h>
  67. X#endif
  68. X
  69. X/* from Text.c */
  70. X
  71. Xextern void ForceBuildLineTable(); /* in Text.c */
  72. X
  73. Xstatic XtResource string_resources[] = {
  74. X  {XtNstring, XtCString, XtRString, sizeof(String),
  75. X     XtOffset(AsciiStringWidget, ascii_string.string), XtRString, NULL}
  76. X};
  77. X
  78. Xstatic XtResource disk_resources[] = {
  79. X  {XtNfile, XtCFile, XtRString, sizeof(String),
  80. X     XtOffset(AsciiDiskWidget, ascii_disk.file_name), XtRString, NULL}
  81. X};
  82. X
  83. Xstatic void StringClassInitialize(), StringInitialize(),
  84. X    StringCreateSourceSink(), StringDestroy();
  85. Xstatic Boolean StringSetValues();
  86. X
  87. Xstatic void DiskClassInitialize(), DiskInitialize(),
  88. X    DiskCreateSourceSink(), DiskDestroy();
  89. Xstatic Boolean DiskSetValues();
  90. X
  91. XAsciiStringClassRec asciiStringClassRec = {
  92. X  { /* core fields */
  93. X    /* superclass       */      (WidgetClass) &textClassRec,
  94. X    /* class_name       */      "Text",
  95. X    /* widget_size      */      sizeof(AsciiStringRec),
  96. X    /* class_initialize */      StringClassInitialize,
  97. X    /* class_part_init  */    NULL,
  98. X    /* class_inited     */      FALSE,
  99. X    /* initialize       */      StringInitialize,
  100. X    /* initialize_hook  */    StringCreateSourceSink,
  101. X    /* realize          */      XtInheritRealize,
  102. X    /* actions          */      textActionsTable,
  103. X    /* num_actions      */      0,
  104. X    /* resources        */      string_resources,
  105. X    /* num_ resource    */      XtNumber(string_resources),
  106. X    /* xrm_class        */      NULLQUARK,
  107. X    /* compress_motion  */      TRUE,
  108. X    /* compress_exposure*/      FALSE,
  109. X    /* compress_enterleave*/    TRUE,
  110. X    /* visible_interest */      FALSE,
  111. X    /* destroy          */      StringDestroy,
  112. X    /* resize           */      XtInheritResize,
  113. X    /* expose           */      XtInheritExpose,
  114. X    /* set_values       */      StringSetValues,
  115. X    /* set_values_hook  */    NULL,
  116. X    /* set_values_almost*/    XtInheritSetValuesAlmost,
  117. X    /* get_values_hook  */    NULL,
  118. X    /* accept_focus     */      XtInheritAcceptFocus,
  119. X    /* version          */    XtVersion,
  120. X    /* callback_private */      NULL,
  121. X    /* tm_table         */      XtInheritTranslations,
  122. X    /* query_geometry    */    XtInheritQueryGeometry
  123. X  },
  124. X  { /* text fields */
  125. X    /* empty            */      0
  126. X  },
  127. X  { /* ascii_string fields */
  128. X    /* empty            */      0
  129. X  }
  130. X};
  131. X
  132. XAsciiDiskClassRec asciiDiskClassRec = {
  133. X  { /* core fields */
  134. X    /* superclass       */      (WidgetClass) &textClassRec,
  135. X    /* class_name       */      "Text",
  136. X    /* widget_size      */      sizeof(AsciiDiskRec),
  137. X    /* class_initialize */      DiskClassInitialize,
  138. X    /* class_part_init  */    NULL,
  139. X    /* class_inited     */      FALSE,
  140. X    /* initialize       */      DiskInitialize,
  141. X    /* initialize_hook  */    DiskCreateSourceSink,
  142. X    /* realize          */      XtInheritRealize,
  143. X    /* actions          */      textActionsTable,
  144. X    /* num_actions      */      0,
  145. X    /* resources        */      disk_resources,
  146. X    /* num_ resource    */      XtNumber(disk_resources),
  147. X    /* xrm_class        */      NULLQUARK,
  148. X    /* compress_motion  */      TRUE,
  149. X    /* compress_exposure*/      FALSE,
  150. X    /* compress_enterleave*/    TRUE,
  151. X    /* visible_interest */      FALSE,
  152. X    /* destroy          */      DiskDestroy,
  153. X    /* resize           */      XtInheritResize,
  154. X    /* expose           */      XtInheritExpose,
  155. X    /* set_values       */      DiskSetValues,
  156. X    /* set_values_hook  */    NULL,
  157. X    /* set_values_almost*/    XtInheritSetValuesAlmost,
  158. X    /* get_values_hook  */    NULL,
  159. X    /* accept_focus     */      XtInheritAcceptFocus,
  160. X    /* version          */    XtVersion,
  161. X    /* callback_private */      NULL,
  162. X    /* tm_table         */      XtInheritTranslations,
  163. X    /* query_geometry    */    XtInheritQueryGeometry
  164. X  },
  165. X  { /* text fields */
  166. X    /* empty            */      0
  167. X  },
  168. X  { /* ascii_disk fields */
  169. X    /* empty            */      0
  170. X  }
  171. X};
  172. X
  173. X
  174. XWidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
  175. XWidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
  176. X
  177. X
  178. Xstatic void StringClassInitialize()
  179. X{
  180. X    asciiStringClassRec.core_class.num_actions = textActionsTableCount;
  181. X}
  182. X
  183. X
  184. X/* ARGSUSED */
  185. Xstatic void StringInitialize(request, new)
  186. X    Widget request, new;
  187. X{
  188. X    /* superclass Initialize can't set the following,
  189. X     * as it didn't know the source or sink when it was called */
  190. X    if (request->core.height == DEFAULT_TEXT_HEIGHT)
  191. X    new->core.height = DEFAULT_TEXT_HEIGHT;
  192. X}
  193. X
  194. Xstatic void StringCreateSourceSink(widget, args, num_args)
  195. X    Widget widget;
  196. X    ArgList args;
  197. X    Cardinal *num_args;
  198. X{
  199. X    AsciiStringWidget w = (AsciiStringWidget)widget;
  200. X    void (*NullProc)() = NULL;    /* some compilers require this */
  201. X
  202. X    w->text.source = XtStringSourceCreate( widget, args, *num_args );
  203. X    w->text.sink = XtAsciiSinkCreate( widget, args, *num_args );
  204. X
  205. X    if (w->core.height == DEFAULT_TEXT_HEIGHT)
  206. X        w->core.height = (2*yMargin) + 2
  207. X              + (*w->text.sink->MaxHeight)(widget, 1);
  208. X
  209. X    w->text.lastPos = /* GETLASTPOS */
  210. X      (*w->text.source->Scan) ( w->text.source, 0, XtstAll,
  211. X                    XtsdRight, 1, TRUE );
  212. X
  213. X    if (w->text.sink->SetTabs != NullProc) {
  214. X#define TAB_COUNT 32
  215. X    int i;
  216. X    Position tabs[TAB_COUNT], tab;
  217. X
  218. X    for (i=0, tab=0; i<TAB_COUNT;i++) {
  219. X        tabs[i] = (tab += 8);
  220. X    }
  221. X    (w->text.sink->SetTabs) (widget, w->text.leftmargin, TAB_COUNT, tabs);
  222. X#undef TAB_COUNT
  223. X    }
  224. X
  225. X    ForceBuildLineTable( (TextWidget)w );
  226. X}
  227. X
  228. X
  229. X/* ARGSUSED */
  230. Xstatic Boolean StringSetValues(current, request, new)
  231. X    Widget current, request, new;
  232. X{
  233. X    AsciiStringWidget old = (AsciiStringWidget)current;
  234. X    AsciiStringWidget w = (AsciiStringWidget)new;
  235. X
  236. X    if (w->ascii_string.string != old->ascii_string.string)
  237. X        XtError( "SetValues on AsciiStringWidget string not supported." );
  238. X
  239. X    return False;
  240. X}
  241. X
  242. X
  243. Xstatic void StringDestroy(w)
  244. X    Widget w;
  245. X{
  246. X    XtStringSourceDestroy( ((AsciiStringWidget)w)->text.source );
  247. X    XtAsciiSinkDestroy( ((AsciiStringWidget)w)->text.sink );
  248. X}
  249. X
  250. X
  251. Xstatic void DiskClassInitialize()
  252. X{
  253. X    asciiDiskClassRec.core_class.num_actions = textActionsTableCount;
  254. X}
  255. X
  256. X
  257. X/* ARGSUSED */
  258. Xstatic void DiskInitialize(request, new)
  259. X    Widget request, new;
  260. X{
  261. X    /* superclass Initialize can't set the following,
  262. X     * as it didn't know the source or sink when it was called */
  263. X    if (request->core.height == DEFAULT_TEXT_HEIGHT)
  264. X    new->core.height = DEFAULT_TEXT_HEIGHT;
  265. X}
  266. X
  267. Xstatic void DiskCreateSourceSink(widget, args, num_args)
  268. X    Widget widget;
  269. X    ArgList args;
  270. X    Cardinal *num_args;
  271. X{
  272. X    AsciiDiskWidget w = (AsciiDiskWidget)widget;
  273. X    void (*NullProc)() = NULL;    /* some compilers require this */
  274. X
  275. X    w->text.source = XtDiskSourceCreate( widget, args, *num_args );
  276. X    w->text.sink = XtAsciiSinkCreate( widget, args, *num_args );
  277. X
  278. X    w->text.lastPos = /* GETLASTPOS */
  279. X      (*w->text.source->Scan) ( w->text.source, 0, XtstAll,
  280. X                    XtsdRight, 1, TRUE );
  281. X
  282. X    if (w->core.height == DEFAULT_TEXT_HEIGHT)
  283. X        w->core.height = (2*yMargin) + 2
  284. X              + (*w->text.sink->MaxHeight)(widget, 1);
  285. X
  286. X    if (w->text.sink->SetTabs != NullProc) {
  287. X#define TAB_COUNT 32
  288. X    int i;
  289. X    Position tabs[TAB_COUNT], tab;
  290. X
  291. X    for (i=0, tab=0; i<TAB_COUNT;i++) {
  292. X        tabs[i] = (tab += 8);
  293. X    }
  294. X    (w->text.sink->SetTabs) (widget, w->text.leftmargin, TAB_COUNT, tabs);
  295. X#undef TAB_COUNT
  296. X    }
  297. X
  298. X    ForceBuildLineTable( (TextWidget)w );
  299. X}
  300. X
  301. X
  302. X/* ARGSUSED */
  303. Xstatic Boolean DiskSetValues(current, request, new)
  304. X    Widget current, request, new;
  305. X{
  306. X    AsciiDiskWidget old = (AsciiDiskWidget)current;
  307. X    AsciiDiskWidget w = (AsciiDiskWidget)new;
  308. X
  309. X    if (w->ascii_disk.file_name != old->ascii_disk.file_name)
  310. X        XtError( "SetValues on AsciiDiskWidget file not supported." );
  311. X
  312. X    return False;
  313. X}
  314. X
  315. X
  316. Xstatic void DiskDestroy(w)
  317. X    Widget w;
  318. X{
  319. X    XtDiskSourceDestroy( ((AsciiDiskWidget)w)->text.source );
  320. X    XtAsciiSinkDestroy( ((AsciiDiskWidget)w)->text.sink );
  321. X}
  322. END_OF_FILE
  323. if test 9259 -ne `wc -c <'xconf/AsciiText.c'`; then
  324.     echo shar: \"'xconf/AsciiText.c'\" unpacked with wrong size!
  325. fi
  326. # end of 'xconf/AsciiText.c'
  327. fi
  328. if test -f 'xconf/Dialog.c' -a "${1}" != "-c" ; then 
  329.   echo shar: Will not clobber existing file \"'xconf/Dialog.c'\"
  330. else
  331. echo shar: Extracting \"'xconf/Dialog.c'\" \(8945 characters\)
  332. sed "s/^X//" >'xconf/Dialog.c' <<'END_OF_FILE'
  333. X#ifndef lint
  334. Xstatic char Xrcsid[] = "$XConsortium: Dialog.c,v 1.18 88/09/06 16:41:13 jim Exp $";
  335. X#endif lint
  336. X
  337. X
  338. X/***********************************************************
  339. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  340. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  341. X
  342. X                        All Rights Reserved
  343. X
  344. XPermission to use, copy, modify, and distribute this software and its 
  345. Xdocumentation for any purpose and without fee is hereby granted, 
  346. Xprovided that the above copyright notice appear in all copies and that
  347. Xboth that copyright notice and this permission notice appear in 
  348. Xsupporting documentation, and that the names of Digital or MIT not be
  349. Xused in advertising or publicity pertaining to distribution of the
  350. Xsoftware without specific, written prior permission.  
  351. X
  352. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  353. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  354. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  355. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  356. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  357. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  358. XSOFTWARE.
  359. X
  360. X******************************************************************/
  361. X
  362. X/* NOTE: THIS IS NOT A WIDGET!  Rather, this is an interface to a widget.
  363. X   It implements policy, and gives a (hopefully) easier-to-use interface
  364. X   than just directly making your own form. */
  365. X
  366. X
  367. X#include <X11/Xlib.h>
  368. X#include <X11/Xos.h>
  369. X#include <X11/IntrinsicP.h>
  370. X#ifdef JON
  371. X#include "XawMisc.h"
  372. X#else JON
  373. X#include <X11/XawMisc.h>
  374. X#endif JON
  375. X#include <X11/StringDefs.h>
  376. X#ifdef JON
  377. X#include "AsciiText.h"
  378. X#else JON
  379. X#include <X11/AsciiText.h>
  380. X#endif JON
  381. X#include <X11/Command.h>
  382. X#include <X11/Label.h>
  383. X#include <X11/DialogP.h>
  384. X
  385. X
  386. Xstatic XtResource resources[] = {
  387. X  {XtNlabel, XtCLabel, XtRString, sizeof(String),
  388. X     XtOffset(DialogWidget, dialog.label), XtRString, NULL},
  389. X  {XtNvalue, XtCValue, XtRString, sizeof(String),
  390. X     XtOffset(DialogWidget, dialog.value), XtRString, NULL},
  391. X  {XtNmaximumLength, XtCMax, XtRInt, sizeof(int),
  392. X     XtOffset(DialogWidget, dialog.max_length), XtRString, "256"}
  393. X};
  394. X
  395. Xstatic void Initialize(), ConstraintInitialize();
  396. Xstatic Boolean SetValues();
  397. X
  398. XDialogClassRec dialogClassRec = {
  399. X  { /* core_class fields */
  400. X    /* superclass         */    (WidgetClass) &formClassRec,
  401. X    /* class_name         */    "Dialog",
  402. X    /* widget_size        */    sizeof(DialogRec),
  403. X    /* class_initialize   */    NULL,
  404. X    /* class_part init    */    NULL,
  405. X    /* class_inited       */    FALSE,
  406. X    /* initialize         */    Initialize,
  407. X    /* initialize_hook    */    NULL,
  408. X    /* realize            */    XtInheritRealize,
  409. X    /* actions            */    NULL,
  410. X    /* num_actions        */    0,
  411. X    /* resources          */    resources,
  412. X    /* num_resources      */    XtNumber(resources),
  413. X    /* xrm_class          */    NULLQUARK,
  414. X    /* compress_motion    */    TRUE,
  415. X    /* compress_exposure  */    TRUE,
  416. X    /* compress_enterleave*/    TRUE,
  417. X    /* visible_interest   */    FALSE,
  418. X    /* destroy            */    NULL,
  419. X    /* resize             */    XtInheritResize,
  420. X    /* expose             */    XtInheritExpose,
  421. X    /* set_values         */    SetValues,
  422. X    /* set_values_hook    */    NULL,
  423. X    /* set_values_almost  */    XtInheritSetValuesAlmost,
  424. X    /* get_values_hook    */    NULL,
  425. X    /* accept_focus       */    NULL,
  426. X    /* version            */    XtVersion,
  427. X    /* callback_private   */    NULL,
  428. X    /* tm_table           */    NULL,
  429. X    /* query_geometry     */    XtInheritQueryGeometry,
  430. X    /* display_accelerator*/    XtInheritDisplayAccelerator,
  431. X    /* extension          */    NULL
  432. X  },
  433. X  { /* composite_class fields */
  434. X    /* geometry_manager   */   XtInheritGeometryManager,
  435. X    /* change_managed     */   XtInheritChangeManaged,
  436. X    /* insert_child       */   XtInheritInsertChild,
  437. X    /* delete_child       */   XtInheritDeleteChild,
  438. X    /* extension          */   NULL
  439. X  },
  440. X  { /* constraint_class fields */
  441. X    /* subresourses       */   NULL,
  442. X    /* subresource_count  */   0,
  443. X    /* constraint_size    */   sizeof(DialogConstraintsRec),
  444. X    /* initialize         */   ConstraintInitialize,
  445. X    /* destroy            */   NULL,
  446. X    /* set_values         */   NULL,
  447. X    /* extension          */   NULL
  448. X  },
  449. X  { /* form_class fields */
  450. X    /* empty              */   0
  451. X  },
  452. X  { /* dialog_class fields */
  453. X    /* empty              */   0
  454. X  }
  455. X};
  456. X
  457. XWidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
  458. X
  459. X
  460. X/* ARGSUSED */
  461. Xstatic void Initialize(request, new)
  462. XWidget request, new;
  463. X{
  464. X    DialogWidget dw = (DialogWidget)new;
  465. X    static Arg label_args[] = {
  466. X    {XtNlabel, (XtArgVal)NULL},
  467. X    {XtNborderWidth, (XtArgVal) 0}
  468. X    };
  469. X    static Arg text_args[] = {
  470. X    {XtNwidth, (XtArgVal)NULL},
  471. X    {XtNstring, (XtArgVal)NULL},
  472. X    {XtNlength, (XtArgVal)0},
  473. X    {XtNfromVert, (XtArgVal)NULL},
  474. X    {XtNresizable, (XtArgVal)TRUE},
  475. X    {XtNtextOptions, (XtArgVal)(resizeWidth | resizeHeight)},
  476. X    {XtNeditType, (XtArgVal)XttextEdit},
  477. X    {XtNright, (XtArgVal)XtChainRight}
  478. X    };
  479. X    Widget children[2], *childP = children;
  480. X
  481. X    label_args[0].value = (XtArgVal)dw->dialog.label;
  482. X    dw->dialog.labelW = XtCreateWidget( "label", labelWidgetClass, new,
  483. X                        label_args, XtNumber(label_args) );
  484. X    *childP++ = dw->dialog.labelW;
  485. X
  486. X    if (dw->dialog.value) {
  487. X        String initial_value = dw->dialog.value;
  488. X    Cardinal length = Max( dw->dialog.max_length, strlen(initial_value) );
  489. X    dw->dialog.value = XtMalloc( length );
  490. X    strcpy( dw->dialog.value, initial_value );
  491. X    text_args[0].value = (XtArgVal)dw->dialog.labelW->core.width; /*|||hack*/
  492. X    text_args[1].value = (XtArgVal)dw->dialog.value;
  493. X    text_args[2].value = (XtArgVal)length;
  494. X    text_args[3].value = (XtArgVal)dw->dialog.labelW;
  495. X    dw->dialog.valueW = XtCreateWidget("value",asciiStringWidgetClass,new,
  496. X                       text_args, XtNumber(text_args) );
  497. X    *childP++ = dw->dialog.valueW;
  498. X#ifdef notdef
  499. X    static int grabfocus;
  500. X    static Resource resources[] = {
  501. X        {XtNgrabFocus, XtCGrabFocus, XtRBoolean, sizeof(int),
  502. X         (caddr_t)&grabfocus, (caddr_t)NULL}
  503. X    };
  504. X    XrmNameList names;
  505. X    XrmClassList classes;
  506. X    grabfocus = FALSE;
  507. X    XtGetResources(dpy, resources, XtNumber(resources), args, argCount,
  508. X               parent, "dialog", "Dialog", &names, &classes);
  509. X    XrmFreeNameList(names);
  510. X    XrmFreeClassList(classes);
  511. X    if (grabfocus) XSetInputFocus(dpy, data->value, RevertToParent,
  512. X                      CurrentTime); /* !!! Hackish. |||*/
  513. X#endif notdef
  514. X    } else {
  515. X        dw->dialog.valueW = NULL;
  516. X    }
  517. X
  518. X    XtManageChildren( children, (Cardinal)(childP - children) );
  519. X}
  520. X
  521. X
  522. X/* ARGSUSED */
  523. Xstatic void ConstraintInitialize(request, new)
  524. XWidget request, new;
  525. X{
  526. X    DialogWidget dw = (DialogWidget)new->core.parent;
  527. X    WidgetList children = dw->composite.children;
  528. X    DialogConstraints constraint = (DialogConstraints)new->core.constraints;
  529. X    Widget *childP;
  530. X
  531. X    if (!XtIsSubclass(new, commandWidgetClass))    /* if not a button */
  532. X    return;                    /* then just use defaults */
  533. X
  534. X    constraint->form.left = constraint->form.right = XtChainLeft;
  535. X    constraint->form.vert_base = dw->dialog.valueW
  536. X                 ? dw->dialog.valueW
  537. X                 : dw->dialog.labelW;
  538. X
  539. X    if (dw->composite.num_children > 1) {
  540. X        for (childP = children + dw->composite.num_children - 1;
  541. X         childP >= children; childP-- ) {
  542. X        if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
  543. X            break;
  544. X        if (XtIsManaged(*childP) &&
  545. X        XtIsSubclass(*childP, commandWidgetClass)) {
  546. X            constraint->form.horiz_base = *childP;
  547. X        break;
  548. X        }
  549. X    }
  550. X    }
  551. X}
  552. X
  553. X
  554. X/* ARGSUSED */
  555. Xstatic Boolean SetValues(current, request, new)
  556. XWidget current, request, new;
  557. X{
  558. X    DialogWidget w = (DialogWidget)new;
  559. X    DialogWidget old = (DialogWidget)current;
  560. X
  561. X    if (w->dialog.label != old->dialog.label
  562. X    || (w->dialog.label != NULL
  563. X        && old->dialog.label != NULL
  564. X        && strcmp(w->dialog.label, old->dialog.label))
  565. X    )
  566. X    {
  567. X    Arg args[1];
  568. X    XtSetArg( args[1], XtNlabel, w->dialog.label );
  569. X    XtSetValues( w->dialog.labelW, args, XtNumber(args) );
  570. X    }
  571. X
  572. X    return False;
  573. X}
  574. X
  575. X
  576. Xvoid XtDialogAddButton(dialog, name, function, param)
  577. XWidget dialog;
  578. Xchar *name;
  579. Xvoid (*function)();
  580. Xcaddr_t param;
  581. X{
  582. X    DialogWidget parent = (DialogWidget)dialog;
  583. X    static XtCallbackRec callback[] = { {NULL, NULL}, {NULL, NULL} };
  584. X    static Arg arglist[] = {
  585. X    {XtNcallback, (XtArgVal) callback},
  586. X    {XtNfromVert, (XtArgVal) NULL},
  587. X    {XtNleft, (XtArgVal) XtChainLeft},
  588. X    {XtNright, (XtArgVal) XtChainLeft}
  589. X    };
  590. X
  591. X    callback[0].callback = function;
  592. X    callback[0].closure =  param;
  593. X
  594. X    if (parent->dialog.value)
  595. X       arglist[1].value = (XtArgVal) parent->dialog.value;
  596. X    else
  597. X       arglist[1].value = (XtArgVal) parent->dialog.label;
  598. X
  599. X    XtCreateManagedWidget( name, commandWidgetClass, dialog, 
  600. X               arglist, XtNumber(arglist) );
  601. X}
  602. X
  603. X
  604. Xchar *XtDialogGetValueString(w)
  605. XWidget w;
  606. X{
  607. X    return ((DialogWidget)w)->dialog.value;
  608. X}
  609. END_OF_FILE
  610. if test 8945 -ne `wc -c <'xconf/Dialog.c'`; then
  611.     echo shar: \"'xconf/Dialog.c'\" unpacked with wrong size!
  612. fi
  613. # end of 'xconf/Dialog.c'
  614. fi
  615. if test -f 'xconf/DiskSrc.c' -a "${1}" != "-c" ; then 
  616.   echo shar: Will not clobber existing file \"'xconf/DiskSrc.c'\"
  617. else
  618. echo shar: Extracting \"'xconf/DiskSrc.c'\" \(11969 characters\)
  619. sed "s/^X//" >'xconf/DiskSrc.c' <<'END_OF_FILE'
  620. X#ifndef lint
  621. Xstatic char Xrcsid[] = "$XConsortium: DiskSrc.c,v 1.20 88/10/18 12:29:54 swick Exp $";
  622. X#endif lint
  623. X
  624. X
  625. X/***********************************************************
  626. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  627. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  628. X
  629. X                        All Rights Reserved
  630. X
  631. XPermission to use, copy, modify, and distribute this software and its 
  632. Xdocumentation for any purpose and without fee is hereby granted, 
  633. Xprovided that the above copyright notice appear in all copies and that
  634. Xboth that copyright notice and this permission notice appear in 
  635. Xsupporting documentation, and that the names of Digital or MIT not be
  636. Xused in advertising or publicity pertaining to distribution of the
  637. Xsoftware without specific, written prior permission.  
  638. X
  639. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  640. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  641. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  642. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  643. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  644. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  645. XSOFTWARE.
  646. X
  647. X******************************************************************/
  648. X
  649. X/* File: DiskSource.c */
  650. X/* Documentation for source specfic routine semantics may be found in the
  651. X * TextPrivate.h file.
  652. X */
  653. X
  654. X#include <stdio.h>
  655. X#include <sys/param.h>
  656. X#include <X11/IntrinsicP.h>
  657. X#include <X11/StringDefs.h>
  658. X#include <X11/Xatom.h>
  659. X#include <X11/Xmu.h>
  660. X#ifdef JON
  661. X#include "TextP.h"
  662. X#else JON
  663. X#include <X11/TextP.h>
  664. X#endif JON
  665. X
  666. X#define TMPSIZ 32        /* bytes to allocate for tmpnam */
  667. X
  668. Xextern char *tmpnam();
  669. Xvoid bcopy();
  670. X
  671. X/** private DiskSource definitions **/
  672. X
  673. Xtypedef struct _DiskSourceData {
  674. X    /* resources */
  675. X    char       *fileName;
  676. X    /* private data */
  677. X    Boolean    is_tempfile;
  678. X    FILE *file;        
  679. X    XtTextPosition position,     /* file position of first char in buffer */
  680. X            length;     /* length of file */
  681. X    char *buffer;        /* piece of file in memory */
  682. X    int charsInBuffer;        /* number of bytes used in memory */
  683. X} DiskSourceData, *DiskSourcePtr;
  684. X
  685. X#define bufSize 1000
  686. X
  687. X#define Increment(data, position, direction)\
  688. X{\
  689. X    if (direction == XtsdLeft) {\
  690. X    if (position > 0) \
  691. X        position -= 1;\
  692. X    }\
  693. X    else {\
  694. X    if (position < data->length)\
  695. X        position += 1;\
  696. X    }\
  697. X}
  698. X
  699. Xstatic XtResource diskResources[] = {
  700. X    {XtNfile, XtCFile, XtRString, sizeof (char *),
  701. X        XtOffset(DiskSourcePtr, fileName), XtRString, NULL},
  702. X};
  703. X
  704. Xstatic XtResource sourceResources[] = {
  705. X    {XtNeditType, XtCEditType, XtREditMode, sizeof(int), 
  706. X        XtOffset(XtTextSource, edit_mode), XtRString, "read"},
  707. X};
  708. X
  709. Xstatic char Look(data, position, direction)
  710. X  DiskSourcePtr data;
  711. X  XtTextPosition position;
  712. X  XtTextScanDirection direction;
  713. X{
  714. X
  715. X    if (direction == XtsdLeft) {
  716. X    if (position == 0)
  717. X        return('\n');
  718. X    else {
  719. X        FillBuffer(data, position - 1);
  720. X        return(data->buffer[position - data->position - 1]);
  721. X    }
  722. X    }
  723. X    else {
  724. X    if (position == data->length)
  725. X        return('\n');
  726. X    else {
  727. X        FillBuffer(data, position);
  728. X        return(data->buffer[position - data->position]);
  729. X    }
  730. X    }
  731. X}
  732. X
  733. X
  734. X
  735. Xstatic XtTextPosition DiskReadText (src, pos, text, length)
  736. X  XtTextSource src;
  737. X  XtTextPosition pos;    /** starting position */
  738. X  XtTextBlock *text;    /** RETURNED: text read in */
  739. X  int length;        /** max number of bytes to read **/
  740. X{
  741. X    XtTextPosition count;
  742. X    DiskSourcePtr data;
  743. X
  744. X    data = (DiskSourcePtr) src->data;
  745. X    FillBuffer(data, pos);
  746. X    text->firstPos = pos;
  747. X    text->ptr = data->buffer + (pos - data->position);
  748. X    count = data->charsInBuffer - (pos - data->position);
  749. X    text->length = (length > count) ? count : length;
  750. X    return pos + text->length;
  751. X}
  752. X
  753. X/*
  754. X * this routine reads text starting at "pos" into memory.
  755. X * Contains heuristic for keeping the read position centered in the buffer.
  756. X */
  757. Xstatic int FillBuffer (data, pos)
  758. X  DiskSourcePtr data;
  759. X  XtTextPosition pos;
  760. X{
  761. X    long readPos;
  762. X    if ((pos < data->position ||
  763. X        pos >= data->position + data->charsInBuffer - 100) &&
  764. X        data->charsInBuffer != data->length) {
  765. X    if (pos < (bufSize / 2))
  766. X        readPos = 0;
  767. X    else
  768. X        if (pos >= data->length - bufSize)
  769. X        readPos = data->length - bufSize;
  770. X        else
  771. X        if (pos >= data->position + data->charsInBuffer - 100)
  772. X            readPos = pos - (bufSize / 2);
  773. X        else
  774. X            readPos = pos;
  775. X    (void) fseek(data->file, readPos, 0);
  776. X    data->charsInBuffer = fread(data->buffer, sizeof(char), bufSize,
  777. X                data->file);
  778. X    data->position = readPos;
  779. X    }
  780. X}
  781. X
  782. X/*
  783. X * This is a dummy routine for read only disk sources.
  784. X */
  785. X/*ARGSUSED*/  /* keep lint happy */
  786. Xstatic int DummyReplaceText (src, startPos, endPos, text)
  787. X  XtTextSource src;
  788. X  XtTextPosition startPos, endPos;
  789. X  XtTextBlock *text;
  790. X{
  791. X    return(EditError);
  792. X}
  793. X
  794. X
  795. X/*
  796. X * This routine will only append to the end of a source.  If incorrect
  797. X * starting and ending positions are given, an error will be returned.
  798. X */
  799. Xstatic int DiskAppendText (src, startPos, endPos, text)
  800. X  XtTextSource src;
  801. X  XtTextPosition startPos, endPos;
  802. X  XtTextBlock *text;
  803. X{
  804. X    long topPosition = 0;
  805. X    char *tmpPtr;
  806. X    DiskSourcePtr data;
  807. X    data = (DiskSourcePtr) src->data;
  808. X    if (startPos != endPos || endPos != data->length)
  809. X        return (PositionError);
  810. X    /* write the new text to the end of the file */
  811. X    if (text->length > 0) {
  812. X    (void) fseek(data->file, data->length, 0);
  813. X    (void) fwrite(text->ptr, sizeof(char), text->length, data->file);
  814. X    } else
  815. X    /* if the delete key was hit, blank out last char in the file */
  816. X    if (text->length < 0) {
  817. X        (void) fseek(data->file, data->length-1, 0);
  818. X        (void) fwrite(" ", sizeof(char), 1, data->file);
  819. X    }
  820. X    /* need this in case the application trys to seek to end of file. */
  821. X     (void) fseek(data->file, topPosition, 2);    
  822. X     
  823. X    /* put the new text into the buffer in memory */
  824. X    data->length += text->length;
  825. X    if (data->charsInBuffer + text->length <= bufSize) {
  826. X/**** NOTE: need to check if text won't fit in the buffer ***/
  827. X    if (text->length > 0) {
  828. X        tmpPtr = data->buffer + data->charsInBuffer;
  829. X        bcopy(text->ptr, tmpPtr, text->length);
  830. X    }
  831. X    data->charsInBuffer += text->length;
  832. X    } else
  833. X    FillBuffer(data, data->length - text->length);
  834. X
  835. X    return (EditDone);
  836. X}
  837. X
  838. X
  839. Xstatic int DiskSetLastPos (src, lastPos)
  840. X  XtTextSource src;
  841. X  XtTextPosition lastPos;
  842. X{
  843. X    ((DiskSourceData *)(src->data))->length = lastPos;
  844. X}
  845. X
  846. X/*
  847. X * This routine will start at
  848. X * the "pos" position of the source and scan in the appropriate
  849. X * direction until it finds something of the right sType.  It returns 
  850. X * the new position.  If upon reading it hits the end of the buffer
  851. X * in memory, it will refill the buffer.
  852. X */
  853. Xstatic XtTextPosition DiskScan (src, pos, sType, dir, count, include)
  854. X  XtTextSource      src;
  855. X  XtTextPosition pos;
  856. X  XtTextScanType sType;
  857. X  XtTextScanDirection  dir;
  858. X  int          count;
  859. X  Boolean     include;
  860. X{
  861. X    DiskSourcePtr data;
  862. X    XtTextPosition position;
  863. X    int     i, whiteSpace;
  864. X    char    c;
  865. X
  866. X    data = (DiskSourcePtr) src->data;
  867. X    position = pos;
  868. X    switch (sType) {
  869. X    case XtstPositions: 
  870. X        if (!include && count > 0)
  871. X        count -= 1;
  872. X        for (i = 0; i < count; i++) {
  873. X        Increment(data, position, dir);
  874. X        }
  875. X        break;
  876. X    case XtstWhiteSpace: 
  877. X        for (i = 0; i < count; i++) {
  878. X        whiteSpace = 0;
  879. X        while (position >= 0 && position <= data->length) {
  880. X            FillBuffer(data, position);
  881. X            c = Look(data, position, dir);
  882. X            whiteSpace = (c == ' ') || (c == '\t') || (c == '\n');
  883. X            if (whiteSpace)
  884. X            break;
  885. X            Increment(data, position, dir);
  886. X        }
  887. X        if (i + 1 != count)
  888. X            Increment(data, position, dir);
  889. X        }
  890. X        if (include)
  891. X        Increment(data, position, dir);
  892. X        break;
  893. X    case XtstEOL: 
  894. X        for (i = 0; i < count; i++) {
  895. X        while (position >= 0 && position <= data->length) {
  896. X            if (Look(data, position, dir) == '\n')
  897. X            break;
  898. X            Increment(data, position, dir);
  899. X        }
  900. X        if (i + 1 != count)
  901. X            Increment(data, position, dir);
  902. X        }
  903. X        if (include) {
  904. X        /* later!!!check for last char in file # eol */
  905. X        Increment(data, position, dir);
  906. X        }
  907. X        break;
  908. X    case XtstAll: 
  909. X        if (dir == XtsdLeft)
  910. X        position = 0;
  911. X        else
  912. X        position = data->length;
  913. X    }
  914. X    return(position);
  915. X}
  916. X
  917. Xstatic Boolean ConvertSelection(d, src, selection, target,
  918. X                type, value, length, format)
  919. X  Display* d;
  920. X  XtTextSource src;
  921. X  Atom *selection, *target, *type;
  922. X  caddr_t *value;
  923. X  unsigned long *length;
  924. X  int *format;
  925. X{
  926. X    DiskSourcePtr data = (DiskSourcePtr)src->data;
  927. X    if (*selection != XA_PRIMARY) return False;
  928. X    if (*target == XA_TARGETS(d)) {
  929. X    *value = XtMalloc(sizeof(Atom));
  930. X    *(Atom*)*value = XA_FILENAME(d);
  931. X    *type = XA_ATOM;
  932. X    *length = 1;
  933. X    *format = 32;
  934. X    return True;
  935. X    } else if (*target == XA_FILENAME(d)) {
  936. X#ifdef unix
  937. X    if (*data->fileName != '/') {
  938. X        char fullname[MAXPATHLEN+2];        /* +2 for getcwd */
  939. X        char *p = data->fileName;
  940. X        int len;
  941. X#ifdef SYSV
  942. X        extern char *getcwd();
  943. X#define get_current_directory(buf,len) getcwd (buf, len)
  944. X#else
  945. X        extern char *getwd();
  946. X#define get_current_directory(buf,len) getwd (buf)
  947. X#endif
  948. X
  949. X        if (get_current_directory (fullname, sizeof fullname) == NULL)
  950. X          fullname[0] = '\0';
  951. X
  952. X        while (*p == '.') {
  953. X        if (*++p == '/') {
  954. X            p++;
  955. X            continue;
  956. X        }
  957. X        if (*p == '.' && *++p == '/') {
  958. X            char *d = rindex(fullname, '/');
  959. X            if (d != NULL) *d = '\0';
  960. X            p++;
  961. X            continue;
  962. X        }
  963. X        else break;
  964. X        }
  965. X        if (fullname[len=strlen(fullname)] != '/')
  966. X        fullname[len++] = '/';
  967. X        strcpy(&fullname[len], p);
  968. X        *value = XtNewString(fullname);
  969. X    }
  970. X    else
  971. X#endif /*unix*/
  972. X        *value = XtNewString(data->fileName);
  973. X    *type = XA_STRING;
  974. X    *length = strlen(*value);
  975. X    *format = 8;
  976. X    return True;
  977. X    }
  978. X    /* else */
  979. X    return False;
  980. X}
  981. X
  982. X
  983. X/******* Public routines **********/
  984. X
  985. XXtTextSource XtDiskSourceCreate(parent, args, num_args)
  986. X    Widget    parent;
  987. X    ArgList    args;
  988. X    Cardinal    num_args;
  989. X{
  990. X    XtTextSource src;
  991. X    DiskSourcePtr data;
  992. X    long topPosition = 0;
  993. X
  994. X    src = XtNew(XtTextSourceRec);
  995. X
  996. X    XtGetSubresources (parent, (caddr_t)src, XtNtextSource, XtCTextSource,
  997. X               sourceResources, XtNumber(sourceResources),
  998. X               args, num_args);
  999. X
  1000. X    src->Read = DiskReadText;
  1001. X    src->SetLastPos = DiskSetLastPos;
  1002. X    src->Scan = DiskScan;
  1003. X    src->SetSelection = NULL;
  1004. X    src->ConvertSelection = ConvertSelection;
  1005. X    data = XtNew(DiskSourceData);
  1006. X    src->data = (caddr_t)data;
  1007. X
  1008. X    XtGetSubresources (parent, (caddr_t)data, XtNtextSource, XtCTextSource,
  1009. X        diskResources, XtNumber(diskResources),
  1010. X    args, num_args);
  1011. X
  1012. X    if (data->fileName == NULL) {
  1013. X    data->fileName = tmpnam (XtMalloc((unsigned)TMPSIZ));
  1014. X    data->is_tempfile = TRUE;
  1015. X    } else
  1016. X        data->is_tempfile = FALSE;
  1017. X
  1018. X    switch (src->edit_mode) {
  1019. X        case XttextRead:
  1020. X           if ((data->file = fopen(data->fileName, "r")) == 0)
  1021. X                XtError("Cannot open source file in XtDiskSourceCreate");
  1022. X            src->Replace = DummyReplaceText;
  1023. X            break;
  1024. X        case XttextAppend:
  1025. X            if ((data->file = fopen(data->fileName, "r+")) == 0)
  1026. X                XtError("Cannot open source file in XtDiskSourceCreate");
  1027. X            src->Replace = DiskAppendText;
  1028. X            break;
  1029. X        default:
  1030. X            if ((data->file = fopen(data->fileName, "r")) == 0)
  1031. X                XtError("Cannot open source file in XtDiskSourceCreate");
  1032. X            src->Replace = DummyReplaceText;
  1033. X    }
  1034. X    (void) fseek(data->file, topPosition, 2);  
  1035. X    data->length = ftell (data->file);  
  1036. X    data->buffer = (char *) XtMalloc((unsigned)bufSize);
  1037. X    data->position = 0;
  1038. X    data->charsInBuffer = 0;
  1039. X    return src;
  1040. X}
  1041. X
  1042. Xvoid XtDiskSourceDestroy (src)
  1043. X  XtTextSource src;
  1044. X{
  1045. X    DiskSourcePtr data;
  1046. X    data = (DiskSourcePtr) src->data;
  1047. X    XtFree((char *) data->buffer);
  1048. X    if (data->is_tempfile) {
  1049. X        unlink(data->fileName);
  1050. X    XtFree((char *) data->fileName);
  1051. X    }
  1052. X    XtFree((char *) src->data);
  1053. X    XtFree((char *) src);
  1054. X}
  1055. END_OF_FILE
  1056. if test 11969 -ne `wc -c <'xconf/DiskSrc.c'`; then
  1057.     echo shar: \"'xconf/DiskSrc.c'\" unpacked with wrong size!
  1058. fi
  1059. # end of 'xconf/DiskSrc.c'
  1060. fi
  1061. if test -f 'xconf/Imakefile' -a "${1}" != "-c" ; then 
  1062.   echo shar: Will not clobber existing file \"'xconf/Imakefile'\"
  1063. else
  1064. echo shar: Extracting \"'xconf/Imakefile'\" \(553 characters\)
  1065. sed "s/^X//" >'xconf/Imakefile' <<'END_OF_FILE'
  1066. X#define JON
  1067. X#define JOKE
  1068. X#define SUNRPC
  1069. X
  1070. XINCLUDES = -I. -I$(XLIBSRC) -I$(TOP)/X11 -I$(TOP)/lib/Xt
  1071. XCC = cc -DJON -DSUNRPC -DJOKE
  1072. X
  1073. XLOCAL_LIBRARIES =  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) 
  1074. XSYS_LIBRARIES = -lrpcsvc
  1075. X           SRCS = xconf.c \
  1076. X          ru.c \
  1077. X          Text.c AsciiText.c AsciiSink.c DiskSrc.c StringSrc.c \
  1078. X          Dialog.c \
  1079. X          Converters.c GCManager.c
  1080. X           OBJS = xconf.o \
  1081. X          ru.o \
  1082. X          Text.o AsciiText.o AsciiSink.o DiskSrc.o StringSrc.o \
  1083. X          Dialog.o \
  1084. X          Converters.o GCManager.o
  1085. X
  1086. XComplexProgramTarget(xconf)
  1087. XNormalLintTarget($(SRCS))
  1088. END_OF_FILE
  1089. if test 553 -ne `wc -c <'xconf/Imakefile'`; then
  1090.     echo shar: \"'xconf/Imakefile'\" unpacked with wrong size!
  1091. fi
  1092. # end of 'xconf/Imakefile'
  1093. fi
  1094. if test -f 'xconf/StringSrc.c' -a "${1}" != "-c" ; then 
  1095.   echo shar: Will not clobber existing file \"'xconf/StringSrc.c'\"
  1096. else
  1097. echo shar: Extracting \"'xconf/StringSrc.c'\" \(8103 characters\)
  1098. sed "s/^X//" >'xconf/StringSrc.c' <<'END_OF_FILE'
  1099. X#ifndef lint
  1100. Xstatic char Xrcsid[] = "$XConsortium: StringSrc.c,v 1.20 88/10/18 12:31:59 swick Exp $";
  1101. X#endif lint
  1102. X
  1103. X
  1104. X/***********************************************************
  1105. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  1106. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1107. X
  1108. X                        All Rights Reserved
  1109. X
  1110. XPermission to use, copy, modify, and distribute this software and its 
  1111. Xdocumentation for any purpose and without fee is hereby granted, 
  1112. Xprovided that the above copyright notice appear in all copies and that
  1113. Xboth that copyright notice and this permission notice appear in 
  1114. Xsupporting documentation, and that the names of Digital or MIT not be
  1115. Xused in advertising or publicity pertaining to distribution of the
  1116. Xsoftware without specific, written prior permission.  
  1117. X
  1118. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1119. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1120. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1121. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1122. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1123. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1124. XSOFTWARE.
  1125. X
  1126. X******************************************************************/
  1127. X
  1128. X/* File: StringSource.c */
  1129. X
  1130. X#include <sys/types.h>
  1131. X#include <sys/stat.h>
  1132. X#include <X11/IntrinsicP.h>
  1133. X#include <X11/StringDefs.h>
  1134. X#ifdef JON
  1135. X#include "Text.h"
  1136. X#include "TextP.h"
  1137. X#else JON
  1138. X#include <X11/Text.h>
  1139. X#include <X11/TextP.h>
  1140. X#endif JON
  1141. X
  1142. X/* Private StringSource Definitions */
  1143. X
  1144. X#define MAGICVALUE        -1
  1145. X#define DEFAULTMAXLENGTH    100
  1146. X
  1147. X
  1148. Xtypedef struct _StringSourceData {
  1149. X    char *str;
  1150. X    XtTextPosition length, maxLength;
  1151. X    XtTextPosition left, right;        /* selection */
  1152. X} StringSourceData, *StringSourcePtr;
  1153. X
  1154. X#define Increment(data, position, direction)\
  1155. X{\
  1156. X    if (direction == XtsdLeft) {\
  1157. X    if (position > 0) \
  1158. X        position -= 1;\
  1159. X    }\
  1160. X    else {\
  1161. X    if (position < data->length)\
  1162. X        position += 1;\
  1163. X    }\
  1164. X}
  1165. X
  1166. Xstatic int magic_value = MAGICVALUE;
  1167. X
  1168. Xstatic XtResource stringResources[] = {
  1169. X    {XtNstring, XtCString, XtRString, sizeof (char *),
  1170. X        XtOffset(StringSourcePtr, str), XtRString, NULL},
  1171. X    {XtNlength, XtCLength, XtRInt, sizeof (int),
  1172. X        XtOffset(StringSourcePtr, maxLength), XtRInt, (caddr_t)&magic_value},
  1173. X};
  1174. X
  1175. Xstatic XtResource sourceResources[] = {
  1176. X    {XtNeditType, XtCEditType, XtREditMode, sizeof(XtTextEditType), 
  1177. X        XtOffset(XtTextSource, edit_mode), XtRString, "read"},
  1178. X};
  1179. X
  1180. Xchar Look(data, position, direction)
  1181. X  StringSourcePtr data;
  1182. X  XtTextPosition position;
  1183. X  XtTextScanDirection direction;
  1184. X{
  1185. X/* Looking left at pos 0 or right at position data->length returns newline */
  1186. X    if (direction == XtsdLeft) {
  1187. X    if (position == 0)
  1188. X        return(0);
  1189. X    else
  1190. X        return(data->str[position-1]);
  1191. X    }
  1192. X    else {
  1193. X    if (position == data->length)
  1194. X        return(0);
  1195. X    else
  1196. X        return(data->str[position]);
  1197. X    }
  1198. X}
  1199. X
  1200. Xstatic XtTextPosition StringReadText (src, pos, text, maxRead)
  1201. X  XtTextSource src;
  1202. X  int pos;
  1203. X  XtTextBlock *text;
  1204. X  int maxRead;
  1205. X{
  1206. X    int     charsLeft;
  1207. X    StringSourcePtr data;
  1208. X
  1209. X    data = (StringSourcePtr) src->data;
  1210. X    text->firstPos = pos;
  1211. X    text->ptr = data->str + pos;
  1212. X    charsLeft = data->length - pos;
  1213. X    text->length = (maxRead > charsLeft) ? charsLeft : maxRead;
  1214. X    return pos + text->length;
  1215. X}
  1216. X
  1217. Xstatic int StringReplaceText (src, startPos, endPos, text)
  1218. X  XtTextSource src;
  1219. X  XtTextPosition startPos, endPos;
  1220. X  XtTextBlock *text;
  1221. X{
  1222. X    StringSourcePtr data;
  1223. X    int     i, length, delta;
  1224. X
  1225. X    data = (StringSourcePtr) src->data;
  1226. X    switch (src->edit_mode) {
  1227. X        case XttextAppend: 
  1228. X        if (startPos != endPos || endPos!= data->length)
  1229. X        return (PositionError);
  1230. X        break;
  1231. X    case XttextRead:
  1232. X        return (EditError);
  1233. X    case XttextEdit:
  1234. X        break;
  1235. X    default:
  1236. X        return (EditError);
  1237. X    }
  1238. X    length = endPos - startPos;
  1239. X    if ((data->length - length + text->length) > data->maxLength)
  1240. X        return (EditError);
  1241. X
  1242. X    delta = text->length - length;
  1243. X    if (delta < 0)        /* insert shorter than delete, text getting
  1244. X                   shorter */
  1245. X    for (i = startPos; i < data->length + delta; ++i)
  1246. X        data->str[i] = data->str[i - delta];
  1247. X    else
  1248. X    if (delta > 0)    {    /* insert longer than delete, text getting
  1249. X                   longer */
  1250. X        for (i = data->length; i > startPos-1; --i)
  1251. X        data->str[i + delta] = data->str[i];
  1252. X    }
  1253. X    if (text->length != 0)    /* do insert */
  1254. X    for (i = 0; i < text->length; ++i)
  1255. X        data->str[startPos + i] = text->ptr[i];
  1256. X    data->length = data->length + delta;
  1257. X    data->str[data->length] = 0;
  1258. X    return (EditDone);
  1259. X}
  1260. X
  1261. Xstatic StringSetLastPos (src, lastPos)
  1262. X  XtTextSource src;
  1263. X  XtTextPosition lastPos;
  1264. X{
  1265. X    ((StringSourceData *) (src->data))->length = lastPos;
  1266. X}
  1267. X
  1268. Xstatic XtTextPosition StringScan (src, pos, sType, dir, count, include)
  1269. X  XtTextSource     src;
  1270. X  XtTextPosition pos;
  1271. X  XtTextScanType sType;
  1272. X  XtTextScanDirection dir;
  1273. X  int         count;
  1274. X  Boolean     include;
  1275. X{
  1276. X    StringSourcePtr data;
  1277. X    XtTextPosition position;
  1278. X    int     i, whiteSpace;
  1279. X    char    c;
  1280. X    int ddir = (dir == XtsdRight) ? 1 : -1;
  1281. X
  1282. X    data = (StringSourcePtr) src->data;
  1283. X    position = pos;
  1284. X    switch (sType) {
  1285. X    case XtstPositions: 
  1286. X        if (!include && count > 0)
  1287. X        count -= 1;
  1288. X        for (i = 0; i < count; i++) {
  1289. X        Increment(data, position, dir);
  1290. X        }
  1291. X        break;
  1292. X    case XtstWhiteSpace: 
  1293. X
  1294. X        for (i = 0; i < count; i++) {
  1295. X        whiteSpace = -1;
  1296. X        while (position >= 0 && position <= data->length) {
  1297. X            c = Look(data, position, dir);
  1298. X            if ((c == ' ') || (c == '\t') || (c == '\n')){
  1299. X                if (whiteSpace < 0) whiteSpace = position;
  1300. X            } else if (whiteSpace >= 0)
  1301. X            break;
  1302. X            position += ddir;
  1303. X        }
  1304. X        }
  1305. X        if (!include) {
  1306. X        if(whiteSpace < 0 && dir == XtsdRight) whiteSpace = data->length;
  1307. X        position = whiteSpace;
  1308. X        }
  1309. X        break;
  1310. X    case XtstEOL: 
  1311. X        for (i = 0; i < count; i++) {
  1312. X        while (position >= 0 && position <= data->length) {
  1313. X            if (Look(data, position, dir) == '\n')
  1314. X            break;
  1315. X            if(((dir == XtsdRight) && (position == data->length)) || 
  1316. X            (dir == XtsdLeft) && ((position == 0)))
  1317. X            break;
  1318. X            Increment(data, position, dir);
  1319. X        }
  1320. X        if (i + 1 != count)
  1321. X            Increment(data, position, dir);
  1322. X        }
  1323. X        if (include) {
  1324. X        /* later!!!check for last char in file # eol */
  1325. X        Increment(data, position, dir);
  1326. X        }
  1327. X        break;
  1328. X    case XtstAll: 
  1329. X        if (dir == XtsdLeft)
  1330. X        position = 0;
  1331. X        else
  1332. X        position = data->length;
  1333. X    }
  1334. X    if (position < 0) position = 0;
  1335. X    if (position > data->length) position = data->length;
  1336. X    return(position);
  1337. X}
  1338. X
  1339. Xstatic void SetSelection(src, left, right, selection)
  1340. X    XtTextSource src;
  1341. X    Atom selection;
  1342. X    XtTextPosition left, right;
  1343. X{
  1344. X    ((StringSourcePtr)src->data)->left = left;
  1345. X    ((StringSourcePtr)src->data)->right = right;
  1346. X}
  1347. X
  1348. X/***** Public routines *****/
  1349. X
  1350. XXtTextSource XtStringSourceCreate (parent, args, argCount)
  1351. X    Widget parent;
  1352. X    ArgList args;
  1353. X    Cardinal argCount;
  1354. X{
  1355. X    XtTextSource src;
  1356. X    StringSourcePtr data;
  1357. X
  1358. X    src = XtNew(XtTextSourceRec);
  1359. X
  1360. X    XtGetSubresources (parent, (caddr_t)src, XtNtextSource, XtCTextSource,
  1361. X        sourceResources, XtNumber(sourceResources), args, argCount);
  1362. X
  1363. X    src->Read = StringReadText;
  1364. X    src->Replace = StringReplaceText;
  1365. X    src->SetLastPos = StringSetLastPos;
  1366. X    src->Scan = StringScan;
  1367. X    src->SetSelection = SetSelection;
  1368. X    src->ConvertSelection = NULL;
  1369. X    data = XtNew(StringSourceData);
  1370. X    src->data = (caddr_t)data;
  1371. X    data->left = data->right = 0;
  1372. X
  1373. X    XtGetSubresources (parent, (caddr_t)data, XtNtextSource, XtCTextSource,
  1374. X        stringResources, XtNumber(stringResources), args, argCount);
  1375. X
  1376. X    if (data->str == NULL) {
  1377. X    if (data->maxLength == MAGICVALUE) data->maxLength = DEFAULTMAXLENGTH;
  1378. X    data->str = (char *) XtMalloc ((unsigned)data->maxLength);
  1379. X    data->length = 0;
  1380. X    } else {
  1381. X        data->length = strlen(data->str);
  1382. X    if (data->maxLength < data->length) data->maxLength = data->length;
  1383. X    }
  1384. X
  1385. X    return src;
  1386. X}
  1387. X
  1388. Xvoid XtStringSourceDestroy (src)
  1389. X  XtTextSource src;
  1390. X{
  1391. X    XtFree((char *) src->data);
  1392. X    XtFree((char *) src);
  1393. X}
  1394. END_OF_FILE
  1395. if test 8103 -ne `wc -c <'xconf/StringSrc.c'`; then
  1396.     echo shar: \"'xconf/StringSrc.c'\" unpacked with wrong size!
  1397. fi
  1398. # end of 'xconf/StringSrc.c'
  1399. fi
  1400. if test -f 'xconf/Text.h' -a "${1}" != "-c" ; then 
  1401.   echo shar: Will not clobber existing file \"'xconf/Text.h'\"
  1402. else
  1403. echo shar: Extracting \"'xconf/Text.h'\" \(6512 characters\)
  1404. sed "s/^X//" >'xconf/Text.h' <<'END_OF_FILE'
  1405. X/*
  1406. X* $XConsortium: Text.h,v 1.16 88/10/23 14:36:28 swick Exp $
  1407. X*/
  1408. X
  1409. X
  1410. X/***********************************************************
  1411. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  1412. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1413. X
  1414. X                        All Rights Reserved
  1415. X
  1416. XPermission to use, copy, modify, and distribute this software and its 
  1417. Xdocumentation for any purpose and without fee is hereby granted, 
  1418. Xprovided that the above copyright notice appear in all copies and that
  1419. Xboth that copyright notice and this permission notice appear in 
  1420. Xsupporting documentation, and that the names of Digital or MIT not be
  1421. Xused in advertising or publicity pertaining to distribution of the
  1422. Xsoftware without specific, written prior permission.  
  1423. X
  1424. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1425. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1426. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1427. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1428. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1429. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1430. XSOFTWARE.
  1431. X
  1432. X******************************************************************/
  1433. X
  1434. X#ifndef _XtText_h
  1435. X#define _XtText_h
  1436. X
  1437. X/****************************************************************
  1438. X *
  1439. X * Text widget
  1440. X *
  1441. X ****************************************************************/
  1442. X
  1443. X/* Parameters:
  1444. X
  1445. X Name             Class        RepType        Default Value
  1446. X ----             -----        -------        -------------
  1447. X background         Background        Pixel        XtDefaultBackground
  1448. X border             BorderColor    Pixel        XtDefaultForeground
  1449. X borderWidth         BorderWidth    Dimension    1
  1450. X destroyCallback     Callback        Pointer        NULL
  1451. X dialogHOffset         Margin        int        10
  1452. X dialogVOffset         Margin        int        10
  1453. X displayPosition     TextPosition    int        0
  1454. X editType         EditType        XtTextEditType    XttextRead
  1455. X height             Height        Dimension    font height
  1456. X insertPosition         TextPosition    int        0
  1457. X leftMargin         Margin        Dimension    2
  1458. X mappedWhenManaged   MappedWhenManaged    Boolean        True
  1459. X selectTypes         SelectTypes    Pointer        (internal)
  1460. X selection         Selection        Pointer        empty selection
  1461. X sensitive         Sensitive        Boolean        True
  1462. X textOptions         TextOptions    int        0
  1463. X textSink         TextSink        Pointer        (none)
  1464. X textSource         TextSource        Pointer        (none)
  1465. X width             Width        Dimension    100
  1466. X x             Position        int        0
  1467. X y             Position        int        0
  1468. X
  1469. X*/
  1470. X
  1471. X
  1472. X#define XtNtextOptions        "textOptions"
  1473. X#define XtNdialogHOffset    "dialogHOffset"
  1474. X#define XtNdialogVOffset    "dialogVOffset"
  1475. X#define XtNdisplayPosition      "displayPosition"
  1476. X#define XtNinsertPosition    "insertPosition"
  1477. X#define XtNleftMargin        "leftMargin"
  1478. X#define XtNselectTypes        "selectTypes"
  1479. X#define XtNtextSource        "textSource"
  1480. X#define XtNtextSink        "textSink"
  1481. X#define XtNselection        "selection"
  1482. X#ifdef JON
  1483. X#define XtNcallback        "callback"
  1484. X#endif
  1485. X
  1486. X#define XtNeditType        "editType"
  1487. X#define XtNfile            "file"
  1488. X#define XtNstring        "string"
  1489. X#define XtNlength        "length"
  1490. X#define XtNfont            "font"
  1491. X
  1492. X#define XtCSelectTypes        "SelectTypes"
  1493. X
  1494. X/* Return codes from XtTextReplace */
  1495. X#define XawEditDone        0
  1496. X#define XawEditError        1
  1497. X#define XawPositionError    2
  1498. X
  1499. X/* Class record constants */
  1500. X
  1501. Xextern WidgetClass textWidgetClass;
  1502. Xextern Atom FMT8BIT;
  1503. X
  1504. Xtypedef struct _TextClassRec *TextWidgetClass;
  1505. Xtypedef struct _TextRec      *TextWidget;
  1506. X
  1507. X/* other stuff */
  1508. X
  1509. Xtypedef long XtTextPosition;
  1510. Xtypedef struct _XtTextSource XtTextSourceRec, *XtTextSource;
  1511. Xtypedef struct _XtTextSink XtTextSinkRec, *XtTextSink;
  1512. X
  1513. Xtypedef enum {XttextRead, XttextAppend, XttextEdit} XtTextEditType;
  1514. Xtypedef enum {XtselectNull, XtselectPosition, XtselectChar, XtselectWord,
  1515. X    XtselectLine, XtselectParagraph, XtselectAll} XtTextSelectType;
  1516. X
  1517. X#define wordBreak        0x01
  1518. X#define scrollVertical        0x02
  1519. X#define scrollHorizontal    0x04
  1520. X#define scrollOnOverflow    0x08
  1521. X#define resizeWidth        0x10
  1522. X#define resizeHeight        0x20
  1523. X#define editable        0x40
  1524. X
  1525. Xtypedef struct {
  1526. X    int  firstPos;
  1527. X    int  length;
  1528. X    char *ptr;
  1529. X    Atom format;
  1530. X    } XtTextBlock, *XtTextBlockPtr;
  1531. X
  1532. Xextern void XtTextDisplay(); /* w */
  1533. X    /* Widget w; */
  1534. X
  1535. Xextern void XtTextSetSelectionArray(); /* w, sarray */
  1536. X    /* Widget        w;        */
  1537. X    /* SelectionType *sarray;   */
  1538. X
  1539. Xextern void XtTextSetLastPos(); /* w, lastPos */
  1540. X    /* Widget        w;        */
  1541. X    /* XtTextPosition lastPos;  */
  1542. X
  1543. Xextern void XtTextGetSelectionPos(); /* dpy, w, left, right */
  1544. X    /* Widget        w;        */
  1545. X    /* XtTextPosition *left, *right;    */
  1546. X
  1547. Xextern void XtTextSetSource(); /* dpy, w, source, startPos */
  1548. X    /* Widget         w;        */
  1549. X    /* XtTextSource   source;       */
  1550. X    /* XtTextPosition startPos;     */
  1551. X
  1552. Xextern int XtTextReplace(); /* w, startPos, endPos, text */
  1553. X    /* Widget        w;        */
  1554. X    /* XtTextPosition   startPos, endPos; */
  1555. X    /* XtTextBlock      *text; */
  1556. X
  1557. Xextern XtTextPosition XtTextTopPosition(); /* w */
  1558. X    /* Widget        w;        */
  1559. X
  1560. Xextern void XtTextSetInsertionPoint(); /*  w, position */
  1561. X    /* Widget        w;        */
  1562. X    /* XtTextPosition position; */
  1563. X
  1564. Xextern XtTextPosition XtTextGetInsertionPoint(); /* w */
  1565. X    /* Widget        w;        */
  1566. X
  1567. Xextern void XtTextUnsetSelection(); /* w */
  1568. X    /* Widget        w;        */
  1569. X
  1570. Xextern void XtTextChangeOptions(); /* w, options */
  1571. X    /* Widget        w;        */
  1572. X    /* int    options; */
  1573. X
  1574. Xextern int XtTextGetOptions(); /* w */
  1575. X    /* Widget        w;        */
  1576. X
  1577. Xextern void XtTextSetSelection(); /* w, left, right */
  1578. X    /* Widget        w;        */
  1579. X    /* XtTextPosition left, right; */
  1580. X
  1581. Xextern void XtTextInvalidate(); /* w, from, to */
  1582. X    /* Widget        w;        */
  1583. X    /* XtTextPosition from, to; */
  1584. X
  1585. Xextern XtTextSource XtTextGetSource() ; /* w */
  1586. X    /* Widget        w;        */
  1587. X
  1588. X/*
  1589. X * Stuff from AsciiSink
  1590. X */
  1591. X
  1592. Xextern XtTextSink XtAsciiSinkCreate(); /* parent, args, num_args */
  1593. X    /* Widget parent;        */
  1594. X    /* ArgList args;        */
  1595. X    /* Cardinal num_args;    */
  1596. X
  1597. Xextern void XtAsciiSinkDestroy(); /* sink */
  1598. X    /* XtTextSink  sink */
  1599. X
  1600. X/*
  1601. X * from DiskSrc
  1602. X */
  1603. Xextern XtTextSource XtDiskSourceCreate(); /* parent, args, num_args */
  1604. X    /* Widget    parent;        */
  1605. X    /* ArgList    args;        */
  1606. X    /* Cardinal    num_args;    */
  1607. X
  1608. Xextern void XtDiskSourceDestroy(); /* src */
  1609. X    /* XtTextSource src;    */
  1610. X
  1611. X/*
  1612. X * from StringSrc
  1613. X */
  1614. X
  1615. Xextern XtTextSource XtStringSourceCreate(); /* parent, args, num_args */
  1616. X    /* Widget parent;        */
  1617. X    /* ArgList args;        */
  1618. X    /* Cardinal num_args;    */
  1619. X
  1620. Xextern void XtStringSourceDestroy(); /* src */
  1621. X    /* XtTextSource src;    */
  1622. X
  1623. X
  1624. X#endif _XtText_h
  1625. X/* DON'T ADD STUFF AFTER THIS #endif */
  1626. END_OF_FILE
  1627. if test 6512 -ne `wc -c <'xconf/Text.h'`; then
  1628.     echo shar: \"'xconf/Text.h'\" unpacked with wrong size!
  1629. fi
  1630. # end of 'xconf/Text.h'
  1631. fi
  1632. if test -f 'xconf/TextP.h' -a "${1}" != "-c" ; then 
  1633.   echo shar: Will not clobber existing file \"'xconf/TextP.h'\"
  1634. else
  1635. echo shar: Extracting \"'xconf/TextP.h'\" \(5475 characters\)
  1636. sed "s/^X//" >'xconf/TextP.h' <<'END_OF_FILE'
  1637. X/*
  1638. X* $XConsortium: TextP.h,v 1.28 88/10/18 13:12:54 swick Exp $
  1639. X*/
  1640. X
  1641. X
  1642. X/***********************************************************
  1643. XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  1644. Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  1645. X
  1646. X                        All Rights Reserved
  1647. X
  1648. XPermission to use, copy, modify, and distribute this software and its 
  1649. Xdocumentation for any purpose and without fee is hereby granted, 
  1650. Xprovided that the above copyright notice appear in all copies and that
  1651. Xboth that copyright notice and this permission notice appear in 
  1652. Xsupporting documentation, and that the names of Digital or MIT not be
  1653. Xused in advertising or publicity pertaining to distribution of the
  1654. Xsoftware without specific, written prior permission.  
  1655. X
  1656. XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1657. XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1658. XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1659. XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1660. XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1661. XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1662. XSOFTWARE.
  1663. X
  1664. X******************************************************************/
  1665. X
  1666. X#ifndef _XtTextP_h
  1667. X#define _XtTextP_h
  1668. X
  1669. X
  1670. X#ifdef JON
  1671. X#include "Text.h"
  1672. X#else JON
  1673. X#include <X11/Text.h>
  1674. X#endif JON
  1675. X#include <X11/SimpleP.h>
  1676. X#include <X11/TextSrcP.h>
  1677. X
  1678. X/****************************************************************
  1679. X *
  1680. X * Text widget private
  1681. X *
  1682. X ****************************************************************/
  1683. X#define MAXCUT    30000    /* Maximum number of characters that can be cut. */
  1684. X
  1685. X#define LF    0x0a
  1686. X#define CR    0x0d
  1687. X#define TAB    0x09
  1688. X#define BS    0x08
  1689. X#define SP    0x20
  1690. X#define DEL    0x7f
  1691. X#define BSLASH    '\\'
  1692. X
  1693. X/* constants that subclasses may want to know */
  1694. X#define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
  1695. X#define  yMargin 2
  1696. X
  1697. X
  1698. X/* displayable text management data structures */
  1699. X
  1700. Xtypedef struct {
  1701. X    XtTextPosition position;
  1702. X    Position x, y, endX;
  1703. X    } XtTextLineTableEntry, *XtTextLineTableEntryPtr;
  1704. X
  1705. X/* Line Tables are n+1 long - last position displayed is in last lt entry */
  1706. Xtypedef struct {
  1707. X    XtTextPosition     top;    /* Top of the displayed text.        */
  1708. X    int             lines;    /* How many lines in this table.    */
  1709. X    XtTextLineTableEntry *info;    /* A dynamic array, one entry per line  */
  1710. X    } XtTextLineTable, *XtTextLineTablePtr;
  1711. X
  1712. X#define IsPositionVisible(ctx, pos) \
  1713. X        (pos >= ctx->text.lt.info[0].position && \
  1714. X         pos < ctx->text.lt.info[ctx->text.lt.lines].position)
  1715. X
  1716. X/* Private Text Definitions */
  1717. X
  1718. Xtypedef int (*ActionProc)();
  1719. X
  1720. X/* New fields for the Text widget class record */
  1721. X
  1722. Xtypedef struct {int empty;} TextClassPart;
  1723. X
  1724. X/* Full class record declaration */
  1725. Xtypedef struct _TextClassRec {
  1726. X    CoreClassPart    core_class;
  1727. X    SimpleClassPart    simple_class;
  1728. X    TextClassPart    text_class;
  1729. X} TextClassRec;
  1730. X
  1731. Xextern TextClassRec textClassRec;
  1732. X
  1733. X/* New fields for the Text widget record */
  1734. Xtypedef struct _TextPart {
  1735. X    /* resources */
  1736. X    XtTextSource    source;
  1737. X    XtTextSink        sink;
  1738. X    XtTextPosition    insertPos;
  1739. X    XtTextSelection    s;
  1740. X    XtTextSelectType    *sarray;       /* Array to cycle for selections. */
  1741. X    Dimension        client_leftmargin;   /* client-visible resource */
  1742. X    int            options;         /* wordbreak, scroll, etc. */
  1743. X    int            dialog_horiz_offset; /* position for popup dialog */
  1744. X    int            dialog_vert_offset;  /* position for popup dialog */
  1745. X    /* private state */
  1746. X    XtTextLineTable    lt;
  1747. X    XtTextScanDirection extendDir;
  1748. X    XtTextSelection    origSel;    /* the selection being modified */
  1749. X    Dimension        leftmargin;        /* Width of left margin. */
  1750. X    Time        lasttime;        /* timestamp of last processed action */
  1751. X    Time        time;        /* time of last key or button action */ 
  1752. X    Position        ev_x, ev_y;        /* x, y coords for key or button action */
  1753. X    Widget        sbar;        /* The vertical scroll bar (none = 0).  */
  1754. X    Widget        outer;        /* Parent of scrollbar & text (if any) */
  1755. X    XtTextPosition  *updateFrom;    /* Array of start positions for update. */
  1756. X    XtTextPosition  *updateTo;        /* Array of end positions for update. */
  1757. X    int            numranges;        /* How many update ranges there are. */
  1758. X    int            maxranges;        /* How many ranges we have space for */
  1759. X    Boolean        showposition;   /* True if we need to show the position. */
  1760. X    XtTextPosition  lastPos;        /* Last position of source. */
  1761. X    struct _dialog {
  1762. X    TextWidget  text;        /* the dialog's parent */
  1763. X    Widget      widget;        /* the dialog widget */
  1764. X    Widget        doit;        /* the confirm button */
  1765. X    Widget        message;        /* the (occasional) error message */
  1766. X    Boolean        mapped;        /* True if this dialog is in-use */
  1767. X    struct _dialog *next;        /* a list of dialogs */
  1768. X    } *dialog;                /* InsertFile pop-up widget */
  1769. X    GC              gc;
  1770. X    Boolean         hasfocus;       /* TRUE if we currently have input focus.*/
  1771. X    Boolean        update_disabled; /* TRUE if display updating turned off */
  1772. X    XtTextPosition  old_insert;      /* Last insertPos for batched updates */
  1773. X#ifdef JON
  1774. X    XtCallbackList callbacks;        /* JONS OWN Callbacks */
  1775. X#endif JON
  1776. X} TextPart;
  1777. X
  1778. X/****************************************************************
  1779. X *
  1780. X * Full instance record declaration
  1781. X *
  1782. X ****************************************************************/
  1783. X
  1784. Xtypedef struct _TextRec {
  1785. X    CorePart    core;
  1786. X    SimplePart    simple;
  1787. X    TextPart    text;
  1788. X} TextRec;
  1789. X
  1790. X
  1791. X#endif _XtTextP_h
  1792. END_OF_FILE
  1793. if test 5475 -ne `wc -c <'xconf/TextP.h'`; then
  1794.     echo shar: \"'xconf/TextP.h'\" unpacked with wrong size!
  1795. fi
  1796. # end of 'xconf/TextP.h'
  1797. fi
  1798. echo shar: End of archive 4 \(of 5\).
  1799. cp /dev/null ark4isdone
  1800. MISSING=""
  1801. for I in 1 2 3 4 5 ; do
  1802.     if test ! -f ark${I}isdone ; then
  1803.     MISSING="${MISSING} ${I}"
  1804.     fi
  1805. done
  1806. if test "${MISSING}" = "" ; then
  1807.     echo You have unpacked all 5 archives.
  1808.     rm -f ark[1-9]isdone
  1809. else
  1810.     echo You still need to unpack the following archives:
  1811.     echo "        " ${MISSING}
  1812. fi
  1813. ##  End of shell archive.
  1814. exit 0
  1815.