Highlight Gcode in Gedit

cnc-club.ru for English speaking users
Аватара пользователя
Nick
Мастер
Сообщения: 22776
Зарегистрирован: 23 ноя 2009, 16:45
Репутация: 1735
Заслуга: Developer
Откуда: Gatchina, Saint-Petersburg distr., Russia
Контактная информация:

Highlight Gcode in Gedit

Сообщение Nick »

Despite it's simplicity Gedit (it's default "Notepad" for Gnome for Linux) has a lot of useful functions. One of them is syntax highlighting for different programing languages, scripts, htlm, xml, etc. By default Gedit supports about 100 different languages but unfortunately Gcode not in that list. So I've decided to write Gcode syntax highlighting for Gedit.

Here's how it's look like using "Oblivion" color scheme:
0079 gedit gcode hightlight.png (21373 просмотра) <a class='original' href='./download/file.php?id=619&sid=fbb5a78e39f2b3db0deb94352aa1399c&mode=view' target=_blank>Загрузить оригинал (161.19 КБ)</a>

How to get your Gedit highlight the Gcode
and make your own Gcode viewer

  1. Download this file:
    gcode.lang
    (7.31 КБ) 2459 скачиваний
  2. Save it into "/usr/share/gtksourceview-2.0/language-specs/". Restart Gedit if it needed.
  3. If you want to st up color scheme same to my do the following Edit->Preferences->Fonts & Colors and select "Oblivion".
PS Just before I've finished my gcdoe.lang I've found almost the same one at wiki.linuxcnc.org. But there some major differences.
My version differentiates different G and M codes for example coolant M codes M7, M8 and M9 are drawn in blue, start / stop M codes are on red background. Also some spindle and feed parameters which can appear inside the line with G code are drawn in green so they become more visible.


Hope there wont be any bugs/mistakes but if you've found one do not hesitate to report it ;) .
James628
Новичок
Сообщения: 28
Зарегистрирован: 19 июн 2012, 19:55
Репутация: 0
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение James628 »

Hi Nick,


I installed the Gedit G-code highlight file, it's much better than I had previously, but still there are some small issues. Especially with the named parameters.
What can be the problem?

Изображение

Thanks for your support in advance.

James
Аватара пользователя
Nick
Мастер
Сообщения: 22776
Зарегистрирован: 23 ноя 2009, 16:45
Репутация: 1735
Заслуга: Developer
Откуда: Gatchina, Saint-Petersburg distr., Russia
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение Nick »

hmmmm... probably it's because "-" not in the variable pattern

line 68. <match>#([0-9]+|<[a-zA-Z_0-9\-]+>)</match>

Fixed version is in the header.
James628
Новичок
Сообщения: 28
Зарегистрирован: 19 июн 2012, 19:55
Репутация: 0
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение James628 »

Hi Nick,

Thanks a lot!!
That was very quick.

Now only one item left: comments after semicolon are too colorful yet ;)
As in the screenshot above

James
Аватара пользователя
Nick
Мастер
Сообщения: 22776
Зарегистрирован: 23 ноя 2009, 16:45
Репутация: 1735
Заслуга: Developer
Откуда: Gatchina, Saint-Petersburg distr., Russia
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение Nick »

Do I get it right - everything after semicolon till the end of line is a comment?
Аватара пользователя
Nick
Мастер
Сообщения: 22776
Зарегистрирован: 23 ноя 2009, 16:45
Репутация: 1735
Заслуга: Developer
Откуда: Gatchina, Saint-Petersburg distr., Russia
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение Nick »

Fixed. See updated file in the header.

PS Thanks for the bug report! :)
James628
Новичок
Сообщения: 28
Зарегистрирован: 19 июн 2012, 19:55
Репутация: 0
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение James628 »

Hi Nick,

Thanks for the fix.
I am wondering how much excellent information can be found on this forum.. very good job...
Аватара пользователя
Nick
Мастер
Сообщения: 22776
Зарегистрирован: 23 ноя 2009, 16:45
Репутация: 1735
Заслуга: Developer
Откуда: Gatchina, Saint-Petersburg distr., Russia
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение Nick »

James628 писал(а):I am wondering how much excellent information can be found on this forum.. very good job...
Not so much in English, there's much more info in Russian, but it is much more difficult to find something in that mess :freak:
James628
Новичок
Сообщения: 28
Зарегистрирован: 19 июн 2012, 19:55
Репутация: 0
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение James628 »

Sure, mainly I meant here the Russian language content. Google translation is quite usable.
Although I learnt almost ten years Russian language, but I hardly can remember anything.
anmol77
Новичок
Сообщения: 1
Зарегистрирован: 11 май 2016, 14:01
Репутация: 0
Настоящее имя: JALWA ANMOL
Контактная информация:

Re: Highlight Gcode in Gedit

Сообщение anmol77 »

Some spindle and feed parameters which can appear inside the line with G code are drawn in green so they become more visible.
Ответить

Вернуться в «English forum»