Tuesday, February 15, 2011

PEM Editor tip: Group filter (new feature)

This is a new feature in version 6.50.

A new option, 'Groups' has been added in the Filter section. This feature is modelled after the 'Layout', 'Data', and 'Other' tabs in the Property Sheet.


Customization

The list of groups and the items in each group may be customized. There are two tables, GroupNames and PEMNameGroups, which can be copied from the 'Sample Plug-Ins' folder into the 'Live Plug-Ins' folder and modified as follows:
  1. You can create new groups by adding records to GroupNames. (One new group is already created in the file). You can also change the order of display by setting the values in the field {DisplayOrd}
  2. You can identify the items in the new group, or add records to the pre-defined system groups, by adding records into PEMNameGroups. The names are not case-sensitive and may appear in more than one group.
  3. You can remove records from the pre-defined system groups by adding a record into PEMNameGroups and setting the {Removed} flag

Saturday, February 12, 2011

PEM Editor tip: the Tools object (_oPEMEditor.oTools)

This is a new feature in version 6.50.

The object _oPEMEditor.oTools, documented here, contains a number of useful tools which may be of value either in customizing PEM Editor or for use in other tools.

Note that the PEM Editor form need not be open for these tools to work.

Methods (Parameters)Description
AddMRUFile (tcFileName, tcClassName) Adds a file to its appropriate MRU list (in the FoxPro resource file). If the file is a class library, but no class name is supplied, adds the file to the MRU list for class libraries (unique to PEM Editor)
CloseForms() Close the PEM Editor and Document TreeView forms, if open
CreateNewPEM (tcType, tcName, txValue) Creates a new property or method:
tcType = 'P' for Property, 'M' for Method
tcName = Name for new PEM (_MemberData if appropriate
txValue = Value (for properties) or method code (for methods)
CloseForms() Close the PEM Editor and Document TreeView forms, if open
DiskFileName (tcFileName)Returns the file name as it is stored on disk (that is, with current upper/lower case).
EditMethod (toObject, tcMethodName)Opens a method (or event) for editing. {toObject} may be an object reference, .T. for the current form or class, or empty for the current object.
EditSourceX (tcFileName, tcClass, tnStartRange, tnEndRange)Opens any file for editing (as EditSource does), with additional capabilities:
The file is added to its appropriate MRU library.
The file is opened with the correct case for the file name, so that when it is saved the case for the file name will not be changed.
If the file is a class library, and no class name is supplied, the class browser is opened.
You will be asked whether you want to check out the file from Source Code Control (if you use SCC and you have marked the appropriate item in the Preferences file.)
FindObjects (tcSearchText)Finds all objects matching the search criteria in {tcSearchText}. The search criteria are the same as are specified by the 'Find' (binoculars) search button. The result is a collection, where each item in the collection is an object with two properties:
Object - a reference to the object
FullObjectName - the full path name to the object
For example, .FindObjects ('Exists ("ControlSource")' ) returns a collection of all objects having a ControlSource.
FindProcedure (tcName)Finds a PRG named {tcName}, or a procedure or function named {tcName} within a PRG, or a constant named {tcName}, opens the file for editing, and highlights the searched-for name.
GetCurrentObject (tlTopOfForm)Returns the currently selected object or form/class
GetPEMList (toObject, tcTypes)Returns a collection of the names of PEMs for an object. {toObject} may be an object reference, .T. for the current form or class, or empty for the current object. {tcTypes} may be one or more of 'P' (for properties), 'E' (for Events), or 'M' (for Methods); or, if empty or missing, the collection will contain all PEMs.
GetMRUList (tcName)Returns a collection of file names in a MRU list. {tcName} may be a file name, a file extension, or the actual MRU-ID (if you know it)

Sunday, February 6, 2011

PEM Editor tip: the EditorWindow object (_oPEMEditor.oEditorWin)

This is a new feature in version 6.50.

All of the IDE features of PEM Editor use the functions from FoxTools.fll to access and modify the currently open editing window. Recognizing that these tools may be of value to those who wish to customize PEM Editor (such as when creating Dynamic Snippets) or for other uses, the object _oPEMEditor.oEditorWin is documented here.

The methods in this object serve two purposes:
  1. As wrappers for the function in FoxTools
  2. To simplify the task of identifying the currently open editing window.
Editing windows are identified by a numeric value called a handle. All of the IDE features in PEM Editor first call _oPEMEditor.oEditorWin.FindWindow(), which determines the handle for the currently open window and saves it. Thereafter, all of the other methods of this object refer to this saved window handle so that it need not be explicitly referenced in their parameters. Some further notes:
  1. Character positions and line counts start at 0, not 1. (i.e., be careful)
  2. There is full documentation for the functions in FoxTools.fll available. In the Source folder, execute
  3. The PEM Editor form need not be open for these tools to work.



























































Window manipulation: handles, size, position, title, etc.
Methods (Parameters) Description
CloseWindow() Close the current window
FindLastWindow() Returns the handle of the most recently used window which is either of a PRG or method code from the Form or Class Designer.
FindWindow() Saves the handle for the currently active window, and returns its window type:
0 – Command Window, Form and Class Designers, other FoxPro windows
1 – Program file (MODIFY COMMAND)
2 – Text Editor (MODIFY FILE)
8 – Menu code edit window
10 – Method code edit window of the Class or Form Designer
12 – Stored procedure in a DBC (MODIFY PROCEDURE)
-1 - None
GetHeight() Returns the height of the editing window, in pixels.
GetLeft() Returns the left position of the editing window, in pixels.
GetOpenWindows() Returns a collection of the handles of all open windows, most recently used first.
GetTitle() Returns the title for the current window
GetTop() Returns the top position of the editing window, in pixels.
GetWidth() Returns the width of the editing window, in pixels.
GetWindowHandle() Returns the handle of the current editing window
MoveWindow (tnLeft, tnTop) Moves the editing window to position {tnLeft}, {tnTop}. Both are in pixels.
ResizeWindow (tnWidth, tnHeight) Resizes the editing window to {tnWidth} by {tHeight}. Both are in pixels.
SelectWindow (tnHandle) Selects (brings to the foreground) window with handle {tnhandle}
SetHandle (tnHandle) Sets the handle (used to indicate the window being referenced in most of these commands/)
SetTitle (tcNewTitle) Sets the title for the editing window to {tcNewTitle}

Text manipulation
Methods (Parameters) Description
Copy() Copies the currently highlighted text into the clipboard
Cut() Cuts the currently highlighted text
EnsureVisible (tnPosition, tlScroll) Ensures that the character at position {tnPosition} is visible in the editing window. If {tlScroll} is true, it is brought to the mid-point of the editing window
GetCharacter (tnPosition) Returns the character at position {tnPosition}
GetEnvironment {tnIndex} Returns a single environment setting. {tnIndex} takes values from 1 to 25. See _EdGetEnv in the help for FoxTools for a description of all the settings. Frequently used values are:
2 – File Size
17 – Selection start
18 – Selection end
25 – Window Type (see above)
GetFileSize() Returns the file size
GetLineNumber (tnSelStart) Returns the line number for the character at position {tnPosition}
GetLineStart (tnSelStart, tnLineOffset) Determines the line number for the character at position {tnPosition} and returns the position for the character at the beginning of that line. If {tnLineOffset} is supplied, it first offsets the line number by that amount. Thus .GetLineStart (tnSelStart, 1) gives the start position of the next line after the line for {tnSelStart}
GetSelEnd() Returns the position for the end of the currently highlighted text
GetSelStart() Returns the position for the start of the currently highlighted text
GetString (tnSelStart, tnSelEnd) Returns the string of characters from position {tnSelStart} through {tnSelEnd}
Paste() Pastes the contents of the clipboard into the editing window
Select (tnSelStart, tnSelEnd) Selects (highlights) the string of characters from position {tnSelStart} through {tnSelEnd}
SetInsertionPoint (tnPosition) Sets the insertion point to {tnPosition}