v04i085: xconf -- X-based conferencing tool, Part01/05

Dan Heller argv at island.uu.net
Tue Jul 25 18:11:01 AEST 1989


Submitted-by: Jon Crowcroft <J.Crowcroft at Cs.Ucl.AC.UK>
Posting-number: Volume 4, Issue 85
Archive-name: xconf/part01



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix at uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 4 (of 5)."
# Contents:  xconf/AsciiText.c xconf/Dialog.c xconf/DiskSrc.c
#   xconf/Imakefile xconf/StringSrc.c xconf/Text.h xconf/TextP.h
# Wrapped by argv at sumatra on Tue Jul 25 01:01:07 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xconf/AsciiText.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/AsciiText.c'\"
else
echo shar: Extracting \"'xconf/AsciiText.c'\" \(9259 characters\)
sed "s/^X//" >'xconf/AsciiText.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char Xrcsid[] = "$XConsortium: AsciiText.c,v 1.18 88/10/18 12:28:26 swick Exp $";
X#endif lint
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#include <X11/copyright.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#ifdef JON
X#include "AsciiTextP.h"
X#else JON
X#include <X11/AsciiTextP.h>
X#endif
X
X/* from Text.c */
X
Xextern void ForceBuildLineTable(); /* in Text.c */
X
Xstatic XtResource string_resources[] = {
X  {XtNstring, XtCString, XtRString, sizeof(String),
X     XtOffset(AsciiStringWidget, ascii_string.string), XtRString, NULL}
X};
X
Xstatic XtResource disk_resources[] = {
X  {XtNfile, XtCFile, XtRString, sizeof(String),
X     XtOffset(AsciiDiskWidget, ascii_disk.file_name), XtRString, NULL}
X};
X
Xstatic void StringClassInitialize(), StringInitialize(),
X    StringCreateSourceSink(), StringDestroy();
Xstatic Boolean StringSetValues();
X
Xstatic void DiskClassInitialize(), DiskInitialize(),
X    DiskCreateSourceSink(), DiskDestroy();
Xstatic Boolean DiskSetValues();
X
XAsciiStringClassRec asciiStringClassRec = {
X  { /* core fields */
X    /* superclass       */      (WidgetClass) &textClassRec,
X    /* class_name       */      "Text",
X    /* widget_size      */      sizeof(AsciiStringRec),
X    /* class_initialize */      StringClassInitialize,
X    /* class_part_init  */	NULL,
X    /* class_inited     */      FALSE,
X    /* initialize       */      StringInitialize,
X    /* initialize_hook  */	StringCreateSourceSink,
X    /* realize          */      XtInheritRealize,
X    /* actions          */      textActionsTable,
X    /* num_actions      */      0,
X    /* resources        */      string_resources,
X    /* num_ resource    */      XtNumber(string_resources),
X    /* xrm_class        */      NULLQUARK,
X    /* compress_motion  */      TRUE,
X    /* compress_exposure*/      FALSE,
X    /* compress_enterleave*/	TRUE,
X    /* visible_interest */      FALSE,
X    /* destroy          */      StringDestroy,
X    /* resize           */      XtInheritResize,
X    /* expose           */      XtInheritExpose,
X    /* set_values       */      StringSetValues,
X    /* set_values_hook  */	NULL,
X    /* set_values_almost*/	XtInheritSetValuesAlmost,
X    /* get_values_hook  */	NULL,
X    /* accept_focus     */      XtInheritAcceptFocus,
X    /* version          */	XtVersion,
X    /* callback_private */      NULL,
X    /* tm_table         */      XtInheritTranslations,
X    /* query_geometry	*/	XtInheritQueryGeometry
X  },
X  { /* text fields */
X    /* empty            */      0
X  },
X  { /* ascii_string fields */
X    /* empty            */      0
X  }
X};
X
XAsciiDiskClassRec asciiDiskClassRec = {
X  { /* core fields */
X    /* superclass       */      (WidgetClass) &textClassRec,
X    /* class_name       */      "Text",
X    /* widget_size      */      sizeof(AsciiDiskRec),
X    /* class_initialize */      DiskClassInitialize,
X    /* class_part_init  */	NULL,
X    /* class_inited     */      FALSE,
X    /* initialize       */      DiskInitialize,
X    /* initialize_hook  */	DiskCreateSourceSink,
X    /* realize          */      XtInheritRealize,
X    /* actions          */      textActionsTable,
X    /* num_actions      */      0,
X    /* resources        */      disk_resources,
X    /* num_ resource    */      XtNumber(disk_resources),
X    /* xrm_class        */      NULLQUARK,
X    /* compress_motion  */      TRUE,
X    /* compress_exposure*/      FALSE,
X    /* compress_enterleave*/	TRUE,
X    /* visible_interest */      FALSE,
X    /* destroy          */      DiskDestroy,
X    /* resize           */      XtInheritResize,
X    /* expose           */      XtInheritExpose,
X    /* set_values       */      DiskSetValues,
X    /* set_values_hook  */	NULL,
X    /* set_values_almost*/	XtInheritSetValuesAlmost,
X    /* get_values_hook  */	NULL,
X    /* accept_focus     */      XtInheritAcceptFocus,
X    /* version          */	XtVersion,
X    /* callback_private */      NULL,
X    /* tm_table         */      XtInheritTranslations,
X    /* query_geometry	*/	XtInheritQueryGeometry
X  },
X  { /* text fields */
X    /* empty            */      0
X  },
X  { /* ascii_disk fields */
X    /* empty            */      0
X  }
X};
X
X
XWidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec;
XWidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec;
X
X
Xstatic void StringClassInitialize()
X{
X    asciiStringClassRec.core_class.num_actions = textActionsTableCount;
X}
X
X
X/* ARGSUSED */
Xstatic void StringInitialize(request, new)
X    Widget request, new;
X{
X    /* superclass Initialize can't set the following,
X     * as it didn't know the source or sink when it was called */
X    if (request->core.height == DEFAULT_TEXT_HEIGHT)
X	new->core.height = DEFAULT_TEXT_HEIGHT;
X}
X
Xstatic void StringCreateSourceSink(widget, args, num_args)
X    Widget widget;
X    ArgList args;
X    Cardinal *num_args;
X{
X    AsciiStringWidget w = (AsciiStringWidget)widget;
X    void (*NullProc)() = NULL;	/* some compilers require this */
X
X    w->text.source = XtStringSourceCreate( widget, args, *num_args );
X    w->text.sink = XtAsciiSinkCreate( widget, args, *num_args );
X
X    if (w->core.height == DEFAULT_TEXT_HEIGHT)
X        w->core.height = (2*yMargin) + 2
X			  + (*w->text.sink->MaxHeight)(widget, 1);
X
X    w->text.lastPos = /* GETLASTPOS */
X      (*w->text.source->Scan) ( w->text.source, 0, XtstAll,
X			        XtsdRight, 1, TRUE );
X
X    if (w->text.sink->SetTabs != NullProc) {
X#define TAB_COUNT 32
X	int i;
X	Position tabs[TAB_COUNT], tab;
X
X	for (i=0, tab=0; i<TAB_COUNT;i++) {
X	    tabs[i] = (tab += 8);
X	}
X	(w->text.sink->SetTabs) (widget, w->text.leftmargin, TAB_COUNT, tabs);
X#undef TAB_COUNT
X    }
X
X    ForceBuildLineTable( (TextWidget)w );
X}
X
X
X/* ARGSUSED */
Xstatic Boolean StringSetValues(current, request, new)
X    Widget current, request, new;
X{
X    AsciiStringWidget old = (AsciiStringWidget)current;
X    AsciiStringWidget w = (AsciiStringWidget)new;
X
X    if (w->ascii_string.string != old->ascii_string.string)
X        XtError( "SetValues on AsciiStringWidget string not supported." );
X
X    return False;
X}
X
X
Xstatic void StringDestroy(w)
X    Widget w;
X{
X    XtStringSourceDestroy( ((AsciiStringWidget)w)->text.source );
X    XtAsciiSinkDestroy( ((AsciiStringWidget)w)->text.sink );
X}
X
X
Xstatic void DiskClassInitialize()
X{
X    asciiDiskClassRec.core_class.num_actions = textActionsTableCount;
X}
X
X
X/* ARGSUSED */
Xstatic void DiskInitialize(request, new)
X    Widget request, new;
X{
X    /* superclass Initialize can't set the following,
X     * as it didn't know the source or sink when it was called */
X    if (request->core.height == DEFAULT_TEXT_HEIGHT)
X	new->core.height = DEFAULT_TEXT_HEIGHT;
X}
X
Xstatic void DiskCreateSourceSink(widget, args, num_args)
X    Widget widget;
X    ArgList args;
X    Cardinal *num_args;
X{
X    AsciiDiskWidget w = (AsciiDiskWidget)widget;
X    void (*NullProc)() = NULL;	/* some compilers require this */
X
X    w->text.source = XtDiskSourceCreate( widget, args, *num_args );
X    w->text.sink = XtAsciiSinkCreate( widget, args, *num_args );
X
X    w->text.lastPos = /* GETLASTPOS */
X      (*w->text.source->Scan) ( w->text.source, 0, XtstAll,
X			        XtsdRight, 1, TRUE );
X
X    if (w->core.height == DEFAULT_TEXT_HEIGHT)
X        w->core.height = (2*yMargin) + 2
X			  + (*w->text.sink->MaxHeight)(widget, 1);
X
X    if (w->text.sink->SetTabs != NullProc) {
X#define TAB_COUNT 32
X	int i;
X	Position tabs[TAB_COUNT], tab;
X
X	for (i=0, tab=0; i<TAB_COUNT;i++) {
X	    tabs[i] = (tab += 8);
X	}
X	(w->text.sink->SetTabs) (widget, w->text.leftmargin, TAB_COUNT, tabs);
X#undef TAB_COUNT
X    }
X
X    ForceBuildLineTable( (TextWidget)w );
X}
X
X
X/* ARGSUSED */
Xstatic Boolean DiskSetValues(current, request, new)
X    Widget current, request, new;
X{
X    AsciiDiskWidget old = (AsciiDiskWidget)current;
X    AsciiDiskWidget w = (AsciiDiskWidget)new;
X
X    if (w->ascii_disk.file_name != old->ascii_disk.file_name)
X        XtError( "SetValues on AsciiDiskWidget file not supported." );
X
X    return False;
X}
X
X
Xstatic void DiskDestroy(w)
X    Widget w;
X{
X    XtDiskSourceDestroy( ((AsciiDiskWidget)w)->text.source );
X    XtAsciiSinkDestroy( ((AsciiDiskWidget)w)->text.sink );
X}
END_OF_FILE
if test 9259 -ne `wc -c <'xconf/AsciiText.c'`; then
    echo shar: \"'xconf/AsciiText.c'\" unpacked with wrong size!
