3 Script Screen
dxtr edited this page 2026-10-19 08:32:36 +02:00

The Script Screen

The editor's code editor is its Script screen, one of its main screens beside the 2D viewport, as Godot's Script screen is: the 2D and Script buttons at the top of the window, or Control+F1 and Control+F3, choose between them, and the scene tabs stay above either. In it you write a game's Lisp, compile it into the editor's Lisp, and so into a game that plays there, without Emacs; Emacs, connected by SLY to the same Lisp, works beside it, a file changed in one read again in the other.

(defvar *editor* (pyssel/editor:edit "~/games/arena/"))

;; As a double click on a Lisp file in the File System dock does:
(pyssel/scene:call-in-tree
 (pyssel/editor:editor-tree *editor*)
 (lambda () (pyssel/editor:open-script *editor* "arena.lisp" :line 10)))

A panel down the screen's left lists the files open, a filter field over them, (*) after a file's name while it has changes not saved, and under them the definitions of the Lisp file shown, as Godot's members overview; a click on one goes to it, and Control+\ shows and hides the panel. The file shown is edited in a code edit, its find and replace bar under it, and the status line under that says where the caret is, as line : column. Each file keeps its own undo history, its code edit's. The File, Edit, Search and Lisp menus hold what the keys below do; their keys act while the keyboard focus is in the Script screen.

Opening, saving and closing

A double click on a Lisp file, .lisp, .lsp, .cl or .asd, or a text file, as .txt, .md or .org, in the File System dock opens it, as open-script does, or shows it if it is open; File > Open... opens any. A file is read into lines and written from them, never as one string, and a keystroke costs what it changes, so a file of 90,000 lines types, indents and hints as quickly at its end as a short one.

Key Does
Control+Alt+S Save the file shown
Shift+Alt+S Save every file with changes
Control+W Close the file shown, asking first if it has changes
Control+Shift+T Open again the file closed last
Control+\ Show or hide the panel
Control+F1, Control+F3 Show the 2D viewport, or the Script screen

Quitting the editor, or Quit to Project List, asks about the files with changes too, with the scenes and resources. A file changed on disk, as by Emacs, is read again as the editor's window takes the keyboard focus, or its page shows, if its page has no changes; with changes, you are asked whether to read it again or keep yours. The editor keeps the files open, the one shown and the main screen shown in the project's .pyssel/editor.layout, and opens them again with the project.

Editing Lisp

A Lisp file is coloured as Emacs's Lisp mode colours it: comments, strings, characters, keywords, numbers, lambda-list keywords, the names definitions define, and the operators the editor's Lisp knows as macros and special operators, in the colours of Godot's editor, dark or light as the editor's theme is. Brackets and strings close as they are typed, and #| closes with |#; the bracket matching the caret's is marked, and a list left open on a line folds from its fold arrow. Return indents the new line as Emacs with SLY indents it, by the rules of Emacs's cl-indent.el and the specs SLY reads from macros' lambda lists, so a file edited in both editors keeps its indentation; Tab and Shift+Tab indent and unindent, and Control+I indents the lines selected, or the caret's, as Emacs would.

Key Does
Control+Space Complete the symbol before the caret
Control+K Comment the lines selected, or the caret's, with ;; , or uncomment them
Control+I Indent the lines selected, or the caret's
Alt+Up, Alt+Down Move the lines selected up or down
Control+Shift+K Delete the lines selected
Control+Shift+D Duplicate the selection, or the caret's line
Control+Alt+Down Duplicate the lines selected
Control+F, F3, Shift+F3 Find, find the next, find the one before
Control+R Replace
Control+Shift+F Find in the project's files
Control+L Go to a line

Completion offers the symbols whose names have the characters typed in order, as SLY's flex completion finds them, in the package the file's in-package names at the caret: those the package reaches, and other packages' external symbols with their shortest nickname, so uite finds ui:text-edit. Each shows the icon of what it names, a function, a macro, a class, a variable or a keyword. As the caret moves in a form, the hint under it shows the lambda list of the operator around it, the argument at the caret underlined, as SLY's autodoc: inside a macro's destructuring argument, as filespec of with-open-file; a keyword argument by its keyword; and make-instance of a quoted class with the class's initargs.

Compiling and evaluating

Key Does
Control+Return Compile the top-level form at the caret, or the last before it, as SLY's C-c C-c
Control+Shift+Return Save the file and compile it, as SLY's C-c C-k
Control+Shift+E Evaluate the selection, or the form before the caret, as SLY's C-x C-e
Lisp > Expand Macro Show the expansion of the form before the caret

Forms are read in the package the file's last in-package before them names, as SLY reads them. The editor compiles and evaluates on a thread of its own, so it draws on while the compiler works, and what they print goes to the Output dock. What compiles is loaded unless the compilation failed, on an error or a warning that is not a style warning, so a definition the compiler found wrong does not replace a working one. The compiler's notes are marked on the lines of the forms they concern, the forms underlined in red, yellow or blue as the note is an error, a warning or a style warning or note, the note in the mark's tooltip; and the Output dock lists them, a click on one going to its form. Compiling a form marks its lines afresh, and compiling the file the whole file. Evaluating says the values in the Output dock, as => 120, printed in the file's package; an error brings the Script screen's thread into the Debugger dock, where its ABORT abandons the evaluation. A redefined node class changes the scene shown and a game that plays at their next frames.

Finding things

Key Does
Alt+Period, or a click with Control Go to the definition of the symbol at the caret, as SLY's M-.
Alt+Comma Go back to where you went from, as SLY's M-,
Alt+F1 Show the symbol's help in a page of its own
Lisp > Who Calls List in the Output dock the functions that call it
Lisp > Who Macroexpands List where a macro expands

Going to a definition opens its file at its form, choosing among several, as a generic function's methods, in a dialog. The Scene dock's menu has Go to Class Definition, which opens a node's class's define-node form. Help shows what the symbol names: its lambda list or its value, a class's superclasses and slots, and their documentation.

Control+Shift+F asks what to find, in which folder, the project's by default, and in files of which types, lisp asd by default, with Match Case and Whole Words, as Godot's Find in Files; the Search Results dock, beside the Output dock, lists each occurrence under its file, a click on one showing it. Replace... lists them with a field and Replace All, which replaces every occurrence listed in the files on disk; a file open is read again then.

Thread rules

The Script screen is the editor's tree's, used on its thread, as open-script is called; it compiles and evaluates on a thread of its own, the jobs one after another in the order given, in the editor's session, and hands what they found back to the editor's tree. The services it asks, which any program may ask too, are on Code Services, and the reading of Lisp's text that colours, indents and finds forms on Lisp Text.