Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ DtEditorReplace(3) — Digital UNIX 3.2c

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

DtEditor(5)

DtEditor(3)

DtEditorAppend(3)

DtEditorAppendFromFile(3)

DtEditorGetContents(3)

DtEditorInsert(3)

DtEditorInsertFromFile(3)

DtEditorReplaceFromFile(3)

DtEditorSaveContentsToFile(3)

DtEditorSetContents(3)

DtEditorSetContentsFromFile(3)

DtEditorReplace(3)  —  Subroutines

NAME

DtEditorReplace − replace a portion of the content of a DtEditor widget

SYNOPSIS

#include <Dt/Editor.h>
DtEditorErrorCode DtEditorReplace(Widget widget,
XmTextPosition startPos,
XmTextPosition endPos,
DtEditorContentRec ∗data)

DESCRIPTION

The DtEditorReplace() function replaces part of the contents of a DtEditor widget with a string, a wide character string or sized buffer. The data is transfered to the DtEditor widget using a DtEditorContentRec, which indicates the type of data being transfered along with the actual data.  All data following the start position through the end position is replaced.  If the start position and the end position are equal, the data is inserted after the end position.  The character positions begin at zero and are numbered sequentially from the beginning of the text.  After the replacement, the insertion cursor is positioned after the last character inserted. 

The widget argument specifies the DtEditor widget ID. 

The startPos argument specifies the starting character position of the portion to replace.  The replacement begins after this character. 

The endPos argument specifies the ending character position of the portion to replace.  The replacement ends after this character. 

The data argument is a pointer to a data structure containing the data to insert. 

For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3). 

For a complete definition of DtEditorContentRec, see <DtEditor>. 

RETURN VALUE

Upon successful completion, the DtEditorReplace() function returns DtEDITOR_NO_ERRORS; otherwise, if it cannot replace the string, the function returns one of the following values:

DtEDITOR_INVALID_TYPE
If type is not recognized

DtEDITOR_INVALID_RANGE
If startPos is greater than endPos

DtEDITOR_ILLEGAL_SIZE
If the size of the buffer passed in is negative

EXAMPLES

The following code segment modifies the contents of a DtEditor widget to "The quick fox."

Widgeteditor;
DtEditorContentReccr;
DtEditorErrorCodestatus;
XmTextPositionstart = (XmTextPosition) 3,
end = (XmTextPosition) 8;
char∗sampleString1="The brown fox",
∗sampleString2="quick";
 cr.type = DtEDITOR_TEXT;
cr.value.string = sampleString1;
status = DtEditorSetContents ( editor, &cr );
if (status != DtEDITOR_NO_ERRORS) {
  printf("Unable to set contents of the widget\n");
}
else {
  cr.type = DtEDITOR_TEXT;
  cr.data.string = sampleString2;
  status = DtEditorReplace ( editor, start, end, &cr );
  if (status != DtEDITOR_NO_ERRORS)
    printf("Unable to replace part of the contents of the widget\n");
}

APPLICATION USAGE

If the data is in a disk file, rather than in memory, the application should use DtEditorReplaceFromFile(3). 

SEE ALSO

DtEditor(5), DtEditor(3), DtEditorAppend(3), DtEditorAppendFromFile(3), DtEditorGetContents(3), DtEditorInsert(3), DtEditorInsertFromFile(3), DtEditorReplaceFromFile(3), DtEditorSaveContentsToFile(3), DtEditorSetContents(3), DtEditorSetContentsFromFile(3). 
 
 
 
 
 
 

  —  30 July 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026