mtext_prop_range(3m17n)

πŸ“¦
version 1.8.4 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– mtext_prop_range(3m17n) πŸ’–

okay so bestie. welcome to section 3m17n of The m17n Library manual, and today's main character is mtext_prop_range. she's a little function with a big job and honestly? she ate. let's get into it 🫢


✨ NAME ✨

mtext_prop_range -

yes bestie the original really put the dash and then nothing after it. no tagline. no blurb. just vibes and a hyphen πŸ’€. we respect the mystery.


🌸 SYNOPSIS 🌸

int mtext_prop_range (MText * mt, MSymbol key, int pos, int * from, int * to, int deeper)

that's the whole signature, no cap. six args, one int coming back at you 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

so what does she do? she finds the range where the value of a text property is the same. that's the whole mission statement.

the mtext_prop_range() function investigates the extent where all characters have the same value for a text property. like, she goes snooping to find how far the sameness stretches. here's her little process, step by step:

  1. first she finds the value of the property specified by key of the character at pos in M-text mt. that's her starting point, her anchor, her moment ✨
  2. then she checks if adjacent characters have the same value for the property key. one by one. left and right. she's thorough like that.

the beginning and the end of the found range get stored to the variable pointed to by from and to.

⚠️ okay this part is IMPORTANT bestie, don't skip: the character position stored in from is inclusive, but the one in to is exclusive. this fashion is compatible with the range specification in the mtext_put_prop() function, etc. so from is like "we start HERE, she's in the club" and to is like "we stop right before HERE, she's not invited". πŸŽ€

now, deeper. if deeper is not 0, then not only the topmost but also all the stacked properties whose key is key are compared. she goes deep, she looks through the whole stack, layers on layers, no surface-level takes here πŸ’…

and about those pointers:

  • if from is NULL, the beginning of range is not searched for. she's not looking for the start, periodt.
  • if to is NULL, the end of range is not searched for. she's not looking for the finish either.

so you can genuinely ask her for just one edge of the range if that's all you need. efficient queen πŸ‘‘


πŸ”₯ RETURN VALUE πŸ”₯

if the operation was successful, mtext_prop_range() returns the number of values the property key has at pos. that's the good ending 🌟

otherwise she returns -1 and assigns an error code to the external variable merror_code. yeah. that's the bad ending, and she will be telling on herself via merror_code 😭


πŸ’€ ERRORS πŸ’€

these are the codes that can land in merror_code when things go sideways:

  • MERROR_RANGE
  • MERROR_SYMBOL

that's the whole list, fr fr.


🌈 SEE ALSO 🌈

her friend group, her little crew, her entourage 🫢 go check them out:

  • mtext_put_prop()
  • mtext_put_prop_values()
  • mtext_get_prop()
  • mtext_get_prop_values()
  • mtext_pop_prop()
  • mtext_push_prop()

Copyright (C) 2001 Information-technology Promotion Agency (IPA)

Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>.


and that's the whole page bestie, we made it to the very end πŸŽ€ this was Version 1.8.4, dated Mon Sep 25 2023, and it lives in the m17n Library manual as mtext_prop_range(3m17n). stan a well-documented property-range-finder. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from