jmzambon / libreoffice-code-highlighter

Code snippet highlighter for LibreOffice.
https://extensions.libreoffice.org/en/extensions/show/5814
Other
79 stars 5 forks source link

Add opportunity to highlight all code in user selected row of the all tables in Writer where first (or user selected too) row has some key phrase #32

Closed kompilainenn closed 2 months ago

kompilainenn commented 3 months ago

Add opportunity to highlight all code in user selected row of the all tables in Writer where first (or user selected too) row has some key phrase, for example 'Python listing' or 'C++ listing'. User should have an opportunity to enter that key phrase manually inside the dialog.

The use case here is next: I write some book with many code examples. I want to highlight it all at once just by using some conditions like table's row number with the code example and by entering some key phrase that should be in first row of these tables inside all document.

Thanks for your great extension!

jmzambon commented 3 months ago

Hi,

I'm not sure at all to understand what you describe. Would it be possible to provide a real life example, or a sort of mock up? Thanks.

kompilainenn commented 3 months ago

I'm not sure at all to understand what you describe. Would it be possible to provide a real life example, or a sort of mock up? Thanks.

Ok, I added the ODT file with some examples of source code in different tables Example for Code highlighting issue.odt

So, now I want to highlight all these code examples for only one action using your extension.

Let me show you how it can look in the dialog or sub-dialog: image

jmzambon commented 3 months ago

Thank you very much! This is highly specific. What about a dedicated macro, shipped with the extension? Or an advanced option to show such a specific button? I must think about this... If you have any arguments they would be welcome.

kompilainenn commented 3 months ago

If you have any arguments they would be welcome.

Hi. I had a discussion about this feature with my friend who is a LibreOffice developer and he gave me another idea: to highlight only text that has some user selected Paragraph style! In this case we don't need tables and its cells as conditions, we will have in the document many text blocks that will have the same Paragraph style, then we just select the style in drop-down list in your dialog and then click "Highlight all text with selected style" button (for example).

Let me show you the another mock-up for this variant: image

What do you think?

jmzambon commented 3 months ago

This is a top idea. I was thinking about something similar, reusing the character style that one can define as base style for the option "use character styles" (see More... button). But paragraph style sounds better. I'll try to work on this as soon as possible.

jmzambon commented 2 months ago

Hi,

I have uploaded a beta version. Would you have some time to test it on some of your files? It should work either with text tables, text frames and normal plain texts. Only for Writer obviously... Thanks a lot.

kompilainenn commented 2 months ago

Now I could install it. Works like a charm! There is only one problem I saw: why error message do we show after highlight ending operation?

image

May be it should be just a message type window?

kompilainenn commented 2 months ago

Another nitpick: drop-down list with styles should remember selected style inside one user LibreOffice session, what do you think?

jmzambon commented 2 months ago

Error message is obviously... an error :) . Should be an info box. I was in fact wondering about keeping or not the paragraph style. Remembering it for the current session seems quite evident.

kompilainenn commented 2 months ago

I tested latest OXT variant right now. It works as I expected. A huge thank you! This feature will very useful for me and other writers who write books about programming!

Btw, I have some other ideas and questions for your extension (I can write different issues if you want):

  1. For what we use a 'Use character styles' checkbox? After this issue fixing it's still needed?
  2. Would be cool to see a Preview without button clicking, just after Language and Style selecting at once. And the Preview should be inside the dialog not in the document
  3. Would be cool to split light, dark and colorful themes in the drop-down list
  4. 'Set background color' checkbox should be named 'Set background color from Style'
  5. Instead 'More...' button I would create some expanding section for 'Line numbering' options (I can create some mock-up if you will interesting)
jmzambon commented 2 months ago

Hi, Thanks for your interest in this extension! About your last comments:

  1. Character formatting can be done by mean of "direct formatting" or using the character styles. The later help the user to tweak the style more easily : only one place for changing every snippet formatted with the same style... Paragraph styles and character styles are different things and can be mixed without problem.
  2. It was the idea at start, but previewing requires to activate all the highlighting machinery, which is not responsive enough to be bound to such events. But I keep thinking about other solutions.
  3. An issue exists about that. But Pygments styles, if I'm right, have no such tags, so it's not easy at all to implement and automate. It could be done manually, but when I'll have some more time.
  4. Your right, it is unclear as it. I'll modify it.
  5. Probably much more coding for managing the dialog, but not impossible. Here a new issue and a mock-up of your secret would be nice ;-) .
jmzambon commented 2 months ago
  1. 'Set background color' checkbox should be named 'Set background color from Style'

For information, that is specified in the tooltip (when you move the pointer over the control).

kompilainenn commented 2 months ago

For information, that is specified in the tooltip (when you move the pointer over the control).

Direct label is more clear I think.

I think we can close this issue as Fixed. Thanks so much!