Topic: Extension-Dependent Syntax Colors (1 of 19), Read 46 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Tuesday, April 18, 2006 09:13 AM

Is it possible to automatically load a new set of syntax colors based on the extension of the file being opened? I would like to, say, use a different color for string highlighting in HTML files than I do in INI files. I know that the eight syntax color assignments are stored in the vedit.cfg file, but have not determined whether those are buffer-dependent configuration parameters, or whether there is any way to override those eight parameters based on the extension of the file being opened.

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (2 of 19), Read 36 times
Conf: Program develop.,Color syntax
From: Christian Ziemski
Date: Tuesday, April 18, 2006 11:29 AM

On Tue, 18 Apr 2006 09:13:00 -0400, Dale Cook wrote:

>Is it possible to automatically load a new set of syntax colors
>based on the extension of the file being opened?

You can do it this way:

Open a file with that extension, enable syntax highlighting, load the
appropriate syntax file manually and then save that configuration via
{Config, File-open config, Save filename extension config}

Be sure to have
{Config, File-open config, Enable File-open configuration} enabled.


Christian

 


Topic: Re: Extension-Dependent Syntax Colors (3 of 19), Read 38 times
Conf: Program develop.,Color syntax
From: Ted Green
Date: Tuesday, April 18, 2006 11:34 AM

At 11:29 AM 4/18/2006, you wrote:
>>Is it possible to automatically load a new set of syntax colors
>>based on the extension of the file being opened?

As Christian replied, the answer is Yes.
Refer to the on-line help topic "File-open configuration" for details.

Ted.

 


