gbSnippets is a freeware program which provides an extremely easy-to-use method of storing and searching single and multi-line text data. In addition, it provides special features which make it useful as a source code librarian and programmers editor. Only these special features are covered on this page.
Overview Enabling Programmers Features Language Support Programmers Menu |
Context Menu Toolbar Special Commands Download Files |
gbSnippets makes no effort to compete with the leading Programmer's Editors. It does, however, try to provide enough editing features that programmers will feel comfortable in editing their source code within gbSnippets, before transferring the snippets to the language IDE.
Programmers Editor
gbSnippets contains a general purpose source code editor which provide syntax
highlighting of keywords, comments, and strings. While not intended to be a
replacement for the major programmers editors, gbSnippets nonetheless provides
reasonable support for editing and displaying source code.
The editor provides other special features for programmers, such as batch indentation, line commenting, compilable template insertions, optional keyword case display (upper/lower/mixed/as typed) and insertion of a snippet directly into the language IDE.
gbSnippets also offers a dialog for comparing two snippets for differences - a side-by-side comparison of two blocks of code.
Multi-language support
Each snippet library can be associated with a programming language. That
association will determine the syntax highlighting rules used to display the
source code.
IDE Insertion
Snippets can be transferred from gbSnippets directly into the language IDE - ready
for compilation or execution. An entire snippet, or just a selected part of a snippet,
can be transferred.
A special portion of a snippet, called the compilable example can also be extracted from the snippet and placed in the language IDE.
Finally, a snippet (or selection) can be inserted into a user-defined template prior to being placed in the language IDE. Each language can have its own template. Additional, each library can designate a snippet as the template for only that library.
Snippet Libraries
Multiple source code libraries, which include over 1,000 snippets, are provided as
part of the gbSnippets distribution.
Snippet libraries include primary code (just the basic code demonstrating a concept) as well as compilable code (the primary code wrapped in enough code to successfully compile in the language IDE and that demonstrates how the code works).
Libraries also include significant reference materials - command syntax, function descriptions, mini-tutorials and generous comments on each snippet.
Library Management
gbSnippets offers several features that help to handle multiple libraries.
The QuickOpen feature allows a user to associate snippet files with up to three
toolbar buttons for quick switching between frequently used snippet libraries.
Library files can be merged (one imported into another) and procedures (Sub/Function)
can be imported from the original language source code files.
gbSnippets snippet libraries are stored as text files. This enables the programmers to potentially use other editors to make batch changes - as long as the format integrity of the files are maintained. Libraries may also be exported to HTML files and gbSnippets can automatically generate index files with links to the various snippet files.
gbSnippets also offers simple library encryption to protect files against casual snooping.
OnLine Snippet Libraries & OnLine Snippet Libraries
All of the snippets distributed with gbSnippets can be found online at my PowerBASIC
code archive.
gbSnippets provides the user with a means of downloading a daily text stream - which will contain either a message form the author or a snippet recently added to the library.
The gbSnippets distribution libraries may be downloaded from the gbSnippet home page. These will contain the most recent snippets available.
Note: snippet content is actually displayed in a RichEdit control. However, throughout this Help page the control may be referred to as a textbox.
Here's the new look of the main menu and toolbar, showing the new Programmers menu item and the three new toolbar selections.
Main Menu
Here's a closer view that shows the now-visible "Programmers" menu item.
Toolbar
And here's a closer view of the three new selections on the toolbar.
TextBox Context Menu
The context menu for the node content textbox will now display 6 new entries, found
at the bottom of the menu.
Programmers Menu
And finally, the dropdown portion of the main menu "Programmers" item has the following selections.
All of these programmer-specific options are discussed in the following paragraphs.
The keyword list for each language is kept in the "languages" subfolder, in files named *.syn (powerbasic.syn, qbasic.syn, html.syn, ...). Syn files for c, c++, csharp, dos, html, java, javascript, perl, php, powerbasic, python, qbasic, quickbasic, sql, and visualbasic are included in the installation.
When a snippet library is created, it is assigned the language of the currently opened snippet library. To manually associate any snippet library with a language, simply use the Programmers/Language/Select Language menu option and select the appropriate language. When the file is saved, the language association is saved within the file.
Language selection determines how gbSnippets uses syntax highlighting (keywords, comments, and strings) for that language. Syntax highlighting parameters are built into gbSnippets - they are not defined in the *.syn files.
Keyword files (*.syn) and IDE templates (*.ide) are included in the gbSnippets distribution.
If you'd like gbSnippets to support a new language, let me know and I'll work to accommodate the request.
Current Limitations
The bottom line is that while I've written gbSnippets to handle multiple languages,
it currently fully supports only PowerBASIC.
Select Language | Associates a language with the currently opened file. When the file is saved, the language designation is saved with the file. The language designation determines which *.syn keyword file and *.ide IDE template file are used when the file is loaded. The language also determines how syntax highlighting is handled by gbSnippets. | |||
Select Syntax Colors | The user may select a color for displaying language
keywords, strings, or comments. If none are selected the colors
blue, red and dark-green are used by default.
To provide a user with additional syntax highlight tailoring, placement of either a ' or + as the first character in a snippet will override the default syntax colors. Using a ' as the first character prevents any syntax highlighting from being applied to the current snippet, whereas using + as the first character allows only comment syntax highlighting to be applied. There are several snippets, particularly reference content, which contain keywords and strings which the user may not want to be colored. These two first-character tweaks provide such capabilities. | |||
Enable Highlighting | Enables syntax highlighting of the keywords, strings, and comments found within source code snippets. The keyword files are found in the "languages" subfolder and are named as "language.syn" (where "language" is replaced with the appropriate language name). The keyword files are listed one per line, in "mixed case" formatting. | |||
Exclude Title Line | Instructs the syntax highlighting code to ignore the 1st line of the snippet. This is especially useful because the 1st line is also displayed in the Tree and usually the user does not want the first line to use syntax highlighting. | |||
Limited IDE Transfer | Directs the "Open in IDE" menu option to transfer only the portion of the snippet starting with the line which begins with "'Compilable Example:". This allows the snippet to contain miscellaneous information (above that line) which may not be compatible with the IDE compiler. Most of the snippets distributed with gbSnippets end with this section. | |||
Upper Case | When using syntax highlighting, keywords are converted to upper case. | |||
Lower Case | When using syntax highlighting, keywords are converted to lower case. | |||
Mixed Case | When using syntax highlighting, keywords are converted to mixed case. Mixed case is defined as the case entered in the *.syn file for the languages (i.e., in the *.syn file a keyword might be entered as "Rnd"). | |||
As Typed | When using syntax highlighting, keywords are highlighted but their case is not modified. | |||
Display ASCII Table | Opens a messagebox containing a table of ASCII codes and the corresponding characters. | |||
Import Procedures | Opens an "Open File" dialog from which the user
can select any text file from which gbSnippets will extract code
between the following pairs:
These pairs must start in column one. The import is NOT case sensitive.
| |||
Open in IDE | Saves the snippet in a text file, using a gbsnippet-assigned extension for the current language, then opens the file in the default client for files with that extension. For example, a PowerBASIC snippet would be saved as a *.bas extension, then the PowerBASIC IDE would be called to open the file. | |||
Open in IDE+ | This option is identical to "Open in IDE" except that the
snippet is inserted into a template before being saved.
The templates use the language name, with a *.ide extension. Templates are found in
the folder "languages", which gbSnippets creates beneath the folder where gbSnippets
was installed. Templates are simple text files and may be edited by the user to
customize the code in which the snippet is placed. The snippet is used to
replace the string "
A user can also designate a specific snippet to be used as the template, for that
library only. Simply place the string "<
gbSnippets looks for a template override snippet on startup. If a snippet is edited
to designate it as the template override, the change will take effect in the next
session. Or, the command "..override" may be entered to make the override take effect
immediately.
|
Comment Selection | Comments out the selected lines, using the comment character associated with the language of the loaded snippets file. Lines already commented are not modified. | |||
UnComment Selection | Uncomments out the selected lines, using the comment character associated with the language of the loaded snippets file. Lines which are not commented are not modified. | |||
Source Code Indentation | Indents source code according to match the hierarchy of statements found in the code. The indentation used is the same as that used in the "Indent" context menu option. Recognizes Sub, Function, Do, For, If, Select Case, While, Interface, Method, and Property as hierarchy keywords. Note: does not recognize same-line placement of hierarchy end points. (i.e., If and End If cannot be on the same line). Note the limitation to BASIC languages at this time. | |||
Open in Default IDE | Copies the currently selected snippet text, or entire snippet if no selection is made, or portion of snippet labeled "Compilable Code" is that menu option is chosen to a text file, using the default extension for the current language, then opens the file in the default client for files with that extension. For example, a PowerBASIC snippet would be saved as a *.bas extension, then the PowerBASIC IDE would be called to open the file. | |||
Open in Default IDE+ | This option is identical to "Open in Default
IDE" except that the snippet is inserted into a template before being saved.
The templates use the language name, with a *.ide extension. They are found in
the folder "languages", which gbSnippets creates beneath the folder where gbSnippets
was installed. These are simple text files and may be edited by the user to
customize the code in which the snippet is placed. The snippet is used to
replace the string "
A user can also designate a specific snippet to be used as the template, for that
library only. Simply place the string "<
gbSnippets looks for a template override snippet on startup. If a snippet is edited
to designate it as the template override, the change will take effect in the next
session. Or, the command "..override" may be entered to make the override take effect
immediately.
|
Color Highlighting | Enables coloring of language keywords, comments, and text strings. Keywords are found in the \languages\*.syn keyword files. | |
Display in IDE | Copies the currently selected snippet text, or entire snippet if no selection is made, or portion of snippet labeled "Compilable Code" is that menu option is chosen to a temporary file, using the default extension for the current language, then opens the file in the default client for files with that extension. For example, a PowerBASIC snippet would be saved as a *.bas extension, then the PowerBASIC IDE would be called to open the file. | |
Display in IDE+ | Copies the currently selected snippet text, or entire snippet if no selection is made, or portion of snippet labeled "Compilable Code" is that menu option is chosen to a temporary file whose extension matches the standard extension for the current language. It wraps the copied text in the contents of the appropriate \languages\*.ide template file. The template files contain the string "<gb_ide>", which is replaced with the copied text. The temporary file is then opened in the default client for files with that extension. |
The *.gbs, *.ide, and *.syn files are all text uncompressed text files. You can click on them to read them inside your browser. But to save to your PC, you must use your browser's right-mouse click, "Save Target/Link As ..." menu option.
All other files can be downloaded by the usual left-click on the link.
Support Files
PowerBASIC
Visual BASIC
QBasic
QuickBasic
Perl
HTML
JavaScript
Java
C
C++
C#
SQL
DOS
PHP
Python
I value user input, so if you have suggestions please let me know!