fi
# end of 'xconf/AsciiText.c'
fi
if test -f 'xconf/Dialog.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/Dialog.c'\"
else
echo shar: Extracting \"'xconf/Dialog.c'\" \(8945 characters\)
sed "s/^X//" >'xconf/Dialog.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char Xrcsid[] = "$XConsortium: Dialog.c,v 1.18 88/09/06 16:41:13 jim Exp $";
X#endif lint
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X/* NOTE: THIS IS NOT A WIDGET!  Rather, this is an interface to a widget.
X   It implements policy, and gives a (hopefully) easier-to-use interface
X   than just directly making your own form. */
X
X
X#include <X11/Xlib.h>
X#include <X11/Xos.h>
X#include <X11/IntrinsicP.h>
X#ifdef JON
X#include "XawMisc.h"
X#else JON
X#include <X11/XawMisc.h>
X#endif JON
X#include <X11/StringDefs.h>
X#ifdef JON
X#include "AsciiText.h"
X#else JON
X#include <X11/AsciiText.h>
X#endif JON
X#include <X11/Command.h>
X#include <X11/Label.h>
X#include <X11/DialogP.h>
X
X
Xstatic XtResource resources[] = {
X  {XtNlabel, XtCLabel, XtRString, sizeof(String),
X     XtOffset(DialogWidget, dialog.label), XtRString, NULL},
X  {XtNvalue, XtCValue, XtRString, sizeof(String),
X     XtOffset(DialogWidget, dialog.value), XtRString, NULL},
X  {XtNmaximumLength, XtCMax, XtRInt, sizeof(int),
X     XtOffset(DialogWidget, dialog.max_length), XtRString, "256"}
X};
X
Xstatic void Initialize(), ConstraintInitialize();
Xstatic Boolean SetValues();
X
XDialogClassRec dialogClassRec = {
X  { /* core_class fields */
X    /* superclass         */    (WidgetClass) &formClassRec,
X    /* class_name         */    "Dialog",
X    /* widget_size        */    sizeof(DialogRec),
X    /* class_initialize   */    NULL,
X    /* class_part init    */    NULL,
X    /* class_inited       */    FALSE,
X    /* initialize         */    Initialize,
X    /* initialize_hook    */    NULL,
X    /* realize            */    XtInheritRealize,
X    /* actions            */    NULL,
X    /* num_actions        */    0,
X    /* resources          */    resources,
X    /* num_resources      */    XtNumber(resources),
X    /* xrm_class          */    NULLQUARK,
X    /* compress_motion    */    TRUE,
X    /* compress_exposure  */    TRUE,
X    /* compress_enterleave*/    TRUE,
X    /* visible_interest   */    FALSE,
X    /* destroy            */    NULL,
X    /* resize             */    XtInheritResize,
X    /* expose             */    XtInheritExpose,
X    /* set_values         */    SetValues,
X    /* set_values_hook    */    NULL,
X    /* set_values_almost  */    XtInheritSetValuesAlmost,
X    /* get_values_hook    */    NULL,
X    /* accept_focus       */    NULL,
X    /* version            */    XtVersion,
X    /* callback_private   */    NULL,
X    /* tm_table           */    NULL,
X    /* query_geometry     */	XtInheritQueryGeometry,
X    /* display_accelerator*/	XtInheritDisplayAccelerator,
X    /* extension          */	NULL
X  },
X  { /* composite_class fields */
X    /* geometry_manager   */   XtInheritGeometryManager,
X    /* change_managed     */   XtInheritChangeManaged,
X    /* insert_child       */   XtInheritInsertChild,
X    /* delete_child       */   XtInheritDeleteChild,
X    /* extension          */   NULL
X  },
X  { /* constraint_class fields */
X    /* subresourses       */   NULL,
X    /* subresource_count  */   0,
X    /* constraint_size    */   sizeof(DialogConstraintsRec),
X    /* initialize         */   ConstraintInitialize,
X    /* destroy            */   NULL,
X    /* set_values         */   NULL,
X    /* extension          */   NULL
X  },
X  { /* form_class fields */
X    /* empty              */   0
X  },
X  { /* dialog_class fields */
X    /* empty              */   0
X  }
X};
X
XWidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
X
X
X/* ARGSUSED */
Xstatic void Initialize(request, new)
XWidget request, new;
X{
X    DialogWidget dw = (DialogWidget)new;
X    static Arg label_args[] = {
X	{XtNlabel, (XtArgVal)NULL},
X	{XtNborderWidth, (XtArgVal) 0}
X    };
X    static Arg text_args[] = {
X	{XtNwidth, (XtArgVal)NULL},
X	{XtNstring, (XtArgVal)NULL},
X	{XtNlength, (XtArgVal)0},
X	{XtNfromVert, (XtArgVal)NULL},
X	{XtNresizable, (XtArgVal)TRUE},
X	{XtNtextOptions, (XtArgVal)(resizeWidth | resizeHeight)},
X	{XtNeditType, (XtArgVal)XttextEdit},
X	{XtNright, (XtArgVal)XtChainRight}
X    };
X    Widget children[2], *childP = children;
X
X    label_args[0].value = (XtArgVal)dw->dialog.label;
X    dw->dialog.labelW = XtCreateWidget( "label", labelWidgetClass, new,
X				        label_args, XtNumber(label_args) );
X    *childP++ = dw->dialog.labelW;
X
X    if (dw->dialog.value) {
X        String initial_value = dw->dialog.value;
X	Cardinal length = Max( dw->dialog.max_length, strlen(initial_value) );
X	dw->dialog.value = XtMalloc( length );
X	strcpy( dw->dialog.value, initial_value );
X	text_args[0].value = (XtArgVal)dw->dialog.labelW->core.width; /*|||hack*/
X	text_args[1].value = (XtArgVal)dw->dialog.value;
X	text_args[2].value = (XtArgVal)length;
X	text_args[3].value = (XtArgVal)dw->dialog.labelW;
X	dw->dialog.valueW = XtCreateWidget("value",asciiStringWidgetClass,new,
X					   text_args, XtNumber(text_args) );
X	*childP++ = dw->dialog.valueW;
X#ifdef notdef
X	static int grabfocus;
X	static Resource resources[] = {
X	    {XtNgrabFocus, XtCGrabFocus, XtRBoolean, sizeof(int),
X		 (caddr_t)&grabfocus, (caddr_t)NULL}
X	};
X	XrmNameList names;
X	XrmClassList classes;
X	grabfocus = FALSE;
X	XtGetResources(dpy, resources, XtNumber(resources), args, argCount,
X		       parent, "dialog", "Dialog", &names, &classes);
X	XrmFreeNameList(names);
X	XrmFreeClassList(classes);
X	if (grabfocus) XSetInputFocus(dpy, data->value, RevertToParent,
X				      CurrentTime); /* !!! Hackish. |||*/
X#endif notdef
X    } else {
X        dw->dialog.valueW = NULL;
X    }
X
X    XtManageChildren( children, (Cardinal)(childP - children) );
X}
X
X
X/* ARGSUSED */
Xstatic void ConstraintInitialize(request, new)
XWidget request, new;
X{
X    DialogWidget dw = (DialogWidget)new->core.parent;
X    WidgetList children = dw->composite.children;
X    DialogConstraints constraint = (DialogConstraints)new->core.constraints;
X    Widget *childP;
X
X    if (!XtIsSubclass(new, commandWidgetClass))	/* if not a button */
X	return;					/* then just use defaults */
X
X    constraint->form.left = constraint->form.right = XtChainLeft;
X    constraint->form.vert_base = dw->dialog.valueW
X				 ? dw->dialog.valueW
X				 : dw->dialog.labelW;
X
X    if (dw->composite.num_children > 1) {
X        for (childP = children + dw->composite.num_children - 1;
X	     childP >= children; childP-- ) {
X	    if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
X	        break;
X	    if (XtIsManaged(*childP) &&
X		XtIsSubclass(*childP, commandWidgetClass)) {
X	        constraint->form.horiz_base = *childP;
X		break;
X	    }
X	}
X    }
X}
X
X
X/* ARGSUSED */
Xstatic Boolean SetValues(current, request, new)
XWidget current, request, new;
X{
X    DialogWidget w = (DialogWidget)new;
X    DialogWidget old = (DialogWidget)current;
X
X    if (w->dialog.label != old->dialog.label
X	|| (w->dialog.label != NULL
X	    && old->dialog.label != NULL
X	    && strcmp(w->dialog.label, old->dialog.label))
X	)
X    {
X	Arg args[1];
X	XtSetArg( args[1], XtNlabel, w->dialog.label );
X	XtSetValues( w->dialog.labelW, args, XtNumber(args) );
X    }
X
X    return False;
X}
X
X
Xvoid XtDialogAddButton(dialog, name, function, param)
XWidget dialog;
Xchar *name;
Xvoid (*function)();
Xcaddr_t param;
X{
X    DialogWidget parent = (DialogWidget)dialog;
X    static XtCallbackRec callback[] = { {NULL, NULL}, {NULL, NULL} };
X    static Arg arglist[] = {
X	{XtNcallback, (XtArgVal) callback},
X	{XtNfromVert, (XtArgVal) NULL},
X	{XtNleft, (XtArgVal) XtChainLeft},
X	{XtNright, (XtArgVal) XtChainLeft}
X    };
X
X    callback[0].callback = function;
X    callback[0].closure =  param;
X
X    if (parent->dialog.value)
X       arglist[1].value = (XtArgVal) parent->dialog.value;
X    else
X       arglist[1].value = (XtArgVal) parent->dialog.label;
X
X    XtCreateManagedWidget( name, commandWidgetClass, dialog, 
X			   arglist, XtNumber(arglist) );
X}
X
X
Xchar *XtDialogGetValueString(w)
XWidget w;
X{
X    return ((DialogWidget)w)->dialog.value;
X}
END_OF_FILE
if test 8945 -ne `wc -c <'xconf/Dialog.c'`; then
    echo shar: \"'xconf/Dialog.c'\" unpacked with wrong size!
