/* $TOG: TextSrc.c /main/21 1998/05/25 08:17:30 kaleb $ */
/*
Copyright 1989, 1994, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Chris Peterson, MIT X Consortium.
* Much code taken from X11R3 String and Disk Sources.
*/
/*
* TextSrc.c - TextSrc object. (For use with the text widget).
*
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include "XawI18n.h"
#include <stdio.h>
#include <ctype.h>
/****************************************************************
*
* Full class record constant
*
****************************************************************/
/* Private Data */
};
static void CvtStringToEditMode();
static Boolean ConvertSelection();
static int Replace();
{
/* core_class fields */
/* class_name */ "TextSrc",
/* widget_size */ sizeof(TextSrcRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize */ ClassPartInitialize,
/* class_inited */ FALSE,
/* initialize */ NULL,
/* initialize_hook */ NULL,
/* realize */ NULL,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* compress_motion */ FALSE,
/* compress_exposure */ FALSE,
/* compress_enterleave */ FALSE,
/* visible_interest */ FALSE,
/* destroy */ NULL,
/* resize */ NULL,
/* expose */ NULL,
/* set_values */ NULL,
/* set_values_hook */ NULL,
/* set_values_almost */ NULL,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ NULL,
/* display_accelerator */ NULL,
/* extension */ NULL,
},
/* textSrc_class fields */
{
/* Read */ Read,
/* Replace */ Replace,
/* Scan */ Scan,
/* Search */ Search,
/* SetSelection */ SetSelection,
/* ConvertSelection */ ConvertSelection
}
};
static void
{
}
static void
{
/*
* We don't need to check for null super since we'll get to TextSrc
* eventually.
*/
}
/************************************************************
*
* Class specific methods.
*
************************************************************/
/* Function Name: Read
* Description: This function reads the source.
* Arguments: w - the TextSrc Object.
* pos - position of the text to retreive.
* RETURNED text - text block that will contain returned text.
* length - maximum number of characters to read.
* Returns: The number of characters read into the buffer.
*/
/* ARGSUSED */
static XawTextPosition
Widget w;
int length;
{
"TextSrc Object: No read function is defined.");
return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
}
/* Function Name: Replace.
* Description: Replaces a block of text with new text.
* Arguments: src - the Text Source Object.
* startPos, endPos - ends of text that will be removed.
* text - new text to be inserted into buffer at startPos.
* Returns: XawEditError.
*/
/*ARGSUSED*/
static int
Widget w;
{
return(XawEditError);
}
/* Function Name: Scan
* Description: Scans the text source for the number and type
* of item specified.
* Arguments: w - the TextSrc Object.
* position - the position to start scanning.
* type - type of thing to scan for.
* dir - direction to scan.
* count - which occurance if this thing to search for.
* include - whether or not to include the character found in
* the position that is returned.
* Returns: EXITS WITH AN ERROR MESSAGE.
*
*/
/* ARGSUSED */
static
Widget w;
int count;
Boolean include;
{
"TextSrc Object: No SCAN function is defined.");
return( (XawTextPosition) 0 ); /* for gcc -Wall and lint */
}
/* Function Name: Search
* Description: Searchs the text source for the text block passed
* Arguments: w - the TextSource Object.
* position - the position to start scanning.
* dir - direction to scan.
* text - the text block to search for.
* Returns: XawTextSearchError.
*/
/* ARGSUSED */
static XawTextPosition
Widget w;
XawTextBlock * text;
{
return(XawTextSearchError);
}
/* Function Name: ConvertSelection
* Description: Dummy selection converter.
* Arguments: w - the TextSrc object.
* selection - the current selection atom.
* target - the current target atom.
* type - the type to conver the selection to.
* RETURNED value, length - the return value that has been converted.
* RETURNED format - the format of the returned value.
* Returns: TRUE if the selection has been converted.
*
*/
/* ARGSUSED */
static Boolean
Widget w;
unsigned long * length;
int * format;
{
return(FALSE);
}
/* Function Name: SetSelection
* Description: allows special setting of the selection.
* Arguments: w - the TextSrc object.
* left, right - bounds of the selection.
* selection - the selection atom.
* Returns: none
*/
/* ARGSUSED */
static void
Widget w;
{
/* This space intentionally left blank. */
}
/* ARGSUSED */
static void
{
XrmQuark q;
if ( !inited ) {
}
q = XrmStringToQuark(lowerName);
else {
return;
}
return;
}
}
/************************************************************
*
* Public Functions.
*
************************************************************/
/* Function Name: XawTextSourceRead
* Description: This function reads the source.
* Arguments: w - the TextSrc Object.
* pos - position of the text to retreive.
* RETURNED text - text block that will contain returned text.
* length - maximum number of characters to read.
* Returns: The number of characters read into the buffer.
*/
int length)
#else
Widget w;
int length;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"XawTextSourceRead's 1st parameter must be subclass of asciiSrc.",
}
/* Function Name: XawTextSourceReplace.
* Description: Replaces a block of text with new text.
* Arguments: src - the Text Source Object.
* startPos, endPos - ends of text that will be removed.
* text - new text to be inserted into buffer at startPos.
* Returns: XawEditError or XawEditDone.
*/
/*ARGSUSED*/
int
#else
Widget w;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"XawTextSourceReplace's 1st parameter must be subclass of asciiSrc.",
}
/* Function Name: XawTextSourceScan
* Description: Scans the text source for the number and type
* of item specified.
* Arguments: w - the TextSrc Object.
* position - the position to start scanning.
* type - type of thing to scan for.
* dir - direction to scan.
* count - which occurance if this thing to search for.
* include - whether or not to include the character found in
* the position that is returned.
* Returns: The position of the text.
*
*/
#else
#endif
int count,
int include)
#else
Boolean include)
#endif
#else
Widget w;
int count;
Boolean include;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"XawTextSourceScan's 1st parameter must be subclass of asciiSrc.",
}
/* Function Name: XawTextSourceSearch
* Description: Searchs the text source for the text block passed
* Arguments: w - the TextSource Object.
* position - the position to start scanning.
* dir - direction to scan.
* text - the text block to search for.
* Returns: The position of the text we are searching for or
* XawTextSearchError.
*/
int dir,
#else
#endif
#else
Widget w;
XawTextBlock * text;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"XawTextSourceSearch's 1st parameter must be subclass of asciiSrc.",
}
/* Function Name: XawTextSourceConvertSelection
* Description: Dummy selection converter.
* Arguments: w - the TextSrc object.
* selection - the current selection atom.
* target - the current target atom.
* type - the type to conver the selection to.
* RETURNED value, length - the return value that has been converted.
* RETURNED format - the format of the returned value.
* Returns: TRUE if the selection has been converted.
*
*/
#else
Widget w;
unsigned long * length;
int * format;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"XawTextSourceConvertSelectionXawTextSourceConvertSelection's 1st parameter must be subclass of asciiSrc.",
}
/* Function Name: XawTextSourceSetSelection
* Description: allows special setting of the selection.
* Arguments: w - the TextSrc object.
* left, right - bounds of the selection.
* selection - the selection atom.
* Returns: none
*/
void
#else
Widget w;
#endif
{
if ( !XtIsSubclass( w, textSrcObjectClass ) )
"'s 1st parameter must be subclass of asciiSrc.",
}
/********************************************************************
*
* External Functions for Multi Text.
*
********************************************************************/
/*
* TextFormat():
* returns the format of text: FMT8BIT or FMTWIDE.
*
*/
#else
#endif
{
}
/* _XawTextWCToMB():
* convert the wchar string to external encoding.
* The caller is responsible for freeing both the source and ret string.
*
* wstr - source wchar string.
* len_in_out - lengh of string.
* As In, length of source wchar string, measured in wchar.
* As Out, length of returned string.
*/
char *
Display* d;
int* len_in_out;
{
*len_in_out = 0;
return( NULL );
}
}
/* _XawTextMBToWC():
* convert the string to internal processing codeset WC.
* The caller is responsible for freeing both the source and ret string.
*
* str - source string.
* len_in_out - lengh of string.
* As In, it is length of source string.
* As Out, it is length of returned string, measured in wchar.
*/
Display *d;
char *str;
int *len_in_out;
{
if (*len_in_out == 0) {
return(NULL);
} else {
char *buf;
int count;
if (!buf) {
*len_in_out = 0;
return (NULL); /* The above function doesn't really return. */
}
!= Success) {
*len_in_out = 0;
return (NULL);
}
if (XwcTextPropertyToTextList(d, &textprop,
*len_in_out = 0;
return (NULL);
}
*len_in_out = 0;
return (NULL); /* The above function doesn't really return. */
}
return(wstr);
}
}