Topic: no syntax highlighting, uniform template editing (1 of 9), Read 44 times
Conf: Installation, Configuration
From: Bernd Richert
Date: Wednesday, January 05, 2005 11:03 AM

May be someone is interested in getting the same.

I don't like syntax highlighting and extension specific template editing, but I like uniform template editing.

My solution is, adding..
regSet(115,`//enable uniform template editing for all files
Config(PG_E_TEMPLAT,1,LOCAL)
Config(PG_E_SYNTAX,0)
Config_String(VTM_Name,"general.vtm",LOCAL)
`)
..to startup.vdm, and adding file general.vdm to the Vedit installation directory. The example 'general.vdm' does automatically indent/undent on '{'/'}'.
Unfortunately the template macro is not called after [RETURN], so the indent function can not be done before the first character is entered into the line following the "{".

?? Is there some method to directly react on [RETURN]?

The example 'general.vtm' is listed below.

Regards
Bernd


---------------------------------
//
// general.vtm - general template-editing macro.
//
// Due to
// regSet(115,`//enable uniform template editing for all files
// Config(PG_E_TEMPLAT,1,LOCAL)
// Config(PG_E_SYNTAX,0)
// Config_String(VTM_Name,"general.vtm",LOCAL)
// `)
// .. in startup.vdm, this macro will be activated for each opened file.
//
// Function:
// - indent current line, if
// ("{" is at the end of the previous line) and
// (the indentation level of the current line is the same as that of the previous line)
// and (a non-white character is entered at that indentation level)
// - undent current line, if
// ("}" is eneterd at the indentation level of the current line)
//


