#endif /* lint && SABER */
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#include <stdio.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <./Xaw3_1XawInit.h>
#include <./Xaw3_1AsciiSinkP.h>
#include <./Xaw3_1AsciiSrcP.h> /* For source function defs. */
#include <./Xaw3_1TextP.h> /* I also reach into the text widget. */
#ifdef GETLASTPOS
#endif
static void Initialize(), Destroy();
};
{
/* core_class fields */
/* class_name */ "AsciiSink",
/* widget_size */ sizeof(AsciiSinkRec),
/* class_initialize */ XawInitializeWidgetSet,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* obj1 */ NULL,
/* obj2 */ NULL,
/* obj3 */ 0,
/* resources */ resources,
/* xrm_class */ NULLQUARK,
/* obj4 */ FALSE,
/* obj5 */ FALSE,
/* obj6 */ FALSE,
/* obj7 */ FALSE,
/* destroy */ Destroy,
/* obj8 */ NULL,
/* obj9 */ NULL,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* obj10 */ NULL,
/* get_values_hook */ NULL,
/* obj11 */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* obj12 */ NULL,
/* obj13 */ NULL,
/* obj14 */ NULL,
/* extension */ NULL
},
/* text_sink_class fields */
{
/* DisplayText */ DisplayText,
/* InsertCursor */ InsertCursor,
/* ClearToBackground */ XtInheritClearToBackground,
/* FindPosition */ FindPosition,
/* FindDistance */ FindDistance,
/* Resolve */ Resolve,
/* MaxLines */ XtInheritMaxLines,
/* MaxHeight */ XtInheritMaxHeight,
/* SetTabs */ XtInheritSetTabs,
/* GetCursorBounds */ GetCursorBounds
},
/* ascii_sink_class fields. */
{
/* Keep Compiler happy. */ NULL
}
};
/* Utilities */
static int
CharWidth (w, x, c)
Widget w;
int x;
unsigned char c;
{
if ( c == LF ) return(0);
if (c == TAB) {
/* Adjust for Left Margin. */
if (x < *tab) {
return *tab - x;
else
return 0;
}
}
return 0;
}
if ( (nonPrinting = (c < (unsigned char) SP)) )
c += '@';
else {
c = SP;
nonPrinting = False;
}
else
if (nonPrinting)
return width;
}
/* Function Name: PaintText
* Description: Actually paints the text into the windoe.
* Arguments: w - the text widget.
* gc - gc to paint text with.
* x, y - location to paint the text.
* buf, len - buffer and length of text to paint.
* Returns: the width of the text painted, or 0.
*
* NOTE: If this string attempts to paint past the end of the window
* then this function will return zero.
*/
static Dimension
Widget w;
Position x, y;
unsigned char * buf;
int len;
{
if ( ((int) width) <= -x) /* Don't draw if we can't see it. */
return(width);
(unsigned int) width,
return(0);
}
return(width);
}
/* Sink Object Functions */
/*
* This function does not know about drawing more than one line of text.
*/
static void
Widget w;
Position x, y;
{
int j, k;
if (j >= BUFSIZ) { /* buffer full, dump the text. */
j = 0;
}
continue;
else if (buf[j] == '\t') {
return;
x += temp;
invgc, (int) x,
(unsigned int) width,
x += width;
j = -1;
}
else if ( buf[j] < (unsigned char) ' ' ) {
buf[j] = '^';
j++;
}
else
buf[j] = ' ';
}
j++;
}
}
if (j > 0)
}
static Pixmap
Screen *s;
{
}
/* Function Name: GetCursorBounds
* Description: Returns the size and location of the cursor.
* Arguments: w - the text object.
* RETURNED rect - an X rectangle to return the cursor bounds in.
* Returns: none.
*/
static void
Widget w;
XRectangle * rect;
{
}
/*
* The following procedure manages the "insert" cursor.
*/
static void
Widget w;
Position x, y;
{
GetCursorBounds(w, &rect);
}
/*
* Given two positions, find the distance between them.
*/
static void
Widget w;
int fromx; /* Horizontal location of first position. */
int *resWidth; /* Distance between fromPos and resPos. */
int *resHeight; /* Height required. */
{
register unsigned char c;
/* we may not need this */
*resWidth = 0;
if (c == LF) {
index++;
break;
}
}
}
static void
Widget w;
int fromx; /* Horizontal location of starting position.*/
int width; /* Desired width. */
int stopAtWordBreak; /* Whether the resulting position should be at
a word break. */
int *resWidth; /* Actual width used. */
int *resHeight; /* Height required. */
{
unsigned char c;
*resWidth = 0;
c = 0;
}
if (c == LF) {
index++;
break;
}
}
index--;
if (stopAtWordBreak && whiteSpaceSeen) {
}
}
}
static void
Widget w;
{
if (*leftPos > GETLASTPOS)
*leftPos = GETLASTPOS;
}
static void
{
}
/***** Public routines *****/
/* Function Name: Initialize
* Description: Initializes the TextSink Object.
* Arguments: request, new - the requested and new values for the object
* instance.
* Returns: none.
*
*/
/* ARGSUSED */
static void
{
}
/* Function Name: Destroy
* Description: This function cleans up when the object is
* destroyed.
* Arguments: w - the AsciiSink Object.
* Returns: none.
*/
static void
Destroy(w)
Widget w;
{
}
/* Function Name: SetValues
* Description: Sets the values for the AsciiSink
* Arguments: current - current state of the object.
* request - what was requested.
* new - what the object will become.
* Returns: True if redisplay is needed.
*/
/* ARGSUSED */
static Boolean
{
GetGC(w);
} else {
(w->ascii_sink.display_nonprinting !=
}
return False;
}