Paul, I comment my code *heavily* so that I can remember what-I-did/why-I-did-it. But those heavy comments get in the way of reading the code quote often.
Any chance you could give me a command that would toggle, both, the comment foreground and background colors, from my chosen colors to the same color as the main background color and back again; thereby "hiding" the comments temporarily?
Does that sound like something that would be useful to anyone other than my greedy little self? [smile]
Thanks!
Bruce
Hmmmm.... that's an interesting idea. I think that maybe it could be done via a UserTool. Invoke the tool via a hotkey, read the WinFBE ini file, and replace the relevant colors, save the ini. WinFBE will read the new ini. I need to check the source code to see if WinFBE does an ApplyProperties to the open documents when configuration file changes (I don't think that it does but that would be easy to add).
Let me give this a shot to see if I can make such a system work. I'll report back once I have something more definitive.
I guess that you want the editor to be RO while in "no comment" mode?
Oh no, Pierre... I still want to be able to edit my code at that time. The hot-key would be a toggle, so easy to flip on/off if I need to see where any comments are. Plus, any comments on the current line would still show up because of the different coloring that takes place on the "current line" (in most of users' setups).
I see, if the current line comment is visible then it make sense.
You could also make it pale so you view it but it doesn't grab attention.
Perhaps there is a way to "Fold" just the comments of a Func/Sub?
@Pierre... I've tried the "pale" option in the past, but it doesn't really work for me.
@SeaVipe... Folding sucks in Scintilla when attempting to use it on a non-block syntax like BASIC. It defaults to using the indent level - and that doesn't work at all in a lot of real world scenarios.
First, just try folding on any of your standard FreeBASIC code. Scintilla gets lost pretty easily there, even when your code is neat and tidy.
Then, add in some of the different types of comments, (', /'...'/, rem, anything after a _ line continuation), and see what you get.
And, heaven forbid you should use preprocessor #if...#endif, etc.... especially at different indent levels than the surrounded code.
Scintilla folding just sucks... [grin]
No problem,
Note that my post wasn't clear, I meant a pale comment
for the current line only and transparent for the rest.
This said, it's a matter of choice and the client is king. :-)
I use a black background in the code editor. Comments are displayed in Light Grey, preprocessor in Signal Red and everything else is some bright, vibrant colour. For me, this combination of colours reduces eye strain as well as keeping the Comments fairly subdued. A small, crisp font like Dina 10 also helps.
It was a good exercise for me today to create the User Tool that toggles on/off the comment coloring. It certainly looks weird when you toggle off the comments :-) I setup the User Tool to invoke via Ctrl+9. Each time it runs it will update the WinFBE config ini. WinFBE detects the new config file, reloads it, and then applies the new settings to all open documents. You just need to remember to re-enable comments prior to closing your main application otherwise when you restart, the comment colors will default to the off colors and you don't want that.
You will need to wait until I upload the next WinFBE version in order to try this out because I had to make a small addition to the main WinFBE message loop in order to re-apply the changed properties.
Quote from: SeaVipe on March 28, 2020, 08:45:59 PM
I use a black background in the code editor. Comments are displayed in Light Grey, preprocessor in Signal Red and everything else is some bright, vibrant colour. For me, this combination of colours reduces eye strain as well as keeping the Comments fairly subdued. A small, crisp font like Dina 10 also helps.
I always have been unable to work with a black backgroung. Can it be because I live in a very sunny country?
Paul, maybe down the road you can throw an [initial comment colors] into the config and have those colors set only when the user sets them through the options dialog. Then, you could pull those values at startup and shove them into the normal [comment colors] as you go. That would bypass the "forgot* and "unscheduled-restart" issues. But many thanks for now!
José, I would get a headache from staring at a bright screen all day... I wear and hat and sunglasses when I go outside... but that would be silly to do when working at my computer! [BIG grin] (Of course, I don't think it's at all silly if you are actually sitting there with a hat and sunglasses on while you stare at your white, bright screen.) [BIG grin again]
And SeaVipe, it sounds like we are related... but my eyes are obviously much worse than yours.... I have my font set to Lucida Console TWELVE for a *MINIMUM*.... later at night, I jump it up to FOURTEEN (or 15 sometimes) so I can keep working. [smile]
Quote from: José Roca on March 28, 2020, 11:09:10 PM
Quote from: SeaVipe on March 28, 2020, 08:45:59 PM
I use a black background in the code editor. Comments are displayed in Light Grey, preprocessor in Signal Red and everything else is some bright, vibrant colour. For me, this combination of colours reduces eye strain as well as keeping the Comments fairly subdued. A small, crisp font like Dina 10 also helps.
I always have been unable to work with a black backgroung. Can it be because I live in a very sunny country?
You know I am the same way. I have tried several times to switch to black themes in other editors when I had to write web applications. VSCode, Sublime Text and Atom... I always kept coming back to light backgrounds.
Quote from: Bruce Huber on March 29, 2020, 02:08:55 AM
Paul, maybe down the road you can throw an [initial comment colors] into the config and have those colors set only when the user sets them through the options dialog. Then, you could pull those values at startup and shove them into the normal [comment colors] as you go. That would bypass the "forgot* and "unscheduled-restart" issues. But many thanks for now!
I've been thinking about this and I think that maybe I'll allow passing parameters to the user tool. So when you set up the tool you can specify a default foreground and background color. That would simplify things greatly.
The "problem" I made for myself is the way that store colors in the WinFBE config file. I pack the colors into repeating groups within the THEME section tag. In addition to the foreground and background color, I also have to store bold, italic, underline. Maybe down the road I will revise how colors are stored.
Yes, changing to the command line parameter approach was much better and reliable.
Here is the code as it stands right now. You'll need to wait until the next WinFBE update comes out before it will actually work.
' HideComments - WinFBE User Tool
' Copyright (C) 2020 Paul Squires, PlanetSquires Software
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT any WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
' Simple WinFBE User Tool that acts as a toggle that changes the internal
' color values for comment colors. By setting the comment foreground color
' to match that of the background color, the comments in the documents
' would essentially render invisible although the text itself does not
' disappear.
' SYNTAX:
' HideComments <Foreground> <Background>
'
' example: HideComments 32768 16777215
'
#Define UNICODE
#include once "Afx\AfxWin.inc"
#include once "Afx\AfxStr.inc"
#include once "Afx\CIniFile.inc"
' Colors
enum colors
ID_THEME = 1
CLR_CARET
CLR_COMMENTS
CLR_HIGHLIGHTED
CLR_KEYWORD
CLR_FOLDMARGIN
CLR_FOLDSYMBOL
CLR_LINENUMBERS
CLR_OPERATORS
CLR_INDENTGUIDES
CLR_PREPROCESSOR
CLR_SELECTION
CLR_STRINGS
CLR_TEXT
CLR_WINDOW
end enum
type APPDATA
wszFilename as CWSTR
wszThemeSection as CWSTR
wszThemeData as CWSTR
wszDefaultFG as CWSTR
wszDefaultBG as CWSTR
end type
dim shared g as APPDATA
''
''
function GetParameters() as Long
' Get the commandline parameters for the default comment FB and BG colors.
g.wszDefaultFG = AfxCommand(1)
g.wszDefaultBG = AfxCommand(2)
if g.wszDefaultFG = "" then g.wszDefaultFG = "32768" ' green
if g.wszDefaultBG = "" then g.wszDefaultBG = "16777215" ' white
function = 0
end function
''
''
function LoadThemeData() as long
' Retrieve the current Theme from the config file
dim as CWSTR wszThemeGUID, _ ' {BB8DFE1F-CF2C-4357-BDCE-E1843CDDD608}
wszThemeSection, _ ' THEME_00, THEME_01, etc
wszThemeData ' The actual data of the theme
dim cIni as CIniFile = g.wszFilename
wszThemeGUID = cIni.GetString( "Themes", "SelectedTheme" )
for i as long = 0 to 99
wszThemeSection = "THEME_" & right( "00" & i, 2 )
wszThemeData = cIni.GetString( "Themes", wszThemeSection )
if left(wszThemeData, len(wszThemeGUID)) = wszThemeGUID then
g.wszThemeSection = wszThemeSection
g.wszThemeData = wszThemeData
exit function
end if
next
function = 0
end function
''
''
function SetThemeColor() as long
' The structure of the THEME is:
' Theme data is saved in parse blocks separated by a "|" pipe symbol. Within
' each of of those parsed pipe blocks the data is further divided and separated
' by "," comma blocks. The first pipe block is always the theme id and description.
' From pipe block 2 to parsecount, the pipe blocks are the actual colors. Each
' color block is comma separated and composed of foreground color, background color,
' and 0/1 indicating if to use default background color.
dim as CWSTR wszComment, wszSavedTheme, wszNewTheme
dim as CWSTR wszPiece( 1 to 6 )
' Get the FG/BG colors from the Theme data currently in the WinFBE config ini.
wszComment = AfxStrParse( g.wszThemeData, colors.CLR_COMMENTS, "|" )
' The first comma separated value is the foreground color. The second
' value is the background color. The remaining values are not needed.
for i as long = 1 to 6
wszPiece(i) = AfxStrParse( wszComment, i, "," )
next
' If the FG and BG colors are the same then the comment color must have
' been turned off. If they differ then comments must be turned on.
if wszPiece(1) = wszPiece(2) then
' Reset the colors to the default as specified by the user
wszPiece(1) = g.wszDefaultFG
wszPiece(2) = g.wszDefaultBG
? "Comments have been turned ON"
else
' Change the color so that FG matches the BG
wszPiece(1) = wszPiece(2)
? "Comments have been turned OFF"
end if
' Reassemble the comment data
wszComment = ""
for i as long = 1 to 6
wszComment = wszComment & wszPiece(i) & ","
next
wszComment = rtrim(wszComment, ",")
' Reassemble the theme data
wszNewTheme = ""
for i as long = 1 to colors.CLR_WINDOW
if i = colors.CLR_COMMENTS then
wszNewTheme = wszNewTheme & wszComment & "|"
else
wszNewTheme = wszNewTheme & AfxStrParse( g.wszThemeData, i, "|" ) & "|"
end if
next
g.wszThemeData = rtrim( wszNewTheme, "|" )
function = 0
end function
''
''
function SaveThemeData() as Long
' Save the new theme data to the WinFBE configuration file.
dim cIni as CIniFile = g.wszFilename
cIni.WriteValue( "Themes", wstr(g.wszThemeSection), wstr(g.wszThemeData) )
function = 0
end function
' ========================================================================================
' Main Program entry point
' ========================================================================================
' Set the WinFBE configuration filename
g.wszFilename = "..\Settings\WinFBE.ini"
if AfxFileExists( g.wszFilename ) then
GetParameters() ' get commandline comment FG and BG colors
LoadThemeData() ' get current WinFBE theme data
SetThemeColor() ' this will toggle comments on/off
SaveThemeData() ' save theme data back to WinFBE ini
else
? "WinFBE configuration file not found"
end if
QuoteAnd SeaVipe, it sounds like we are related... but my eyes are obviously much worse than yours.... I have my font set to Lucida Console TWELVE for a *MINIMUM*.... later at night, I jump it up to FOURTEEN (or 15 sometimes) so I can keep working. [smile]
For me black background goes way back to another lifetime when I worked with marine engineering companies. Their offices were full of engineers and designers with the blinds drawn and all the lights out. All the monitors were set to black background. After a while I tried it myself and I found that I was able to work longer and better with less eye strain and fewer/no headaches. So it stuck.
Also, I find that most other colours show up better on a black background. Yellow on white is just a blurr to me!
José, the area of Canada where I live is classified as Semi Arid Desert. We have long hot, dry summers and short cold winters and vineyards! Not ancient like Spanish vineyards, but they will be one day.
I suppose this post should be in the General section. :0)
Quote from: SeaVipe on March 29, 2020, 02:44:40 PM
José, the area of Canada where I live is classified as Semi Arid Desert. We have long hot, dry summers and short cold winters and vineyards! Not ancient like Spanish vineyards, but they will be one day.
I'm over in Newfoundland and I can certainly say that we're not classified as a semi arid desert! When I retire I'll move over your part of Canada! :-)
The ideal climate for wine production is:
A mild spring with not too heavy rain to help the vineyard grow, with a calm and temperate period during which the vineyard blooms, followed by a hot and sunny summer with little rain to allow the fruit to ripen at that time in growth and a late dry summer and early fall to finish ripening the grapes and for the harvest.
A cold winter that inhibits growth, thus being able to rest the vineyard, with frosts to exterminate infections, although not too strong not to affect the vineyard, and with enough rain to have moisture reserves in the soil.
The kind of soil is also important, but that is another story.
I think we tick all the boxes here, José.
Quote
I'm over in Newfoundland and I can certainly say that we're not classified as a semi arid desert! When I retire I'll move over your part of Canada! :-)
Paul, my Wife and her siblings are from South East, Placentia. 2 of her 4 sisters live in the Vancouver area (we're in Kamloops) When we have a family get together (and soon I hope) I can barely follow the conversation. Jigg's Dinner? Another story!
;-)
Quote from: SeaVipe on March 29, 2020, 04:28:27 PM
Quote
I'm over in Newfoundland and I can certainly say that we're not classified as a semi arid desert! When I retire I'll move over your part of Canada! :-)
Paul, my Wife and her siblings are from South East, Placentia. 2 of her 4 sisters live in the Vancouver area (we're in Kamloops) When we have a family get together (and soon I hope) I can barely follow the conversation. Jigg's Dinner? Another story!
;-)
Lol, yeah we have some rather unique traditions an language here. I'm in St. John's. Placentia is not too far away.
I'm down in Dallas, Texas... normally almost semi-arid desert, except this is one of those years... we are already 13 inches above normal rainfall for this year! Back in the 1950's, Dalllas and Fort Worth were smart and said, "if we want to grow, we must have water!". So, although it is very flat here, they dammed up every little stream they had and made 15 lakes of very many acres each - but the deepest one is only about 40 feet deep! So, even with all of those lakes, with so many people moved/moving to Dallas; every year we run out of water and go on water restrictions! Even crazy rain doesn't matter, because the lakes are shallow and fill quick... but at 100 degrees F all summer, they also evaporate quick.
I like Vancouver... [heavy sigh]
And black edit screen... Paul and José must be youngsters. All we had back in the early 70's were terminals with black screens and, usually, green characters. I guess my eyes got adjusted to 80 hours a week of that back then... white screens give me a headache. Xerox Parc and their crazy "graphic screen" ideas just ruined it for everyone. You all will probably go blind before your time! [BIG Smile]
(And if I need to help someone on their Win10 PC and they have a white screen, I go in to the notifications and turn on [Night Light] while I'm there, so that it cuts down the blue wavelength glare).
FYI, here is how I have HideComments setup as a User Tool (see attachment)