/*********************************************************************** * * TITLE: xmutil.c * * AUTHOR: Cassie Mulnix * * DESCRIPTION: This module is part of the OPPS editor, xopps. It contains * useful Motif / X utilities * * CHANGE HISTORY * $Log: mxutil.c,v $ * Revision 1.5 1994/05/04 23:34:36 clm * ported to ANSI C * * Revision 1.4 1992/05/20 22:28:51 clm * *** empty log message *** * * Revision 1.3 1992/05/20 19:50:57 clm * cleaned up file and help format * * Revision 1.1 90/10/26 18:14:06 kevin * Initial revision * *********************************************************************** * * WARNINGS: * * EXTERNAL CALLABLE COMPONENTS (PUBLIC): * * GLOBALS: * * WAIVERS: * * NOTES: * * MANPAGE: * ***********************************************************************/ #ifndef lint static char rcsid[] = "$Id: mxutil.c,v 1.5 1994/05/04 23:34:36 clm OEL $"; #endif #include char *extract_normal_string(XmString cs); XmString string_array_to_xmstr(char *cs[], int n); /*********************************************************************** * * FUNCTION: extract_normal_string() * * INPUTS: cs (XmString) * * OUTPUTS: * * RETURNS: * * EXTERNALLY READ: * * EXTERNALLY MODIFIED: * * DESCRIPTION: reads text values returned by widgets */ char * extract_normal_string(XmString cs) { XmStringContext context; XmStringCharSet charset; XmStringDirection direction; Boolean separator; static char *primitive_string; XmStringInitContext(&context, cs); XmStringGetNextSegment (context, &primitive_string, &charset, &direction, &separator); XmStringFreeContext (context); return primitive_string; } /*********************************************************************** * * FUNCTION: string_array_to_xmstr() * * INPUTS: cs (char * []) * n (int) * * OUTPUTS: * * RETURNS: * * EXTERNALLY READ: * * EXTERNALLY MODIFIED: * * DESCRIPTION: takes an array of character strings and returns an * equivalent compound string, assuming each string in the array * represents one line of multi-line piece of text. */ XmString string_array_to_xmstr(char *cs[], int n) { XmString xmstr; int i; /* If the array is empty, return an empty string */ if (n <=0) { return (XmStringCreate("", XmSTRING_DEFAULT_CHARSET)); } xmstr = (XmString) NULL; for (i = 0; i < n; i++) { if (i > 0) { xmstr = XmStringConcat(xmstr, XmStringSeparatorCreate()); } xmstr = XmStringConcat(xmstr, XmStringCreate(cs[i], XmSTRING_DEFAULT_CHARSET)); } return(xmstr); }