How to add syntax color for Yab in Pe?

Hey, I’m writing a significant amount of code these days in YAB, and I’d like to add syntax colors to my code. I really like the simplicity of Pe and I like running my .yab files in Terminal. Is it just a script I can add to a lib folder somewhere?

How is this done? Thanks

It is done by writting a “Language” extension for Pe. Those are written in C++. You can see the code for all the currently available ones under this folder.

Notice that there’s a Sources dir (for the… mmm, source files, duh!), and a Resources one. The latter contains files with list of keywords that a language might recognize (those files can contain more than just keywords. listing global variable names, or functions from a given API, for example). Said files do nothing on their own though. You will need to write an extension.

Notice that for a given language, you’re likely to see two .cpp files… taking Lua as example… we have Lua_Language.cpp (that does the syntax-highlighting), and a Lua_Popup.cpp, that provides the “jump to function” / “open header/module/import” functionality. The latter is optional.

Some extensions are written using parser generators (bison/yacc). Others are hand-written. Which approach you use… depends on what you find easier, and on the complexity of the language your trying to add support for.

Many, many moons ago, seems I added the ASM, D, Lua, and Lout extensions, and did some work on the C/++ and Pascal ones. I’d probably forgot more than I ever knew about them.

I used to have a .zip file with some skeleton extension, but that was in the era where looking code online was more difficult than now.

I would suggests you to look for an existing extension that is the closest to what Yab looks like, and just start hacking :smiley:

EDIT: just in case, I uploaded my old “Pe Language AddOn Template”. The CLang_XxX.cpp file at least has lots of comments to help guide the process.

2 Likes

I suggest using Genio IDE, it has YAB support:

3 Likes

Genio sadly requires clangd. and that’s a big package to require for people that just want to use Genio with something other than C/C++. Other than that… yeah… Genio is pretty sweet! :slight_smile:

4 Likes

I’m learning C++ while I code in Yab, so possibly worth it for me. I use a dedicated Haiku machine (Thinkpad T480) so my harddrive is fairly empty at this point, nothing is emulated or virtualized.

On the note of using IDE over a text/script editor like Pe, I was going to use YAB-IDE, but I can’t seem to figure out how to change the font. The font is set at 12, and the font size selector is greyed out and I can’t figure out how to change that.

Koder on HaikuPorts is a native editor for Haiku that comes with a Yab syntax highlighter also. The fonts can be easily changed from the settings menu item.

2 Likes

Please make a bug report to our bug tracker, so we can take a look at this.

@lorglas we need to take a look at the output area, not all are displayed here.

yab website (besly) - yab forum (bbjimmy)

1 Like

Hi,

i greyed out the fontsize, because i have error with the lineheight and the linenumbers.

Regards lorglas

2 Likes