You are here: PSPad forum > English discussion forum > setSyntax "C + +", "vbs" etc.

setSyntax "C + +", "vbs" etc.

#1 setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 12/13/2011 18:38 | IP: IP Logged

Hi!

If the ability to write PSpad that when you click on the key combination will change the syntax highlighting.

For example opened the *.vbs press "CTRL +1" and the syntax highlighting was the same as for C++.

That is, analog runPSPadAction "aSyntaxChange", but without a dialog box. That is, syntax highlighting should be changed immediately.

That is, need a function in the likeness of setSyntax "C++"

Thanks in advance!

Ivan

Options: Reply | Quote | Up ^


#2 Re: setSyntax "C + +", "vbs" etc.

Posted by: pspad | Date: 12/14/2011 22:57 | IP: IP Logged

There is editor script function Highlighter:

highlighter([s: string]): string
returns/set highlighter for editor

Edited 1 time(s). Last edit at 12/14/2011 22:57 by pspad.

Options: Reply | Quote | Up ^


#3 Re: setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 12/16/2011 11:33 | IP: IP Logged

Thank you very much!smiling smiley

Options: Reply | Quote | Up ^


#4 Re: setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 03/26/2012 22:15 | IP: IP Logged

Dear, pspad

highlighter for some reason doesn't work sad smiley


Const module_name = "Row To Block"
Const module_ver = "2.00"

Sub Init
menuName = "&TLUPS"
addMenuItem "&Format Row To Block", menuName, "FormatRowToBlock", "CTRL+F3"
End Sub

Sub FormatRowToBlock
Set ed = newEditor()
ed.assignActiveEditor

ed.openFile("D:\MyProgramm\PSPad editor\Script\svn_xml.h")
ss = ed.highlighter

ed.openFile("D:\MyProgramm\PSPad editor\Script\VBScript\ListTransform.vbs")
ed.highlighter(ss)
ss2 = ed.highlighter
echo ss2

End Sub

echo out С\С++, but the highlighter remained "MS VBscript"

Prompt, why highlighter didn't change?
What it is possible to make?
Please help!
sad smiley

Options: Reply | Quote | Up ^


#5 Re: setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 03/26/2012 22:40 | IP: IP Logged

...
Addition helped at the end:

runPSPadAction("aSyntax")
runPSPadAction("aSyntax")

Const module_name = "Row To Block"
Const module_ver = "2.00"

Sub Init
menuName = "&TLUPS"
addMenuItem "&Format Row To Block", menuName, "FormatRowToBlock", "CTRL+F3"
End Sub

Sub FormatRowToBlock
Set ed = newEditor()
ed.assignActiveEditor

ed.openFile("D:\MyProgramm\PSPad editor\Script\svn_xml.h")
ss = ed.highlighter

ed.openFile("D:\MyProgramm\PSPad editor\Script\VBScript\ListTransform.vbs")
ed.highlighter(ss)
ss2 = ed.highlighter

runPSPadAction("aSyntax")
runPSPadAction("aSyntax")
echo ss2

End Sub

But this decision isn't "beautiful"

Options: Reply | Quote | Up ^


#6 Re: setSyntax "C + +", "vbs" etc.

Posted by: pspad | Date: 03/26/2012 22:53 | IP: IP Logged

I still don't understand, what you want to do.

Try this:

Sub Init
menuName = "&TLUPS"
addMenuItem "&Format Row To Block", menuName, "FormatRowToBlock", "CTRL+F3"
End Sub

Sub FormatRowToBlock
Set ed = newEditor()
ed.openFile("D:\MyProgramm\PSPad editor\Script\svn_xml.h")
ed.Highlighter("C")
Set ed = newEditor()
ed.openFile("D:\MyProgramm\PSPad editor\Script\VBScript\ListTransform.vbs")
ed.highlighter("MS VBScript")
End Sub

Options: Reply | Quote | Up ^


#7 Re: setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 03/27/2012 19:16 | IP: IP Logged

What sense to set highlighter "MS Script" for the file with ".vbs" extension, after all it and so it is by default exposed in "MS Script"?

My purpose just to make highlighter of "C" for files with ".vbs" extension.

But after execution of this code it all the same "MS Script" highlighter:

Set ed = newEditor()
ed.openFile("D:\MyProgramm\PSPad editor\Script\VBScript\ListTransform.vbs")
ed.Highlighter("C")

I also noted that after "Ctrl+R" clicking highlighter to become "С/С++". This that that I want.

I suppose that

runPSPadAction("aSyntax")
runPSPadAction("aSyntax")

does the same as "Ctrl+R".

That is highlighter is exposed, but for some reason isn't displayed. Most likely there is no screen refresh. In it my problem consists.

Quote:
I still don't understand, what you want to do.

At me files have no extensions.
I want to make so after clicking of the button one of my files opened and, in the user highlighter (it is called at me as "MyBasiInfo") necessary to me.

Edited 2 time(s). Last edit at 03/27/2012 19:20 by gangstervano.

Options: Reply | Quote | Up ^


#8 Re: setSyntax "C + +", "vbs" etc.

Posted by: pspad | Date: 03/27/2012 19:47 | IP: IP Logged

VBS = Visual basic script and the best highlighter for it is MS VBScript.

If you want to use C++ highlighter for all .VBS files, remove extension *.vbs from MS VBScript highlighter and add it to C++ highlighter in menu Settings / Highlighter settings

Example I provided you worked for me and changed highlighter as I need it.

Options: Reply | Quote | Up ^


#9 Re: setSyntax "C + +", "vbs" etc.

Posted by: gangstervano | Date: 03/27/2012 20:24 | IP: IP Logged

Quote:
VBS = Visual basic script and the best highlighter for it is MS VBScript.

Ok. But it not my main goal and an artificial example created for facilitation of understanding of my problem.

Quote:
If you want to use C++ highlighter for all .VBS files, remove extension *.vbs from MS VBScript highlighter and add it to C++ highlighter in menu Settings / Highlighter settings

I achieve not it. It is only simplified example, for understanding of a problem. Besides highlighter for files with ".vbs" extension as is necessary for saving. All changes shall concerns only my new script. All remaining shall work as earlier.

At me files have no extensions. I want to make so after push of the button (CTRL+F3) one of my files opened and, in the user highlighter (it is called at me as "MyBasiInfo") necessary to me.

Quote:
Example I provided you worked for me and changed highlighter as I need it.

In the version "4.5.7 (2441) English" really everything works as it is necessary. Before I used version 4.5.6 (2427) which to be in the section download.
Most likely above the specified problems were connected to it.

I am sorry for that that couldn't describe a problem in more detail directly.

Nevertheless the problem is decided smiling smiley.

Once again many thanks for the sincere, highly qualified help and prompt replies.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2014 Jan Fiala
Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák