XMTEXTXYTOPOS(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

πŸ’– XmTextXYToPos β€” a lil library call from the Text girlies πŸ’–

okay so bestie, we're in the library call section of the manual, and today's main character is XmTextXYToPos from the XmText fam. pull up a chair, grab a boba, and let's get into it πŸ§‹βœ¨


✨ NAME ✨

XmTextXYToPos β€” a Text function that accesses the character position nearest an x and y position πŸ’…

like. it's the "which letter am I hovering over" girlie. she does one job and she does it flawlessly. periodt.


πŸŽ€ SYNOPSIS πŸŽ€

#include <Xm/Text.h>
XmTextPosition XmTextXYToPos(
Widget widget,
Position x,
Position y);

yes, that's the whole thing. three args. no drama. no cap. πŸ¦‹


🌸 DESCRIPTION 🌸

so XmTextXYToPos accesses the character position nearest to the specified x and y position, relative to the upper left corner of the Text widget. like, upper left is home base, that's where we start counting from, always 🌈

and here's the tea about orientation, because she's bilingual in writing directions:

  • in the case of horizontal writing, the position is the origin of the character.
  • in the case of vertical writing, the position is the vertical origin of the character.

so whichever way your text is vibing, she knows where the "start" of that character lives. she's not confused. she's never confused. πŸ‘‘

the arguments, one by one πŸ’«

  • widget β€” specifies the Text widget ID. this is your girl, the widget you're asking about 🫢
  • x β€” specifies the x position, relative to the upper left corner of the widget.
  • y β€” specifies the y position, relative to the upper left corner of the widget.
heads up bestie: for a complete definition of Text and its associated resources, see XmText(3). that's the deep lore page, this one's just the little spotlight moment ✨

πŸ”₯ RETURN πŸ”₯

she returns the character position in the text nearest the x and y position specified. and ngl that's an integer number of characters from the beginning of the buffer.

and listen β€” the first character position is 0 (zero). zero-indexed, like a true programmer. not me being shocked, we been knew πŸ˜­πŸ’€



lowkey remember: this is a function, not a macro, so she's got a real return value, and that return value is a XmTextPosition. treat her right and she'll tell you exactly which character you're pointing at πŸ’–

okay that's the whole page, you ate that, I ate that, we all ate πŸ“ and for the lil sign-off: this was XmTextXYToPos from the library call manual, sourced straight from the XmText corner of the docs β€” mwah, sending you and your widget nothing but good vibes πŸŽ€πŸ’œβœ¨