Skip to content

Commit ef7a7f2

Browse files
committed
Update the debugger's documentation, add a table of contents
1 parent 55a6637 commit ef7a7f2

File tree

1 file changed

+109
-71
lines changed

1 file changed

+109
-71
lines changed

Diff for: README.md

+109-71
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,41 @@ This package adds support for the GDScript programming language from the Godot
77
game engine in Emacs. It gives syntax highlighting and indentations.
88
[Contributors](#contributing) are welcome!
99

10+
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
11+
**Table of Contents**
12+
13+
- [Features](#features)
14+
- [Contributing](#contributing)
15+
- [How to install](#how-to-install)
16+
- [How to use](#how-to-use)
17+
- [Opening the project in the editor](#opening-the-project-in-the-editor)
18+
- [Running Godot with visual debug options](#running-godot-with-visual-debug-options)
19+
- [Using Hydra](#using-hydra)
20+
- [Formatting code with gdformat](#formatting-code-with-gdformat)
21+
- [Browsing the Godot API with eww](#browsing-the-godot-api-with-eww)
22+
- [Keyboard shortcuts](#keyboard-shortcuts)
23+
- [Customization](#customization)
24+
- [Using the debugger](#using-the-debugger)
25+
- [Adding and removing breakpoints](#adding-and-removing-breakpoints)
26+
- [Running the project with the debugger active](#running-the-project-with-the-debugger-active)
27+
- [Fetching an object's details](#fetching-an-objects-details)
28+
- [Debug Hydra](#debug-hydra)
29+
- [The `* Stack frame vars *` buffer](#the--stack-frame-vars--buffer)
30+
- [`* Inspector *` buffer](#-inspector--buffer)
31+
- [`* Stack dump *` buffer](#-stack-dump--buffer)
32+
- [`* Breakpoints *` buffer](#-breakpoints--buffer)
33+
- [`* Scene tree *` buffer](#-scene-tree--buffer)
34+
35+
<!-- markdown-toc end -->
36+
37+
1038
## Features
1139

12-
This mode already features all the essentials:
40+
This mode features all the essentials:
1341

1442
- Syntax highlighting.
1543
- Code folding.
44+
- Debugger support.
1645
- [Imenu](https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html).
1746
- Support for scenes (`.tscn`) and script (`.gd`) files.
1847
- Comment wrapping when using `fill-paragraph`.
@@ -233,111 +262,120 @@ Code example:
233262
(setq gdscript-gdformat-save-and-format t) ;; Save all buffers and format them with gdformat anytime Godot executable is run.
234263
```
235264

236-
## Debugger
265+
## Using the debugger
266+
267+
Emacs GDScript mode includes support for the GDScript debugger. You can use breakpoints, use code stepping functions, see your nodes' state at runtime, and more.
268+
269+
To get started with this feature, you need to add a least one breakpoint.
237270

238-
Use <kbd>C-c C-d b</kbd> to add breakpoint to your GDScript file. Red dot will appear in the left fringe to indicate position where breakpoint is placed.
239-
Use <kbd>C-c C-d r</kbd> to remove breakpoint.
271+
### Adding and removing breakpoints
240272

241-
Once first breakpoint is added to the project, buffer named `* Breakpoints *` is created. This buffer displays all existing breakpoints in a project. Pressing <kbd>D</kbd> on breakpoint line deletes the breakpoint. Pressing <kbd>RET</kbd> on breakpoint line shows GDScript file with that breakpoint in other buffer.
273+
You can add a breakpoint on the current line with `gdscript-debug-add-breakpoint` (<kbd>C-c C-d b</kbd>). A red dot should appear in the left fringe. Use `gdscript-debug-remove-breakpoint` (<kbd>C-c C-d r</kbd>) to remove a breakpoint on the current line.
242274

243-
When any breakpoint exists, running project will automatically start debugger server (if one isn't already running) and connect to it.
244-
Debugger server runs on `localhost` with port specified by `gdscript-debug-port` customizable variable (`6010` by default).
275+
After adding at least one breakpoint to the project, a buffer named `* Breakpoints *` is created. This buffer displays all existing breakpoints in a project. In that buffer, pressing <kbd>D</kbd> on a breakpoint line deletes the breakpoint. Pressing <kbd>RET</kbd> opens the corresponding GDScript file in another buffer.
245276

246-
Once breakpoint is hit in your code, Emacs will show two special buffers with information related to a position of the breakpoint:
277+
### Running the project with the debugger active
247278

248-
- `* Stack frame vars *` - Display locals/members/globals variables for current stack point. It show variable name, its type and its value.
249-
- `* Inspector *` - Display detailed information about selected `ObjectId`. By default it show `self` reference.
279+
When any breakpoint exists, running the project with `gdscript-godot-run-project` will automatically start the debugger's server if one isn't already running and connect to it.
250280

251-
Any `ObjectId` in those two buffers can be inspected by pressing <kbd>RET</kbd> when point is on corresponding line.
281+
The debugger's server runs on `localhost` through port `6010` by default. You can customize the port with the `gdscript-debug-port` variable.
252282

253-
### Oneline/multiline display
283+
Once Godot hits a breakpoint, Emacs displays two new buffers:
254284

255-
Variable values of types `Dictionary`, `PoolRealArray`, `PoolStringArray`, `PoolVector2Array`, `PoolVector3Array` and `PoolColorArray` could be toggled from one line display to multiline display by pressing `TAB` on corresponding line.
285+
- `* Stack frame vars *` displays the locals, members, and globals variables for the current stack point. It show variable name, its type and its value.
286+
- `* Inspector *` displays detailed information about the selected object. By default, it shows the properties of `self`.
256287

257-
### Fetching `ObjectId` details
288+
You can inspect any object in those two buffers by pressing <kbd>RET</kbd> on the corresponding line.
258289

259-
Pressing <kbd>d</kbd> in `* Stack frame vars *` or `* Inspector *` buffers (or on Debug Hydra) will fetch on the background data for all `ObjectId`s present in those two buffers and once all `ObjectId`s data are fetched, these two buffer are redisplayed. This redisplay will contain two additional informations about given `ObjectId`:
260-
- real type (for example `KinematicBody2D` instead of `ObjectId`)
261-
- node path
290+
#### Multi-line display
262291

263-
Also fetched data are cached and not fetched again when said `ObjectId` is inspected later on (until new breakpoint is hit).
292+
You can toggle between one-line and multi-line display for values of type `Dictionary`, `PoolRealArray`, `PoolStringArray`, `PoolVector2Array`, `PoolVector3Array` and `PoolColorArray`. To do so, press `TAB` on the corresponding line.
264293

265-
On breakpoint hit Debug Hydra will be displayed below `* Stack frame vars *` and `* Inspector *` buffers.
294+
### Fetching an object's details
295+
296+
Pressing <kbd>d</kbd> in `* Stack frame vars *` or `* Inspector *` buffers (or in the debug hydra) will fetch on the background data for all objects present in those two buffers and redisplay once done. Doing that adds two extra bits of information about the objects:
297+
298+
- Their real type, for example, `KinematicBody2D` instead of `ObjectId`.
299+
- Their node path.
266300

267301
### Debug Hydra
268302

303+
If `hydra` is available, the debug hydra displays below `* Stack frame vars *` and `* Inspector *` buffers upon hitting a breakpoint.
304+
305+
You can also call it by pressing <kbd>C-c n</kbd>.
306+
269307
```
270308
n next c continue m step b breakpoints s stack v vars i inspector t scene-tree d details
271309
o pin u unpin q quit
272310
```
273311

274-
- <kbd>n</kbd> - Jump to next line and stops there
275-
- <kbd>c</kbd> - Continue program execution until another breakpoint is hit
276-
- <kbd>m</kbd> - Step into
277-
- <kbd>s</kbd> - Show `* Stack dump *` buffer
278-
- <kbd>v</kbd> - Show `* Stack frame vars *` buffer
279-
- <kbd>i</kbd> - Show `* Inspector *` buffer
280-
- <kbd>t</kbd> - Show `* Scene tree *` buffer
281-
- <kbd>d</kbd> - Fetch details for all `ObjectId`s present in `* Stack frame vars *` and `* Inspector *` buffers and redisplay them
282-
- <kbd>o</kbd> - Pin current `self` `ObjectId` in `* Inspector *` buffer. It stays displayed until it cease to exists or until it get unpinned
283-
- <kbd>u</kbd> - Unpin currently pinned `ObjectId`
284-
- <kbd>q</kbd> - Close Debug Hydra
285-
286-
### `* Stack frame vars *` buffer
287-
288-
Main source of information about running program. Contains information about locals/members/globals variables.
289-
290-
- Press <kbd>TAB</kbd> to toggling oneline/multiline display for selected types
291-
- Press <kbd>RET</kbd> on `ObjectId` line to display its details in `* Inspector *`buffer
292-
- Press <kbd>l</kbd> to display `* Stack dump *` buffer
293-
- Press <kbd>d</kbd> to display additional details for `ObjectId` variables
294-
- Press <kbd>p</kbd> to go to previous line
295-
- Press <kbd>n</kbd> to go to next line
296-
- Press <kbd>o</kbd> to pin current `ObjectId` in `* Inspector *` buffer
297-
- Press <kbd>u</kbd> to unpin currently pinned `ObjectId`
298-
- Press <kbd>q</kbd> to close the buffer
312+
- <kbd>n</kbd> - Steps to the next line of code.
313+
- <kbd>c</kbd> - Continue program execution until the next breakpoint.
314+
- <kbd>m</kbd> - Steps into the code.
315+
- <kbd>s</kbd> - Shows the `* Stack dump *` buffer.
316+
- <kbd>v</kbd> - Shows the `* Stack frame vars *` buffer.
317+
- <kbd>i</kbd> - Shows the `* Inspector *` buffer.
318+
- <kbd>t</kbd> - Shows the `* Scene tree *` buffer.
319+
- <kbd>d</kbd> - Fetches details for all object present in the `* Stack frame vars *` and `* Inspector *` buffers and redisplay the buffers.
320+
- <kbd>o</kbd> - Pins `self` in the `* Inspector *` buffer. It stays displayed until Godot frees the instance or you unpin it.
321+
- <kbd>u</kbd> - Unpins the currently pinned object.
322+
- <kbd>q</kbd> - Closes the debug hydra.
323+
324+
### The `* Stack frame vars *` buffer
325+
326+
The stack frame buffer displays the locals, members, and globals variables for the current stack point. Here are available keyboard shortcuts:
327+
328+
- <kbd>TAB</kbd> toggles multi-line display for selected types.
329+
- <kbd>RET</kbd> on an object line to display its details in the `* Inspector *`buffer.
330+
- <kbd>l</kbd> displays the `* Stack dump *` buffer.
331+
- <kbd>d</kbd> displays additional details for `ObjectId` variables.
332+
- <kbd>p</kbd> goes to the previous line.
333+
- <kbd>n</kbd> goes to the next line.
334+
- <kbd>o</kbd> pins the current object in the `* Inspector *` buffer.
335+
- <kbd>u</kbd> unpins the currently pinned object.
336+
- <kbd>q</kbd> closes the buffer.
299337

300338
### `* Inspector *` buffer
301339

302340
Contains information about inspected object. By default `self` variable from `* Stack frame vars *` is displayed. Inspected object is kept to be focused until other object is inspected or until inspected object cease to exists, in which case current `self` is displayed instead.
303341

304-
- Press <kbd>TAB</kbd> to toggling oneline/multiline display for selected types
305-
- Press <kbd>RET</kbd> on `ObjectId` line to display its details
306-
- Press <kbd>RET</kbd> on `Node/path` line (second line from the top) to show given `ObjectId` in `* Scene Tree *` buffer
307-
- Press <kbd>l</kbd> deep in nested `ObjectId` to navigate one level up in the structure (ie. back). Pressing `l` while on top level object displays `* Stack frame vars *` buffer
308-
- Press <kbd>d</kbd> to display additional details for `ObjectId` variables
309-
- Press <kbd>p</kbd> to go to previous line
310-
- Press <kbd>n</kbd> to go to next line
311-
- Press <kbd>o</kbd> to pin current `ObjectId` in `* Inspector *` buffer
312-
- Press <kbd>u</kbd> to unpin currently pinned `ObjectId`
313-
- Press <kbd>q</kbd> to close the buffer
342+
- Press <kbd>TAB</kbd> to toggle multi-line display for selected typess.
343+
- Press <kbd>RET</kbd> on object line to display its detailss.
344+
- Press <kbd>RET</kbd> on `Node/path` line (second line from the top) to show given object in `* Scene Tree *` buffers.
345+
- Press <kbd>l</kbd> deep in nested object to navigate one level up in the structure (ie. back). Pressing `l` while on top level object displays `* Stack frame vars *` buffers.
346+
- Press <kbd>d</kbd> to display additional details for object variabless.
347+
- Press <kbd>p</kbd> to go to the previous lines.
348+
- Press <kbd>n</kbd> to go to the next lines.
349+
- Press <kbd>o</kbd> to pin current object in `* Inspector *` buffers.
350+
- Press <kbd>u</kbd> to unpin currently pinned objects.
351+
- Press <kbd>q</kbd> to close the buffers.
314352

315353
### `* Stack dump *` buffer
316354

317355
Contains stack dump information.
318356

319-
- Press <kbd>SPC</kbd> to jump to gdscript file where stack frame points to
320-
- Press <kbd>RET</kbd> to jump to gdscript file and to show `* Stack frame vars *`, `* Inspector *` buffers and a Debug Hydra
321-
- Press <kbd>l</kbd> to display `* Stack frame vars *` buffer
322-
- Press <kbd>p</kbd> to go to previous line
323-
- Press <kbd>n</kbd> to go to next line
324-
- Press <kbd>q</kbd> to close the buffer
357+
- Press <kbd>SPC</kbd> to jump to gdscript file where stack frame points to.
358+
- Press <kbd>RET</kbd> to jump to gdscript file and to show `* Stack frame vars *`, `* Inspector *` buffers and a debug hydra.
359+
- Press <kbd>l</kbd> to display the `* Stack frame vars *` buffer.
360+
- Press <kbd>p</kbd> to go to the previous line.
361+
- Press <kbd>n</kbd> to go to the next line.
362+
- Press <kbd>q</kbd> to close the buffer.
325363

326364
### `* Breakpoints *` buffer
327365

328-
Contains list of all existing breakpoints.
366+
Lists all existing breakpoints in the project.
329367

330-
- Press <kbd>SPC</kbd> to enable/disable all breakpoints
331-
- Press <kbd>RET</kbd> to open gdscript file where on give breakpoint position
332-
- Press <kbd>TAB</kbd> to display `* Stack dump *` buffer
333-
- Press <kbd>D</kbd> to delete the breakpoint
334-
- Press <kbd>q</kbd> to close the buffer
368+
- Press <kbd>SPC</kbd> to enable or disable all breakpoints.
369+
- Press <kbd>RET</kbd> to jump to the file and line corresponding to the breakpoint..
370+
- Press <kbd>TAB</kbd> to display the `* Stack dump *` buffer.
371+
- Press <kbd>D</kbd> to delete the breakpoint.
372+
- Press <kbd>q</kbd> to close the buffer.
335373

336374
### `* Scene tree *` buffer
337375

338-
Contains tree visualisation of all `ObjectId`s in the running program.
376+
Contains a tree visualisation of all objects in the running program.
339377

340-
- Press <kbd>RET</kbd> to open corresponding `ObjectId` in `* Inspector *` buffer
341-
- Press <kbd>p</kbd> to go to previous line
342-
- Press <kbd>n</kbd> to go to next line
343-
- Press <kbd>q</kbd> to close the buffer
378+
- Press <kbd>RET</kbd> to open the corresponding object in the `* Inspector *` buffer.
379+
- Press <kbd>p</kbd> to go to the previous line.
380+
- Press <kbd>n</kbd> to go to the next line.
381+
- Press <kbd>q</kbd> to close the buffer.

0 commit comments

Comments
 (0)