Annotation of researchv9/X11/src/X.V11R1/lib/Xtk/TextKinds.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char rcsid[] = "$Header: TextKinds.c,v 1.3 87/09/13 13:25:40 swick Exp $";
        !             3: #endif lint
        !             4: 
        !             5: /*
        !             6:  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
        !             7:  * 
        !             8:  *                         All Rights Reserved
        !             9:  * 
        !            10:  * Permission to use, copy, modify, and distribute this software and its 
        !            11:  * documentation for any purpose and without fee is hereby granted, 
        !            12:  * provided that the above copyright notice appear in all copies and that
        !            13:  * both that copyright notice and this permission notice appear in 
        !            14:  * supporting documentation, and that the name of Digital Equipment
        !            15:  * Corporation not be used in advertising or publicity pertaining to
        !            16:  * distribution of the software without specific, written prior permission.  
        !            17:  * 
        !            18:  * 
        !            19:  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
        !            20:  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
        !            21:  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
        !            22:  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
        !            23:  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
        !            24:  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
        !            25:  * SOFTWARE.
        !            26:  */
        !            27: #include "Xresource.h"
        !            28: #include "Intrinsic.h"
        !            29: #include "Text.h"
        !            30: #include "TextP.h"
        !            31: #include "Atoms.h"
        !            32: /* #include "TextDisp.h" */
        !            33: #include <strings.h>
        !            34: 
        !            35: extern char *tmpnam();
        !            36: 
        !            37: /* ||| Bogus definitions to go in some .h file */
        !            38: 
        !            39: extern int *XtDiskSourceCreate (/* name, mode */);
        !            40:     /* char       *name;       */
        !            41:     /* XtEditType mode;                */
        !            42: 
        !            43: extern int *XtStringSourceCreate (/* str, maxLength, mode */);
        !            44:     /* char            *str;           */
        !            45:     /* int             maxLength;      */      
        !            46:     /* XtEditType      mode;           */
        !            47: 
        !            48: 
        !            49: /* Private definitions. */
        !            50: 
        !            51: typedef enum _TextKinds {diskText, stringText} TextKinds;
        !            52: 
        !            53: static int *source;
        !            54: 
        !            55: static Boolean initialized = FALSE;
        !            56: 
        !            57: /* EditType enumeration constants */
        !            58: 
        !            59: static  XrmQuark  XtQTextRead;
        !            60: static  XrmQuark  XtQTextAppend;
        !            61: static  XrmQuark  XtQTextEdit;
        !            62: 
        !            63: /*ARGSUSED*/
        !            64: #define done(address, type) \
        !            65:         { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; }
        !            66: 
        !            67: extern void _XLowerCase();
        !            68: 
        !            69: static void CvtStringToEditMode(dpy, fromVal, toVal)
        !            70:     Display     *dpy;
        !            71:     XrmValue    fromVal;
        !            72:     XrmValue    *toVal;
        !            73: {
        !            74:     static XtEditType editType;
        !            75:     XrmQuark    q;
        !            76:     char        lowerName[1000];
        !            77: 
        !            78: /* ||| where to put LowerCase */
        !            79:     _XLowerCase((char *) fromVal.addr, lowerName);
        !            80:     q = XrmAtomToQuark(lowerName);
        !            81:     if (q == XtQTextRead ) {
        !            82:         editType = XttextRead;
        !            83:         done(&editType, XtEditType);
        !            84:         return;
        !            85:     }
        !            86:     if (q == XtQTextAppend) {
        !            87:         editType = XttextAppend;
        !            88:         done(&editType, XtEditType);
        !            89:         return;
        !            90:     }
        !            91:     if (q == XtQTextEdit) {
        !            92:         editType = XttextEdit;
        !            93:         done(&editType, XtEditType);
        !            94:         return;
        !            95:     }
        !            96:     (*toVal).size = 0;
        !            97:     (*toVal).addr = NULL;
        !            98: };
        !            99: 
        !           100: static TextKindsInitialize(w)
        !           101: Widget w;
        !           102: {
        !           103:     if (initialized)
        !           104:        return;
        !           105:     XtQTextRead = XrmAtomToQuark(XtEtextRead);
        !           106:     XtQTextAppend   = XrmAtomToQuark(XtEtextAppend);
        !           107:     XtQTextEdit  = XrmAtomToQuark(XtEtextEdit);
        !           108:     XrmRegisterTypeConverter(XrmRString, XtREditMode, CvtStringToEditMode);
        !           109:     initialized = TRUE;
        !           110: 
        !           111: }
        !           112: 
        !           113: static Widget AsciiTextCreate(w, args, argCount, src)
        !           114:     Widget w;
        !           115:     Arg        *args;
        !           116:     int        argCount;
        !           117:     int        *src;
        !           118: {
        !           119:     TextWidget tw = (TextWidget)w;
        !           120:     ArgList mergedArgs;
        !           121:     Arg myArgs[2];
        !           122: 
        !           123:     XtSetArg(myArgs[0], XtNtextSource, (XtArgVal) src);
        !           124:     XtSetArg(myArgs[1], XtNtextSink, 
        !           125:        (XtArgVal) XtAsciiSinkCreate(w, NULL, 0));
        !           126: 
        !           127:     mergedArgs = XtMergeArgLists(args, argCount, myArgs, XtNumber(myArgs) );
        !           128: /* XXX first param is bogus */
        !           129:     tw = (TextWidget) XtCreateWidget("textname", textWidgetClass,
        !           130:        w, mergedArgs, argCount+XtNumber(myArgs));
        !           131: 
        !           132:     XtFree((char *) mergedArgs);
        !           133:     return (Widget)tw;
        !           134: }
        !           135: 
        !           136: /***** Public routines. *****/
        !           137: 
        !           138: Widget XtTextDiskCreate(w, args, argCount)
        !           139:     Widget w;
        !           140:     ArgList args;
        !           141:     int     argCount;
        !           142: {
        !           143:     if (!initialized) TextKindsInitialize(w);
        !           144:     source = XtDiskSourceCreate (w);
        !           145:     return (AsciiTextCreate (w, args, argCount, source));
        !           146: }
        !           147: 
        !           148: XtTextDiskDestroy(w)
        !           149:     Widget w;
        !           150: {
        !           151:     XtDestroyWidget(w);
        !           152: }
        !           153: 
        !           154: Widget XtTextStringCreate(w, args, argCount)
        !           155:     Widget w;    
        !           156:     ArgList args;
        !           157:     int     argCount;
        !           158: {
        !           159:     if (!initialized) TextKindsInitialize(w);
        !           160: 
        !           161:     /* need option for specifying read append mode */
        !           162:     source = XtStringSourceCreate (w, args, argCount);
        !           163:     return (AsciiTextCreate (w, args, argCount, source));
        !           164: }
        !           165: 
        !           166: XtTextStringDestroy(w)
        !           167:   Widget w;
        !           168: {
        !           169:     XtDestroyWidget(w);
        !           170: }
        !           171: 
        !           172: 
        !           173: Widget XtTextSourceCreate(w, args, argCount, passedSource)
        !           174:     Widget w;
        !           175:     ArgList args;
        !           176:     int     argCount;
        !           177:     int     *passedSource;  /* ||| NOTE:  should be in args */
        !           178: {
        !           179:     if (!initialized) TextKindsInitialize(w);
        !           180:     return (AsciiTextCreate (w, args, argCount, passedSource));
        !           181: }
        !           182: 
        !           183: XtTextSourceDestroy(w)
        !           184:     Widget w;
        !           185: {
        !           186:     XtDestroyWidget(w);
        !           187: }
        !           188: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.