Page 1 of 1

Syntax highlighting for gedit

Posted: Tue Jan 31, 2012 9:21 am
by untitled.bmp
I've been surprised that no one yet implemented syntax highlighting of CFDG files for gedit.
So here it is:
cfdg.lang.zip
(1.74 KiB) Downloaded 1271 times
To install just extract archive to ~/.local/share/gtksourceview-3.0/language-specs directory.
Adapted for Context Free 3 and gedit 3.

If you have any remarks and suggestions, I'll be glad to hear them.

As a bonus, here are the simple script to make contextfreeing in gedit easier:

Code: Select all

#!/bin/bash

viewer="eog"
size="700"

cfdg_file="$GEDIT_CURRENT_DOCUMENT_PATH"
png_file="$GEDIT_CURRENT_DOCUMENT_DIR/`basename "$GEDIT_CURRENT_DOCUMENT_NAME" .cfdg`.png"

cfdg "$cfdg_file" "$png_file" -w $size -h $size && $viewer "$png_file"
To use it, choose Tools > Manage External Tools in the menu, click little "+" button and copy-paste this script in the field to the right. Then click "Shortcut Key" field, and press some key combination, for example CTRL+R. When you press it again after closing configuration window, your currently opened file will be rendered by cfdg and result presented to you.

Re: Syntax highlighting for gedit

Posted: Thu Mar 14, 2019 2:39 pm
by hatep
Thanks for the file.
Being on Mint 17, I had to extract it in folder /usr/share/gtksourceview-2.0/language-specs
I had an error on my computer when parsing that file, but commented lines 158 through 160, and it works like a charm now:

Code: Select all

...
    <context id="cfdg" class="no-spell-check">
      <include>
       <!--  <context ref="def:c-like-comment"/>
        <context ref="def:c-like-comment-multiline"/>
        <context ref="def:c-like-close-comment-outside-comment"/>  -->
        <context ref="numbers"/>
        ...