fi
# end of 'xconf/Dialog.c'
fi
if test -f 'xconf/DiskSrc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/DiskSrc.c'\"
else
echo shar: Extracting \"'xconf/DiskSrc.c'\" \(11969 characters\)
sed "s/^X//" >'xconf/DiskSrc.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char Xrcsid[] = "$XConsortium: DiskSrc.c,v 1.20 88/10/18 12:29:54 swick Exp $";
X#endif lint
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X/* File: DiskSource.c */
X/* Documentation for source specfic routine semantics may be found in the
X * TextPrivate.h file.
X */
X
X#include <stdio.h>
X#include <sys/param.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#include <X11/Xatom.h>
X#include <X11/Xmu.h>
X#ifdef JON
X#include "TextP.h"
X#else JON
X#include <X11/TextP.h>
X#endif JON
X
X#define TMPSIZ 32		/* bytes to allocate for tmpnam */
X
Xextern char *tmpnam();
Xvoid bcopy();
X
X/** private DiskSource definitions **/
X
Xtypedef struct _DiskSourceData {
X	/* resources */
X    char       *fileName;
X	/* private data */
X    Boolean	is_tempfile;
X    FILE *file;		
X    XtTextPosition position, 	/* file position of first char in buffer */
X 		   length; 	/* length of file */
X    char *buffer;		/* piece of file in memory */
X    int charsInBuffer;		/* number of bytes used in memory */
X} DiskSourceData, *DiskSourcePtr;
X
X#define bufSize 1000
X
X#define Increment(data, position, direction)\
X{\
X    if (direction == XtsdLeft) {\
X	if (position > 0) \
X	    position -= 1;\
X    }\
X    else {\
X	if (position < data->length)\
X	    position += 1;\
X    }\
X}
X
Xstatic XtResource diskResources[] = {
X    {XtNfile, XtCFile, XtRString, sizeof (char *),
X        XtOffset(DiskSourcePtr, fileName), XtRString, NULL},
X};
X
Xstatic XtResource sourceResources[] = {
X    {XtNeditType, XtCEditType, XtREditMode, sizeof(int), 
X        XtOffset(XtTextSource, edit_mode), XtRString, "read"},
X};
X
Xstatic char Look(data, position, direction)
X  DiskSourcePtr data;
X  XtTextPosition position;
X  XtTextScanDirection direction;
X{
X
X    if (direction == XtsdLeft) {
X	if (position == 0)
X	    return('\n');
X	else {
X	    FillBuffer(data, position - 1);
X	    return(data->buffer[position - data->position - 1]);
X	}
X    }
X    else {
X	if (position == data->length)
X	    return('\n');
X	else {
X	    FillBuffer(data, position);
X	    return(data->buffer[position - data->position]);
X	}
X    }
X}
X
X
X
Xstatic XtTextPosition DiskReadText (src, pos, text, length)
X  XtTextSource src;
X  XtTextPosition pos;	/** starting position */
X  XtTextBlock *text;	/** RETURNED: text read in */
X  int length;		/** max number of bytes to read **/
X{
X    XtTextPosition count;
X    DiskSourcePtr data;
X
X    data = (DiskSourcePtr) src->data;
X    FillBuffer(data, pos);
X    text->firstPos = pos;
X    text->ptr = data->buffer + (pos - data->position);
X    count = data->charsInBuffer - (pos - data->position);
X    text->length = (length > count) ? count : length;
X    return pos + text->length;
X}
X
X/*
X * this routine reads text starting at "pos" into memory.
X * Contains heuristic for keeping the read position centered in the buffer.
X */
Xstatic int FillBuffer (data, pos)
X  DiskSourcePtr data;
X  XtTextPosition pos;
X{
X    long readPos;
X    if ((pos < data->position ||
X	    pos >= data->position + data->charsInBuffer - 100) &&
X	    data->charsInBuffer != data->length) {
X	if (pos < (bufSize / 2))
X	    readPos = 0;
X	else
X	    if (pos >= data->length - bufSize)
X		readPos = data->length - bufSize;
X	    else
X		if (pos >= data->position + data->charsInBuffer - 100)
X		    readPos = pos - (bufSize / 2);
X		else
X		    readPos = pos;
X	(void) fseek(data->file, readPos, 0);
X	data->charsInBuffer = fread(data->buffer, sizeof(char), bufSize,
X				data->file);
X	data->position = readPos;
X    }
X}
X
X/*
X * This is a dummy routine for read only disk sources.
X */
X/*ARGSUSED*/  /* keep lint happy */
Xstatic int DummyReplaceText (src, startPos, endPos, text)
X  XtTextSource src;
X  XtTextPosition startPos, endPos;
X  XtTextBlock *text;
X{
X    return(EditError);
X}
X
X
X/*
X * This routine will only append to the end of a source.  If incorrect
X * starting and ending positions are given, an error will be returned.
X */
Xstatic int DiskAppendText (src, startPos, endPos, text)
X  XtTextSource src;
X  XtTextPosition startPos, endPos;
X  XtTextBlock *text;
X{
X    long topPosition = 0;
X    char *tmpPtr;
X    DiskSourcePtr data;
X    data = (DiskSourcePtr) src->data;
X    if (startPos != endPos || endPos != data->length)
X        return (PositionError);
X    /* write the new text to the end of the file */
X    if (text->length > 0) {
X	(void) fseek(data->file, data->length, 0);
X	(void) fwrite(text->ptr, sizeof(char), text->length, data->file);
X    } else
X	/* if the delete key was hit, blank out last char in the file */
X	if (text->length < 0) {
X		(void) fseek(data->file, data->length-1, 0);
X		(void) fwrite(" ", sizeof(char), 1, data->file);
X	}
X    /* need this in case the application trys to seek to end of file. */
X     (void) fseek(data->file, topPosition, 2);	
X     
X    /* put the new text into the buffer in memory */
X    data->length += text->length;
X    if (data->charsInBuffer + text->length <= bufSize) {
X/**** NOTE: need to check if text won't fit in the buffer ***/
X	if (text->length > 0) {
X		tmpPtr = data->buffer + data->charsInBuffer;
X		bcopy(text->ptr, tmpPtr, text->length);
X	}
X	data->charsInBuffer += text->length;
X    } else
X	FillBuffer(data, data->length - text->length);
X
X    return (EditDone);
X}
X
X
Xstatic int DiskSetLastPos (src, lastPos)
X  XtTextSource src;
X  XtTextPosition lastPos;
X{
X    ((DiskSourceData *)(src->data))->length = lastPos;
X}
X
X/*
X * This routine will start at
X * the "pos" position of the source and scan in the appropriate
X * direction until it finds something of the right sType.  It returns 
X * the new position.  If upon reading it hits the end of the buffer
X * in memory, it will refill the buffer.
X */
Xstatic XtTextPosition DiskScan (src, pos, sType, dir, count, include)
X  XtTextSource 	 src;
X  XtTextPosition pos;
X  XtTextScanType sType;
X  XtTextScanDirection  dir;
X  int     	 count;
X  Boolean	 include;
X{
X    DiskSourcePtr data;
X    XtTextPosition position;
X    int     i, whiteSpace;
X    char    c;
X
X    data = (DiskSourcePtr) src->data;
X    position = pos;
X    switch (sType) {
X	case XtstPositions: 
X	    if (!include && count > 0)
X		count -= 1;
X	    for (i = 0; i < count; i++) {
X		Increment(data, position, dir);
X	    }
X	    break;
X	case XtstWhiteSpace: 
X	    for (i = 0; i < count; i++) {
X		whiteSpace = 0;
X		while (position >= 0 && position <= data->length) {
X		    FillBuffer(data, position);
X		    c = Look(data, position, dir);
X		    whiteSpace = (c == ' ') || (c == '\t') || (c == '\n');
X		    if (whiteSpace)
X			break;
X		    Increment(data, position, dir);
X		}
X		if (i + 1 != count)
X		    Increment(data, position, dir);
X	    }
X	    if (include)
X		Increment(data, position, dir);
X	    break;
X	case XtstEOL: 
X	    for (i = 0; i < count; i++) {
X		while (position >= 0 && position <= data->length) {
X		    if (Look(data, position, dir) == '\n')
X			break;
X		    Increment(data, position, dir);
X		}
X		if (i + 1 != count)
X		    Increment(data, position, dir);
X	    }
X	    if (include) {
X	    /* later!!!check for last char in file # eol */
X		Increment(data, position, dir);
X	    }
X	    break;
X	case XtstAll: 
X	    if (dir == XtsdLeft)
X		position = 0;
X	    else
X		position = data->length;
X    }
X    return(position);
X}
X
Xstatic Boolean ConvertSelection(d, src, selection, target,
X				type, value, length, format)
X  Display* d;
X  XtTextSource src;
X  Atom *selection, *target, *type;
X  caddr_t *value;
X  unsigned long *length;
X  int *format;
X{
X    DiskSourcePtr data = (DiskSourcePtr)src->data;
X    if (*selection != XA_PRIMARY) return False;
X    if (*target == XA_TARGETS(d)) {
X	*value = XtMalloc(sizeof(Atom));
X	*(Atom*)*value = XA_FILENAME(d);
X	*type = XA_ATOM;
X	*length = 1;
X	*format = 32;
X	return True;
X    } else if (*target == XA_FILENAME(d)) {
X#ifdef unix
X	if (*data->fileName != '/') {
X	    char fullname[MAXPATHLEN+2];		/* +2 for getcwd */
X	    char *p = data->fileName;
X	    int len;
X#ifdef SYSV
X	    extern char *getcwd();
X#define get_current_directory(buf,len) getcwd (buf, len)
X#else
X	    extern char *getwd();
X#define get_current_directory(buf,len) getwd (buf)
X#endif
X
X	    if (get_current_directory (fullname, sizeof fullname) == NULL)
X	      fullname[0] = '\0';
X
X	    while (*p == '.') {
X		if (*++p == '/') {
X		    p++;
X		    continue;
X		}
X		if (*p == '.' && *++p == '/') {
X		    char *d = rindex(fullname, '/');
X		    if (d != NULL) *d = '\0';
X		    p++;
X		    continue;
X		}
X		else break;
X	    }
X	    if (fullname[len=strlen(fullname)] != '/')
X		fullname[len++] = '/';
X	    strcpy(&fullname[len], p);
X	    *value = XtNewString(fullname);
X	}
X	else
X#endif /*unix*/
X	    *value = XtNewString(data->fileName);
X	*type = XA_STRING;
X	*length = strlen(*value);
X	*format = 8;
X	return True;
X    }
X    /* else */
X    return False;
X}
X
X
X/******* Public routines **********/
X
XXtTextSource XtDiskSourceCreate(parent, args, num_args)
X    Widget	parent;
X    ArgList	args;
X    Cardinal	num_args;
X{
X    XtTextSource src;
X    DiskSourcePtr data;
X    long topPosition = 0;
X
X    src = XtNew(XtTextSourceRec);
X
X    XtGetSubresources (parent, (caddr_t)src, XtNtextSource, XtCTextSource,
X		       sourceResources, XtNumber(sourceResources),
X		       args, num_args);
X
X    src->Read = DiskReadText;
X    src->SetLastPos = DiskSetLastPos;
X    src->Scan = DiskScan;
X    src->SetSelection = NULL;
X    src->ConvertSelection = ConvertSelection;
X    data = XtNew(DiskSourceData);
X    src->data = (caddr_t)data;
X
X    XtGetSubresources (parent, (caddr_t)data, XtNtextSource, XtCTextSource,
X        diskResources, XtNumber(diskResources),
X	args, num_args);
X
X    if (data->fileName == NULL) {
X	data->fileName = tmpnam (XtMalloc((unsigned)TMPSIZ));
X	data->is_tempfile = TRUE;
X    } else
X        data->is_tempfile = FALSE;
X
X    switch (src->edit_mode) {
X        case XttextRead:
X           if ((data->file = fopen(data->fileName, "r")) == 0)
X                XtError("Cannot open source file in XtDiskSourceCreate");
X            src->Replace = DummyReplaceText;
X            break;
X        case XttextAppend:
X            if ((data->file = fopen(data->fileName, "r+")) == 0)
X                XtError("Cannot open source file in XtDiskSourceCreate");
X            src->Replace = DiskAppendText;
X            break;
X        default:
X            if ((data->file = fopen(data->fileName, "r")) == 0)
X                XtError("Cannot open source file in XtDiskSourceCreate");
X            src->Replace = DummyReplaceText;
X    }
X    (void) fseek(data->file, topPosition, 2);  
X    data->length = ftell (data->file);  
X    data->buffer = (char *) XtMalloc((unsigned)bufSize);
X    data->position = 0;
X    data->charsInBuffer = 0;
X    return src;
X}
X
Xvoid XtDiskSourceDestroy (src)
X  XtTextSource src;
X{
X    DiskSourcePtr data;
X    data = (DiskSourcePtr) src->data;
X    XtFree((char *) data->buffer);
X    if (data->is_tempfile) {
X        unlink(data->fileName);
X	XtFree((char *) data->fileName);
X    }
X    XtFree((char *) src->data);
X    XtFree((char *) src);
X}
END_OF_FILE
if test 11969 -ne `wc -c <'xconf/DiskSrc.c'`; then
    echo shar: \"'xconf/DiskSrc.c'\" unpacked with wrong size!
