novelWriter icon indicating copy to clipboard operation
novelWriter copied to clipboard

Apply "Toggle Comment" to all selected text

Open HeyMyian opened this issue 2 years ago • 3 comments

When I use the "Toggle Comment" function on a bunch of selected text that has multiple paragraphs, only the paragraph that has the curser in it gets converted to a comment. Perhaps the function could toggle the comment state on all selected paragraphs instead. If the selected text has mixed paragraphs (comments and non-comments), the function could first convert all paragraphs to a comment, and on second use to non-comment paragraphs.

(As I'm opening so many issues and feature request, I wanted to also say THANK you so much for your work. I dabbled with a few different writing softwares, and novelWriter is the one that stuck with me. It feels so cozy and clean in what it does, runs lightning fast on my 14 year old netbook, stored inside a Dropbox, I can use it seamlessly between my Windows and Lubuntu machines, the project files are tiny, and thanks to your tip somewhere here I also use GitHub as backup and version control. Thank you <3)

HeyMyian avatar Apr 19 '22 14:04 HeyMyian

All the formatting options use the same underlying function in the code, and they are not based on selection at all, only cursor position. It makes sense for some of them to apply to a selected range of blocks if a selection has been made, so I'll look into adding a wrapper call with a loop in those cases. However, for the comments, it would toggle all paragraphs separately. So all commented ones would be un-commented, and vice versa. But I'll have a look to see if there is a way to do this without having to rewrite the whole feature.

Feedback is always appreciated. I like tinkering with novelWriter, and try to implement requests that fit with the general philosophy of the app and doesn't bloat it too much.

I'm glad you find novelWriter useful. It was designed from the get go to work with file sync and version control, as I too use both. I've considered integrating git directly into the app, but it would pull in a new dependency, so I'm a bit uncertain whether it's a good idea. It is also a tool only developers generally know how to use.

vkbo avatar Apr 19 '22 16:04 vkbo

I only cared about the comments, but the behavior is actually consistent with all block formatting options - they only apply to the paragraph with the cursor. Inline formatting doesn't - they always apply to the first paragraph in the selection (or a part of the first paragraph if only a part is selected of course). Perhaps you could consider the other formats too, if you decide to rewrite the feature. If it makes a lot of sense wanting to apply "Heading 3" to multiple selected paragraphs, I don't know.

HeyMyian avatar Apr 19 '22 19:04 HeyMyian

It makes no sense to apply heading formats to multiple paragraphs. That is what the feature was originally designed for though. I then extended it to comments, then to alignments and indentation. The latter three makes sense to change.

vkbo avatar Apr 19 '22 21:04 vkbo

PR #1690 adds a new "ignored text format" which is just a %~ instead of % in front of the paragraph. This modified version will always exclude the text from manuscript builds even if you include comments. It's just an optional feature, and something I want for my own writing.

In any case, in the context of adding that, I made the comment, ignore text, and reset format commands apply to multiple paragraphs, Since the first two are toggle commands, they will make the decision based on the first of the selected paragraphs, and apply it to the remaining in the selection.

I hope this is good solution to this request.

vkbo avatar Feb 10 '24 17:02 vkbo