749N/ACopyright (c) 1989, 1994 X Consortium 749N/APermission is hereby granted, free of charge, to any person obtaining a copy 749N/Aof this software and associated documentation files (the "Software"), to deal 749N/Ain the Software without restriction, including without limitation the rights 749N/Ato use, copy, modify, merge, publish, distribute, sublicense, and/or sell 749N/Acopies of the Software, and to permit persons to whom the Software is 749N/Afurnished to do so, subject to the following conditions: 749N/AThe above copyright notice and this permission notice shall be included in 749N/Aall copies or substantial portions of the Software. 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/AX CONSORTIUM 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/AExcept as contained in this notice, the name of the X Consortium 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 X Consortium. 749N/A/**************************************************************** 749N/A * Full class record constant 749N/A ****************************************************************/ 749N/A /* class_name */ "AsciiSrc",
749N/A/* textSrc_class fields */ 749N/A/* asciiSrc_class fields */ 749N/A /* Keep the compiler happy */ '\0' 749N/A/************************************************************ 749N/A * Semi-Public Interfaces. 749N/A ************************************************************/ 749N/A/* Function Name: ClassInitialize 749N/A * Description: Class Initialize routine, called only once. 749N/A/* Function Name: Initialize 749N/A * Description: Initializes the simple menu widget 749N/A * Arguments: request - the widget requested by the argument list. 749N/A * new - the new widget with both resource and non 749N/A * Set correct flags (override resources) depending upon widget class. 749N/A/* Function Name: ReadText 749N/A * Description: This function reads the source. 749N/A * Arguments: w - the AsciiSource widget. 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/* Function Name: ReplaceText. 749N/A * Description: Replaces a block of text with new text. 749N/A * Arguments: w - the AsciiSource widget. 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 * Editing a read only source is not allowed. 749N/A * If empty and not the only piece then remove it. 749N/A else {
/* We are fully in one piece. */ 749N/A * Put in the New Stuff. 749N/A * If we are in ascii string emulation mode. Then the 749N/A * string is not allowed to grow. 749N/A * Description: Scans the text source for the number and type 749N/A * Arguments: w - the AsciiSource widget. 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 item found. 749N/A * Note: While there are only 'n' characters in the file there are n+1 749N/A * possible cursor positions (one before the first character and 749N/A * one after the last character. 749N/A * Scanning right from src->ascii_src.length??? 749N/A return(0);
/* Scanning left from 0??? */ 749N/A * If the buffer is empty then return 0. 749N/A else {
/* XawstParagraph */ 749N/A/* case XawstAll: ---- handled in special code above */ 749N/A/* Function Name: Search 749N/A * Description: Searchs the text source for the text block passed 749N/A * Arguments: w - the AsciiSource Widget. 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 item found. 749N/A/* Function Name: SetValues 749N/A * Description: Sets the values for the AsciiSource. 749N/A * Arguments: current - current state of the widget. 749N/A * request - what was requested. 749N/A * new - what the widget will become. 749N/A * Returns: True if redisplay is needed. 749N/A "AsciiSrc: The XtNuseStringInPlace resource may not be changed.");
749N/A/* Function Name: GetValuesHook 749N/A * Description: This is a get values hook routine that sets the 749N/A * values specific to the ascii source. 749N/A * Arguments: w - the AsciiSource Widget. 749N/A * args - the argument list. 749N/A * num_args - the number of args. 749N/A/* Function Name: Destroy 749N/A * Description: Destroys an ascii source (frees all data) 749N/A * Arguments: src - the Ascii source Widget to free. 749N/A/************************************************************ 749N/A ************************************************************/ 749N/A/* Function Name: XawAsciiSourceFreeString 749N/A * Description: Frees the string returned by a get values call 749N/A * on the string when the source is of type string. 749N/A * Arguments: w - the AsciiSrc widget. 749N/A /* If the src is really a multi, call the multi routine.*/ 749N/A "XawAsciiSourceFreeString's parameter must be an asciiSrc or multiSrc.",
749N/A/* Function Name: XawAsciiSave 749N/A * Description: Saves all the pieces into a file or string as required. 749N/A * Arguments: w - the asciiSrc Widget. 749N/A * Returns: TRUE if the save was successful. 749N/A /* If the src is really a multi, call the multi save. */ 749N/A "XawAsciiSave's parameter must be an asciiSrc or multiSrc.",
749N/A * If using the string in place then there is no need to play games 749N/A * to get the internal info into a readable string. 749N/A/* Function Name: XawAsciiSaveAsFile 749N/A * Description: Save the current buffer as a file. 749N/A * Arguments: w - the AsciiSrc widget. 749N/A * name - name of the file to save this file into. 749N/A * Returns: True if the save was sucessful. 749N/A /* If the src is really a multi, call the multi save. - */ 749N/A "XawAsciiSaveAsFile's 1st parameter must be an asciiSrc or multiSrc.",
749N/A/* Function Name: XawAsciiSourceChanged 749N/A * Description: Returns true if the source has changed since last saved. 749N/A * Arguments: w - the ascii source widget. 749N/A * Returns: a Boolean (see description). 749N/A "XawAsciiSourceChanged parameter must be an asciiSrc or multiSrc.",
749N/A/************************************************************ 749N/A ************************************************************/ 749N/A/* Function Name: WriteToFile 749N/A * Description: Write the string specified to the begining of the file 749N/A * Arguments: string - string to write. 749N/A * name - the name of the file 749N/A * Returns: returns TRUE if sucessful, FALSE otherwise. 749N/A/* Function Name: StorePiecesInString 749N/A * Description: store the pieces in memory into a standard ascii string. 749N/A * Arguments: data - the ascii pointer data. 749N/A * This will refill all pieces to capacity. 749N/A/* Function Name: InitStringOrFile. 749N/A * Description: Initializes the string or file. 749N/A * Arguments: src - the AsciiSource. 749N/A * Returns: none - May exit though. 749N/A /* In case the length resource is incorrectly set */ 749N/A * type is XawAsciiFile. 749N/A "Creating a read only disk widget and no file specified.",
749N/A "Bad editMode for ascii source; must be Read, Append or Edit.",
749N/A /* Allocate new memory for the temp filename, because it is held in 749N/A * a stack variable, not static memory. This widget does not need 749N/A * to keep the private state field is_tempfile -- it is only accessed 749N/A * in this routine, and its former setting is unused. 749N/A "openError",
"asciiSourceCreate",
"XawWarning",
749N/A *
sizeof(
unsigned char));
749N/A *
sizeof(
unsigned char));
749N/A/* Function Name: AllocNewPiece 749N/A * Description: Allocates a new piece of memory. 749N/A * Arguments: src - The AsciiSrc Widget. 749N/A * prev - the piece just before this one, or NULL. 749N/A * Returns: the allocated piece. 749N/A/* Function Name: FreeAllPieces 749N/A * Description: Frees all the pieces 749N/A * Arguments: src - The AsciiSrc Widget. 749N/A (
void)
printf(
"Xaw AsciiSrc Object: possible memory leak in FreeAllPieces().\n");
749N/A/* Function Name: RemovePiece 749N/A * Description: Removes a piece from the list. 749N/A * piece - the piece to remove. 749N/A/* Function Name: FindPiece 749N/A * Description: Finds the piece containing the position indicated. 749N/A * Arguments: src - The AsciiSrc Widget. 749N/A * position - the position that we are searching for. 749N/A * RETURNED first - the position of the first character in this piece. 749N/A * Returns: piece - the piece that contains this position. 749N/A return(
old_piece);
/* if we run off the end the return the last piece */ 749N/A/* Function Name: MyStrncpy 749N/A * Description: Just like string copy, but slower and will always 749N/A * work on overlapping strings. 749N/A * Arguments: (same as strncpy) - s1, s2 - strings to copy (2->1). 749N/A * n - the number of chars to copy. 749N/A/* Function Name: BreakPiece 749N/A * Description: Breaks a full piece into two new pieces. 749N/A * Arguments: src - The AsciiSrc Widget. 749N/A * piece - the piece to break. 749N/A/************************************************************ 749N/A * Compatability functions. 749N/A ************************************************************/ 749N/A/* Function Name: AsciiStringSourceCreate 749N/A * Description: Creates a string source. 749N/A * Arguments: parent - the widget that will own this source. 749N/A * args, num_args - the argument list. 749N/A * Returns: a pointer to the new text source. 749N/A * This is hacked up to try to emulate old functionality, it 749N/A * may not work, as I have not old code to test it on. 749N/A * Chris D. Peterson 8/31/89. 749N/A#
endif /* ASCII_STRING */ 749N/A/* Function Name: AsciiDiskSourceCreate 749N/A * Description: Creates a disk source. 749N/A * Arguments: parent - the widget that will own this source. 749N/A * args, num_args - the argument list. 749N/A * Returns: a pointer to the new text source.