Text.getSelection

string getSelection(int selectionNum, out int startOffset, out int endOffset)

Gets the text from the specified selection.

Parameters

selectionNumThe selection number. The selected regions are assigned numbers that correspond to how far the region is from the start of the text. The selected region closest to the beginning of the text region is assigned the number 0, etc. Note that adding, moving or deleting a selected region can change the numbering.
startOffsetpasses back the starting character offset of the selected region
endOffsetpasses back the ending character offset (offset immediately past) of the selected region

Returns

a newly allocated string containing the selected text. Use [glib.global.gfree]

to free the returned string.