fi
# end of 'xconf/DiskSrc.c'
fi
if test -f 'xconf/Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/Imakefile'\"
else
echo shar: Extracting \"'xconf/Imakefile'\" \(553 characters\)
sed "s/^X//" >'xconf/Imakefile' <<'END_OF_FILE'
X#define JON
X#define JOKE
X#define SUNRPC
X
XINCLUDES = -I. -I$(XLIBSRC) -I$(TOP)/X11 -I$(TOP)/lib/Xt
XCC = cc -DJON -DSUNRPC -DJOKE
X
XLOCAL_LIBRARIES =  $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) 
XSYS_LIBRARIES = -lrpcsvc
X           SRCS = xconf.c \
X		  ru.c \
X		  Text.c AsciiText.c AsciiSink.c DiskSrc.c StringSrc.c \
X		  Dialog.c \
X		  Converters.c GCManager.c
X           OBJS = xconf.o \
X		  ru.o \
X		  Text.o AsciiText.o AsciiSink.o DiskSrc.o StringSrc.o \
X		  Dialog.o \
X		  Converters.o GCManager.o
X
XComplexProgramTarget(xconf)
XNormalLintTarget($(SRCS))
END_OF_FILE
if test 553 -ne `wc -c <'xconf/Imakefile'`; then
    echo shar: \"'xconf/Imakefile'\" unpacked with wrong size!
fi
# end of 'xconf/Imakefile'
fi
if test -f 'xconf/StringSrc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/StringSrc.c'\"
else
echo shar: Extracting \"'xconf/StringSrc.c'\" \(8103 characters\)
sed "s/^X//" >'xconf/StringSrc.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char Xrcsid[] = "$XConsortium: StringSrc.c,v 1.20 88/10/18 12:31:59 swick Exp $";
X#endif lint
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X/* File: StringSource.c */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#ifdef JON
X#include "Text.h"
X#include "TextP.h"
X#else JON
X#include <X11/Text.h>
X#include <X11/TextP.h>
X#endif JON
X
X/* Private StringSource Definitions */
X
X#define MAGICVALUE		-1
X#define DEFAULTMAXLENGTH	100
X
X
Xtypedef struct _StringSourceData {
X    char *str;
X    XtTextPosition length, maxLength;
X    XtTextPosition left, right;		/* selection */
X} StringSourceData, *StringSourcePtr;
X
X#define Increment(data, position, direction)\
X{\
X    if (direction == XtsdLeft) {\
X	if (position > 0) \
X	    position -= 1;\
X    }\
X    else {\
X	if (position < data->length)\
X	    position += 1;\
X    }\
X}
X
Xstatic int magic_value = MAGICVALUE;
X
Xstatic XtResource stringResources[] = {
X    {XtNstring, XtCString, XtRString, sizeof (char *),
X        XtOffset(StringSourcePtr, str), XtRString, NULL},
X    {XtNlength, XtCLength, XtRInt, sizeof (int),
X        XtOffset(StringSourcePtr, maxLength), XtRInt, (caddr_t)&magic_value},
X};
X
Xstatic XtResource sourceResources[] = {
X    {XtNeditType, XtCEditType, XtREditMode, sizeof(XtTextEditType), 
X        XtOffset(XtTextSource, edit_mode), XtRString, "read"},
X};
X
Xchar Look(data, position, direction)
X  StringSourcePtr data;
X  XtTextPosition position;
X  XtTextScanDirection direction;
X{
X/* Looking left at pos 0 or right at position data->length returns newline */
X    if (direction == XtsdLeft) {
X	if (position == 0)
X	    return(0);
X	else
X	    return(data->str[position-1]);
X    }
X    else {
X	if (position == data->length)
X	    return(0);
X	else
X	    return(data->str[position]);
X    }
X}
X
Xstatic XtTextPosition StringReadText (src, pos, text, maxRead)
X  XtTextSource src;
X  int pos;
X  XtTextBlock *text;
X  int maxRead;
X{
X    int     charsLeft;
X    StringSourcePtr data;
X
X    data = (StringSourcePtr) src->data;
X    text->firstPos = pos;
X    text->ptr = data->str + pos;
X    charsLeft = data->length - pos;
X    text->length = (maxRead > charsLeft) ? charsLeft : maxRead;
X    return pos + text->length;
X}
X
Xstatic int StringReplaceText (src, startPos, endPos, text)
X  XtTextSource src;
X  XtTextPosition startPos, endPos;
X  XtTextBlock *text;
X{
X    StringSourcePtr data;
X    int     i, length, delta;
X
X    data = (StringSourcePtr) src->data;
X    switch (src->edit_mode) {
X        case XttextAppend: 
X	    if (startPos != endPos || endPos!= data->length)
X		return (PositionError);
X	    break;
X	case XttextRead:
X	    return (EditError);
X	case XttextEdit:
X	    break;
X	default:
X	    return (EditError);
X    }
X    length = endPos - startPos;
X    if ((data->length - length + text->length) > data->maxLength)
X        return (EditError);
X
X    delta = text->length - length;
X    if (delta < 0)		/* insert shorter than delete, text getting
X				   shorter */
X	for (i = startPos; i < data->length + delta; ++i)
X	    data->str[i] = data->str[i - delta];
X    else
X	if (delta > 0)	{	/* insert longer than delete, text getting
X				   longer */
X	    for (i = data->length; i > startPos-1; --i)
X		data->str[i + delta] = data->str[i];
X	}
X    if (text->length != 0)	/* do insert */
X	for (i = 0; i < text->length; ++i)
X	    data->str[startPos + i] = text->ptr[i];
X    data->length = data->length + delta;
X    data->str[data->length] = 0;
X    return (EditDone);
X}
X
Xstatic StringSetLastPos (src, lastPos)
X  XtTextSource src;
X  XtTextPosition lastPos;
X{
X    ((StringSourceData *) (src->data))->length = lastPos;
X}
X
Xstatic XtTextPosition StringScan (src, pos, sType, dir, count, include)
X  XtTextSource	 src;
X  XtTextPosition pos;
X  XtTextScanType sType;
X  XtTextScanDirection dir;
X  int		 count;
X  Boolean	 include;
X{
X    StringSourcePtr data;
X    XtTextPosition position;
X    int     i, whiteSpace;
X    char    c;
X    int ddir = (dir == XtsdRight) ? 1 : -1;
X
X    data = (StringSourcePtr) src->data;
X    position = pos;
X    switch (sType) {
X	case XtstPositions: 
X	    if (!include && count > 0)
X		count -= 1;
X	    for (i = 0; i < count; i++) {
X		Increment(data, position, dir);
X	    }
X	    break;
X	case XtstWhiteSpace: 
X
X	    for (i = 0; i < count; i++) {
X		whiteSpace = -1;
X		while (position >= 0 && position <= data->length) {
X		    c = Look(data, position, dir);
X		    if ((c == ' ') || (c == '\t') || (c == '\n')){
X		        if (whiteSpace < 0) whiteSpace = position;
X		    } else if (whiteSpace >= 0)
X			break;
X		    position += ddir;
X		}
X	    }
X	    if (!include) {
X		if(whiteSpace < 0 && dir == XtsdRight) whiteSpace = data->length;
X		position = whiteSpace;
X	    }
X	    break;
X	case XtstEOL: 
X	    for (i = 0; i < count; i++) {
X		while (position >= 0 && position <= data->length) {
X		    if (Look(data, position, dir) == '\n')
X			break;
X		    if(((dir == XtsdRight) && (position == data->length)) || 
X			(dir == XtsdLeft) && ((position == 0)))
X			break;
X		    Increment(data, position, dir);
X		}
X		if (i + 1 != count)
X		    Increment(data, position, dir);
X	    }
X	    if (include) {
X	    /* later!!!check for last char in file # eol */
X		Increment(data, position, dir);
X	    }
X	    break;
X	case XtstAll: 
X	    if (dir == XtsdLeft)
X		position = 0;
X	    else
X		position = data->length;
X    }
X    if (position < 0) position = 0;
X    if (position > data->length) position = data->length;
X    return(position);
X}
X
Xstatic void SetSelection(src, left, right, selection)
X    XtTextSource src;
X    Atom selection;
X    XtTextPosition left, right;
X{
X    ((StringSourcePtr)src->data)->left = left;
X    ((StringSourcePtr)src->data)->right = right;
X}
X
X/***** Public routines *****/
X
XXtTextSource XtStringSourceCreate (parent, args, argCount)
X    Widget parent;
X    ArgList args;
X    Cardinal argCount;
X{
X    XtTextSource src;
X    StringSourcePtr data;
X
X    src = XtNew(XtTextSourceRec);
X
X    XtGetSubresources (parent, (caddr_t)src, XtNtextSource, XtCTextSource,
X        sourceResources, XtNumber(sourceResources), args, argCount);
X
X    src->Read = StringReadText;
X    src->Replace = StringReplaceText;
X    src->SetLastPos = StringSetLastPos;
X    src->Scan = StringScan;
X    src->SetSelection = SetSelection;
X    src->ConvertSelection = NULL;
X    data = XtNew(StringSourceData);
X    src->data = (caddr_t)data;
X    data->left = data->right = 0;
X
X    XtGetSubresources (parent, (caddr_t)data, XtNtextSource, XtCTextSource,
X        stringResources, XtNumber(stringResources), args, argCount);
X
X    if (data->str == NULL) {
X	if (data->maxLength == MAGICVALUE) data->maxLength = DEFAULTMAXLENGTH;
X	data->str = (char *) XtMalloc ((unsigned)data->maxLength);
X	data->length = 0;
X    } else {
X        data->length = strlen(data->str);
X	if (data->maxLength < data->length) data->maxLength = data->length;
X    }
X
X    return src;
X}
X
Xvoid XtStringSourceDestroy (src)
X  XtTextSource src;
X{
X    XtFree((char *) src->data);
X    XtFree((char *) src);
X}
END_OF_FILE
if test 8103 -ne `wc -c <'xconf/StringSrc.c'`; then
    echo shar: \"'xconf/StringSrc.c'\" unpacked with wrong size!
