tsujan / FeatherPad

Lightweight Qt Plain-Text Editor for Linux
GNU General Public License v3.0
391 stars 67 forks source link

configurable syntax highlighting #30

Closed pvanek closed 7 years ago

pvanek commented 7 years ago

it would be great to use standalone config files for various prg languages instead to hardcode it into c++ code...

tsujan commented 7 years ago

If you mean the highlighting colors, I intentionally made them hard-coded because FeatherPad's background color value can be changed by users. I had a hard time to choose highlight colors in such a way that the text would be clearly readable with all bg color values FeatherPad accepted.

pvanek commented 7 years ago

no, I mean content of highlighter*.cpp files. It's full of "if lang == c" like conditions. Now it's extremely hard to add a new lang support. If these "configs" would be stored in separate files (like eg. Juffed or kwrite does it), there can be only an easy loader and all these keywords and whatever can be loaded on demand.

Examples: https://github.com/Mezomish/juffed/tree/master/apis

tsujan commented 7 years ago

This is a really good idea.

The highlighter code was the most hard-to-implement part of FeatherPad and can't be seen as finished. Seeing that even an editor like Kate or gEdit had problems with some texts, I realized that there was no universal way of syntax highlighting. There were some common structures in some languages but each one had its special syntax/rules. Adding a language requires dealing with a new structure. But keywords are different.

Maybe the syntax highlighting code can be simplified or maybe there are better approaches. I'll look into it Thanks for the suggestion!

tsujan commented 7 years ago

I took a look at JuffEd (your link above). It uses qscintilla for syntax highlighting. gEdit uses gtksourceview and Kate uses KDE libraries. That's while FeatherPad is self-sufficient in that regard :) I guess the syntax highlighter code is something that most coders don't want to deal with ;)

tsujan commented 7 years ago

FeatherPad's syntax highlighting will never be configurable because it's hard-coded (no external library).

ghost commented 5 years ago

...Why?

GNU nano also doesn't use any libraries for highlighting, it uses its own regex-based and extensible format, and it's pretty good at it, albeit being a terminal editor. It's what keeps me from using Featherpad to be honest.

tsujan commented 5 years ago

...Why?

Because its syntax highlighting is "a little" different from that of nano:

nano

SjoerdV commented 1 year ago

if you open up a PowerShell script file (ps1) then there is no highlighting whatsoever. @tsujan are you saying this can be tweaked in settings? If so, is there some guidance on this?

tsujan commented 1 year ago

are you saying this can be tweaked in settings?

Preferences → Syntax colors. It was done a long time ago, and it's the most that can be done.

This page is very old.

tsujan commented 1 year ago

if you open up a PowerShell script file (ps1) then there is no highlighting whatsoever.

It seems that what you mean is not related to this page.

If you mean Microsoft's PowerShell and if uses the syntax of SH, then you could change the language to sh with the language button (check Preferences → Text → Support syntax override).

If it doesn't use the syntax of SH, then it isn't (and won't be) supported by FeatherPad. Its extension (ps1) isn't even recognized as a mime type.

BTW, why should one use Microsoft's PowerShell on Linux?!

SjoerdV commented 1 year ago

BTW, why should one use Microsoft's PowerShell on Linux?!

Well both the language and shell are now cross-platform, so it works natively on Linux and does it's job. I also do bash and python btw but PowerShell is handy for API operations with the Microsoft Cloud which I use professionally

Ah, actually the Ruby highlighter does an OK job. Thanks for your guidance! Love the Featherpad program BTW -> Quick, fast and speedy -> like all QT Apps!

tsujan commented 1 year ago

actually the Ruby highlighter does an OK job

Are you sure that PowerShell's syntax is that of Ruby?

Featherpad supports more than 36 syntaxes without depending on an external library. If PowerShell is really compatible with one of them, I could make Featherpad open ps1 files with that syntax.

SjoerdV commented 1 year ago

Are you sure that PowerShell's syntax is that of Ruby?

Well, it performs 'alright', not perfect, but it does a well enough job.

If PowerShell is really compatible with one of them, I could make Featherpad open ps1 files with that syntax.

I am all in favor not having to change the highlighting manually every time, but people might take offense that when a ps1 file is opened 'ruby' is displayed in the lower right. is that little text also something that can be changed?

tsujan commented 1 year ago

is that little text also something that can be changed?

No. It shows the syntax; shouldn't be changed.

With the syntax of Ruby for PowerShell, problems will appear sooner or later. Each programming language needs its own syntax highligting. If PowerShell was among commonly used languages in Linux, I might add code for highlighting its syntax.

Therefore, I don't recommend FeatherPad for working with PowerShell scripts.