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

✨ NAME ✨

XmTextFieldGetSubstring β€” a TextField function that retrieves a copy of a portion of the internal text buffer 🫢


🌸 SYNOPSIS 🌸

#include <Xm/TextF.h>
int XmTextFieldGetSubstring(
Widget widget,
XmTextPosition start,
int num_chars,
int buffer_size,
char *buffer);

πŸ’… DESCRIPTION πŸ’…

okay so bestie, listen. XmTextFieldGetSubstring retrieves a copy of a portion of the internal text buffer of a TextField widget. literally it copies a specified number of characters from a given start position in the internal text buffer into a buffer that you, the application, provide. and yes, a NULL terminator gets placed at the end of the copied data. slay. ✨

the size of the required buffer depends on the maximum number of bytes per character (MB_CUR_MAX) for the current locale. MB_CUR_MAX is a macro defined in stdlib.h. so your buffer should be large enough to contain the substring to be copied and a NULL terminator. use this equation to calculate the size of buffer the application should provide:

buffer_size = (num_chars* MB_CUR_MAX) + 1
(void)

πŸŽ€ the parameters (the whole cast, main character energy) πŸŽ€

  • widget β€” Specifies the TextField widget ID. πŸͺͺ
  • start β€” Specifies the beginning character position from which the data will be retrieved. This is an integer number of characters from the beginning of the text buffer. The first character position is 0 (zero). not one. zero. iykyk. πŸ“
  • num_chars β€” Specifies the number of characters to be copied into the provided buffer.
  • buffer_size β€” Specifies the size of the supplied buffer in bytes. This size should account for a NULL terminator. do not forget the terminator, i am begging πŸ™ˆ
  • buffer β€” Specifies the character buffer into which the internal text buffer will be copied.

for a complete definition of TextField and its associated resources, see XmTextField(3). go read it, it's giving essential. πŸ“š


πŸ”₯ RETURN πŸ”₯

  • XmCOPY_SUCCEEDED β€” The function was successful. ate. πŸ’–
  • XmCOPY_FAILED β€” The function failed because it was unable to copy the specified number of characters into the buffer provided. The buffer size may be insufficient. The contents of buffer are undefined. yeah that's the scary one, no cap. πŸ’€
  • XmCOPY_TRUNCATED β€” The requested number of characters extended beyond the internal buffer. The function copied characters between start and the end of the widget's buffer and terminated the string with a NULL terminator; fewer than num_chars characters were copied. so you got some of it, just not all of it. 😭

XmTextField(3) and XmTextFieldGetSubstringWcs(3). ✨


and that's the whole page, bestie πŸ¦‹ this was XmTextFieldGetSubstring, a library call straight out of the Xm crew β€” footer said so and everything. now go forth and never forget that + 1 for the NULL terminator. periodt. πŸ’