fi
# end of 'xconf/StringSrc.c'
fi
if test -f 'xconf/Text.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/Text.h'\"
else
echo shar: Extracting \"'xconf/Text.h'\" \(6512 characters\)
sed "s/^X//" >'xconf/Text.h' <<'END_OF_FILE'
X/*
X* $XConsortium: Text.h,v 1.16 88/10/23 14:36:28 swick Exp $
X*/
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#ifndef _XtText_h
X#define _XtText_h
X
X/****************************************************************
X *
X * Text widget
X *
X ****************************************************************/
X
X/* Parameters:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X background	     Background		Pixel		XtDefaultBackground
X border		     BorderColor	Pixel		XtDefaultForeground
X borderWidth	     BorderWidth	Dimension	1
X destroyCallback     Callback		Pointer		NULL
X dialogHOffset	     Margin		int		10
X dialogVOffset	     Margin		int		10
X displayPosition     TextPosition	int		0
X editType	     EditType		XtTextEditType	XttextRead
X height		     Height		Dimension	font height
X insertPosition	     TextPosition	int		0
X leftMargin	     Margin		Dimension	2
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X selectTypes	     SelectTypes	Pointer		(internal)
X selection	     Selection		Pointer		empty selection
X sensitive	     Sensitive		Boolean		True
X textOptions	     TextOptions	int		0
X textSink	     TextSink		Pointer		(none)
X textSource	     TextSource		Pointer		(none)
X width		     Width		Dimension	100
X x		     Position		int		0
X y		     Position		int		0
X
X*/
X
X
X#define XtNtextOptions		"textOptions"
X#define XtNdialogHOffset	"dialogHOffset"
X#define XtNdialogVOffset	"dialogVOffset"
X#define XtNdisplayPosition      "displayPosition"
X#define XtNinsertPosition	"insertPosition"
X#define XtNleftMargin		"leftMargin"
X#define XtNselectTypes		"selectTypes"
X#define XtNtextSource		"textSource"
X#define XtNtextSink		"textSink"
X#define XtNselection		"selection"
X#ifdef JON
X#define XtNcallback		"callback"
X#endif
X
X#define XtNeditType		"editType"
X#define XtNfile			"file"
X#define XtNstring		"string"
X#define XtNlength		"length"
X#define XtNfont			"font"
X
X#define XtCSelectTypes		"SelectTypes"
X
X/* Return codes from XtTextReplace */
X#define XawEditDone		0
X#define XawEditError		1
X#define XawPositionError	2
X
X/* Class record constants */
X
Xextern WidgetClass textWidgetClass;
Xextern Atom FMT8BIT;
X
Xtypedef struct _TextClassRec *TextWidgetClass;
Xtypedef struct _TextRec      *TextWidget;
X
X/* other stuff */
X
Xtypedef long XtTextPosition;
Xtypedef struct _XtTextSource XtTextSourceRec, *XtTextSource;
Xtypedef struct _XtTextSink XtTextSinkRec, *XtTextSink;
X
Xtypedef enum {XttextRead, XttextAppend, XttextEdit} XtTextEditType;
Xtypedef enum {XtselectNull, XtselectPosition, XtselectChar, XtselectWord,
X    XtselectLine, XtselectParagraph, XtselectAll} XtTextSelectType;
X
X#define wordBreak		0x01
X#define scrollVertical		0x02
X#define scrollHorizontal	0x04
X#define scrollOnOverflow	0x08
X#define resizeWidth		0x10
X#define resizeHeight		0x20
X#define editable		0x40
X
Xtypedef struct {
X    int  firstPos;
X    int  length;
X    char *ptr;
X    Atom format;
X    } XtTextBlock, *XtTextBlockPtr;
X
Xextern void XtTextDisplay(); /* w */
X    /* Widget w; */
X
Xextern void XtTextSetSelectionArray(); /* w, sarray */
X    /* Widget        w;		*/
X    /* SelectionType *sarray;   */
X
Xextern void XtTextSetLastPos(); /* w, lastPos */
X    /* Widget        w;		*/
X    /* XtTextPosition lastPos;  */
X
Xextern void XtTextGetSelectionPos(); /* dpy, w, left, right */
X    /* Widget        w;		*/
X    /* XtTextPosition *left, *right;    */
X
Xextern void XtTextSetSource(); /* dpy, w, source, startPos */
X    /* Widget         w;	    */
X    /* XtTextSource   source;       */
X    /* XtTextPosition startPos;     */
X
Xextern int XtTextReplace(); /* w, startPos, endPos, text */
X    /* Widget        w;		*/
X    /* XtTextPosition   startPos, endPos; */
X    /* XtTextBlock      *text; */
X
Xextern XtTextPosition XtTextTopPosition(); /* w */
X    /* Widget        w;		*/
X
Xextern void XtTextSetInsertionPoint(); /*  w, position */
X    /* Widget        w;		*/
X    /* XtTextPosition position; */
X
Xextern XtTextPosition XtTextGetInsertionPoint(); /* w */
X    /* Widget        w;		*/
X
Xextern void XtTextUnsetSelection(); /* w */
X    /* Widget        w;		*/
X
Xextern void XtTextChangeOptions(); /* w, options */
X    /* Widget        w;		*/
X    /* int    options; */
X
Xextern int XtTextGetOptions(); /* w */
X    /* Widget        w;		*/
X
Xextern void XtTextSetSelection(); /* w, left, right */
X    /* Widget        w;		*/
X    /* XtTextPosition left, right; */
X
Xextern void XtTextInvalidate(); /* w, from, to */
X    /* Widget        w;		*/
X    /* XtTextPosition from, to; */
X
Xextern XtTextSource XtTextGetSource() ; /* w */
X    /* Widget        w;		*/
X
X/*
X * Stuff from AsciiSink
X */
X
Xextern XtTextSink XtAsciiSinkCreate(); /* parent, args, num_args */
X    /* Widget parent;		*/
X    /* ArgList args;		*/
X    /* Cardinal num_args;	*/
X
Xextern void XtAsciiSinkDestroy(); /* sink */
X    /* XtTextSink  sink */
X
X/*
X * from DiskSrc
X */
Xextern XtTextSource XtDiskSourceCreate(); /* parent, args, num_args */
X    /* Widget	parent;		*/
X    /* ArgList	args;		*/
X    /* Cardinal	num_args;	*/
X
Xextern void XtDiskSourceDestroy(); /* src */
X    /* XtTextSource src;	*/
X
X/*
X * from StringSrc
X */
X
Xextern XtTextSource XtStringSourceCreate(); /* parent, args, num_args */
X    /* Widget parent;		*/
X    /* ArgList args;		*/
X    /* Cardinal num_args;	*/
X
Xextern void XtStringSourceDestroy(); /* src */
X    /* XtTextSource src;	*/
X
X
X#endif _XtText_h
X/* DON'T ADD STUFF AFTER THIS #endif */
END_OF_FILE
if test 6512 -ne `wc -c <'xconf/Text.h'`; then
    echo shar: \"'xconf/Text.h'\" unpacked with wrong size!
