.. index:: single: Blade Runner single: Script editor single: BLADE command The Blade Runner Script Editor ============================== **Blade Runner** is IQcad's built-in editor for Python and Pascal scripts. It runs *inside* IQcad against the open drawing, so a script can be written, run, corrected and re-run without leaving the application or reloading anything. Open it with the ``BLADE`` command (alias ``BLADERUNNER``). The window is non-modal: leave it open beside the drawing while you work. The languages themselves are documented in :doc:`02_python_reference` and :doc:`03_pascal_scripting`; this chapter covers the editor. .. index:: single: Blade Runner — buffers Buffers and Files ----------------- Open scripts appear as tabs across the top of the editor. Each tab keeps its own caret position, scroll offset, undo history and language; switching tabs swaps the editor content. .. list-table:: :header-rows: 1 :widths: 26 16 58 * - Action - Shortcut - Notes * - **New Python** - Ctrl+N - Opens an empty buffer with Python syntax highlighting. * - **New Pascal** - — - The same for Pascal. * - **Open…** - Ctrl+O - The language follows the file extension: ``.py`` or ``.pas``. * - **Open Recent** - — - The ten most recently opened scripts, kept across sessions. * - **Save** - Ctrl+S - * - **Save As…** - Ctrl+Shift+S - * - **Close** - Ctrl+W - Closes the current tab; you are asked about unsaved changes. .. index:: single: Blade Runner — running scripts Running a Script ---------------- .. list-table:: :header-rows: 1 :widths: 26 16 58 * - Action - Shortcut - Notes * - **Run** - F5 - Runs the whole buffer against the active drawing. * - **Run Selection** - Shift+F5 - Runs only the highlighted text — the fastest way to try one call without splitting the file. Output appears in the pane below the editor: everything the script prints (``iqcad.write_line`` and its Pascal equivalent) is tee'd there **as well as** to IQcad's command line, so nothing is lost if the editor is closed. Runtime errors are reported in the same pane with their message and, where the host provides it, the line number. **Esc** interrupts a long-running script — see *Responsiveness and Esc* in the scripting chapters. Toggle the output pane from **View › Output**; drag the splitter to resize it. .. index:: single: Blade Runner — sidebar The Sidebar ----------- An activity bar down the left edge switches the sidebar between four panels. **Ctrl+B** shows and hides the sidebar; the panel you were last on, and the sidebar width, are remembered between sessions. .. list-table:: :header-rows: 1 :widths: 22 78 * - Panel - Contents * - **Recent** - The recent-files list. Double-click, or select and press **Enter**, to open one. * - **Snippets / Samples** - The sample scripts shipped with IQcad, Python first and then Pascal, each group sorted by name. Open one to use it as a starting point. * - **Outline** - The symbols in the current buffer: ``def`` and ``class`` for Python (indented by nesting), procedures, functions and type declarations for Pascal. Click a symbol to jump the caret to its line. * - **Explorer** - A file tree rooted at a folder of your choosing — point it at your script library and open files straight from it. .. index:: single: Blade Runner — find and replace Find, Replace and Navigation ---------------------------- .. list-table:: :header-rows: 1 :widths: 30 18 52 * - Action - Shortcut - Notes * - **Find** - Ctrl+F - Opens the find bar with **Aa** (match case), **W** (whole word) and **.\*** (regular expression) toggles, and a live match count. * - **Replace** - Ctrl+H - Adds the replace field, with **Replace** and **All**. * - **Find Next / Previous** - F3 / Shift+F3 - * - **Go to Line** - Ctrl+G - **Esc** closes the find bar. .. index:: single: Blade Runner — command palette The Command Palette ------------------- **F1** opens a command palette over the editor. Type any part of a command name — the match is fuzzy, so ``rsel`` finds *Run Selection* — and press **Enter** to run the top hit. Every editor action is reachable this way, with its shortcut shown beside it. .. index:: single: Blade Runner — theme Appearance ---------- **View › Theme** switches between the **dark** theme (the default, a VS-Code-style palette) and a **light** one. The choice applies to the editor, both syntax highlighters and the surrounding panels, and is remembered. Window position and size, the output-pane height, the sidebar state and the theme are all stored in IQcad's ``settings.json`` — see :doc:`/parts/cad_environment/15_settings`.