slap-editor / slap

Sublime-like terminal-based text editor
MIT License
6.14k stars 216 forks source link

Some styles from editor-widget.ini don't do anything for JavaScript. #366

Closed BobbyBabes closed 7 years ago

BobbyBabes commented 7 years ago

Ref : https://github.com/slap-editor/editor-widget/blob/1ceaf95cd044bdf90e28fc3aee0f7aa67a2b6b10/editor-widget.ini#L130-L173

First of all thanks for a wonderful console editor. I only just discovered it from this page : https://github.com/showcases/text-editors

I copied the style lines from editor-widget.ini to ~/.slap/config. Then changed some styles. But styles like operator = "{green-fg}" and variable = "{yellow-fg}" don't seem to have any influence whatsoever (only tested with JavaScript code). Even before changing them. While other styles do,

And adding a foreground colour to function = "", for example {light-green-fg}, changes the text colour of the complete line the function name is on. Including the keyword function, which had a red colour because of the style keyword = "{red-fg}". And the text colour of the function parameters also turns green from white (although it's styled with params = "{bold}").

What am I doing wrong? Or maybe what's going on?

And why can't we use styles from /opt/node/lib/node_modules/slap/node_modules/highlight.js/styles?

dbkaplun commented 7 years ago

@BobbyBabes I'm glad you are enjoying the editor! One of the main reasons I wrote the editor in JS is so you can see exactly how the code works without having to learn a more complicated language or framework. I see you were able to find those styles in the source code. Here is how they are detected with highlight.js: https://github.com/slap-editor/editor-widget/blob/b8f3cf67b84b74bf4b0f5f481f82d27e05031bbe/lib/highlight/server.js#L41

In essence, the styles are language specific, as discovered by highlight.js. Changing operator or variable will change those styles for one language but may not change it for another. Initially, I tested various files and found those styles from highlight.js' output, so I added them to the file, but they may not apply anymore as highlight.js has been updated since then. Does that help?

BobbyBabes commented 7 years ago

Thanks for the pointer to how styles are detected by highlight.js. I assumed that the styles were aware of multiple languages (not necessarily all though). But at least JavaScript. This was wrong of course.

I'll look further into the style detection. I might be able to find a better suited style, or change things to my liking.

Thanks for your explanation. I'm OK now.