Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

LexAHK: syntax highlighting for Scintilla (SciTE, others?)


  • Please log in to reply
65 replies to this topic
BoBo
  • Guests
  • Last active:
  • Joined: --
PhilHo wrote:

Perhaps using a Notepad2 base: small*, a bit rustic (tried it only briefly!) although friendlier than SciTE, open source, so not too hard to adapt

Exactly what I've wanted to point out. Thx for your confirmation. :D

* a single executable

BoBo
  • Guests
  • Last active:
  • Joined: --
In case someone is able to deal with implementing PhilHo's lexer:

Could you please explain how to add or modify syntax schemes?

This requires modification of the Notepad2 source code.

The Scintilla documentation has an overview of syntax highlighting, and how to write your own lexer, in case the language you'd like to add is not supported by Scintilla.

The structures relevant to syntax highlighting can be found in Styles.c of the Notepad2 source code. Add your own structures to the global pLexArray, then adjust NUMLEXERS to the total number of syntax schemes. The style definitions can be found in SciLexer.h of the Scintilla source code.

Include the Lex*.cxx files from Scintilla required for your languages in your project and follow the instructions in Readme.txt to rebuild Notepad2. I recommend using Visual Studio .NET 7 or above.

[Notepad2 1.0.12 Source Code]



PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

It will be very helpful to the community if you can

[*:ngx3iw2k]Recompile Notepad++ to automatically support AHK Syntax Highlighting
[*:ngx3iw2k]Provide a download in .ZIP format ( requiring no installation )
[*:ngx3iw2k].REG files to associate Notepad++ to be the default editor for AHK

Notepad++ uses regular SciLexer.dll, so replacing the provided one with mine and replacing two XML files should do the trick (once I finished doing that). No need for recompiling it. That's Notepad2 which needs recompiling. And I won't do it, I prefer to spend my scarce free time to improve the lexer (and do other projects).
[EDIT] My bad, both need recompiling, see below!
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

Notepad++ uses regular SciLexer.dll, so replacing the provided one with mine and replacing two XML files should do the trick (once I finished doing that). No need for recompiling it.


And will that add AHK to the Languages Menu? :shock:

Posted Image

Thanks!. Awaiting eagerly :D

Regards, :)
kWo4Lk1.png

BoBo
  • Guests
  • Last active:
  • Joined: --

That's Notepad2 which needs recompiling. And I won't do it, I prefer to spend my scare free time to improve the lexer (and do other projects).

Fair enough :wink:

(Scare free time or spare free time - that's the question! (Hamlet) :))

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

(Scare free time or spare free time - that's the question! (Hamlet) :))


I guess it should have been "Scarce free time" :)

Regards, :)
kWo4Lk1.png

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Ehe, a c has been lost, indeed!

I made a sad discovery, Goyyah was right, Notepad++ needs to be recompiled too.
While the stylers.xml and langs.xml files looked like the program was flexible, looking in the sources to see why I didn't saw AutoHotkey in the language menu (as shown by Goyyah), I saw that author, for some reason, hard-coded the language lists in several places!
I don't understand this choice that forbid using less common languages already supported by Scintilla. Being more flexible wouldn't cost probably much. Of course, replacing its SciLexer.dll by a standard or customized one might break some features (perhaps the line draw mode, perhaps the user defined one) and would bloat it (since this is a subset of languages, it is smaller than standard one). But I am still disappointed.

Well, perhaps you can petition the author:
1) To be more flexible;
2) (more likely) To support AHK.
I still have the above XML files, in case they become useful someday.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

Well, perhaps you can petition the author:
1) To be more flexible;
2) (more likely) To support AHK.
I still have the above XML files, in case they become useful someday.


:( :cry: :(

As BoBo requested, maybe someday you should re-compile Notepad2 atleast.

Regards, :)
kWo4Lk1.png

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
First update, see first post to see what is changed: various bug fixes, functionnal folding.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

As BoBo requested, maybe someday you should re-compile Notepad2 atleast.

Not me, sorry.
I downloaded the source of Notepad2, out of curiosity, and I saw it is even worse (read: less flexible) than Notepad++, in the sense that keywords and styles are hard-coded in the source code, so it seems very hard to alter them (style are overridable, but I saw no way to add or change keywords).

Again, I won't do it, but it shouldn't be such a hard task to upgrade these editors.

For Notepad++, I wrote a message in their forum, asking for more flexibility or perhaps future AHK support.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

BoBo
  • Guests
  • Last active:
  • Joined: --
@ PhiLho
I'm fine with that and I really appreciate your effort to provide an AHK lexer. Thx mate. :D

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

For Notepad++, I wrote a message in their forum, asking for more flexibility or perhaps future AHK support.


I have sub-posted : <!-- m -->http://sourceforge.n...?msg_id=3722727<!-- m -->

Anybody else willing?

Regards, :)
kWo4Lk1.png

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
@PhiLho: Nice work on the lexer :)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Dear PhiLho, :)

In your post

Well, perhaps you can petition the author:
1) To be more flexible;
2) (more likely) To support AHK.
I still have the above XML files, in case they become useful someday


I do not how but AHK shows in the bottom of the "Languages Menu"

Posted Image

Can I have a copy of those XML Files.. Please!

Regards, :)
kWo4Lk1.png

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
They are stylers.xml and langs.xml, with only the AHK definitions, ie. they have to be merged in the existing files.

But I think you only created a User Defined language, and you already have the corresponding syntax files in %A_AhkPath%\Extras\Editors\Notepad++\
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")