XMTEXTREPLACE(3)

πŸ“¦
version 2.5.2 Β· 2 versions
, in alpine 3.24, arch rolling, centos-stream 9, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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_pos must be 1
  • to_pos must be 3

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. when from_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_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
  • 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.

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. πŸ“


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. πŸ’…βœ¨πŸŽ€