Fold all lines which are not found in Find dialog

bepaytion
Posts: 4
Joined: 11.10.2022 03:54

Fold all lines which are not found in Find dialog

Post by bepaytion »

plugin or feature?

1. how to folding not match, like notepad 3
notepad3 view
notepad3 view
2. when folding , how to show whole line instead of [...] short line, also ,like notepad3
n3 folding
n3 folding
folding
folding
ths for reply. :)
miro.matas
Posts: 67
Joined: 26.08.2013 06:16

Post by miro.matas »

ad 2/
Attachments
Screenshot 2022-10-11 124238.png
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

Be more verbose, I did not understand: "how to folding not match, like notepad 3".
bepaytion
Posts: 4
Joined: 11.10.2022 03:54

Post by bepaytion »

before "Focused View"
before.png
after "Focused View"
after.png
the lines contain find text would be shown, others would be folded
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

Cud cannot do that. I tried the "fold selected lines" cmd, but it don't support multi-selections. Multi-selections can be made by Find dialog [...] / "Select all", then "Selection / Invert selection".
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

Checked the API. found Editor.folding() API. https://wiki.freepascal.org/CudaText_API#Editor.folding
it can do FOLDING_ADD (add fold range - you can create it for any lines). and FOLDING_FOLD (fold any range). so plugin is possible here. plugin can fold all lines except the lines with carets. so user puts carets (via Find dialog), then calls the plugin.
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

I wrote this plugin: it's in the zip file here,
https://github.com/kvichans/cuda_ext/issues/203
Open zip file in CudaText to install it.
It adds menu item "Plugins / Fold lines w/o carets".
Later it will be integrated to CudaExt.
Please test.
bepaytion
Posts: 4
Joined: 11.10.2022 03:54

Post by bepaytion »

it is not perfect, but yes, that 's the way that i want

1. fold should be start on the line that is found , and stop on the line that is found
the lines that i marked should be fold
2. all lines which are found should be shown, but now, only the line i choose is shown
chooseAll.png
3. so i chose all lines which are found, then run , that is more like that i want, except the line before and the line after(marked at more.png)
more.png
more.png (8.48 KiB) Viewed 1221 times
after_all.png
4. can fold be revent when i run it again?
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

I don't understand how you get your 1st screenshot and last screenshot. plugin must remove all fold-ranges first, so existing {...} ranges must not mess with plugin.

I do in 'history files.json'
- enter 'tab_spaces', call in dialog - [...] / Select all
- call plugin
I get good picture--
Screenshot from 2022-10-12 13-18-02.png
main Alexey
Posts: 2245
Joined: 25.08.2021 18:15

Post by main Alexey »

all lines which are found should be shown, but now, only the line i choose is shown
what do you mean "only the line I choose"? I called [...]/Select_all, so editor puts multi-carets on 'tab_spaces', I don't need to choose anything.

maybe you had _folded_ ranges before calling my new plugin?
can fold be revent when i run it again?
you mean 'reverted'? you can right-click the gutter-fold-column, choose 'Unfold all'. ok?
Post Reply