Wing Tips: Overlaying Debug Data onto Wing Pro's Editor

Apr 30, 2019


In this issue of Wing Tips we take a look at Wing Pro's ability to display the value of all visible symbols, using an overlay on top of the editor.

This is what it looks like:

/images/blog/debug-value-tips/debug-value-tips.gif

Notice that values are shown for any variable and also for dotted names like self.args.config_vars. When Shift-Space is released, the values are hidden.

Try it Yourself

To try this out, paste the following into a new file in Wing and save it to disk with name testtips.py:

import random
x = 3.14 ** 2
y = 'test ' * 8
z = random.randint(0, 1000000)
print("<-- Set breakpoint here by clicking on leftmost margin")

Then set a breakpoint on the last line by clicking on the margin to the left, or by moving the editor caret to that line and using Add Breakpoint in the Debug menu.

Next start debug with Debug Current File in the Debug menu and let Wing run to the breakpoint.

Finally, press and hold Shift-Space and you should see the value of x, y, and z overlaid onto the editor as follows:

/images/blog/debug-value-tips/testtips.gif

When you release Shift-Space the overlay is removed.

Binding Alternative Keys

If you don't like having to hold down the keys, another option is to bind different keys to the commands debug-show-value-tips and debug-hide-value-tips. This is done with the User Interface > Keyboard > Custom Key Bindings preference in Wing.

For example, you might bind the single key Ctrl-' to the command sequence debug-show-value-tips, debug-hide-value-tips. Wing executes the first available command in a comma-separated list, so pressing Ctrl-' the first time will show the values and pressing it again will hide them.

If you also want to override the default binding for Shift-Space, so Wing inserts a space even when the debugger is active, use the command send-keys(keys=" ")



That's it for now! In the next Wing Tip we'll take a look at using multiple selections to more easily complete some types of edits.



Share this article: