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?
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
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!
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.