Macro Scopes and References. Source Dynamics Source Insight 4.0
Reklama
Reklama
Macro Scopes and References
For example, this function becomes a user-level command, and it can be assigned to a keystroke: macro SaveCurrentFileNow ()
{
perform_save()
}
You can use Options > Key Assignments to locate the SaveCurrentFileNow command and assign a keystroke to it.
However this function can only be called from another macro function, because it is declared with the function
keyword: function perform_save ()
{
var hbuf
hbuf = GetCurrentBuf()
if (hbuf != nil)
SaveBuf(hbuf)
}
Macro Scopes and References
All macro functions live in the same global namespace. All macros declared in any open file, stored in a project, or in a project on the project symbol path are in scope. That is, you can have forward references to macros. You do not have to declare them before calling them.
Source Insight uses its symbol lookup engine to resolve references to macro functions when macros are executed and when the user invokes a macro command. Therefore, symbol lookup rules apply to macro name
binding. See “Symbols and Projects” on page 46.
Browse Project Symbols dialog box and jump to its definition.
Running Macros
You can run macros by invoking the macro command directly with a keystroke or menu item, or by using the
Run Macro
command to begin running macro statements at the current cursor position. You can also run a macro by selecting the macro command inside the Options > Key Assignments, or Options > Menu Assign-
ments
dialog, then clicking the Run button.
Macros as Commands
If a macro function is declared with the macro
keyword, and has no parameters, then Source Insight considers it to be a user-level command. User-level macro commands appear in the command lists of the Key
Assignments
and Menu Assignments dialog boxes. This allows you to place macro commands on the menu or in the keymap. You can also run commands directly from those dialog boxes. If a macro function has parameters, it will not appear as a command in the command lists, and you wont be able to assign a keystroke to it or put it on a menu.
Source Insight 4 User Guide 367
Preuzimanje
Reklama