4.4 The programming window

To pop up the programming window, click on Toolkits / Edit Toolkits in nip2’s main image processing window. The window shown in Figure 2.11 should appear.

Each of the things down the left of the program window is a toolkit. Each toolkit is a text file containing a set of definitions in nip2’s programming language. See Chapter 6 for details on the language.

If you open a toolkit, nip2 shows all of the definitions in that file. If you click on one of these nip2 shows the source for that definition in the main part of the program window. After editing a definition, click on File / Process to make nip2 read what you typed, compile it, and update itself.

Click on File / New / Tool to add a new definition to a toolkit, click on File / New / Toolkit to make a completely new toolkit. You can also right-click on tools and toolkits to get a context menu, and you can left-drag tools to move them around within a toolkit or between toolkits.

Some toolkits are loaded from files when nip2 starts up, others are built from the VIPS operation database (for example, _arithmetic), and one (called _builtin) contains the functions that are built into nip2. If you select a tool and then click on Help / Help on Tool, nip2 will try to display the relevant section from the VIPS manual in your web browser. Currently, this works only for things in the VIPS operation database: try _arithmetic / im_add, for example. There’s a section in the Preferences workspace to control which web browser nip2 uses and how it asks for a page.

Toolkits and tools whose names begin with an underscore character are not displayed in the main Toolkits menu. The idea is that they represent little utility functions, rather than stuff a user might be interested in. See §6.12.1 for more information on how tools and toolkits are displayed.

You can have several programming windows open at the same time (often useful, if confusing). The Edit menu lets you search for patterns across all definitions. The Jump To Definition item jumps to the definition of a symbol.

The Debug menu has items which open a trace window (use this to track the actions taken by nip2’s reduction engine) and which report on unresolved symbols and list all current errors.