749N/A/* $TOG: TextSrc.c /main/21 1998/05/25 08:17:30 kaleb $ */
749N/A/*
749N/A
749N/ACopyright 1989, 1994, 1998 The Open Group
749N/A
749N/AAll Rights Reserved.
749N/A
749N/AThe above copyright notice and this permission notice shall be included in
749N/Aall copies or substantial portions of the Software.
749N/A
749N/ATHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
749N/AIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
749N/AFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
749N/AOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
749N/AAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
749N/ACONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
749N/A
749N/AExcept as contained in this notice, the name of The Open Group shall not be
749N/Aused in advertising or otherwise to promote the sale, use or other dealings
749N/Ain this Software without prior written authorization from The Open Group.
749N/A
749N/A*/
749N/A
749N/A/*
749N/A * Author: Chris Peterson, MIT X Consortium.
749N/A * Much code taken from X11R3 String and Disk Sources.
749N/A */
749N/A
749N/A/*
749N/A * TextSrc.c - TextSrc object. (For use with the text widget).
749N/A *
749N/A */
749N/A
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A#include <X11/Xutil.h>
749N/A#include <X11/Xaw/XawInit.h>
749N/A#include <X11/Xaw/TextSrcP.h>
749N/A#include <X11/Xmu/Atoms.h>
749N/A#include <X11/Xmu/CharSet.h>
749N/A#include "XawI18n.h"
749N/A#include <stdio.h>
749N/A#include <ctype.h>
749N/A
749N/A/****************************************************************
749N/A *
749N/A * Full class record constant
749N/A *
749N/A ****************************************************************/
749N/A
749N/A/* Private Data */
749N/A
749N/A#define offset(field) XtOffsetOf(TextSrcRec, textSrc.field)
749N/Astatic XtResource resources[] = {
749N/A {XtNeditType, XtCEditType, XtREditMode, sizeof(XawTextEditType),
749N/A offset(edit_mode), XtRString, "read"},
749N/A};
749N/A
749N/Astatic void ClassInitialize(), ClassPartInitialize(), SetSelection();
749N/Astatic void CvtStringToEditMode();
749N/Astatic Boolean ConvertSelection();
749N/Astatic XawTextPosition Search(), Scan(), Read();
749N/Astatic int Replace();
749N/A
749N/A#define SuperClass (&objectClassRec)
749N/ATextSrcClassRec textSrcClassRec = {
749N/A {
749N/A/* core_class fields */
749N/A /* superclass */ (WidgetClass) SuperClass,
749N/A /* class_name */ "TextSrc",
749N/A /* widget_size */ sizeof(TextSrcRec),
749N/A /* class_initialize */ ClassInitialize,
749N/A /* class_part_initialize */ ClassPartInitialize,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ NULL,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ NULL,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ resources,
749N/A /* num_resources */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ FALSE,
749N/A /* compress_exposure */ FALSE,
749N/A /* compress_enterleave */ FALSE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ NULL,
749N/A /* expose */ NULL,
749N/A /* set_values */ NULL,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost */ NULL,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ NULL,
749N/A /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ NULL,
749N/A /* query_geometry */ NULL,
749N/A /* display_accelerator */ NULL,
749N/A /* extension */ NULL,
749N/A },
749N/A/* textSrc_class fields */
749N/A {
749N/A /* Read */ Read,
749N/A /* Replace */ Replace,
749N/A /* Scan */ Scan,
749N/A /* Search */ Search,
749N/A /* SetSelection */ SetSelection,
749N/A /* ConvertSelection */ ConvertSelection
749N/A }
749N/A};
749N/A
749N/AWidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec;
749N/A
749N/Astatic void
749N/AClassInitialize ()
749N/A{
749N/A XawInitializeWidgetSet ();
749N/A XtAddConverter(XtRString, XtREditMode, CvtStringToEditMode, NULL, 0);
749N/A}
749N/A
749N/A
749N/Astatic void
749N/AClassPartInitialize(wc)
749N/AWidgetClass wc;
749N/A{
749N/A TextSrcObjectClass t_src, superC;
749N/A
749N/A t_src = (TextSrcObjectClass) wc;
749N/A superC = (TextSrcObjectClass) t_src->object_class.superclass;
749N/A
749N/A/*
749N/A * We don't need to check for null super since we'll get to TextSrc
749N/A * eventually.
749N/A */
749N/A if (t_src->textSrc_class.Read == XtInheritRead)
749N/A t_src->textSrc_class.Read = superC->textSrc_class.Read;
749N/A
749N/A if (t_src->textSrc_class.Replace == XtInheritReplace)
749N/A t_src->textSrc_class.Replace = superC->textSrc_class.Replace;
749N/A
749N/A if (t_src->textSrc_class.Scan == XtInheritScan)
749N/A t_src->textSrc_class.Scan = superC->textSrc_class.Scan;
749N/A
749N/A if (t_src->textSrc_class.Search == XtInheritSearch)
749N/A t_src->textSrc_class.Search = superC->textSrc_class.Search;
749N/A
749N/A if (t_src->textSrc_class.SetSelection == XtInheritSetSelection)
749N/A t_src->textSrc_class.SetSelection = superC->textSrc_class.SetSelection;
749N/A
749N/A if (t_src->textSrc_class.ConvertSelection == XtInheritConvertSelection)
749N/A t_src->textSrc_class.ConvertSelection =
749N/A superC->textSrc_class.ConvertSelection;
749N/A}
749N/A
749N/A/************************************************************
749N/A *
749N/A * Class specific methods.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: Read
749N/A * Description: This function reads the source.
749N/A * Arguments: w - the TextSrc Object.
749N/A * pos - position of the text to retreive.
749N/A * RETURNED text - text block that will contain returned text.
749N/A * length - maximum number of characters to read.
749N/A * Returns: The number of characters read into the buffer.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic XawTextPosition
749N/ARead(w, pos, text, length)
749N/AWidget w;
749N/AXawTextPosition pos;
749N/AXawTextBlock *text;
749N/Aint length;
749N/A{
749N/A XtAppError(XtWidgetToApplicationContext(w),
749N/A "TextSrc Object: No read function is defined.");
749N/A
749N/A return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
749N/A}
749N/A
749N/A/* Function Name: Replace.
749N/A * Description: Replaces a block of text with new text.
749N/A * Arguments: src - the Text Source Object.
749N/A * startPos, endPos - ends of text that will be removed.
749N/A * text - new text to be inserted into buffer at startPos.
749N/A * Returns: XawEditError.
749N/A */
749N/A
749N/A/*ARGSUSED*/
749N/Astatic int
749N/AReplace (w, startPos, endPos, text)
749N/AWidget w;
749N/AXawTextPosition startPos, endPos;
749N/AXawTextBlock *text;
749N/A{
749N/A return(XawEditError);
749N/A}
749N/A
749N/A/* Function Name: Scan
749N/A * Description: Scans the text source for the number and type
749N/A * of item specified.
749N/A * Arguments: w - the TextSrc Object.
749N/A * position - the position to start scanning.
749N/A * type - type of thing to scan for.
749N/A * dir - direction to scan.
749N/A * count - which occurance if this thing to search for.
749N/A * include - whether or not to include the character found in
749N/A * the position that is returned.
749N/A * Returns: EXITS WITH AN ERROR MESSAGE.
749N/A *
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic
749N/AXawTextPosition
749N/AScan (w, position, type, dir, count, include)
749N/AWidget w;
749N/AXawTextPosition position;
749N/AXawTextScanType type;
749N/AXawTextScanDirection dir;
749N/Aint count;
749N/ABoolean include;
749N/A{
749N/A XtAppError(XtWidgetToApplicationContext(w),
749N/A "TextSrc Object: No SCAN function is defined.");
749N/A
749N/A return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
749N/A}
749N/A
749N/A/* Function Name: Search
749N/A * Description: Searchs the text source for the text block passed
749N/A * Arguments: w - the TextSource Object.
749N/A * position - the position to start scanning.
749N/A * dir - direction to scan.
749N/A * text - the text block to search for.
749N/A * Returns: XawTextSearchError.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic XawTextPosition
749N/ASearch(w, position, dir, text)
749N/AWidget w;
749N/AXawTextPosition position;
749N/AXawTextScanDirection dir;
749N/AXawTextBlock * text;
749N/A{
749N/A return(XawTextSearchError);
749N/A}
749N/A
749N/A/* Function Name: ConvertSelection
749N/A * Description: Dummy selection converter.
749N/A * Arguments: w - the TextSrc object.
749N/A * selection - the current selection atom.
749N/A * target - the current target atom.
749N/A * type - the type to conver the selection to.
749N/A * RETURNED value, length - the return value that has been converted.
749N/A * RETURNED format - the format of the returned value.
749N/A * Returns: TRUE if the selection has been converted.
749N/A *
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean
749N/AConvertSelection(w, selection, target, type, value, length, format)
749N/AWidget w;
749N/AAtom * selection, * target, * type;
749N/AXtPointer * value;
749N/Aunsigned long * length;
749N/Aint * format;
749N/A{
749N/A return(FALSE);
749N/A}
749N/A
749N/A/* Function Name: SetSelection
749N/A * Description: allows special setting of the selection.
749N/A * Arguments: w - the TextSrc object.
749N/A * left, right - bounds of the selection.
749N/A * selection - the selection atom.
749N/A * Returns: none
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/ASetSelection(w, left, right, selection)
749N/AWidget w;
749N/AXawTextPosition left, right;
749N/AAtom selection;
749N/A{
749N/A /* This space intentionally left blank. */
749N/A}
749N/A
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/ACvtStringToEditMode(args, num_args, fromVal, toVal)
749N/AXrmValuePtr args; /* unused */
749N/ACardinal *num_args; /* unused */
749N/AXrmValuePtr fromVal;
749N/AXrmValuePtr toVal;
749N/A{
749N/A static XawTextEditType editType;
749N/A static XrmQuark QRead, QAppend, QEdit;
749N/A XrmQuark q;
749N/A char lowerName[40];
749N/A static Boolean inited = FALSE;
749N/A
749N/A if ( !inited ) {
749N/A QRead = XrmPermStringToQuark(XtEtextRead);
749N/A QAppend = XrmPermStringToQuark(XtEtextAppend);
749N/A QEdit = XrmPermStringToQuark(XtEtextEdit);
749N/A inited = TRUE;
749N/A }
749N/A
749N/A if (strlen ((char*) fromVal->addr) < sizeof lowerName) {
749N/A XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr);
749N/A q = XrmStringToQuark(lowerName);
749N/A
749N/A if (q == QRead) editType = XawtextRead;
749N/A else if (q == QAppend) editType = XawtextAppend;
749N/A else if (q == QEdit) editType = XawtextEdit;
749N/A else {
749N/A toVal->size = 0;
749N/A toVal->addr = NULL;
749N/A return;
749N/A }
749N/A toVal->size = sizeof editType;
749N/A toVal->addr = (XPointer) &editType;
749N/A return;
749N/A }
749N/A toVal->size = 0;
749N/A toVal->addr = NULL;
749N/A}
749N/A
749N/A
749N/A
749N/A/************************************************************
749N/A *
749N/A * Public Functions.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: XawTextSourceRead
749N/A * Description: This function reads the source.
749N/A * Arguments: w - the TextSrc Object.
749N/A * pos - position of the text to retreive.
749N/A * RETURNED text - text block that will contain returned text.
749N/A * length - maximum number of characters to read.
749N/A * Returns: The number of characters read into the buffer.
749N/A */
749N/A
749N/AXawTextPosition
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceRead(Widget w, XawTextPosition pos, XawTextBlock *text,
749N/A int length)
749N/A#else
749N/AXawTextSourceRead(w, pos, text, length)
749N/AWidget w;
749N/AXawTextPosition pos;
749N/AXawTextBlock *text;
749N/Aint length;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "XawTextSourceRead's 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A return((*class->textSrc_class.Read)(w, pos, text, length));
749N/A}
749N/A
749N/A/* Function Name: XawTextSourceReplace.
749N/A * Description: Replaces a block of text with new text.
749N/A * Arguments: src - the Text Source Object.
749N/A * startPos, endPos - ends of text that will be removed.
749N/A * text - new text to be inserted into buffer at startPos.
749N/A * Returns: XawEditError or XawEditDone.
749N/A */
749N/A
749N/A/*ARGSUSED*/
749N/Aint
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceReplace (Widget w, XawTextPosition startPos,
749N/A XawTextPosition endPos, XawTextBlock *text)
749N/A#else
749N/AXawTextSourceReplace (w, startPos, endPos, text)
749N/AWidget w;
749N/AXawTextPosition startPos, endPos;
749N/AXawTextBlock *text;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "XawTextSourceReplace's 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A return((*class->textSrc_class.Replace)(w, startPos, endPos, text));
749N/A}
749N/A
749N/A/* Function Name: XawTextSourceScan
749N/A * Description: Scans the text source for the number and type
749N/A * of item specified.
749N/A * Arguments: w - the TextSrc Object.
749N/A * position - the position to start scanning.
749N/A * type - type of thing to scan for.
749N/A * dir - direction to scan.
749N/A * count - which occurance if this thing to search for.
749N/A * include - whether or not to include the character found in
749N/A * the position that is returned.
749N/A * Returns: The position of the text.
749N/A *
749N/A */
749N/A
749N/AXawTextPosition
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceScan(Widget w, XawTextPosition position,
749N/A#if NeedWidePrototypes
749N/A int type, int dir,
749N/A#else
749N/A XawTextScanType type, XawTextScanDirection dir,
749N/A#endif
749N/A int count,
749N/A#if NeedWidePrototypes
749N/A int include)
749N/A#else
749N/A Boolean include)
749N/A#endif
749N/A#else
749N/AXawTextSourceScan(w, position, type, dir, count, include)
749N/AWidget w;
749N/AXawTextPosition position;
749N/AXawTextScanType type;
749N/AXawTextScanDirection dir;
749N/Aint count;
749N/ABoolean include;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "XawTextSourceScan's 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A return((*class->textSrc_class.Scan)(w, position, type, dir, count, include));
749N/A}
749N/A
749N/A/* Function Name: XawTextSourceSearch
749N/A * Description: Searchs the text source for the text block passed
749N/A * Arguments: w - the TextSource Object.
749N/A * position - the position to start scanning.
749N/A * dir - direction to scan.
749N/A * text - the text block to search for.
749N/A * Returns: The position of the text we are searching for or
749N/A * XawTextSearchError.
749N/A */
749N/A
749N/AXawTextPosition
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceSearch(Widget w, XawTextPosition position,
749N/A#if NeedWidePrototypes
749N/A int dir,
749N/A#else
749N/A XawTextScanDirection dir,
749N/A#endif
749N/A XawTextBlock *text)
749N/A#else
749N/AXawTextSourceSearch(w, position, dir, text)
749N/AWidget w;
749N/AXawTextPosition position;
749N/AXawTextScanDirection dir;
749N/AXawTextBlock * text;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "XawTextSourceSearch's 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A return((*class->textSrc_class.Search)(w, position, dir, text));
749N/A}
749N/A
749N/A/* Function Name: XawTextSourceConvertSelection
749N/A * Description: Dummy selection converter.
749N/A * Arguments: w - the TextSrc object.
749N/A * selection - the current selection atom.
749N/A * target - the current target atom.
749N/A * type - the type to conver the selection to.
749N/A * RETURNED value, length - the return value that has been converted.
749N/A * RETURNED format - the format of the returned value.
749N/A * Returns: TRUE if the selection has been converted.
749N/A *
749N/A */
749N/A
749N/ABoolean
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceConvertSelection(Widget w, Atom *selection, Atom *target,
749N/A Atom *type, XtPointer *value,
749N/A unsigned long *length, int *format)
749N/A#else
749N/AXawTextSourceConvertSelection(w, selection,
749N/A target, type, value, length, format)
749N/AWidget w;
749N/AAtom * selection, * target, * type;
749N/AXtPointer * value;
749N/Aunsigned long * length;
749N/Aint * format;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "XawTextSourceConvertSelectionXawTextSourceConvertSelection's 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A return((*class->textSrc_class.ConvertSelection)(w, selection, target, type,
749N/A value, length, format));
749N/A}
749N/A
749N/A/* Function Name: XawTextSourceSetSelection
749N/A * Description: allows special setting of the selection.
749N/A * Arguments: w - the TextSrc object.
749N/A * left, right - bounds of the selection.
749N/A * selection - the selection atom.
749N/A * Returns: none
749N/A */
749N/A
749N/Avoid
749N/A#if NeedFunctionPrototypes
749N/AXawTextSourceSetSelection(Widget w, XawTextPosition left,
749N/A XawTextPosition right, Atom selection)
749N/A#else
749N/AXawTextSourceSetSelection(w, left, right, selection)
749N/AWidget w;
749N/AXawTextPosition left, right;
749N/AAtom selection;
749N/A#endif
749N/A{
749N/A TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class;
749N/A
749N/A if ( !XtIsSubclass( w, textSrcObjectClass ) )
749N/A XtErrorMsg("bad argument", "textSource", "XawError",
749N/A "'s 1st parameter must be subclass of asciiSrc.",
749N/A NULL, NULL);
749N/A
749N/A (*class->textSrc_class.SetSelection)(w, left, right, selection);
749N/A}
749N/A
749N/A/********************************************************************
749N/A *
749N/A * External Functions for Multi Text.
749N/A *
749N/A ********************************************************************/
749N/A
749N/A/*
749N/A * TextFormat():
749N/A * returns the format of text: FMT8BIT or FMTWIDE.
749N/A *
749N/A */
749N/AXrmQuark
749N/A#if NeedFunctionPrototypes
749N/A_XawTextFormat(TextWidget tw)
749N/A#else
749N/A_XawTextFormat(tw)
749N/A TextWidget tw;
749N/A#endif
749N/A{
749N/A return (((TextSrcObject)(tw->text.source))->textSrc.text_format);
749N/A}
749N/A
749N/A
749N/A/* _XawTextWCToMB():
749N/A * convert the wchar string to external encoding.
749N/A * The caller is responsible for freeing both the source and ret string.
749N/A *
749N/A * wstr - source wchar string.
749N/A * len_in_out - lengh of string.
749N/A * As In, length of source wchar string, measured in wchar.
749N/A * As Out, length of returned string.
749N/A */
749N/A
749N/A
749N/Achar *
749N/A_XawTextWCToMB( d, wstr, len_in_out )
749N/A Display* d;
749N/A wchar_t* wstr;
749N/A int* len_in_out;
749N/A
749N/A{
749N/A XTextProperty textprop;
749N/A if (XwcTextListToTextProperty(d, (wchar_t**)&wstr, 1,
749N/A XTextStyle, &textprop) < Success) {
749N/A XtWarningMsg("convertError", "textSource", "XawError",
749N/A "Non-character code(s) in buffer.", NULL, NULL);
749N/A *len_in_out = 0;
749N/A return( NULL );
749N/A }
749N/A *len_in_out = textprop.nitems;
749N/A return((char *)textprop.value);
749N/A}
749N/A
749N/A
749N/A/* _XawTextMBToWC():
749N/A * convert the string to internal processing codeset WC.
749N/A * The caller is responsible for freeing both the source and ret string.
749N/A *
749N/A * str - source string.
749N/A * len_in_out - lengh of string.
749N/A * As In, it is length of source string.
749N/A * As Out, it is length of returned string, measured in wchar.
749N/A */
749N/A
749N/Awchar_t* _XawTextMBToWC( d, str, len_in_out )
749N/ADisplay *d;
749N/Achar *str;
749N/Aint *len_in_out;
749N/A{
749N/A if (*len_in_out == 0) {
749N/A return(NULL);
749N/A } else {
749N/A XTextProperty textprop;
749N/A char *buf;
749N/A wchar_t **wlist, *wstr;
749N/A int count;
749N/A buf = XtMalloc(*len_in_out + 1);
749N/A if (!buf) {
749N/A XtErrorMsg("convertError", "multiSourceCreate", "XawError",
749N/A "No Memory", NULL, NULL);
749N/A *len_in_out = 0;
749N/A return (NULL); /* The above function doesn't really return. */
749N/A }
749N/A strncpy(buf, str, *len_in_out);
749N/A *(buf + *len_in_out) = '\0';
749N/A if (XmbTextListToTextProperty(d, &buf, 1, XTextStyle, &textprop)
749N/A != Success) {
749N/A XtWarningMsg("convertError", "textSource", "XawError",
749N/A "No Memory, or Locale not supported.", NULL, NULL);
749N/A XtFree(buf);
749N/A *len_in_out = 0;
749N/A return (NULL);
749N/A }
749N/A XtFree(buf);
749N/A if (XwcTextPropertyToTextList(d, &textprop,
749N/A (wchar_t***)&wlist, &count) != Success) {
749N/A XtWarningMsg("convertError", "multiSourceCreate", "XawError",
749N/A "Non-character code(s) in source.", NULL, NULL);
749N/A *len_in_out = 0;
749N/A return (NULL);
749N/A }
749N/A wstr = (wchar_t *) XtMalloc((wcslen(wlist[0]) + 1) * sizeof(wchar_t));
749N/A if (wstr == (wchar_t *) NULL) {
749N/A XwcFreeStringList(wlist);
749N/A XtErrorMsg("convertError", "multiSourceCreate", "XawError",
749N/A "No Memory", NULL, NULL);
749N/A *len_in_out = 0;
749N/A return (NULL); /* The above function doesn't really return. */
749N/A }
749N/A wcscpy(wstr, wlist[0]);
749N/A *len_in_out = wcslen(wstr);
749N/A XwcFreeStringList(wlist);
749N/A return(wstr);
749N/A }
749N/A}
749N/A