Edit code in the main window
The Editor is the left half of the main Resonon window, from the transport bar to the bottom, left
of the Browser. It shows the entry file of the open project: src/main.non, or the entry that
resonon.toml names. Open the window as the Mixer page
tells you.
Show the Editor
Section titled “Show the Editor”A new session shows the Editor. Press Command-Option-E or click the Editor header to hide it; it folds to a thin strip along the window’s left edge with its name written down it. Click the strip or press the keys again to show it.
Drag the Editor’s right edge to resize it, from a fifth to four fifths of the window. It keeps that share of the window when you resize the window. When you save the session, opening the session restores whether the panel is shown and its share of the window.
The panel shows the entry file after the session opens or runs a project, or runs code in one. Without a project it tells you to open or run one.
Edit the file
Section titled “Edit the file”Click in the text to give the Editor the keyboard. A thin grey outline around the Editor shows that it has the keyboard. Most keys work as in a Mac text editor. Text undo uses Control-Z:
| Keys | Result |
|---|---|
| Click, drag | Places the cursor, selects text. |
| Double-click, triple-click | Selects the word, the line. |
| Shift-click | Extends the selection to the click. |
| Option-arrow, Command-arrow | Moves by word, to the line’s start or end, to the file’s start or end. Shift extends the selection. |
| Command-C, Command-X, Command-V | Copies, cuts, pastes. With nothing selected, copy and cut take the whole line. |
| Control-Z, Control-Shift-Z | Undoes, redoes the last change to the text. |
| Command-Z, Command-Shift-Z | Undoes, redoes the last UI session change. |
| Tab, Shift-Tab | Indents, outdents the selected lines. |
| Command-/ | Comments or uncomments the selected lines. |
| Command-S | Saves the file. |
A dot after the file name shows that the file has changes that are not saved. Input methods work: the text being composed shows underlined at the cursor. Hold a letter to pick an accented one from the macOS accent menu: the accented letter replaces the one you held. When the file changes on disk and the Editor has no changes that are not saved, the Editor shows the new text.
Press Control-Space to show completions at the cursor. The list shows one completion under the other, with the documentation of the selected one beside it. Up and Down select, and the list scrolls to keep the selection in view; Enter or Tab inserts it, and a click inserts the one clicked. Escape closes the list.
Optional Vim bindings
Section titled “Optional Vim bindings”Turn on Vim Mode on the Editor tab of the
Preferences window, or set
editor_vim = true under [display] in ~/.resonon/preferences.toml and run
reload_preferences(). The open Editor changes at once. The default is off. The panel shows the mode and uses a block
cursor in Normal mode and a bar in Insert mode. A file opens in Normal mode, as in Vim, where
typed keys are commands: press i before you type text.
Use i/a/I/A, o/O, Escape, v/V, counts, h/j/k/l, w/b/e,
0/^/$, gg/G, and forward f/t. Operators d/c/y accept motions,
doubled line operators, and iw/aw, i(/a(, i"/a" text objects.
Use x, p/P, u, Control-R, and . to delete, paste, undo, redo,
and repeat a change. One insert session is one undo step, including line breaks.
:w followed by Enter saves the file.
Control-Z and Control-Shift-Z also undo and redo text in every mode. Command-Z and Command-Shift-Z undo and redo session changes in every mode. Command-S and the run shortcuts still work in every mode. Visual selections use the same Run Selection Live path as mouse selections. Escape returns to Normal mode and keeps the keyboard in the Editor. When the completion list is open, Escape closes it and returns to Normal mode. Click the session to give it the keyboard.
Mappings
Section titled “Mappings”Put vimrc mapping lines in editor_vim_maps, under [display]:
[display]editor_vim = trueeditor_vim_maps = ["inoremap fd <Esc>", "noremap H ^", "noremap L $"]With these lines, fd typed in Insert mode returns to Normal mode, and H and L go to the
first character that is not a space and to the end of the line. noremap maps in Normal mode,
Visual mode and after an operator, so dL deletes to the end of the line. nnoremap,
xnoremap, onoremap and inoremap map in one mode. A mapping does not remap: its keys
always have their usual meaning. Keys are characters or <Esc>, <CR>, <Tab>, <BS>,
<Space>, <lt> and <Bar>.
When a key can start a mapping, the Editor waits up to one second for the next key, as Vim’s
timeoutlen does. In Insert mode, the waiting text shows at the cursor. If the next key does
not continue the mapping, or no key comes in time, the waiting keys have their usual meaning.
To type fd as text, pause after f. The Output strip names a line that cannot be applied.
This is a scoped keymap. Search, backward find, named registers, macros, marks,
block selections, window commands, and Ex commands other than :w are not included.
Run code
Section titled “Run code”With the text focused, press Command-Enter to Run Selection Live. With nothing selected, it runs the current line. The range flashes briefly. This evaluates in the current session, like Run Selection Live in VSCode or Neovim. Code execution is not a session undo step. Correct the source and run it again to change the result.
Press Command-Shift-Enter, or click Run File Live, to save the panel’s dirty files and
evaluate the whole entry file into the running session. It does not reset the session or call
setup(), and the transport and the mixer do not change. A changed pattern starts on the next
cycle. A disk conflict or save error prevents the run. Session undo does not undo the run.
To open the project again from its files, select File > Reset Project. It saves the editor files first. It asks before it loses changes made since the last save. If tracks were renamed in the session, choose Update and Open to update their names in code first, or Cancel to keep the current session. See The entry file’s lifecycle.
The Output strip shows printed output and execution errors, including later callback output. Click its header to collapse it, or drag its top edge to resize it. Saving the session keeps its height and whether it is shown. Show other clients includes subsequent output from other editors. Errors and warnings underline their source ranges; hover over an underline for the message. Click a file’s diagnostic in Output to open it. Completing another run replaces that file’s marks.
Give the keys back to the session
Section titled “Give the keys back to the session”Click the Arrangement, the Mixer or the transport bar, or, with Vim bindings off, press Escape. Then Command-S saves the project session, and Space toggles play and pause. While the Editor has the keyboard, Command-S saves the file. Space also toggles play and pause in Vim Normal and Visual modes. In Insert mode, Space types a space. New projects start stopped; press Play in the transport to start playback.
Command-Z and Command-Shift-Z undo and redo session changes with or without the Editor focused. Single-line fields, such as track names, dB entries and Browser search, keep these keys for their own text while focused.
A thin grey outline shows which panel has the keys. The Editor has the outline only while it has the keyboard. Otherwise the outline is on the panel you last clicked in: the Arrangement, the Mixer, the Devices panel or the Browser. A field you type in, such as a track name or the Browser search, puts the outline on its panel. A collapsed panel has the outline on its header or strip. A click on the transport bar does not change the panel you last clicked in. If the Editor had the keyboard, the click gives the keys and the outline back to that panel. When the window opens, the Arrangement has the outline. While the Browser has the outline and no field has the keyboard, the arrow keys and Return go to the Browser; see use the Browser with the keyboard.