NOTICE: Since I have written this program several things has happen. I had suffered a major crash of my hard drive and my backups of programs I written in Gambas on a USB flash drive has been misplaced/lost. I am leaving this page up due to links may be pointing to it and I added some some other options a person may try.
Some options to highlighting code.
The following information remains as an archive
Gc2R (Gambas code To RichText) is a program that I written to convert Gambas Code to RichText (HTML syntax) I wanted a way to copy and past code into my OpenOffice and keep all the color formatting. Also I can save the results directly from the program as HTML so that I can display it in a browser. It is written in Gambas 2.19.
I have put several features into it such as
Bookmarks
Zoom up/down
Clipboard preview
Copy Special Dialog with preview
Auto Comment (For when you want to write blocks of commented lines. It will automatically comment the lines as you type them in.)
Comment Header This allows you to insert a stored block of comments at the beginning. Good for things like Who, Copyright, Disclaimer etc.
Code Editor Expand - This expands the Code Editor in size for more viewing area.
RichText Expand - This expands the RichText Editor in size for more viewing area.
Expand form to review more information on the code.
Navigation Toolbar. Has bookmarks, Top of Code button, Bottom of Code Button, Search, Jump to Line #, etc.
Has Keyboard shortcuts, both standard and custom. The custom key shortcuts will automatically insert custom code/text
Note this is strictly a Editor/RichText formater. It DOES NOT run/compile code.
Below are some screenshots of the program. You may see some minor changes as I worked on the program. For example in the first screenshot
there is no Redo button.
Below you can see it in the process formatting a copy of it's own code into RichText.
Form Expanded Mode
In Form Expanded Mode (image above) a columnlist is revealedl with a listing of each word/symbol that received it own highlight and the type (State) it is. When you
click on a line, the Code Editor is advanced to the proper location for that occurrence. Below the columview is the HTML Viewer which shows the HTML used for the
RichText Editor.
Formatting Gambas Code into RichText
Here is a HTML result of the code segment seen in the above example. Created by the Save to File Feature.
PUBLIC SUB Form_Activate()
'Check if there is Saved Header and Update Status
IF IsNull(Settings["Header/Text"]) THEN
Button32.Enabled = FALSE
Button32.Tag = "Insert Comment Header. NOTE:Header hasn't been created yet."
ELSE
Button32.Enabled = TRUE
Button32.Tag = "Insert Comment Header."
ENDIF
END
Here is the picture of it in Form Expanded Mode.
In the above example you can the Bookmarks feature. In the list is already a bookmark named Code Analyzer and another is being added by using a Inputbox.
When any bookmark is clicked, the Code Editor is advanced to that position.
The Bookmark "Code Analyzer" in the screenshot above is stored as a comment as:
'[Bookmark] Code Analyzer
Also on the other tab Procedures is a listbox of all the procedures (Subs, Functions etc.) When one is clicked the Code Editor is advanced to the beginning of the
procedure. (See next screenshot)
CodeEditor Expanded
In the above example you can see the Code Editor in Expanded mode. Note if the Bookmark view is active, it is expanded in height alone with the Code Editor.
Also you can see that whenever you hover over a button, the info on that button is displayed in the Status bar at the bottom of the screen. In this case, the
cursor is hovering over the Code Editor Expand/Contract Toggle Button.
There is also a similar button on the RichText toolbar that will expand the RichText Editor the same manner as the Code Editor.
Key Shortcuts and Header
In the above screenshot you can see my Shortcuts window. This window,
Shortcuts tab: Displays shortcuts available in Code Editor, RichText Editor, and program. For example Ctrl+C = Copy and Ctrl+F4 = Quit Program.
Auto Insert tab: This allows you to customize keys to Auto Insert text into the Code Editor. In the above screenshot you can see that ALT+C would insert the
text Copyrighted By Ongytenes 2013
Header tab: This is where you can build a Comment Header to insert in the start of a new project. It can be set to auto insert or be inserted with a click of a
button. The Header is intended to hold information ranging from anything like who/what, copyright, disclaimer etc.
Paste Special Dialog
I custom made my idea of a Paste Special Dialog which you can see in the above screenshot. I wanted to use buttons instead of Radiobuttons. In this way the user
can select text he wants to change, click Enclose within Quotes "" to enclose the lines he selected with quotes. Then he follow that by clicking on Insert PRINT
to put the keyword PRINT before all the lines he Quoted .
In the above example I am showing how you can insert a before & after custom insert. In the Special Text 1 I had placed ' ### and in the Special Text 2 I put
<--Check. When I clicked the Enclose with Special Text 1 & 2 button, every line selected got ' ### at the first of the line and <--Check at the end of the line.
Also I had incorporated the Include HTML tags checkbox. if the text in the clipboard is RichText (text/html) then the HTML tags will be displayed
in the window. This is so the user can paste HTML in. He can comment out the HTML before pasting to prevent it being misinterpreted by the Code Editor.
This could come in handy when working with a object like a TextLabel or a TextEdit.
Drag & Drop
Gc2R now supports Drag & Drop. The user can drag and drop code snippits directly from a web page into the Code Editor. He can also drag a file from his File Browser and drop it onto the Code Editor. In this case he should get the above pop-up asking him what he wants to do.