Syntax highlighting

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Syntax highlighting

atnbueno
Hello there.

I've found some inconsistencies with the syntax highlighting of the embedded editor* and they have made me think about readability of code. What should be color differentiated in a code editor? Other than numbers, strings, and comments... only reserved words? operators?

In the particular case of OpenSCAD, my main problem is nesting. I'm not sure if more colors would help (maybe differentiate transformations from solids? 2D from 3D?).

Have an opinion? Want to share? :-)


(*) Single-quoted strings and missing keywords mostly. See details at https://github.com/openscad/openscad/issues/2292 

--
Regards from Spain,
Antonio



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Troberg
I don't think I need any more highlighting, I'm pretty much fine with the way
it is. One thing I like, but which few editors allow, is to change the
background of certain lines or elements. Example:

* Module/function definitions. Give the entire line a different background
and they'll stand out in the code.

* Comments. When I comment, I want them the stand out.

* String values and numbers. I like having a grey background on these, so
they stand out as "fields". This is especially useful when concatenating
strings, which can quickly get messy if the strings contains stuff like ",".

However, intellisense would be amazing. I have large utility libraries with
parts and handy functions, and some of these are seldom used and takes many
arguments, and not having to go to the definition each time would be great.

Also, better description of syntax errors and better accuracy in guessing
where things went wrong would be amazing. At the moment, a missed semicolon
or square bracket may list an error two pages away.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

runsun
In reply to this post by atnbueno
I wrote a syntax file for the editor SynWrite earlier, which might not be
exactly what you need, but maybe you have a use of it ...

OpenSCAD syntax lexer for SynWrite
http://forum.openscad.org/Happy-New-Year-OpenSCAD-syntax-lexer-for-SynWrite-td15402.html

SynWrite is a windows-only editor. Its author also created a cross-platform
clone called *CudaText*, which is what I've been using in the past year
(even I am using Windows) and also highly recommended.

Since we wrote the lexer ourselves, it's possible that you can tailor it to
achieve what you want.


> CudaText: http://uvviewsoft.com/cudatext/
>
> My installation process for references:
>
> 1. Download and install CudaText:
>     https://sourceforge.net/projects/cudatext/files/release/Windows/
>
> 2. Download and extract cudatext python engine: python35_x64.zip
>     http://wiki.freepascal.org/CudaText#Python_on_Windows
>    
> https://sourceforge.net/projects/cudatext/files/release/Windows/Python_engine/)
>
> 3. Copy all files into Cudatext folder:
>      C:\Users\
> <yourname>
> \Downloads\cudatext-win-x64-1.15.0.0
>     It seems that Cudatext uses its own version of python engine, which is
> independent of the python users install on the system.
>
> 4. Install OpenSCAD lexers. Lexer library has only subset of lexers. Other
> lexers (same format as SynWrite has) are at SourceForge:
>     http://sourceforge.net/projects/synwrite-addons/files/Lexers/
>
>     The direct link to OpenSCAD lexers:
>    
> https://sourceforge.net/projects/synwrite-addons/files/Lexers/lexer.OpenSCAD.zip/download
>
>     These zip packages can be installed in CudaText: open zip-file via
>     "File - Open" and confirm installation.
>
>     Click CudaText menu [Plugins]/Install to install OpenSCAD lexer
>
> Lastly, download the demo file from the thingiverse and open it with
> OpenSCAD to see its features:
>    
>     https://www.thingiverse.com/download:1929802





-----

$  Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); &nbsp; $ tips: Collection of tips on github

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

MichaelPFrey
In reply to this post by Troberg
Am 12.02.2018 um 14:07 schrieb Troberg:
> I don't think I need any more highlighting, I'm pretty much fine with the way
> it is.
You can always write your own editor color-scheme.

You can select the color-schema via
preferences -> editor -> color syntax highlighting

The path where the color schemas are stored is depending on the
operating system.
Under windows it should be somewhere like C:\Program
Files\OpenSCAD\color-schemes\editor\

You can simply copy the one you like the most, open it in your favourite
text editor, change the name and start changing things.

Writing your own color schema allows you to give different keywords the
same style.
Meaning: Having more keyword-sets allows you a more differentiated
syntax highlighting, without forcing you to a rainbox of colors.

"Write your own color-schema" also applies to those points:

> One thing I like, but which few editors allow, is to change the
> background of certain lines or elements. Example:
>
> * Module/function definitions. Give the entire line a different background
> and they'll stand out in the code.
>
> * Comments. When I comment, I want them the stand out.
>
> * String values and numbers. I like having a grey background on these, so
> they stand out as "fields". This is especially useful when concatenating
> strings, which can quickly get messy if the strings contains stuff like ",".
If you run into limitations while writing your own color schema, you can
off course ask here for help.

If you are very prude of your color scheme, you can ask one of the
maintainers to integrate it into the master branch.

With Kind regards,
Michael Frey



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Syntax highlighting

Troberg
> If you are very prude of your color scheme, you can ask one of the
maintainers to integrate it into the master branch.

...and if it's a very obscene color scheme? :)



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org