Electric Menu Help
Name:Electric Menu
Version:2.3
Last update:2019-10-17 13:28:53





The Electric Menu allows you to quickly insert context-specific text templates into the active window.

Abstract

The term electric is used throughout Alpha's in the sense of automatic, power assisted behavior which is intended to save time, keystrokes, and brainpower. The basic idea is that you allow Alpha to scan the current context surrounding the cursor a then insert the string that you really want. These strings are referred to as electric templates.
The Electric Menu includes several default templates, and provides utilities so that you can create more of your own.

Introduction

The Electric Menu provides a convenient interface to several different electric functions provided by Alpha's suite of AlphaTcl files. Click here to display the Menus Preferences dialog.
The various types of electric templates are presented as submenus, each of which serves a slighty different purpose as described below. See the Electrics Help window for more information about Alpha's electric behavior and the different packages available to manage and create electric templates in text windows.
Each of the sections below describes the specific submenus available.

Special Keys

The Special Keys menu provides access to the different functions that primarily allow you to navigate template stops. The keyboard shortcuts for these functions can always be set with the Alpha ↣ Global Setup ↣ Keyboard Shortcuts ↣ Special Keys menu command. This menu primarily serves as a visual reminder of the current shortcuts assigned to these functions.
Once you have adjusted your Special Keys shortcuts and can remember them without needing this reminder, you can turn off your Electric Menu preference for Include Special Keys Submenu. Click here to display the Electric Menu Preferences panel to hide this submenu.

Clippings

Clippings are simple text files stored in your Support Folders that can be quickly inserted into the active window as electric templates.
Imagine selecting File ↣ Open, selecting a file name, opening it in Alpha, selecting the entire contents of the new window, copying it into the clipboard, closing this window, and then pasting it where you want.
Now imagine selecting a single menu command to do all of this in one step. That is how the Electric Menu ↣ Clippings menu works. You can create and edit the clipping files in Alpha, adding new or deleting old clipping files as needed. Clippings file can also be personalized to include your name, your e-mail address, the current date or time, the path of the active window, etc. Select the Electric Menu ↣ Clippings ↣ Clippings Help command (or click here) for more information.

Simple Templates

A simple template is a string that will be inserted into the active window, and can either be wrapped around or first delete any current selection. All simple templates can be assigned menu shortcuts. Select Electric Menu ↣ Simple Templates ↣ Simple Templates Help (or click here) for more information.

Standard Templates

Standard templates take the idea of a clipping file one step further, by taking fuller advantage of the full features of the Tcl and AlphaTcl scripting language to create even more sophisticated template insertions. Several AlphaTcl packages define standard templates found in this submenu, such as items to create a new header in the active window, or a new class for C++ and Java files. These template commands can prompt the user for additional input, or perform fancy text manipulations based upon the context of the active window.
You can add your own templates to this menu as well, but this requires you to edit a Tcl procedure to create the text string to be inserted into the active window. A little knowledge of the Tcl scripting language is very useful if you want to create electric template routines using this method; fortunately this is a rather easy programming language to learn.
See Electric Menu ↣ Standard Templates ↣ Standard Templates Help (or click here) for more information.
Most users are content to stick with clippings files for simpler electric template insertions.

License Templates

License Templates are often used to designate how a file can be distributed and modified. The commands in this submenu insert different license styles, personalizing them with your name, e-mail address, etc. The package License Templates allows you to modify the default license templates as needed.

File Paths

This submenu contains commands to insert the full path of a file or folder residing in a local disk into the active window. You can also insert the listing of a folder's contents, or the entire contents of a selected file.
When paths are inserted into programming files, sometimes they need to be surrounded by single or double quotation marks. You can adjust the Electric Menu preferences for Quote Path Names and Quote Paths Using to set your preferred style. Click here to display the Electric Menu Preferences panel.
If you elect to quote the paths, the surrounding text of the active window is checked to see if you have already typed the necessary quotation marks and will add them only if you have not done so.
The Electric Menu ↣ File Paths submenu includes all of the options for this preference; you change the display option globally, or just for the mode of the active window.

Mode Completions

Many modes define a set of electric completions that are inserted into the current window after you press your Complete shortcut. The completion routine will scan the preceding text for a template hint, and insert a template specific to that hint for the current mode of the active window. See the Electrics Help window for more information about how electric completions work.
The Electric Menu ↣ Completions submenu contains utility commands that let you add your own mode-specific completion hint/template combinations if your mode doesn't provide you with everything you need.
Open the Tcl Mode Tutorial electric completions tutorial to experiment.

AlphaTcl Developer Notes

AlphaTcl packages can define global or mode-specific templates that will be automatically inserted in the Electric Menu ↣ Standard Templates menu by adding to the elec::MenuTemplates or <mode>Templates list variables. See the electricMenu.tcl source file for more information.

Known problems

Please report any problem or bug you encounter in Alpha's Bug Tracker.

License and Disclaimer

Copyright (c) 1996-2019, Vince Darley and Contributors.
Contributors: Craig Barton Upright.
All rights reserved.
The Electric Menu package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL VINCE DARLEY OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.