Skip to content

Commit 2282a9b

Browse files
committed
Language cleanups / edit.
1 parent d9aa4c9 commit 2282a9b

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

docs/user-guide/editor.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ If a `setup` editor is present, that's the only PyEditor that needs a config.
173173
Any subsequent related editor will reuse the config parsed and bootstrapped for
174174
the `setup` editor.
175175

176-
## Execution via keyboard
176+
## Run via keyboard
177177

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).
179181

180-
## Execution Override
182+
## Execution override
181183

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.
183185

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:
185187

186188
```html title="Overriding execution via handleEvent."
187189
<script type="mpy-editor" id="foreign">
@@ -197,21 +199,30 @@ def handle_event(event):
197199
# prevent default execution
198200
return False
199201
202+
# Grab reference to the editor
200203
foreign = document.getElementById("foreign")
201-
204+
# Override handleEvent with your own customisation.
202205
foreign.handleEvent = handle_event
203206
</script>
204207
```
205208

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.
209+
This
210+
[live example](https://agiammarchi.pyscriptapps.com/pyeditor-iot-example/latest/)
211+
shows how the editor can be used to execute code via a USB serial connection to
212+
a connected MicroPython microcontroller.
207213

208214
## Tab behavior
209215

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.
213219

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
225+
code.
215226

216227

217228
## Still missing

0 commit comments

Comments
 (0)