How to get a portion of a segment based on cursor position in the active target segment?

Hello,

I've been trying to find a way to get the cursor position on the target segment. This is actually the first step of something that should be fairly simple: I'd like to get the portion of the target segment from the beginning of the segment up to the cursor position, as plain text.

Is there a way to do that?

Thanks in advance.

emoji