Friday, April 10, 2020

Customizing Intellisense - I

One question that seems to come up fairly often is how to control some of the more irritating facets of the Visual FoxPro IntelliSense engine. IntelliSense was first introduced to the developer world in Microsoft Visual Basic 5.0 and has been widely implemented as an essential developer productivity enhancement in many languages. The implementation in Visual FoxPro, which was introduced in Version 7.0, is unique among them in that it features an open architecture that allows developers to both customize and extend the built-in features. Whilst a discussion of the full capabilities of IntelliSense is beyond a simple Blog article, I hope the following information on configuring IntelliSense will prove useful.

_VFP.EditorOptions

The basic functionality of IntelliSense is controlled through the EditorOptions property of the VFP Application Object (which can be accessed directly or by using the _VFP system variable). The default setting for this property is “LQKT” although there actually are five basic features that are implemented in all versions of IntelliSense, and a sixth that was added in Visual FoxPro Version 9.0. These are:
·         Hyperlinks (“K or k”). Determines how links are activated. Setting to “k” requires only a single mouse click, while “K” requires that CTRL+Click is used - which is the default. If neither is specified, hyperlinks are treated as normal text in editing or command windows.
·         Word Drag ‘n’ Drop (“W”). When enabled, text can only be dragged to a position immediately following a space. Prevents text being (inadvertently) inserted into existing text when using drag and drop in an editor or the command window. This behavior is disabled by default.
·         Designer Value Tips (“T”). This controls whether the items displayed in lists show their associated ‘tool tips’. By default, they are shown as you scroll through member lists.
·         List Members (“L or l”). This controls whether, and when, the object member lists are displayed. By default, lists are automatic (“L”). When set to the lower case “l” option the list only appears when CTRL+J is pressed (or select ‘List Members’ from the “Edit” pad on the main FoxPro menu).
·         Quick Info (“Q or q”). This controls whether, and when, the various types of Quick Info is displayed. By default, the display is automatic (“Q”). When set to the lower case “q” the Quick Info only appears when you press CTRL+I (or select ‘Quick Info’ from the “Edit” pad on the main FoxPro menu).
·         Rich Text Copy( “X”). This setting was introduced in VFP Version 9.0 and suppresses the functionality that copies text to the clipboard using rich text formatting. By default it is omitted, so that all text is copied in rich text format. This means that when you paste it into another application (an E-Mail message, or Document for example) it retains the syntax coloring and settings that you have set up in the VFP editor. By including the “X” in the EditorOptions string, ensure that text is copied as plain text – this is useful when producing documentation, or other materials, that must print properly in black and white.
The important ones to note here are the lower case options for the List Members and Quick Info settings. If you substitute the lower case values for the defaults, you do not disable IntelliSense but it will not display automatically.
So if you are constantly irritated by the appearance of the large yellow boxes that hide your work when writing simple SQL Select or Browse commands, try setting the “Q” value to “q” instead. This stops the quick info tips popping up automatically but if you need to see one, pressing CTRL+I, anywhere in the command, will immediately display the tooltip. (Note that doing this will also disable the lists of commands/options available when you, for example, you type SET or USE).
Similarly if you find the constant popping up of lists of object properties, events and methods annoying, just set the “L” to “l”. Now you can continue to type your object references yourself but, if you need a list have it available by pressing CTRL+J.

CustomPEMs Record in FoxCode.dbf

In addition to the EditorOptions property there is a special record in the FoxCode table that stores the settings for a number of additional configuration properties. These can be accessed through the advanced tab of the IntelliSense Manager or by opening FoxCode.DBF directly and issuing the command:
LOCATE FOR TYPE = "Z" AND ABBREV = "CustomPEMs"
The number of properties depends upon the version of Visual FoxPro that you are using. In VFP 7.0 there were 6 (one of which never made it into the documentation), while an extra two were added in VFP 8. The following table lists these properties and describes what they do:
Property
Purpose
lEnableFullSetDisplay
Default = .T.
Many SET commands take, as part of the basic syntax, a ‘TO’ modifier. This property determines whether that ‘TO’ is included as part of the IntelliSense auto-expanded command. The default value is True, but we prefer to turn this one off. The reason is that even if you type the full command yourself, IntelliSense still adds the ‘TO’ with the result that you tend to get errors because you end up with a command line like this:
SET INDEX TO TO names
lHideScriptErrors
Default = .F.
According to the help file this property “Suppresses screen output of IntelliSense script errors”. The default is False. In fact, this is another setting that only applies to scripts that use a local instance of the FoxCodeScript class. That class defines a custom error display and it is whether that display is enabled or not that this property controls.
If there is an error in any other type of script you will get either the appropriate standard error message (when applicable) or a simple dialog with the text “FoxCode Script Failure” irrespective of the setting of this property.
lKeyWordCapitalization
Default = .T.
Controls the auto-expansion and capitalization of the subordinate parts of commands. The default setting is True. Used in the ReplaceKeyWord() method of foxcode.prg. Note: This only affects capitalization when you actually type the full command (e.g. CLEAR ALL). Auto-inserted commands are capitalized according to their individual rules.
lPropertyValueEditors
Default = .T.
According to the help file this property “Enables scripts that trigger value editors for certain properties”. The default is True. In fact, this property determines whether scripts defined in foxcode.dbf for records with Type = “P” are executed. It does not affect any of the standard value lists that are defined for properties that continue to be displayed irrespective of this setting.
lExpandCOperators
Default = .T.
Enables “C-style” auto-expansion of plus and minus operators:
lcVar ++” and “lcVar - -” expand as “lcVar = lcVar + 1” and “lcVar = lcVar –1
But, unlike C, VFP IntelliSense also allows us to use the “=” with any arithmetic operator to auto-expand the string. Thus,
lcVar +=” becomes “lcVar = lcVar + ” and “lcVar *=” becomes “lcVar = lcVar *
lAllowCustomDefScripts
Default = .T.
This was the undocumented property in VFP 7.0. The FoxCodeScript.DefaultScript() method (which is the method called whenever IntelliSense encounters a space) uses the setting of this property to determine whether a hook method named HandleCustomScripts() is called or not. If you do not intend to use custom scripts to modify default behavior, you should set this one to False because the default script is called every time you type a space in an editing window
lEnableMultiWordCmdExpansion
Default = .T.
VFP 8.0 and later
Controls whether multiple part commands are automatically expanded. The default is .T. and when set to .F. commands like INDEX ON must be typed in full. Note that setting this to .F. also disables capitalization of the secondary key words, irrespective of the setting of lKeyWordCapitalization
lDebugScripts
Default = .F.
VFP 8.0 and later
Controls whether scripts that use a custom version of the foxcode object can be traced line by line in the debugger. The default is .F. Note that this only affects scripts that use their own local instance of the FoxCodeScript class.
Published Sunday, April 03, 2005 3:51 PM by andykr

No comments:

Post a Comment

Writing better code (Part 1)

Writing better code (Part 1) As we all know, Visual FoxPro provides an extremely rich and varied development environment but sometimes to...