---
name: "XmTextReplace"
section: "3"
platform: "linux"
package: "openmotif"
version: "2.3.8-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/XmTextReplace"
---

# XmTextReplace(3)

A Text function that replaces part of a text string

## NAME

**XmTextReplace** — A Text function that replaces part of a text string

## SYNOPSIS

```
#include <Xm/Text.h>
void XmTextReplace(
Widget widget,
XmTextPosition from_pos,
XmTextPosition to_pos,
char * value);
```

## DESCRIPTION

**XmTextReplace** replaces part of the text string in the Text widget. The character positions begin at 0 (zero) and are numbered sequentially from the beginning of the text.

An example text replacement would be to replace the second and third characters in the text string. To accomplish this, the parameter *from\_pos* must be 1 and *to\_pos* must be 3. To insert a string after the fourth character, both parameters, *from\_pos* and *to\_pos*, must be 4.

This routine calls the widget's **XmNvalueChangedCallback** and verification callbacks, either **XmNmodifyVerifyCallback** or **XmNmodifyVerifyCallbackWcs**, or both. If both verification callback lists are registered, the procedures of the **XmNmodifyVerifyCallback** list are executed first and the resulting data is passed to the **XmNmodifyVerifyCallbackWcs** callbacks. The **XmNmotionVerifyCallback** is generated if *to\_pos* is less than or equal to the cursor position and the length of *value* is not the same as the length of the text being replaced, or if the cursor position is between *from\_pos* and *to\_pos*, and the distance from the cursor position to *from\_pos* is greater than the length of *value*.

- *widget*

  Specifies the Text widget ID

- *from\_pos*

  Specifies the start position of the text to be replaced

- *to\_pos*

  Specifies the end position of the text to be replaced

- *value*

  Specifies the character string value to be added to the text widget

For a complete definition of Text and its associated resources, see [**XmText**(3)](/XmText/3.md).

## RELATED

[**XmText**(3)](/XmText/3.md) and [**XmTextReplaceWcs**(3)](/XmTextReplaceWcs/3.md).