#107 = curPos
if (!atBof & curChar(-1) == 125) { // 125 is '}'
// check for undent current line
char(-1)
if (curCol > 1 & searchBlock('|!|B', bolPos, curPos, BEGIN+NOERR) == 0 ) {
doVisual('\ME\EFU')
char
} else {
gotoPos(#107)
}
return;
}
// check for indentation of current line
#108 = curCol-1
gotoPos(bolPos)
if (curPos != #107 & curPos >= 1+newlineChars) {
char(-newlineChars)
if (curChar(-1) == 123 & match('|N') == 0) { // 123 is '{'
gotoPos(bolPos)
match ('|B', ALL+ADVANCE)
if (curCol == #108) {
line(1)
match ('|B', ALL+ADVANCE)
if (curCol == #108) {
doVisual('\ME\EFI')
char
return
}
}
}
}
gotoPos(#107)
return

 


Topic: Re: no syntax highlighting, uniform template editing (2 of 9), Read 38 times
Conf: Installation, Configuration
From: Ted Green
Date: Wednesday, January 05, 2005 11:38 AM

At 06:03 AM 1/5/2005, you wrote:
>May be someone is interested in getting the same.
>
>I don't like syntax highlighting and extension specific template editing, but I like uniform template editing.

I agree that the current "template editing" is not very useful; I don't use it myself. I would very much like to add "smart" indenting to VEDIT, similar to how Visual Studio works when you edit C code. If we can together write such as macro, I will fully integrate it into VEDIT's code. It would happily add some menu functions and config values as necessary to accommodate different languages and indenting styles.

(Sorry, but I don't have time today to check Berndt's macro.)

Ted.

 


Topic: Re: no syntax highlighting, uniform template editing (3 of 9), Read 36 times
Conf: Installation, Configuration
From: Ian Binnie
Date: Wednesday, January 05, 2005 09:09 PM

On 1/5/2005 11:38:16 AM, Ted Green wrote:
>I agree that the current
>"template editing" is not very
>useful; I don't use it myself.
>I would very much like to add
>"smart" indenting to VEDIT,
>similar to how Visual Studio
>works when you edit C code. If
>we can together write such as
>macro, I will fully integrate
>it into VEDIT's code. It would
>happily add some menu
>functions and config values as
>necessary to accommodate
>different languages and
>indenting styles.
>
Ted,

I use Vedit almost exclusively for editing code from Visual Studio.

I rarely bother to try and format as I write, either C or vdm, because I have my C & Vedit formatting macros in my Tools menu, which I run frequently.

It might be interesting to try & write an automatic formatting macro.

On those rare occasions when I enter code directly into Visual Studio I don't find it formats well, although the Alt F8 works well.

 


Topic: Re: no syntax highlighting, uniform template editing (4 of 9), Read 35 times
Conf: Installation, Configuration
From: Ted Green
Date: Wednesday, January 05, 2005 09:33 PM

At 04:09 PM 1/5/2005, you wrote:
>I rarely bother to try and format as I write, either C or vdm, because I have my C & Vedit formatting macros in my Tools menu, which I run frequently.

Ian, perhaps you could share those formatting macros with us again. I have forgotten about them.

>On those rare occasions when I enter code directly into Visual Studio I don't find it formats well, although the Alt F8 works well.

Hmm, I'm actually impressed with how well Visual Studio formats; maybe because I know how complex that algorithm must be.

Do you think your macros are similar to the Alt-F8 function ("Edit->Advanced->Format selecton") in Visual Studio?

Ted.

 


Topic: Re: no syntax highlighting, uniform template editing (6 of 9), Read 45 times
Conf: Installation, Configuration
From: Ian Binnie
Date: Thursday, January 06, 2005 06:12 PM

On 1/5/2005 9:33:05 PM, Ted Green wrote:
>At 04:09 PM 1/5/2005, you
>wrote:
>>I rarely bother to try and format as I write, either C or vdm, because I have my C & Vedit formatting macros in my Tools menu, which I run frequently.

>Ian, perhaps you could share
>those formatting macros with
>us again. I have forgotten
>about them.

They are on my web page:-
http://members.optusnet.com.au/~ibinnie/Ian/Downloads/download.html

>On those rare occasions when I enter code directly into Visual Studio I don't find it formats well, although the Alt F8 works well.
>
>Hmm, I'm actually impressed
>with how well Visual Studio
>formats; maybe because I know
>how complex that algorithm
>must be.
>
>Do you think your macros are
>similar to the Alt-F8 function
>("Edit->Advanced->Format
>selecton") in Visual Studio?

I think they work as well.
The major difference is that I only support one style of formatting.

 


Topic: Re: no syntax highlighting, uniform template editing (5 of 9), Read 37 times
Conf: Installation, Configuration
From: Bernd Richert
Date: Thursday, January 06, 2005 04:16 AM

Ted,

currently every template macro trigger can be ^Q-escaped.
[RETURN] cannot be escaped that way
(Enter can be escaped but then it does not produce a [RETURN]).

I therefore changed my mind on making [RETURN] a template macro trigger.
If one is consequent, I think, its better to stay with the principle that
template macro triggers can be ^Q-escaped.
This would consequently mean that smart indentation, as with Visual Studio,
can not be implemented in a template macro.

And it would be somewhat too complicated for a macro, I think:
- It is easy to react on braces.
- A macro could skip comments. Although this does already come up with
considerable expense, if you regard comment beginners/terminators within
strings.
- A macro could handle indentation for single conditional statements
(match parenthesis and check for 'if'/'else'/'while'.. in front of '(').
- But I am in doubt whether undenting after a single conditional statement
can be done with tolerable expense. This would include backskipping ANY
single statement and checking whether the user has overridden the proposed
indentation of the single conditional statement.
And finally, this could get recursive - consider:
…………if (a)
…………if (b)
……………………if (c,
………………………continued)
………………………………statement, statement;
………………………………now undent!

I would be worried about solving that by a macro.


To sum up, I think if one likes to have some indent/undent support, one can
live with a solution like that I have introduced in my posting above
(just replace 'gotoPos(bolPos)' by beginOfLine).


Regards
Bernd

 


Topic: Re: no syntax highlighting, uniform template editi (7 of 9), Read 35 times
Conf: Installation, Configuration
From: Pauli Lindgren
Date: Thursday, January 13, 2005 01:30 PM

On 1/5/2005 11:38:16 AM, Ted Green wrote:
>
>I agree that the current "template editing" is not very
>useful; I don't use it myself.
>I would very much like to add "smart" indenting to VEDIT,
>similar to how Visual Studio works when you edit C code. If
>we can together write such as macro, I will fully integrate
>it into VEDIT's code. It would happily add some menu
>functions and config values as necessary to accommodate
>different languages and indenting styles.

Yes, the template editing that comes with Vedit is not very useful. That is why I created my own template editing macro, C123.VTM. I think it is very useful, and I use it all the time.

I have also made a smart indent macro (C_INDENT.VDM). With it, you can re-indent a single line or a highlighted block.

Both of the above support different formats which can be easily selected with macro C_SETUP.VDM. All these are included in my C_Tools package:
http://koti.mbnet.fi/pkl/vedit/c_tools.htm#c_indent

I just noticed that I have not updated this to the latest version. The current version I am using has an additional configuration option to select whether or not case line is indented. Hopefully I can update it in near future.

I have been thinking of modifying C_INDENT.VDM slightly so that it would work on TAB key as in Emacs, or on Return key.
This could be done with keyboard configuration instead of template macro. But it is not possible to configure Tab or Return key, or is it?

--
Pauli

 


Topic: Re: no syntax highlighting, uniform template editi (8 of 9), Read 42 times
Conf: Installation, Configuration
From: Ted Green
Date: Friday, January 14, 2005 01:06 PM

At 01:31 PM 1/13/2005, you wrote:
I have been thinking of modifying C_INDENT.VDM slightly so that it would work on TAB key as in Emacs, or on Return key.
>This could be done with keyboard configuration instead of template macro. But it is not possible to configure Tab or Return key, or is it?

While re-formatting of a block is certainly useful, my goal is on-the-fly formatting as you type. Primarily this requires setting the correct indentation after hitting . The "template editing event macro" can check if was pressed. I can even implement a "Return event macro" if that would help.

Pauli: The Windows version does not fully support configuring the Return, Tab, Esc or F1 keys.

Ted.

 


Topic: Re: no syntax highlighting, uniform template editi (9 of 9), Read 40 times
Conf: Installation, Configuration
From: Pauli Lindgren
Date: Friday, January 14, 2005 12:20 PM

On 1/13/2005 2:12:59 PM, Ted Green wrote:
>
>
>Pauli: The Windows version
>does not fully support
>configuring the , ,
>or keys.

The names of the keys are not visible when reading your messages in WebBoard.

Anyway, maybe the template event macro is still better than configuring keyboard, since template macro can be changed by the file type. So, the template macro should be able to check if TAB or Return has been pressed.

--
Pauli