fi
# end of 'xconf/Text.h'
fi
if test -f 'xconf/TextP.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xconf/TextP.h'\"
else
echo shar: Extracting \"'xconf/TextP.h'\" \(5475 characters\)
sed "s/^X//" >'xconf/TextP.h' <<'END_OF_FILE'
X/*
X* $XConsortium: TextP.h,v 1.28 88/10/18 13:12:54 swick Exp $
X*/
X
X
X/***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its 
Xdocumentation for any purpose and without fee is hereby granted, 
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in 
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.  
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************/
X
X#ifndef _XtTextP_h
X#define _XtTextP_h
X
X
X#ifdef JON
X#include "Text.h"
X#else JON
X#include <X11/Text.h>
X#endif JON
X#include <X11/SimpleP.h>
X#include <X11/TextSrcP.h>
X
X/****************************************************************
X *
X * Text widget private
X *
X ****************************************************************/
X#define MAXCUT	30000	/* Maximum number of characters that can be cut. */
X
X#define LF	0x0a
X#define CR	0x0d
X#define TAB	0x09
X#define BS	0x08
X#define SP	0x20
X#define DEL	0x7f
X#define BSLASH	'\\'
X
X/* constants that subclasses may want to know */
X#define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
X#define  yMargin 2
X
X
X/* displayable text management data structures */
X
Xtypedef struct {
X    XtTextPosition position;
X    Position x, y, endX;
X    } XtTextLineTableEntry, *XtTextLineTableEntryPtr;
X
X/* Line Tables are n+1 long - last position displayed is in last lt entry */
Xtypedef struct {
X    XtTextPosition	 top;	/* Top of the displayed text.		*/
X    int			 lines;	/* How many lines in this table.	*/
X    XtTextLineTableEntry *info;	/* A dynamic array, one entry per line  */
X    } XtTextLineTable, *XtTextLineTablePtr;
X
X#define IsPositionVisible(ctx, pos) \
X		(pos >= ctx->text.lt.info[0].position && \
X		 pos < ctx->text.lt.info[ctx->text.lt.lines].position)
X
X/* Private Text Definitions */
X
Xtypedef int (*ActionProc)();
X
X/* New fields for the Text widget class record */
X
Xtypedef struct {int empty;} TextClassPart;
X
X/* Full class record declaration */
Xtypedef struct _TextClassRec {
X    CoreClassPart	core_class;
X    SimpleClassPart	simple_class;
X    TextClassPart	text_class;
X} TextClassRec;
X
Xextern TextClassRec textClassRec;
X
X/* New fields for the Text widget record */
Xtypedef struct _TextPart {
X    /* resources */
X    XtTextSource	source;
X    XtTextSink		sink;
X    XtTextPosition	insertPos;
X    XtTextSelection	s;
X    XtTextSelectType	*sarray;	   /* Array to cycle for selections. */
X    Dimension		client_leftmargin;   /* client-visible resource */
X    int			options;	     /* wordbreak, scroll, etc. */
X    int			dialog_horiz_offset; /* position for popup dialog */
X    int			dialog_vert_offset;  /* position for popup dialog */
X    /* private state */
X    XtTextLineTable	lt;
X    XtTextScanDirection extendDir;
X    XtTextSelection	origSel;    /* the selection being modified */
X    Dimension	    leftmargin;	    /* Width of left margin. */
X    Time	    lasttime;	    /* timestamp of last processed action */
X    Time	    time;	    /* time of last key or button action */ 
X    Position	    ev_x, ev_y;	    /* x, y coords for key or button action */
X    Widget	    sbar;	    /* The vertical scroll bar (none = 0).  */
X    Widget	    outer;	    /* Parent of scrollbar & text (if any) */
X    XtTextPosition  *updateFrom;    /* Array of start positions for update. */
X    XtTextPosition  *updateTo;	    /* Array of end positions for update. */
X    int		    numranges;	    /* How many update ranges there are. */
X    int		    maxranges;	    /* How many ranges we have space for */
X    Boolean	    showposition;   /* True if we need to show the position. */
X    XtTextPosition  lastPos;	    /* Last position of source. */
X    struct _dialog {
X	TextWidget  text;	    /* the dialog's parent */
X	Widget      widget;	    /* the dialog widget */
X	Widget	    doit;	    /* the confirm button */
X	Widget	    message;	    /* the (occasional) error message */
X	Boolean	    mapped;	    /* True if this dialog is in-use */
X	struct _dialog *next;	    /* a list of dialogs */
X    } *dialog;			    /* InsertFile pop-up widget */
X    GC              gc;
X    Boolean         hasfocus;       /* TRUE if we currently have input focus.*/
X    Boolean	    update_disabled; /* TRUE if display updating turned off */
X    XtTextPosition  old_insert;      /* Last insertPos for batched updates */
X#ifdef JON
X    XtCallbackList callbacks;		/* JONS OWN Callbacks */
X#endif JON
X} TextPart;
X
X/****************************************************************
X *
X * Full instance record declaration
X *
X ****************************************************************/
X
Xtypedef struct _TextRec {
X    CorePart	core;
X    SimplePart	simple;
X    TextPart	text;
X} TextRec;
X
X
X#endif _XtTextP_h
END_OF_FILE
if test 5475 -ne `wc -c <'xconf/TextP.h'`; then
    echo shar: \"'xconf/TextP.h'\" unpacked with wrong size!
fi
# end of 'xconf/TextP.h'
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0



More information about the Comp.sources.x mailing list