11 The Editor
dxtr edited this page 2026-10-20 10:09:08 +02:00

The Editor

edit opens a project, as open-project does, and the editor's window on it, as Godot's editor opens on a project; your REPL stays free:

(asdf:load-system :pyssel/editor)

(pyssel/editor:new-project "~/games/arena/")
(defvar *editor* (pyssel/editor:edit "~/games/arena/"))
;; Editing Arena, in /home/you/games/arena/.

*editor* is the REPL's way in to the editor, as for the examples of Getting Started.

Or build the editor as a program, as Godot's build is its editor:

stift build                       # in pyssel's directory: bin/pyssel
bin/pyssel                        # the project manager
bin/pyssel ~/games/arena          # the editor on a project, and bin/pyssel . on the one here
bin/pyssel --new ~/games/maze     # start a project there, and open the editor on it

The program ends once its window closes. As Godot's, the project manager opens a project by starting pyssel DIR as a new process, and the editor's Quit to Project List starts pyssel, so each project has a Lisp of its own. Control+C closes the window at once, losing the changes not saved, and ends the program with status 130. It holds Pyssel and the compiler, so Play compiles a game's changed files as at the REPL, its Script screen compiles and evaluates code, and its REPL dock is its REPL; it finds the default theme's fonts and the icons in the checkout it was built from, so it runs where it is built. It keeps Pyssel and the libraries as it was built with them, never loading their files again for a game that needs them, so a checkout updated since runs once stift build has built the program again.

