XMTEXTREPLACE(3)
π XmTextReplace π
okay bestie, gather round, because today we're talking about XmTextReplace β it's a Text function (yes, from the Xm library, the manual page lives in XmTextReplace(library call)) and it literally just swaps out part of a text string for you. iconic behavior tbh.
β¨ SYNOPSIS β¨
#include <Xm/Text.h>
void XmTextReplace(
Widget widget,
XmTextPosition from_pos,
XmTextPosition to_pos,
char * value);
like. she's not returning anything. she's just doing it. main character energy fr.
π¦ DESCRIPTION π¦
So XmTextReplace replaces part of the text string in the Text widget. That's the whole gig and she does it beautifully. π
Now here's the part you gotta internalize, bestie: the character positions begin at 0 (zero) and are numbered sequentially from the beginning of the text. Zero-indexed, like a real one. π«Ά
π the little example (do NOT skip this, it's the whole vibe)
An example text replacement would be to replace the second and third characters in the text string. To accomplish that:
from_posmust be1to_posmust be3
And to insert a string after the fourth character, both parameters, from_pos and to_pos, must be 4.
bestie I need you to sit with that for a sec. whenfrom_pos==to_pos, nothing gets deleted, you're just sliding a new string in there. it's giving "make room, I'm arriving." πΈ
π₯ what callbacks get fired (the drama)
This routine calls the widget's XmNvalueChangedCallback and verification callbacks, either XmNmodifyVerifyCallback or XmNmodifyVerifyCallbackWcs, or both. And 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. order matters, no cap. π§
The XmNmotionVerifyCallback is generated if:
to_posis less than or equal to the cursor position and the length ofvalueis not the same as the length of the text being replaced, or- the cursor position is between
from_posandto_pos, and the distance from the cursor position tofrom_posis greater than the length ofvalue.
like she's checking whether the cursor is gonna get moved around by all this. very considerate of her honestly. π
π the parameters (the cast)
widgetβ Specifies the Text widget ID. that's your girl. the widget in question. πfrom_posβ Specifies the start position of the text to be replaced. where the deleting begins, bestie.to_posβ Specifies the end position of the text to be replaced. where the deleting stops. π―valueβ Specifies the character string value to be added to the text widget. the new content, the glow-up, the fresh fit. β¨
π one more thing
For a complete definition of Text and its associated resources, see XmText(3). go read it, it's important, iykyk. π
π RELATED π
the wide-character sister, she's also iconic, go say hi. πΈ
and that's the whole page, bestie!! mwah. this was XmTextReplace(library call) β the Xm library, copyright and all that jazz, and the date on the footer is literally the same as the header so you know it's that girl. slay, stay hydrated, and remember: positions start at 0. π
β¨π
π¦ where this page comes from
- alpine 3.24: motif-doc 2.5.2-r0 Β· LGPL-2.1-or-later
- arch rolling: openmotif 2.3.8-4 Β· LGPL-2.1-or-later
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- epel 10: motif-devel 2.3.8-2.el10_2 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- nixos 26.05: motif 2.3.8
- nixpkgs unstable: motif 2.3.8
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms