slgobinath / libreoffice-code-highlighter

Code snippet highlighter for LibreOffice Writer, Calc and Impress.
https://extensions.libreoffice.org/extensions/code-highlighter
Other
133 stars 16 forks source link

Dialog to select language and style #38

Closed jolange closed 5 years ago

jolange commented 5 years ago

This

The sub-menus have been removed and only one field is used in the tools menu now:

2019-08-19-153408_3840x1200_scrot

2019-08-19-153441_3840x1200_scrot

Closes #22, closes #36

slgobinath commented 5 years ago

@jolange thank you very much for your contribution. I've tried your changes and its working as expected on my LM machine.

I personally find having menu is easy to find a language quickly. It also allows me to set custom shortcuts to a language I use frequently (as shown in readme). With the new implementation, I find it hard to highlight a code snippet with a few clicks or a single shortcut. What do you think about providing both options (the menu as well as the dialog)?

Thanks

jolange commented 5 years ago

Sure, we could of course have both! I did not think about the keyboard shortcuts, to be honest ;-)

It is just a bit ugly to "manually" define a function for each language. I tried generating them automatically using using a loop and exec(), but it seems that the python code is not really executed at startup, but only the variable g_exportedScripts is checked. So the auto-generation does not work, unfortunately.

Edit: And now it is of course a bit arbitrary to offer highlighting in the menu with the default style and nothing else. But it still does not harm to have it.

So I'll update the PR with both variants for now and ping you when ready!

jolange commented 5 years ago

Ok, done! Looks like this now:

2019-08-21-095108_3840x1200_scrot

slgobinath commented 5 years ago

Great!

It is just a bit ugly to "manually" define a function for each language.

Yeah I also tried to simplify it but this how extensions work (according to my understanding). So we have to live with that :(

of course a bit arbitrary to offer highlighting in the menu with the default style

I agree with you. An ideal solution would be letting the user to chose a style he wanna be the default and apply it through menu and providing the option to choose a style in a dialog. Here I am not sticking with menu but the usability.

I find it is easy to select the language in a grouped menu than in a combo-box. Further it allows me to set a keyboard shortcut. I prepare slides for my Java students and have to highlight at least 5-10 code snippets in a presentation (actually that's why I developed this extension ;-) ). I prefer to do this using a shortcut (I assigned default_java to Alt + J) which makes my life easier. I hope other frequent users may also have similar requirements. On the other hand users also want to customize the style.

For the moment, your solution solves both problems. We can consider later on how to improve it further.

Again, thank you very much for your contribution. I am merging the changes and I will update the extension store soon.

jolange commented 5 years ago

Again, thank you very much for your contribution. I am merging the changes and I will update the extension store soon.

You are welcome! Thanks for starting this project in the first place ;-)

Before you update the extension in the store: I have a couple of small changes I'd like to include still (handling bold/italics in styles and optionally setting background colors from styles). I will create a PR soon, so you can check if you want these included!

I agree with you. An ideal solution would be letting the user to chose a style he wanna be the default and apply it through menu and providing the option to choose a style in a dialog. Here I am not sticking with menu but the usability. I find it is easy to select the language in a grouped menu than in a combo-box. Further it allows me to set a keyboard shortcut. I prepare slides for my Java students and have to highlight at least 5-10 code snippets in a presentation (actually that's why I developed this extension ;-) ). I prefer to do this using a shortcut (I assigned default_java to Alt + J) which makes my life easier. I hope other frequent users may also have similar requirements. On the other hand users also want to customize the style.

Yes, I totally understand these use cases. I thought about the following: One could store the latest values chosen in the colorize dialog. Then one could write a function which colorizes with the latest values, without showing a dialog. That could be assigned to a hotkey. So you would only choose 'java'/'default' for you first snippet and for the rest just use your hotkey. Maybe I'll try something like that at a later point.

slgobinath commented 5 years ago

Sure I've already released the new version. Please send me your new changes whenever you are ready. I will release it as the new version.

jolange commented 5 years ago

I already saw it, you were really fast ;-) I pushed my changes to #39