[Gambas-user] About syntax highlighting and copy/paste to OpenOffice

Ongytenes ongytenes at ...626...
Fri Feb 1 04:08:03 CET 2013


Demosthenes Koptsis <demosthenesk <at> gmail.com> writes:

> 
> These days i tried some ways to make the Gambas3 code in an OO3 document
> be highlighted as in Gambas3 editor.
> 
> 1) For this, i used many online web syntax highlighters such as
> http://pygments.org/
> http://pastebin.com/
> http://qbnz.com/highlighter/
> 
> but when i copy the code from webpage OO does not make it "Paste
> Special" in document, i dont know why...! 
> 
> 2) also i found an addon for OO named COOoder
> the old page is 
> http://extensions.services.openoffice.org/node/940
> 
> but has no gambas support and the developer has no plans for any update
> recently.
> 
> Although the COOoder addon is easily configurable.
> Someone can take the GeSHi gambas.php file and feed it at cli to script 
> 
http://cgit.freedesktop.org/libreoffice/build/tree/extensions/coooder/php/from-
geshi.php
> 
> this will make a gambas.xml file which is the highlight for COOoder
> addon.
> 
> (i edited the GeSHi gambas.php to gambas3.php for anyone who want it,
> although it is not complete yet)
> 
> The gambas.xml then must be copied to path
> 
/home/user/.openoffice.org/3/user/uno_packages/cache/uno_packages/o36C8H_/cooode
r-1.1.2.oxt/config/org/openoffice/langs
> 
> or similar... where OO addons exist.
> 
> But unfortunately the COOoder may be has a bug.
> When reach a line with gambas3 comment stops the process of
> highlighting. (see screenshot)
> 
> i sent an email to COOoder writer and i hope to help me or to fix the
> bug.
> 
> -----------
> 
> Do you know any other way to make highlight the code in OO for gambas
> code?
> 
> Is it possible when i copy the code from gambas editor to keep meta-data
> for OO, so i can make a "Paste Special" ?  
> 
> of course the simple paste must keep use raw text.  
> 

I have written a program in Gambas2 that will format and copy the syntax to 
the clipboard. It pastes color correct into OpenOffice. You can see a 
screenshot of the program at:  
https://sites.google.com/site/ongytenes/files/GambasParser_Screenshot1.jpg and 
https://sites.google.com/site/ongytenes/files/GambasParser_Screenshot2.jpg

I am planning on releasing it as opensource and under the creative commons 
license. The first screenshot shows the program in front of OpenOffice with
the pasted results. The second shows the program in expanded mode where it 
shows more information. It currently has one bug that I know about. If you 
indent the code, it cascades the colors. I have written this in only a few 
hours today. I believe the bug is due to how the HTML leading spaces are
deleted. If the code isn't indented, it pastes correctly and
you can indent the code after it been pasted into OpenOffice.
It works by parsing and converting the code into HTML to be copied.

After writing a tutorial on a how to create and link a object array, I was
frustrated the time it took to go through and color-code all the syntax. 
So I decided to look for something last night and after seeing this forum
I decided to write something.





More information about the User mailing list