You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/editor.md
+22-11Lines changed: 22 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,15 +173,17 @@ If a `setup` editor is present, that's the only PyEditor that needs a config.
173
173
Any subsequent related editor will reuse the config parsed and bootstrapped for
174
174
the `setup` editor.
175
175
176
-
## Execution via keyboard
176
+
## Run via keyboard
177
177
178
-
Accordingly with the Operating system you are using, a combination of either `Ctrl-Enter`, `Cmd-Enter` or `Shift-Enter` would implicitly execute the code and show results within the `target` output node without ever needing to reach the *Run* button and lose the focus.
178
+
Depending on your operating system, a combination of either `Ctrl-Enter`,
179
+
`Cmd-Enter` or `Shift-Enter` will execute the code in the editor (no need to
180
+
move the mouse to click the run button).
179
181
180
-
## Execution Override
182
+
## Execution override
181
183
182
-
The editor offers great features even without interpreting code and in some case users would like to just bootstrap an editor then orchestrate what should happen once *Run* button is clicked or any of the keys combined to execute code is pressed.
184
+
Sometimes you just need to override the way the editor runs code.
183
185
184
-
The `handleEvent`attached to the script that bootstraps the editor can be overridden to achieve this with relative ease:
186
+
The editor's `handleEvent` can be overridden to achieve this:
185
187
186
188
```html title="Overriding execution via handleEvent."
187
189
<scripttype="mpy-editor"id="foreign">
@@ -197,21 +199,30 @@ def handle_event(event):
197
199
# prevent default execution
198
200
return False
199
201
202
+
# Grab reference to the editor
200
203
foreign =document.getElementById("foreign")
201
-
204
+
# Override handleEvent with your own customisation.
202
205
foreign.handleEvent= handle_event
203
206
</script>
204
207
```
205
208
206
-
[This live example](https://agiammarchi.pyscriptapps.com/pyeditor-iot-example/latest/) that allows one to play with micro controllers running MicroPython shows how the editor can be used to execute code via serial USB connection.
shows how the editor can be used to execute code via a USB serial connection to
212
+
a connected MicroPython microcontroller.
207
213
208
214
## Tab behavior
209
215
210
-
We are currently trapping the `tab` key in a way that reflects what regular *IDE* do: the code is simply indented, as opposite of losing the focus every single time.
211
-
212
-
We are fully aware of the implications this might have around accessibility so we followed [this detailed Codemirror's documentation](https://codemirror.net/examples/tab/) and allowed that *escape hatch* to be able to explicitly move focus outside the editor when it's meant.
216
+
We currently trap the `tab` key in a way that reflects what a regular code
217
+
editor would do: the code is simply indented, rather than focus moving to
218
+
another element.
213
219
214
-
That is: press `Esc` before `Tab` to see your focus moving to the next focusable element on the page but by default you can press `Tab` to indent the code as you would expect from your daily editor.
220
+
We are fully aware of the implications this might have around accessibility so
221
+
we followed
222
+
[this detailed advice from Codemirror's documentation](https://codemirror.net/examples/tab/)
223
+
We have an *escape hatch* to move focus outside the editor. Press `esc` before
224
+
`tab` to move focus to the next focusable element. Otherwise `tab` indents
0 commit comments