Topic: Re: Extension-Dependent Syntax Colors (4 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Tuesday, April 18, 2006 04:17 PM

On 4/18/2006 11:29:19 AM, Christian Ziemski wrote:

>Open a file with that extension, enable
>syntax highlighting, load the
>appropriate syntax file manually and
>then save that configuration via
>{Config, File-open config, Save filename
>extension config}
>
>Be sure to have
>{Config, File-open config, Enable
>File-open configuration} enabled.

I've tried that, but it seems to change the syntax colors for all file extensions.

I figured out how to accomplish it, though. I found the lines that set syntax colors in vedit.cfg, cut and pasted them into the .cft files, and altered the colors there. Now each filetype has its own comment color, numeric color, etc.

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (5 of 19), Read 45 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Tuesday, April 18, 2006 05:23 PM

I have a follow-up question. I need to set up matching codes to match BOL, an arbitrary number of letters or digits, one period, and another arbitrary number of letters or digits. I tried |<|F+.|F+ but it matches only up to the period and not past it.

As a specific example, I want to be able to highlight in the Reserved1 color everything before the equals sign in a line that begins:

Indicator13.Duration=250

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (15 of 19), Read 35 times
Conf: Program develop.,Color syntax
From: Pauli Lindgren
Date: Thursday, April 20, 2006 10:12 AM

On 4/18/2006 5:23:25 PM, Dale Cook wrote:
>I have a follow-up question. I need to set up matching codes
>to match BOL, an arbitrary number of letters or digits,
>one period, and another arbitrary number of letters or
>digits. I tried |<|F+.|F+ but it matches only up to the
>period and not past it.

I tried that pattern, and it works ok.

Maybe the syntax file contains another pattern that matches the beginning of the line and is checked before this pattern.

I also noticed that if you add '=' at the end of the pattern, i.e. |<|F+.|F+= then the pattern does not work.

--
Pauli

 


Topic: Re: Extension-Dependent Syntax Colors (18 of 19), Read 35 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Friday, April 21, 2006 07:07 AM

On 4/20/2006 10:12:15 AM, Pauli Lindgren wrote:

>Maybe the syntax file contains another
>pattern that matches the beginning of
>the line and is checked before this
>pattern.

Pauli -

That was it - there were two patterns for Reserved1 - reversing their order made everything work correctly. Thanks!

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (19 of 19), Read 38 times
Conf: Program develop.,Color syntax
From: Ted Green
Date: Friday, April 21, 2006 12:49 PM

At 07:07 AM 4/21/2006, you wrote:
>>Maybe the syntax file contains another
>>pattern that matches the beginning of
>>the line and is checked before this
>>pattern.
>
>Pauli -
>
>That was it - there were two patterns for Reserved1 - reversing their order made everything work correctly. Thanks!

Yes, thank you Pauli for debugging his problem.

Ted.

 


Topic: Re: Extension-Dependent Syntax Colors (6 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Ian Binnie
Date: Tuesday, April 18, 2006 07:43 PM

On 4/18/2006 4:17:47 PM, Dale Cook wrote:
>On 4/18/2006 11:29:19 AM, Christian
>Ziemski wrote:
>
>>Open a file with that extension, enable
>>syntax highlighting, load the
>>appropriate syntax file manually and
>>then save that configuration via
>>{Config, File-open config, Save filename
>>extension config}
>>
>>Be sure to have
>>{Config, File-open config, Enable
>>File-open configuration} enabled.
>
>I've tried that, but it seems to change
>the syntax colors for all file
>extensions.
>
>I figured out how to accomplish it,
>though. I found the lines that set
>syntax colors in vedit.cfg, cut and
>pasted them into the .cft files, and
>altered the colors there. Now each
>filetype has its own comment color,
>numeric color, etc.
>
I think the earlier responses to your question did not address what you were asking, which, I believe, is to have different colours for different file types/syntax files.

This is not possible, as the colours are global.
What you have done may appear to work if you only have one file type open, but if you have different types then you will get the same colours, based on the latest file opened.

A better way to do what you have achieved would be to write a file open macro to change the colours.

 


Topic: Re: Extension-Dependent Syntax Colors (7 of 19), Read 43 times
Conf: Program develop.,Color syntax
From: Christian Ziemski
Date: Wednesday, April 19, 2006 02:32 AM

On 4/18/2006 7:43:27 PM, Ian Binnie wrote:

>I think the earlier responses to your
>question did not address what you were
>asking, which, I believe, is to have
>different colours for different file
>types/syntax files.

After reading Dale's original posting I have to agree.
I haven't read it carefully enough.

>This is not possible, as the colours are
>global.

>A better way to do what you have
>achieved would be to write a file open
>macro to change the colours.

I think a "Buffer switch event macro" to switch the colors dependent on the file extension could be helpful.


Christian

 


Topic: Re: Extension-Dependent Syntax Colors (8 of 19), Read 46 times
Conf: Program develop.,Color syntax
From: Christian Ziemski
Date: Wednesday, April 19, 2006 04:36 AM

What about a macro like the following?


//
// SETSYNCOLORS.VDM Christian Ziemski 19.04.2006
//
// Sets the (global) syntax color configuration dependent of the
// current loaded syntax file (if any).
//
// Set up:
//
// Place at least the folowing 8 Config() lines with colors of your choice
// into files with the same name as the corresponding syntax file, but
// with extension .SYC (from SYntax Colors).
// For example the existing VEDIT.SYN gets a companion file VEDIT.SYC now.
//
// Config( C_W_RESERVE_W1, "Color for reserved words 1", 121 )
// Config( C_W_RESERVE_W2, "Color for reserved words 2", 124 )
// Config( C_W_RESERVE_W3, "Color for reserved words 3", 118 )
// Config( C_W_RESERVE_W4, "Color for reserved words 4", 125 )
// Config( C_W_SYMBOL, "Color for symbols", 121 )
// Config( C_W_COMMENT, "Color for comments", 121 )
// Config( C_W_STRING, "Color for strings", 124 )
// Config( C_W_NUMBER, "Color for numeric", 31 )
//
// Usage:
//
// Call this macro via {Misc, Load/exec user macro}
// or assign it to a key
// or put it into the Buffer_Switch_Event_Macro register 114
//
//-----------------------------------------------------------------------------

Reg_Push(103,104)
Num_Push(103,103)

Reg_Set(103, SYN_NAME)
#103=Reg_Size(103)
if (#103 > 0) {
Out_Reg(104)
Reg_Type_Block(103, 0, #103-3)
Out_Reg(CLEAR)
Reg_Set(104, "SYC", APPEND)
if (File_Exist("|(HOME)\|@(104)")) {
Call_File(103, "|(HOME)\|@(104)")
}
}
Num_Pop(103,103)
Reg_Pop(103,104)
Update



Christian

 


Topic: Re: Extension-Dependent Syntax Colors (10 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Wednesday, April 19, 2006 07:44 AM

On 4/19/2006 4:36:03 AM, Christian Ziemski wrote:

>What about a macro like the
>following?

Christian -

Thank you - I will experiment with it.

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (11 of 19), Read 37 times
Conf: Program develop.,Color syntax
From: Ted Green
Date: Wednesday, April 19, 2006 10:54 AM

At 02:32 AM 4/19/2006, you wrote:
>>I think the earlier responses to your
>>question did not address what you were
>>asking, which, I believe, is to have
>>different colours for different file
>>types/syntax files.
>
>After reading Dale's original posting I have to agree.
>I haven't read it carefully enough.

Yes, we all misread your original question. While VEDIT now supports separate .syn files for each buffer, it only has one global set of colors.

Therefore, even if you load a set of colors as part of a file-open config macro, it will only work if you have only one file open. As soon as you open another file, the first file's syntax colors will change. A complex macro using the Buffer-switch event macro (114) might provide a kludgey work-around, but I don't care to persue it.

Although I could make the colors buffer-dependent, I don't really care to as it would make configuration debugging even more complex.

Another "solution" might be to change the assignments of the "RESERVEDx =" keywords in the .syn files. These assignments determine which color is used to highlight each set of language elements. I would prefer to agree with the most commonly used IDE for each language.

Ted.

 


Topic: Re: Extension-Dependent Syntax Colors (12 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Christian Ziemski
Date: Wednesday, April 19, 2006 03:40 PM

On Wed, 19 Apr 2006 10:54:00 -0400, Ted Green wrote:

>As soon as you open another file, the first
>file's syntax colors will change. A complex macro using
>the Buffer-switch event macro (114) might provide a kludgey
>work-around, but I don't care to persue it.

Hey, I know that my little macro SETSYNCOLORS is only a workaround!

It never should be more than exactly that.
Even if there is no perfect solution I'm trying to help.


Christian

 


Topic: Re: Extension-Dependent Syntax Colors (13 of 19), Read 41 times
Conf: Program develop.,Color syntax
From: Ted Green
Date: Wednesday, April 19, 2006 05:10 PM

At 03:41 PM 4/19/2006, you wrote:
>Hey, I know that my little macro SETSYNCOLORS is only a workaround!
>
>It never should be more than exactly that.
>Even if there is no perfect solution I'm trying to help.

Christian:

I was not criticizing your macro, which is a nice workaround! :-)

I was just stating that a "real" solution appears to add too much complexity. Therefore your macro might be the "best" solution.

Ted.

 


Topic: Re: Extension-Dependent Syntax Colors (16 of 19), Read 37 times
Conf: Program develop.,Color syntax
From: Pauli Lindgren
Date: Thursday, April 20, 2006 10:49 AM

On 4/19/2006 10:54:01 AM, Ted Green wrote:
>
>Although I could make the colors buffer-dependent, I
>don't really care to as it would make configuration
>debugging even more complex.

Buffer-dependent colors have been in my wish-list long time.
I would like to be able to distinguish different file types with different colors (perhaps different window background color).

It is possible to change text and background color of a window with "View" -> "Color toggle", but that can not be used if syntax highlight is in use, since syntax colors do not change. And it doesn't seem to work with file type specific configuration either. (But the color of each open window is stored with project. I don't know how.)

Of course, different background colors would be more useful if the color palette could be changed. Then you could have e.g. many pastel colors for background and dark colors for text.

--
Pauli

 


Topic: Re: Extension-Dependent Syntax Colors (17 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Ted Green
Date: Thursday, April 20, 2006 11:01 AM

At 10:49 AM 4/20/2006, you wrote:
>Of course, different background colors would be more useful if the color palette could be changed. Then you could have e.g. many pastel colors for background and dark colors for text.

I plan to implement better color support in VEDIT after 6.2 is released.
I am thinking of simply implementing a new set of color config values to set the RGB value. I think this is simpler than a Palette; e.g. defining
what "Blue" is.
It would be trivial to make the new Config colors buffer dependent.

Ted.


Ted.
-------------------------------------------------------------------------
Ted Green (ted@...) Greenview Data, Inc.
Web: www.... Fax: 734-996-1308 PO Box 1586, Ann Arbor, MI 48106
Tel: (734) 996-1300 Desk: 734-369-3550 VEDIT - Text/Data/Binary Editor
-------------------------------------------------------------------------
www.SpamStopsHere.com ranked #1 in accuracy by Network Computing Magazine

 


Topic: Re: Extension-Dependent Syntax Colors (9 of 19), Read 37 times
Conf: Program develop.,Color syntax
From: Dale Cook
Date: Wednesday, April 19, 2006 07:43 AM

On 4/18/2006 7:43:27 PM, Ian Binnie wrote:

>I think the earlier responses to your
>question did not address what you were
>asking, which, I believe, is to have
>different colours for different file
>types/syntax files.

Ian -

That is exactly what I wanted.

>What you have done may appear to work if
>you only have one file type open, but if
>you have different types then you will
>get the same colours, based on the
>latest file opened.

It is working well enough, as I am edit INI files and HTML in different sessions.

>A better way to do what you have
>achieved would be to write a file open
>macro to change the colours.

I will explore those suggestions given later in this thread.

Dale H. Cook, Chief Engineer, Centennial Broadcasting, Roanoke/Lynchburg, VA - WZZI / WZZU / WLNI / WLEQ
http://members.cox.net/dalehcook/starcity.shtml

 


Topic: Re: Extension-Dependent Syntax Colors (14 of 19), Read 39 times
Conf: Program develop.,Color syntax
From: Pauli Lindgren
Date: Thursday, April 20, 2006 06:58 AM

On 4/19/2006 7:43:18 AM, Dale Cook wrote:
>
>
>It is working well enough, as I am edit
>INI files and HTML in different sessions.

In that case, the best solution is to use projects.
You can change colors and other settings, keyboard configuration, User and Tools menus etc. separately for each project. No need to do any kludges with file open event macros.

For example, I have separate projects for HTML, C programming, Basic programming, Vedit macros and text editing. Especially HTML project has quite different setup, with different keyboard configuration and different menus.

You can then just change the colors from Config menu or by using Color scheme macro, and the settings are saved with the project.

In addition, you can use my configuration preset macro to quickly set configuration for specific file type (e.g. when creating a new project).
http://koti.mbnet.fi/pkl/vedit/misc.htm#config
(BTW, I have now renamed the macro to presets.vdm, but I have not yet updated the web page.)
--
Pauli