Page 1 of 2

Fold all lines which are not found in Find dialog

Posted: 11.10.2022 04:14
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. :)

Posted: 11.10.2022 10:43
by miro.matas
ad 2/

Posted: 11.10.2022 11:06
by main Alexey
Be more verbose, I did not understand: "how to folding not match, like notepad 3".

Posted: 11.10.2022 12:34
by bepaytion
before "Focused View"
before.png
after "Focused View"
after.png
the lines contain find text would be shown, others would be folded

Posted: 11.10.2022 12:57
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".

Posted: 11.10.2022 23:04
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.

Posted: 11.10.2022 23:51
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.

Posted: 12.10.2022 03:04
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 1220 times
after_all.png
4. can fold be revent when i run it again?

Posted: 12.10.2022 10:16
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

Posted: 12.10.2022 10:21
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?