Skip to content

Syntax highlighting and other Ace features

Marco Dickert edited this page Mar 28, 2018 · 1 revision

The IFM uses a very basic variant of the Ace editor, because it shouldn't contain unneccessary stuff by default to prevent it from becoming a bloatware. But for some people it would be very nice to have things like syntax highlighting etc., so I added the ability to bundle these Ace features with the IFM.

To include Ace features, you have to get them from the Ace build repository, which can be cloned from Github. Now choose the components from the src-min-noconflict directory and copy it to your local ifm/src/includes/ace directory. Afterwards you have to recompile the script. On Linux you could do it like this:

$ git clone https://github.com/ajaxorg/ace-builds.git /tmp/ace-builds
$ git clone https://github.com/misterunknown/ifm.git /tmp/ifm
$ cd /tmp/ifm
$ cp /tmp/ace-builds/src-min-noconflict/ext-modelist.js src/includes/ace/
$ cp /tmp/ace-builds/src-min-noconflict/mode-{html,perl,php,javascript}.js src/includes/ace/
$ php ./compiler.php --languages=en

With this, you would include the modelist extension (which is necessary for automatic syntax detection), and syntax highlighting for HTML, Perl, PHP and Javascript. The compiler builds a new ifm.php which you can copy to your destination. (Note: You have to have the PHP CLI installed, as the compiler is written in PHP).

The recompiled ifm.php includes a new select box in the editor options where you can choose the desired syntax highlighting. As I said, if you include the modelist extension, the IFM will guess the syntax based on the file extension. The src/includes/ace directory is not tracked by git, so it's no problem to update the IFM, while keeping your custom extensions, modes and themes.