Hello, when using ed.get_text_sel() to get column selection, it just return '2', is any other method to get the all text of multi-selection?
upadate:
I've read the wiki for CudaAPI, it just return first carset position.
And for multi selection, it seems we need to use get_carets() and get_text_substr() to get all the text?
get text from multi selection
-
- Posts: 2245
- Joined: 25.08.2021 18:15
Re: get text from multi selection
get_text_sel() gets selection of only 1st caret, while you have 3 carets.
note: when calling get_text_substr(), you must put SORTED coords:
yes, right.> it seems we need to use get_carets() and get_text_substr() to get all the text?
note: when calling get_text_substr(), you must put SORTED coords:
>Returns substring from position (x1, y1) to bigger position (x2, y2).
-
- Posts: 2245
- Joined: 25.08.2021 18:15
Re: get text from multi selection
how to get sorted coords for i-th caret
Code: Select all
carets = ed.get_carets()
x0, y0, x1, y1 = carets[i]
if (y0, x0) >= (y1, x1): #note that y first
x0, y0, x1, y1 = x1, y1, x0, y0
Re: get text from multi selection
Thanks, I also find this in wiki page. I test it and find (y0, x0) >= (y1, x1) is always ture for the selection in one line(y0==y1)? When it will be false?main Alexey wrote: ↑11.10.2023 17:08 how to get sorted coords for i-th caretCode: Select all
carets = ed.get_carets() x0, y0, x1, y1 = carets[i] if (y0, x0) >= (y1, x1): #note that y first x0, y0, x1, y1 = x1, y1, x0, y0
-
- Posts: 2245
- Joined: 25.08.2021 18:15
Re: get text from multi selection
you have 2 cases: selection goes to the left, or it goes to the rigght. so x0 can be less or more than x1.