The window has Godot's layout. Along the top are the Scene, Project, Edit and Help menus, the 2D and Script buttons, which choose the main screen, and the Play, Play Scene and Stop buttons, icons whose tooltips say what they do; below them, the main screen, a tab for each scene open, a star in its title while it has changes not saved; around it, the docks: the Scene dock, a tree of the scene shown; the File System dock, the project's folders and files, a double click on a scene opening it, on a resource showing it in the inspector, and on a Lisp or text file opening it in the Script screen, which makes, renames, moves, copies and deletes them as Godot's does; the Inspector dock, the properties of the node selected, with the Node dock beside it, its signals and groups; and the Output dock, what the editor says and what the games it plays print, a compiler's notes among it, which a click goes to, with the REPL dock, a REPL for the editor and one for a game while it plays, the Debugger dock, where a thread that met an error waits, and the Search Results dock beside it. The main screen shows the scene shown in its 2D viewport, as Godot's 2D editor does: drawn as it will play, a game's nodes too, over the project's clear colour; with no scene open, it says how to open one. Or it shows the Script screen, where code is edited, compiled and evaluated, as Godot's Script screen: Control+F1 shows the 2D viewport, and Control+F3 the Script screen, show-main-screen from the REPL.

  • The 2D viewport first shows a scene at 100%, the project's window from its top left, as Godot's 2D editor does. The wheel zooms about the pointer, a step of a tenth a notch, to whole zooms and fractions with Alt, from 0.78% to 12800%; with the viewport's focus, which the pointer over it takes from all but a text field, 1 to 5 zoom to 100% to 1600% and Shift with them to 50% down to 3.125%, about the pointer, and Control with 0 to 100%. The zoom widget in its corner shows the zoom, gives back 100% at a click, and its minus and plus, or Control with - and =, take six steps; Center View before it centres the view on the selection. The middle button pans, as does the left with Space held, and Control with the wheel, across with Shift. Each scene keeps its own view, its tree's root viewport's global canvas transform, as Godot's editor sets the edited scene's, which carries the scene's canvas layers with it, and the nodes under them are picked and handled where they are drawn; and what Godot's 2D editor keeps of a scene, as Godot keeps it in .godot/editor/: its snapping's switches and steps, what the viewport shows over it, and its selection, in a file of its own in the project's .pyssel/views/, written as the scene is saved, as its tab closes and as the editor closes, and read as it opens again; a scene moved in the File System dock takes its view along.
  • Over the picture it draws what Godot's does: the grid, while grid snap is on, or always or never as View > Grid says; the origin's axes and the project's window as a frame, while View's Show Origin and Show Viewport are on; rulers along its top and left edges, numbered in the grid's steps while the grid snaps or shows, else in round numbers, while Show Rulers is on; the guides across it, while Show Guides is; a lock and a group at the origins of locked and grouped nodes, and a cross at the origin of each node that draws nothing, as the Gizmos submenu says; the rectangles of the nodes selected, grey for a locked one, with resize handles around one selected alone, and a control's pivot; the Move and Scale tools' handles; the rectangle of a box selection and the line a turn goes about; the temporary pivot; red lines through what smart snapping snapped to; the names of the nodes that draw nothing under the pointer; and in its bottom left, what a drag does, as Moving: (40, 0) px. With View > Show Helpers, H, a drag also shows where the nodes were, and a control moved or resized alone with the Select tool shows its offsets and size. View's Center Selection, F, centres the view on the selection, and Frame Selection, Shift+F, zooms it to fill nine tenths of the view.
  • The toolbar is Godot's: the Select tool, Q; Move, Rotate and Scale, W, E and R; List Select, Pivot, Pan, G, and Ruler, M, the tool in use in the accent colour; Use Smart Snap, Shift+S, and Use Grid Snap, Shift+G; a menu of the snapping's options, Use Rotation Snap, Use Scale Snap, Snap Relative, Use Pixel Snap, on at first, Smart Snapping, which chooses what smart snapping snaps to, and Configure Snap, which sets the grid's offset and step, 8 units at first, how many steps apart its brighter lines are, the rotation's offset and step, 15 degrees at first, and the scale's step, 0.1 at first, for the scene and for the project, as Godot keeps them: a scene without a view of its own starts from the project's, which the editor's layout keeps; Lock or Unlock, Control+L and Control+Shift+L, and Group or Ungroup, Control+G and Control+Shift+G, which act wherever the focus is; and the View menu. The keypad's * and / double and halve the grid's step while it snaps or shows. The tools' keys and the menus' act while the viewport has the focus.
  • Selecting. A click selects the node drawn there, as the Scene dock shows it: what an instance of another scene made selects the instance's root, a node under one that groups its children selects that one, and a node that draws nothing is picked within 8 units of its origin; a locked node is never picked. Shift adds a node or takes it away, a click on nothing clears the selection, a drag from nothing, or with Shift, selects what its rectangle takes in, but locked nodes and what a group holds, and Escape clears the selection. Alt with the right button, or the List Select tool's click, lists the nodes under the pointer, the topmost first, to choose one: with Alt, locked and grouped nodes too, said so. A double click on an instance selected opens its scene. The right button opens the viewport's menu: Add Node Here and Instantiate Scene Here add a node or an instance where it was opened, under the current node; Paste Node(s) Here pastes the Scene dock's copies there; and Move Node(s) Here moves the canvas items selected there.
  • Changing nodes in the 2D viewport goes as in Godot's 2D editor. A drag of a node selected moves the selection once it goes 8 units, and the Move tool moves it from wherever the drag begins, along one axis from the arrows at the node's origin, and along the axis the pointer went further on alone with Shift. The Rotate tool turns 2D nodes about their origins and controls about their pivots, as the pointer goes round the first one's; the Scale tool scales them by how much further from the origin or pivot the pointer is than where the drag began, both axes alike with Shift, or along one axis from the squares at the origin or pivot, a scale more for each 25 units. The Pivot tool, or V with the Select tool, moves a control's pivot where the pointer is, keeping the control where it is drawn; Shift with either places the temporary pivot instead, and Shift with a click on the Pivot button puts it in the middle of the selection: until the selection changes, turns and scales go about it. A control a container places is neither turned nor scaled, as the Output dock says, and a locked node is not changed. With the Select tool, Alt moves, Control turns and Control with Alt scales. The handles around a node selected alone resize it: a control by its offsets, no smaller than its minimum size, and a 2D node by scaling it, so that what it draws fills the rectangle; Shift keeps the rectangle's shape, Alt resizes it about its middle. The arrow keys nudge the selection a unit, a step of the grid with Shift.
  • Snapping, as Godot's: while Use Smart Snap is on, or Control is held with it off, a move, a resize, a pivot and a guide go to the nearest within 10 units of the view along each of the node's axes of what the Smart Snapping submenu chooses: a node's parent's edges and middle, a control's anchors, its own sides and middle, other nodes' sides, middles and origins, and the guides. Then moves and resizes snap to the grid while grid snap is on, and to whole units while pixel snap is, for what is not turned; with Snap Relative, from where the selection was rather than the grid's offset. Turns snap to the rotation's steps while rotation snap or smart snapping is on, or Control is held with both off, and scales to the scale's steps while scale snap is on and Control is not held; with Snap Relative, both from where they were. Each drag, and each run of the arrows held, is one edit of the scene's history, named as Godot names it, as Move CanvasItem "player" to (40, 100), which one undo takes back whole; the inspector shows the values as they change. Escape or the right button takes a drag back, and undo and redo wait while a button is held.
  • Locking and grouping, as Godot's, are kept in the nodes' metadata, :edit-lock and :edit-group, saved with the scene: Lock Selected, Unlock Selected, Group Selected and Ungroup Selected are edits of the scene's history, and the Scene dock marks a locked or grouped node with a button that unlocks or ungroups it.
  • Guides and the ruler tool. A drag out of the left ruler makes a vertical guide, out of the top one a horizontal guide, and out of their corner one of each, snapped to the grid, pixels and other nodes as they go, saying where they are; a guide dragged on a ruler moves, and dropped back on the rulers it goes. A scene's guides are kept in its root's metadata, :edit-vertical-guides and :edit-horizontal-guides, places in the scene's units, and each change is an edit; View > Clear Guides takes them all away. The ruler tool measures from where its drag begins to the pointer, both snapped: the length, its lengths across and down and the triangle's angles, and in grid steps while grid snap is on.
  • The Scene dock shows the scene's root, its own nodes and the roots of the instances of other scenes among them, without what those instances made, each with its class's icon, as Godot's: a class of your game's shows the icon of the nearest of Pyssel's classes it is made from. The root of an instance has a button at the end of its row that opens its scene, a node an error stopped, from the moment it stops until it resumes, one with the error icon that says what stopped it, a node whose drawing failed, which shows what it drew before, one with the warning icon that says why, and a locked or grouped node one that unlocks it or ungroups its children. Its selection is the scene's, editor-selection, which the 2D viewport and the inspector show too. Add, the plus, or Control+A, asks the Create New Node dialog for a class, the node classes under their superclasses with their icons, filtered as you type, each described by its docstring, and adds a node of it under the current one; Instantiate, the chain's links, or Control+Shift+A, instances a scene there. F2 renames in place, Control+D duplicates, Control+Up and Control+Down move among the siblings, and Delete deletes, once you say so, Shift+Delete without asking; Control+X and Control+C cut and copy the nodes selected, and Control+V pastes them under the node selected, Control+Shift+V beside it, in any scene open, as Godot's; a right click opens a menu of the same, with Go to Class Definition, which opens the define-node form of the node's class in the Script screen. Drag nodes onto another to put them under it, or above or below it to put them beside it, and drag a scene from the File System dock to instance it there. Each change is an edit of the scene's history, named as Godot names it, so Control+Z undoes it.
  • The Inspector dock shows the properties of the node selected last, under headings of the classes that declare them, with their icons, the node's own class first, as Godot's does, filtered as you type in its field. A boolean has a check box; a number a spin box, with a slider where its type or a hint (:range min max :step step) gives it two ends; a string a line edit, with the text a hint (:placeholder text) gives, and a button that browses for a file where a hint (:file "*.scene") says it names one, its path relative to the project; a string a hint (:multiline) says is of several lines a text edit below its title, wrapping its lines, with a button that opens it in Edit Text, a larger dialog, as Godot's; a character a field of one; a member type, such as a deftype of keywords, an option button; a vector two spin boxes, in double-floats for a dvec2, so that a 2D node's position a million units out is edited to the thousandth; a colour a swatch that opens sliders and a hexadecimal field; a node a button that opens the scene's nodes, to choose one of the property's class, and clears it where it may be nil; a resource a button that shows it, its class's icon and its file, if it has one, and shows its properties in place below, to edit them as the node's, and a menu that makes a new one of the property's class or one that inherits from it, loads one, saves it to a file of its own, which the scene then refers to, or clears it; a value object, as a menu's item, a button that shows its properties in place; a list a button that shows its elements below it, as Godot's array editor, each with its editor and buttons that move it up and down or take it away, and a button that adds one, of the type a hint (:elements type hint...) names, as (:elements ui:menu-item) or (:elements string), or for a list without one, of a kind chosen from a menu, each element then edited as its own type says; a value that may be nil a check box beside its editor; a control's own theme items, under Theme Overrides at the end of its properties, as Godot shows them, a row for each item its class draws with, by kind, which a check box overrides, starting from the value it is drawn with, a copy of a style box, so the theme's stays as it was; and the rest are shown read only, for now. Revert, the reload icon beside a property that does not hold its default, gives it back, the default being what saving finds: its class's, or for an instance, its scene's. Each change is an edit of the scene's history, a drag or the typing in one field a single edit, so Control+Z undoes it; a value the node refuses is said in the Output dock. Saving a scene saves the resources with files of their own that it holds and that edits changed, but never over a file something else wrote since, which it says; closing it without saving reads the resources its edits changed from their files again. A resource opened from the File System dock, and the project's settings, which Project > Project Settings opens, show until a node is selected; their edits go into the project's history, the settings saved to project.pyssel at each, and such a resource with any scene, by Control+S, before a play, or as quitting asks. Control+Z undoes the newest edit of the scene shown and the project, as Godot's does, and redo makes edits again in the order they were made.
  • A playing game: while one plays, the Scene dock has two tabs, as Godot's Local and Remote. Playing shows the game's tree, read every second on the game's thread and handed back, so the editor never waits on a game; the node chosen there shows in the inspector as it plays, its values read five times a second, those that are objects read only, and a change handed to the game's thread and kept in no history, since the game goes on changing its nodes. The field being typed in keeps what is typed. Once the game stops, the tabs go. The REPL dock has a Game tab meanwhile, whose REPL evaluates in the game's session, and goes with it too.
  • The Node dock, a tab beside the Inspector's, as Godot's, shows the signals of the node selected last under the classes that declare them, each with the connections the scene keeps. Connect... opens a dialog that connects the signal chosen to a function, by default on-node-signal, read in the game's package, called with a node of the scene chosen there and then the signal's arguments, to persist, so the scene keeps the connection; define the function in the game's code. Disconnect takes the connection chosen away. Its Groups page lists the node's groups: a name adds one, a keyword unless the name gives a package, and each group's button takes the node out of it. Each change is an edit of the scene's history.
  • Shortcuts, Godot's: Control+N a new scene, Control+O to open one, Control+S to save the one shown, Control+Shift+S to save it as another file, Control+Shift+Alt+S to save every scene, Control+Shift+W to close it, Control+Z and Control+Shift+Z or Control+Y to undo and redo in its history, F5 to play the project's main scene, F6 the scene shown, F8 to stop, Control+Q to quit and Control+Shift+Q to quit to the project list, Control+F1 and Control+F3 the 2D viewport and the Script screen; the Scene dock's above, which fire wherever the focus is but in a text field; the File System dock's, on its page; and the Script screen's, on its page.
  • The project manager, the list of your projects, which bin/pyssel opens without a project and Quit to Project List opens, is on Project Manager.
  • Saving first: closing a scene with changes not saved, or quitting, or closing the window, asks whether to save them, and the Script screen's files with changes, as Godot does; playing saves the scenes changed without asking.
  • Playing plays as pyssel/play does, in an engine and a session of the game's own, the game's output in the Output dock, and the editor never waits on it: a game that does not stop when asked has the editor ask whether to wait longer, break into it with the debugger, or let it go. edit's :play-options are given to each play, as :title.
  • Icons are Pyssel's own, as the editor's design has them: SVG files on a 16-unit grid in pyssel/editor's icons/ directory, the node classes' coloured by kind, plain nodes in the theme's font colour, 2D nodes blue and controls green, the rest painted with currentColor, so the theme's font colour tints them, and those pyssel/ui's default theme gives, as the file dialog's folder, in pyssel/ui's. The editor rasterizes them at its window's scale, and again as the scale changes, with a pyssel/ui icon-set, editor-icons, from which icon gives an icon by its name, as (icon (editor-icons editor) :play), class-icon a node class's and file-icon a file's by its type; icon-names lists them. The project manager keeps its own, project-manager-icons.
  • Docks sit in five slots, two at each side and one under the main screen, as Godot's: drag a dock's tab to another slot to move it. The editor keeps where its docks are, where its splits are, the scenes it has open, the Script screen's files, the main screen shown and how the File System dock shows the files, its favorites among them, in the project's .pyssel/editor.layout, as they change, and puts them back when it opens the project again.
  • Settings are yours, not a project's: editor-settings, which load-editor-settings reads from ~/.config/pyssel/editor.settings, or %APPDATA%\Pyssel\ on Windows, and save-editor-settings writes, hold the two colours its theme is made from, make-editor-theme, as Godot's editor makes its own, a contrast, the size of its text, the painter it draws its text with, editor-settings-text-painter, :raster by default, whether its dialogs and popups are drawn inside its window, whether errors go to SLY's debugger while it is connected rather than its own, editor-settings-external-debugger, true by default, the size of the File System dock's thumbnails and the programs it opens files and folders in (see its page), and its shortcuts, an input map whose actions are those above, the project manager's among them. edit and manage-projects take them as :settings.
  • From the REPL: editor-open-scenes and editor-current-scene say what it has open, editor-open-scripts and editor-current-script the Script screen's files, editor-main-screen the main screen shown, editor-tree is its scene tree, whose nodes you reach with call-in-tree, editor-selection the nodes selected in the scene shown, which setf selects, on that tree's thread, inspect-value shows any object in the Inspector dock, and editor-output the stream its Output dock shows. close-editor closes it, changes not saved lost; one editor is open at a time, the session's current-editor, and edit closes the one before.