The officially official Devuan Forum!

You are not logged in.

#1 2022-02-04 12:22:31

hevidevi
Member
Registered: 2021-09-17
Posts: 230  

syntax highlighting

I was wondering what kinds of syntax highlighting folks here like and use?

Ive recently read about only having comments highlighted in a program file , config, script etc and have given it a try in geany and it sort of makes sense that to understand the code, comments are better off highlighted than the actual code itself. So for example, a bashrc, config, C  file will only have the comments in blue and the rest of the input witll be white, so lets say black background, blue syntax foreground and white code foreground for example, only 3 colors used in that order.

thoughts??

example:

2022-02-04-222724-1366x768-scrot.png

Last edited by hevidevi (2022-02-04 12:29:24)

Offline

#2 2022-02-04 18:07:13

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: syntax highlighting

I'm a complete tart so I can't live without syntax highlighting. I find it useful for shell scripts because it indicates when I mess up the syntax, which happens often.

I use the default vim highlighting, here's an example featuring my lame status "script" for sway:

20220204-18h05m44s-grim.png

EDIT: yes, I am using whitespace to centre the clock; I don't know how to use JSON...

EDIT2: btw did you know OpenBSD's ksh can use GNU-style PS1 backslash-escaped special characters?

PS1='\e[36m\w \e[32m>\e[0m '

^ That replicates your PS1 without having to run pwd & sed every time you press <return>.

Last edited by Head_on_a_Stick (2022-02-04 19:18:38)


Brianna Ghey — Rest In Power

Offline

#3 2022-02-04 21:42:41

JWM-Kit
Member
Registered: 2020-06-29
Posts: 113  
Website

Re: syntax highlighting

Head_on_a_Stick wrote:

...EDIT: yes, I am using whitespace to centre the clock; I don't know how to use JSON...

Nothing wrong with that.  if it works.  Why make the code more complicated than it needs to be.  Might I suggest using printf instead of echo which supports using \t for tab and \n for new line.  Example.

printf "$(date +'%H:%M')\t\t\t\t$state$symbols\n"

Syntax highlighting is a blessing.  It helps identify content between quotes, brackets,etc and easily find unclosed brackets, quotes.  It can helps identify which code belongs to a certain code block (like a function or class). The advantage go on it. My job would b e so much more difficult without it.

Last edited by JWM-Kit (2022-02-04 21:44:46)

Offline

#4 2022-02-04 21:53:24

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: syntax highlighting

JWM-Kit wrote:

Might I suggest using printf

Thanks for the suggestion. I need spaces to line up the clock exactly on the centreline, tabs don't quite match. But I suppose it would be slightly cleaner to use mostly tabs with a few spaces:

printf "$(date +'%H∶%M')\t\t\t\t\t\t\t\t\t\t\t\t       %s%s\n" "$state" "$symbols"

Thanks again and apologies to the OP for the diversion.


Brianna Ghey — Rest In Power

Offline

#5 2022-02-04 22:08:59

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 1,106  

Re: syntax highlighting

I need spaces to line up the clock exactly on the centreline, tabs don't quite match.

printf "%$((COLUMNS / 2))s%s%s\n" "$(date +%H%M)" "$state" "$symbols"

Then, for the OP, I think some syntax highlighting is good some really bad; especially when it's made for dark background where I use light background.

Offline

#6 2022-02-04 22:49:39

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: syntax highlighting

Thanks Ralph, that is a beautiful suggestion, but unfortunately the sway-bar status_command doesn't know the value of "$COLUMNS" for the bar so that code just results in no space at all between the clock and the battery indicator.

I've settled on

printf "%s%98s%s\n" "$(date +'%H∶%M')" "$state" "$symbols"

Which does at least look less silly, even if it isn't.

And now back to the thread topic...


Brianna Ghey — Rest In Power

Offline

#7 2022-02-05 11:05:53

PedroReina
Member
From: Madrid, Spain
Registered: 2019-01-13
Posts: 267  
Website

Re: syntax highlighting

hevidevi wrote:

I was wondering what kinds of syntax highlighting folks here like and use?

I don't mind what highlighting to use, as long as there is some one! Currently I use geany and nice editor defaults syntax highlighting configurations. My only concern is using white background, I dislike dark modes. Other than that, I can use any colour scheme.

Offline

#8 2022-02-05 12:16:53

hevidevi
Member
Registered: 2021-09-17
Posts: 230  

Re: syntax highlighting

Thanks for the input everyone. I like dark modes as its easy on the eyes for me, light colors tend to give me eye strain.

Thanks for the heads up on the ps1 in loksh head on a stick wink

Offline

#9 2022-02-05 13:24:35

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,409  

Re: syntax highlighting

There are alternate color schemes for geany. Check out the screenshots directory to see examples.
https://github.com/codebrainz/geany-themes

I used the default highlighting for geany for years, but it's become harder to read the orange on white, so I switched to gedit colors, and sometimes I switch to a dark background and use himbere.

https://github.com/codebrainz/geany-the … /gedit.png
https://github.com/codebrainz/geany-the … mbeere.png

Offline

#10 2022-02-05 14:32:54

hevidevi
Member
Registered: 2021-09-17
Posts: 230  

Re: syntax highlighting

fsmithred, yes ive downloaded and had a look at those geany themes. I like to use the cobalt color scheme, its old one.

https://github.com/katsel/geany-colorscheme-cobalt

Offline

#11 2022-02-05 17:22:00

JWM-Kit
Member
Registered: 2020-06-29
Posts: 113  
Website

Re: syntax highlighting

My opinion on Dark mode is that is depends on the purpose of the text. I prefer dark mode for most jobs, but if I'm using office software I need the white background. I feel that the whole purpose of office software is to create documents that look good on paper. So it needs a background the color of paper. Which is white.

EDIT : Of course syntax highlighting is not used in office apps.  So I guess when it comes to anything with syntax highlighting I prefer dark mode.

Last edited by JWM-Kit (2022-02-05 17:23:31)

Offline

Board footer