diff --git a/BUGS-TO-REPORT.md b/BUGS-TO-REPORT.md
index 575e98ea0..e22cc8df0 100644
--- a/BUGS-TO-REPORT.md
+++ b/BUGS-TO-REPORT.md
@@ -1549,7 +1549,7 @@ On BETA 1034 (and 1010) the read crashed the compiler, under `On Error Resume Ne
Severity: low. The error can be handled, and the workaround is to stop at the folder whose `Path` is `twinbasic:/` without reading its `Parent`.
-
+
---
@@ -13404,7 +13404,7 @@ The list starts with the flag `false`, the value **Smoother Scrolling** has when
On a patched copy of the BETA 1042 install, the lane's test of the second emptying fails, its two controls pass, and both add-in tests pass.
-
+
---
@@ -13496,3 +13496,185 @@ Severity: high. An access violation that `On Error` cannot catch ends the progra
Checked on BETA 1034, which raises 438 for the `Collection` too, so the crash is new in a build after 1034.
+
+---
+
+## Applying a panel layout loses an add-in's tool window that floats shown or is docked: it leaves the page, and the add-in's OnClose never runs
+
+**Describe the bug**
+Applying a panel layout closes every add-in's tool window, so that each add-in can make its window again where the new layout puts it, and the add-in hears of it through the window's `OnClose` event. On BETA 1042 that works only for a floating window that is hidden. A window that floats and shows, or that is docked, is taken out of the IDE's page before it is closed, and the close then fails without a message: the window disappears, the add-in's `OnClose` never runs, and the add-in still holds a `ToolWindow` that shows nothing. Setting its `Visible` to `True` raises no error and shows nothing. A floating window lost this way stays lost until the IDE is restarted: neither applying a layout that floats it nor restarting the compiler brings it back.
+
+**To Reproduce**
+`layout-loses-addin-toolwindow` is an add-in project: building it makes a DLL that the IDE's compiler loads on every start until the DLL is removed. Install it knowingly, in an IDE you can restart, and remove it afterwards.
+
+Steps to reproduce the behavior:
+1. Open `layout-loses-addin-toolwindow.twinproj` (attached as `layout-loses-addin-toolwindow.zip`) and build it for Win32. Copy `Build\LayoutLosesAddinToolwindow_win32.dll` into `%APPDATA%\twinBASIC\addins\win32\` and restart the IDE. Open any project: the toolbar has a button, *Show the tool window*. The add-in adds one tool window, hidden, and makes it again when it is closed, as an add-in that keeps its window does:
+ ```
+ Private Sub MakePane()
+ Set Pane = Host.ToolWindows.Add("Repro", "ReproPane")
+ Pane.Title = "REPRO WINDOW"
+ Pane.RootDomElement.ChildDomElements.Add("reproText", "div").Properties.innerText = "the add-in's tool window"
+ End Sub
+
+ Private Sub ShowButton_OnClick()
+ Pane.Visible = True
+ Host.DebugConsole.PrintText "shown"
+ End Sub
+
+ Private Sub Pane_OnClose()
+ Host.DebugConsole.PrintText "OnClose"
+ MakePane
+ End Sub
+ ```
+2. With the window hidden, choose **Window > Panel Layouts > Default Built-in Layout**. The DEBUG CONSOLE prints `OnClose`: the IDE closed the window, and the add-in made it again. This is right.
+3. Click *Show the tool window*. The window *REPRO WINDOW* floats over the editor.
+4. Choose **Window > Panel Layouts > Default Built-in Layout** again. The window disappears, and the DEBUG CONSOLE prints no `OnClose`.
+5. Click *Show the tool window*. The DEBUG CONSOLE prints `shown`, with no error, and no window appears.
+6. Close the IDE and delete `LayoutLosesAddinToolwindow_win32.dll` from `%APPDATA%\twinBASIC\addins\win32\`.
+
+**Expected behavior**
+The shown window is closed as the hidden one is in step 2: the add-in's `OnClose` runs, and the window it makes again is placed by the new layout. Applying a layout should never lose an add-in's window, nor leave the add-in holding a window that shows nothing.
+
+**Desktop:**
+ - OS: Windows 10 Pro 22H2 (build 19045)
+ - twinBASIC compiler version: BETA 1042
+
+**Additional context**
+A docked window is lost the same way: with a layout that docks the window (an entry `{"id": "ADDIN_ReproPane", ...}` among its docked panels) applied, and the window showing there, applying any other layout takes it out of the page with no `OnClose`. That window comes back in its place, hidden, when a layout that docks it is applied again, and `Visible = True` then shows it, but the add-in has still heard no `OnClose`.
+
+What does not reproduce it: a floating window that is hidden (step 2).
+
+The cause is in `ide/main.js`. `setActivePanelLayoutName` calls `removeAllFloatingPanels` first, which takes every floating panel that has a size out of the page with `closePanelBySectionHeader`, as if it were a built-in panel; a floating add-in window that shows is one of them. Then `restorePanelLayout` takes the dock (`outermostDock`) out of the page, and only then calls `closeAllAddinToolwindows`, which closes each add-in window with `addInEvents.toolWindowClose`. That calls the window's `onClose`, set by `createToolWindowById`, which calls `closePanelBySectionHeader` again on a window that is no longer in the page. It throws, and `toolWindowClose` catches the error and answers with `sendModalResultFailed`, so neither the rest of `onClose` (`delete toolWindowsById[...]`) nor the `closeEventJob` that raises `OnClose` in the add-in runs. The window stays in `toolWindowsById`, out of the page, and a later `ToolWindows.Add` with its id, after a compiler restart too, is handed that window by `createToolWindowById`. A hidden floating window has no size, so `removeAllFloatingPanels` skips it and it is still in the page when it is closed. Closing every add-in window before `removeAllFloatingPanels` runs closes each while it is in the page, with its `OnClose`; an add-in can do that by wrapping `setActivePanelLayoutName`, which is how the twinBASIC help add-in keeps its pane.
+
+Severity: medium. An add-in's window disappears with no message whenever the user applies a layout while it shows, and an add-in that makes its window again in `OnClose`, as one that keeps its window across layouts has to, never gets it back while the IDE runs.
+
+
+
+---
+
+## Showing a floating add-in tool window again gives it the add-in's suggested size, losing the size a panel layout or a resize by hand gave it
+
+**Describe the bug**
+An add-in can suggest the size its tool window floats at, with `RootDomElement.Properties.suggestedWidth` and `suggestedHeight`. On BETA 1042 the IDE applies that size every time the add-in shows the floating window again with `Visible = True`, not only the first time: a window the user resized by hand, or one a panel layout floats at a size of its own, is back at the suggested size once it has been hidden and shown. Its place is kept.
+
+**To Reproduce**
+`toolwindow-show-suggested-size` is an add-in project: building it makes a DLL that the IDE's compiler loads on every start until the DLL is removed. Install it knowingly, in an IDE you can restart, and remove it afterwards.
+
+Steps to reproduce the behavior:
+1. Open `toolwindow-show-suggested-size.twinproj` (attached as `toolwindow-show-suggested-size.zip`) and build it for Win32. Copy `Build\ToolwindowShowSuggestedSize_win32.dll` into `%APPDATA%\twinBASIC\addins\win32\` and restart the IDE. Open any project: the toolbar has a button, *Show or hide the tool window*. The add-in adds one tool window, hidden:
+ ```
+ Set Pane = Host.ToolWindows.Add("Repro", "ReproPane")
+ Pane.Title = "REPRO WINDOW"
+ With Pane.RootDomElement
+ .Properties.suggestedWidth = "500px"
+ .Properties.suggestedHeight = "600px"
+ .ChildDomElements.Add("reproText", "div").Properties.innerText = "the add-in's tool window"
+ End With
+ ```
+ and the button runs:
+ ```
+ Shown = Not Shown
+ Pane.Visible = Shown
+ ```
+2. Click the button. *REPRO WINDOW* floats in the middle of the IDE, 500 by 600 (CSS) pixels.
+3. Drag the window's right edge to the left and its bottom edge up, to make it about 350 by 400.
+4. Click the button twice. The window hides, then shows at its place, 500 by 600 again.
+5. Close the IDE and delete `ToolwindowShowSuggestedSize_win32.dll` from `%APPDATA%\twinBASIC\addins\win32\`.
+
+**Expected behavior**
+The window shows again at the size it had when it was hidden, 350 by 400. A suggested size is the size of a window that has none yet, its first time; once the user or a layout has given it one, that one is kept.
+
+**Desktop:**
+ - OS: Windows 10 Pro 22H2 (build 19045)
+ - twinBASIC compiler version: BETA 1042
+
+**Additional context**
+The same happens to a window a panel layout floats. A layout whose floating panels include `{"id": "ADDIN_ReproPane", "left": 100, "top": 80, "width": 320, "height": 240}` puts the window there at 320 by 240 when it is applied, and once the window has been hidden and shown it is 500 by 600.
+
+What does not reproduce it: a window for which the IDE has a place in `floatingToolWindowsData`, which keeps its size. That object is loaded from the `floatingToolWindows` of the saved panel layout setting, and nothing in BETA 1042 adds to it.
+
+The cause is in `ide/main.js`. `addInEvents.toolWindowSetVisible`, given true for a floating window, sets the floating panel's width and height from `bodyElement.suggestedWidth` and `suggestedHeight` whenever `floatingToolWindowsData[persistenceId]` is missing. The function that writes that entry, `saveFloatingToolWindowPosition`, is called only by the resize bars made in the `if (0)` branch of `addInEvents.createToolWindow`, which never runs. The resize bars of the floating panel the window is actually in (`moveToFloatingPanel`) call `savePanelsConfiguration` alone, and `restoreFloatingConfig`, which floats an add-in window at a layout's place, sets the panel's style alone. Writing the entry where a floating add-in window is resized and where a layout places it, or applying the suggested size only to a window that has not been shown before, would keep the size.
+
+Severity: low. Nothing is lost but the size, but it is lost every time: an add-in that hides and shows its window often, as a help pane does, undoes the user's resize each time, and a layout's size for the window holds only until it is next shown.
+
+
+
+---
+
+## Alt+A and Alt+R run the Find / Replace panel's Replace All and Replace from the code and from Quick Find, with the panel closed
+
+**Describe the bug**
+The Find / Replace panel's keys for **Replace** (Alt+R) and **Replace All** (Alt+A) work outside the panel: in the code, and in the editor's Quick Find widget, while the panel is closed. They run the panel's own search, with the text its **Find What** and **Replace With** hold. Alt+A is also the key of **Edit → Select All Matches**: once **Find What** holds text, Alt+A in the code selects no match and replaces every match of **Find What** in the file with **Replace With** instead. Ctrl+F empties **Replace With**, so after any search with the panel, Alt+A deletes every match of that search. In Quick Find, Alt+R and Alt+A act on the panel's search, not on Quick Find's; Alt+R is the key Monaco's own find widget gives to *Use Regular Expression*, so a user who presses it there to turn regular expressions on changes the code instead. It was observed by operating the IDE with key events in an IDE started with an `APPDATA` of its own, and reading the code, the selections and the message boxes after each key.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Open any project and a module such as:
+ ```
+ Module Fruit
+ Public Sub Main()
+ Dim apple As Long
+ Dim banana As Long
+ apple = 1
+ banana = 2
+ Debug.Print apple + banana
+ End Sub
+ End Module
+ ```
+2. Put the caret inside `banana` on the `Dim banana` line and press Ctrl+F. The panel shows with `banana` in **Find What** and **Replace With** empty. Press Esc: the panel closes.
+3. Put the caret inside `apple` on the `Dim apple` line and press Alt+A. A box says *The specified region has been searched. 3 replacements were made.* Every `banana` is gone, and there is one cursor, not one on each `apple`.
+4. Put the module's text back. Put the caret inside `apple` again and press Alt+R: the next `banana` is selected. Press Alt+R again: that `banana` is deleted.
+5. Put the module's text back. Press Alt+H, type `apple` in the box to find, press Tab, type `pear` in the replace box, and press Shift+Tab. Press Alt+R twice: a `banana` is deleted and no `apple` is replaced. Press Alt+A: every `banana` is deleted, with the same box as in step 3.
+
+**Expected behavior**
+Alt+R and Alt+A run the panel's **Replace** and **Replace All** only while the focus is in the panel, as its other Alt keys do. In the code, Alt+A runs **Select All Matches**: a cursor on each `apple`, as in an IDE whose panel has not been used. In Quick Find, neither key touches the panel's search.
+
+**Desktop:**
+ - OS: Windows 10 Pro 22H2 (build 19045)
+ - twinBASIC compiler version: BETA 1042
+
+**Additional context**
+The cause, read from `ide\main.js`: `globalKeyDown`, a keydown listener on the document in the capture phase, passes each key to `executeKeyboardShortcuts`, which runs every command bound to the key whose `defaultContext` holds, until one sets `completelyStopKeyEventProcesing`. `tbFindReplace_ReplaceNext` and `tbFindReplace_ReplaceAll` have the context `focusedFindReplace || focusedEditor`, like `tbFindReplace_Next` and `tbFindReplace_Prev` (F3 and Shift+F3, which are meant to work from the code too), while the panel's other Alt keys have `focusedFindReplace` alone. `focusedEditor` holds wherever the focus is in the code editor's panel, Quick Find's boxes included. `tbEditor_FindWidget_SelectAllMatches`, also Alt+A, sets no stop flag. Giving the two commands the context `focusedFindReplace` alone would fix both.
+
+What does not reproduce it: Ctrl+Shift+L in the code, which selects every match of the word at the caret and changes nothing, with the panel closed and **Find What** holding text; and Alt+A in an IDE whose panel has not been used, which selects every match.
+
+Severity: high. A key the Edit menu shows for selecting text changes the code instead, every time once the panel has been used, and Alt+R does it with no message at all.
+
+
+
+---
+
+## Enter in Quick Find's replace box adds a line break to the replacement instead of replacing
+
+**Describe the bug**
+In the replace row of the editor's Quick Find widget (Alt+H), Enter puts a line break into the replace box, which grows to two lines, and replaces nothing. **Replace All** then writes that line break into the code after each replacement. In the box to find, Enter goes to the next match. It was observed by operating the IDE with key events in an IDE started with an `APPDATA` of its own, and reading the widget's state and the code.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Open any project and a module such as:
+ ```
+ Module Fruit
+ Public Sub Main()
+ Dim apple As Long
+ apple = 1
+ Debug.Print apple
+ End Sub
+ End Module
+ ```
+2. Press Alt+H, type `apple` in the box to find, press Tab and type `pear` in the replace box.
+3. Press Enter. Nothing is replaced, and the replace box grows from one line to two: the replacement is now `pear` and a line break.
+4. Click **Replace All** (the button at the right of the replace box). Each `apple` becomes `pear` followed by a line break, and the module has three lines more: `Dim pear` and ` As Long` are on two lines.
+
+**Expected behavior**
+Enter in the replace box replaces the current match and goes to the next one, as it does in Monaco's own find widget, which Quick Find is, or it does nothing. It does not change the replacement.
+
+**Desktop:**
+ - OS: Windows 10 Pro 22H2 (build 19045)
+ - twinBASIC compiler version: BETA 1042
+
+**Additional context**
+None of the keys Monaco's find widget has of its own works in Quick Find on BETA 1042 (Alt+C, Alt+W, Alt+L and Alt+P for the toggles, Ctrl+Shift+1 to replace, Ctrl+Alt+Enter to replace all), and its tooltips name no keys, so the IDE handles the widget's keys with its own keymap alone. In it, Enter in Quick Find is `tbFindWidget_FindNext`, with the context `focusedFindWidget`; nothing takes Enter in the replace box, and the box, a text area that holds several lines, takes it as a line break.
+
+Severity: low. The box shows a second line, but nothing says that the replacement now ends with a line break, and **Replace All** then breaks every line it changes.
+
+
+
diff --git a/WIP.Authoring.md b/WIP.Authoring.md
index e4a203395..eb237b916 100644
--- a/WIP.Authoring.md
+++ b/WIP.Authoring.md
@@ -75,7 +75,7 @@ Formatting conventions:
- Code blocks use ` ```tb ` (highlighted via Shiki using the vendored `builder/twinbasic.tmLanguage.json` grammar).
- Parameter lists use the deflist `term` + `: definition` indentation pattern (NOT the MS-style markdown table).
- Set `vba_attribution: true` in the frontmatter on any page derived from VBA-Docs; omit it on fully original content (e.g. VB package pages). The flag drives an extra line in the site footer.
-- An image names the dark `X.png` only, never `X.light.png`, `X.svg` or `X.light.svg`: the build pairs the two themes and shows each theme's SVG where `shoot_docs --svg` wrote one. `png` in the attribute block (`{:width="190" height="337" png}`) keeps that picture's PNG in every output. The rules are in [Authoring, A picture in both themes](docs/Documentation/Authoring.md#a-picture-in-both-themes) and the section after it.
+- An image names the dark `X.png` only, never `X.light.png`, `X.svg` or `X.light.svg`: the build pairs the two themes and shows each theme's SVG where `shoot_docs --svg` wrote one. `png` in the attribute block (`{:width="190" height="337" png}`) keeps that picture's PNG in every output, and `secondary` shows it at 3/4 of its size in the column (`SECONDARY_SCALE` in `builder/render.mjs`): **an IDE page that shows a picture of the Help Add-In marks it `secondary`** (owner). **Everything an IDE page says about an add-in goes in a `> [!ADDIN]
` box** (owner: it does not document the product directly), after the IDE's own behaviour, linking to the section of the add-in's page that has the details ([Authoring, What an add-in adds to the IDE](docs/Documentation/Authoring.md#what-an-add-in-adds-to-the-ide)). It is grey, and a `` outside the book; the book unwraps it. The rules are in [Authoring, A picture in both themes](docs/Documentation/Authoring.md#a-picture-in-both-themes) and the section after it.
### Attribution policy
diff --git a/WIP.Harness.md b/WIP.Harness.md
index e84b34900..c80f6c2a2 100644
--- a/WIP.Harness.md
+++ b/WIP.Harness.md
@@ -924,6 +924,12 @@ phase keep their numbers in the code: the licence and overlay before a press (`p
a crash's file name (`awaitCrashName`, 5 s), `waitForCompile`'s 5 s stand-still and 300 ms
early quiet, the two seconds a failure line is given before a build is taken as failed, and the
operation waits of the lanes and `shoot_docs`.
+One compile has more than the file's limit: the `help-offline` lane's build of the help add-in,
+which embeds the ~60 MB help archive, gets the file's `compile` plus 20 s (`ARCHIVE_COMPILE_MS`
+in `test/addin/help.test.mjs`, through `Lane.addAddin`'s `timeout`). The archive holds the
+compiler's start: on BETA 1042 that compile settled 8.0 to 9.7 s after the project opened (the
+compile itself 6 ms), the add-in without it 1 to 2 s, so the 10 s limit failed the lane now and
+then ("did not settle within 10 s").
### Timing each phase: `TB_TIMINGS`
@@ -1264,6 +1270,23 @@ main.htm" rather than reload a page that has not. A marker still
missing after that is a harness error, exit 2, since the run would have the user's settings. The hook's
connection lives as long as the process, so a `tbbuild --keep` IDE is hooked until `tbbuild` ends.
+**The same script fixes defects of the IDE that would mislead every tool** (`IDE_FIXES` in
+`tb-defaults.mjs`, each named by its BUGS-TO-REPORT.md entry's slug and applying that entry's
+`bugs//fix.js` in the page rather than to the install). The first is
+*console-cleared-at-open*: BETA 1042 empties the DEBUG CONSOLE a second time as the first project
+opens, which erased an add-in's loaded line and failed `help`, `help-offline`, `keys-help` and
+`parent` on the plain install (2026-11-12; before that they were judged on a patched copy, which
+every other tool reading the console at an open had no way to use). The console's list is assigned to
+`debugConsoleContent`, a `var` of `main.js` with no initialiser, so the setter the script puts on
+`window` stays and sees the assignment; it sets the list's `useCachedItemHeights` to `false` when the
+build left it unset, which is the fix's one line. **A fix never hides its defect:** it acts only where
+the build still has the defect (BETA 1034's list, or a fixed build's, has the flag set, and is left
+alone), it is listed in `__tbDefaults.fixes` only when it acted, and the lane that asserts the defect
+leaves it out (`unfixed`, which `launchIde` and `Lane.open`/`openNoProject` take), so `bug_repro.mjs
+verify` still judges the plain build. When the entry is retired, its fix goes from `IDE_FIXES`, and the
+lane's `unfixed` then throws until it goes too. `try-help-addin` (`userSettings`) has no hook, so no
+fixes: it is the user's own IDE. `test/ide-folders.test.mjs` tests the fix and its controls.
+
## A private IDE for every lane
**The compiler loads every DLL in `\addins\win32` or `\win64` as it starts.** A
@@ -1784,6 +1807,16 @@ probe lanes:
The probe opens nothing, so running an IDE without the variable is safe. Two IDEs in one
lane need no change to the runner, and the second takes the lane's slot once the first has
been ended.
+- [test/addin/toolwindow-layouts.test.mjs](test/addin/toolwindow-layouts.test.mjs): two IDE
+ defects of BUGS-TO-REPORT.md, `toolwindow-show-suggested-size` and
+ `layout-loses-addin-toolwindow`, which the help add-in works round in `layouts.js`. Its
+ LayoutsProbe add-in ([test/addin/probes/layouts](test/addin/probes/layouts)) has one tool
+ window with a suggested size, two buttons that show and hide it, and an `OnClose` that
+ prints `closed` and makes the window again. The scenario makes layouts in
+ `customPanelLayouts`, applies them with `setActivePanelLayoutName`, resizes the floating
+ window with mouse events on its resize bars, and reads `toolWindowsById`. A floating window
+ the IDE loses stays lost through a compiler restart, so the docked case opens a second IDE.
+ About 35 s.
**Timing:** the thirteen lanes other than widgets (24 s alone) take about two minutes at the default two at a time
(the env lane is 16 s alone, the help lane 15 to 18 s, of which its sixteen cases are about 6 s). Typical lane costs: an add-in build about 10 s, a host IDE
diff --git a/WIP.HelpAddin.md b/WIP.HelpAddin.md
index 8d9c386c8..002425051 100644
--- a/WIP.HelpAddin.md
+++ b/WIP.HelpAddin.md
@@ -924,8 +924,10 @@ not: a restart saves a harness about a second against opening a new IDE.
lookup from there goes through the search box.
- **The pane's first floating size** is `min(480px, 85vw)` by `min(640px, 85vh)`,
the root's `suggestedWidth` and `suggestedHeight`. `toolWindowSetVisible` in `main.js`
- copies them into the floating panel's `style` the first time the window shows floating,
- when the IDE has no saved place for it (`floatingToolWindowsData`), and then centres the
+ copies them into the floating panel's `style` each time the window shows floating
+ when the IDE has no saved place for it (`floatingToolWindowsData`), which nothing in BETA
+ 1042 writes, so a resize by hand is undone too (BUGS-TO-REPORT.md's
+ toolwindow-show-suggested-size), and then centres the
panel by its laid-out size, so a CSS `min()` works. A plain 640px was taller than the page
of a 1200 by 900 IDE window at 150% (800 by 600): the IDE centred it at a negative
`top`, its title bar partly above the page, and it covered the toolbar. The lane checks 480 by 640 in a
@@ -1287,6 +1289,197 @@ not: a restart saves a harness about a second against opening a new IDE.
options scale text but not icons or controls. Emulated device scaling (what a WebView2
`ZoomFactor` does) was right throughout, so whole-IDE zoom needs that host call
upstream. The probe and pictures are in `.claude/scratch/zoom/`.
+13. **A keyboard shortcut editor** (owner, 2026-11-12: on by default, Table first, the built-in
+ group read-only with no actions, conflicts across every active group), tested by the
+ `ide-test` lane `keyeditor` (`test/ide/keyeditor.test.mjs`, the script put into the page
+ with no add-in) and by the `help` lanes (the settings box, and the script with its
+ descriptions put in by the add-in). `Resources/SCRIPTS/keyeditor.js`, put in by `BuildPane`
+ with a third settings row (`Fixes`, `KeyEditor`, on by default; the window's box follows
+ through `keyeditor:<1|0>`), fills the pane `showManageKeyboardShortcuts` leaves at *Keyboard
+ editor coming soon*. It goes in only while that text is in the function's source.
+ - **Reached by** replacing the global `showConfigEditor` (main.js is a classic script, and
+ the dialog calls it by name) with a function that changes only the call titled *Manage
+ Keyboard Shortcuts*: it wraps the options' `getEntryEditorDomNode`, `addNewEntry` and
+ `deleteEntry`, which `showConfigEditor` looks up on the options at each call. The
+ original is kept as `tbDocsOriginal` on the wrapper and in `window.tbDocsKeyEditor`, so a
+ second run never wraps a wrapper; turned off, the original goes back and an open dialog
+ gets its text area and Edit as JSON box back.
+ - **The group stays the IDE's.** The IDE's JSON pane is built as always (its closure's
+ flag starts true, and the table hides the box that would change it) and hidden; the table
+ reads the group from its text area and writes every change into it with an `input` event,
+ so the IDE's own `oninput` keeps the dialog's copy and turns on Save Changes. The table
+ edits the parsed object in place, so the entries keep their order and an entry it does
+ not touch keeps its strings as written. A group that is not a JSON object is shown as
+ text, and nothing is written to it.
+ - **What the table cannot edit** is listed, never dropped: entries for a command
+ `ideCommands` lacks, a value that is not a list (the IDE stops reading the group there,
+ and so does the table's layering), and a command with two plain entries or `cmd()`, whose
+ row says to edit it as JSON.
+ - **The keys are read as the IDE reads them**: the layering is
+ `applyKeyboardShortcutsLayering`'s (an argument entry adds unless the argument is empty;
+ a value that is not a list ends the group), the codes are `getKeyBindingCodeFromString`'s
+ (copied, since it has `debugger` statements), and a captured key is named as
+ `globalKeyDown` names it (a letter by `e.code`; a key `VirtualKeyCodeLookup` lacks, such
+ as `;`, is refused, as is AltGr). A key bound for its release with Ctrl or Alt never runs
+ (`realKeyPresses`), so the table marks it and does not offer it.
+ - **Conflicts** are codes shared by two commands across the built-in group, every group
+ switched on, the group shown and any added in the dialog (Save switches it on), with the
+ unsaved text of any group shown in the dialog. A shared code is marked only when a group
+ of your own gives one of the commands that code and the built-in group does not, since
+ the built-in group shares keys between commands that apply in different places (Ctrl+X,
+ Ctrl+A), and a group that keeps such a key adds no conflict; `{ALLEXCEPT}` is left out.
+ - **The dialog's own key handler** (on its container: Enter presses the focused button, Esc
+ cancels outside a text box, Tab and the arrows are held) never sees a key from the table,
+ which stops each at its own elements; Esc there closes the editor, then clears the
+ search. Ctrl+F goes to the table's search, and the table removes `textfind.js`'s bar when
+ it shows.
+ - **Its look is the IDE's** (owner, 2026-11-12: fit in with the IDE's controls, and respect
+ each theme's shape of button). Its buttons are the dialog's buttons, from the theme's
+ `--themeDialogButton*` variables (`.msgBoxButton`), so they are square in Dark and Light
+ and rounded in Aurora, with the theme's focus ring. Everything else is taken from the
+ IDE Options and Project Settings dialogs (`tips_injectCss` and `tbps_injectCss` in
+ main.js), which are the same in every theme: the No / Yes control for a choice of one
+ (the filters, Keep / Replace, Table / JSON), their text boxes and drop-downs, their
+ section title (a 4px `#4271ae` bar) for a prefix, their option rows, their yellow banner
+ for a note and their red error line for an error; a plain key is drawn as the dialog's
+ `
`, and the glyphs are codicons. The pane is white in every theme
+ (`.configEditorRHS`), so text and fields are dark on white whatever the theme.
+ - **The header's last line**, *ps. in future we'll have a proper editor for this* (owner,
+ 2026-11-12), is taken out of the options' `info` while the table is on, and put back
+ into an open dialog's `.configEditorInfoHeader` when it is turned off.
+ - **The descriptions** are `scripts/ide-js/command-text.json`, copied on one line to
+ `Resources/KEYS/commands.json` by `ide_js.mjs keymap --update` (and compared by `--check`
+ and by `test/ide-js.test.mjs`), and put in place of the script's `$COMMANDS$` marker by
+ `ApplyFix`.
+14. **A panel layout editor** (owner, 2026-11-12: Manage Panel Layouts in the spirit of item
+ 13, on by default). The editor is add-in 1.3.0, the help's detached state per layout 1.4.0
+ (the last bullets). `Resources/SCRIPTS/layouteditor.js`, put in by
+ `BuildPane` as item 13's script is, with a settings row of its own (`Fixes`,
+ `LayoutEditor`, on by default; the window's box follows through `layouteditor:<1|0>`),
+ tested by the `ide-test` lane `layouteditor` (`test/ide/layouteditor.test.mjs`, the script
+ put into a bare IDE with layouts set in the page, as `keyeditor` does) and by the `help`
+ lanes (the settings box). Picture `Help_LayoutEditor` from `shoot_docs`' help setup.
+ Facts below are from BETA 1042's `main.js`.
+ - **Reached** through one replacement of `showConfigEditor` that the scripts share,
+ `window.tbDocsConfigEditors` (`hookOf` and `unhook`, the same code in keyeditor.js,
+ layouteditor.js and layouts.js): each puts its adapter in `adapters` under its dialog's
+ title, or the title, `|` and a name of its own (layouts.js: `Manage Panel Layouts|help`),
+ and the replacement calls every adapter for the title before the IDE's function. Neither wraps the other's, turning one off leaves the other in, and
+ the IDE's function goes back when the last is off. The editor returns a node of its own
+ in place of the IDE's text area, which it holds, hidden; turned off, the text area takes
+ the node's place again.
+ - **The layout stays the IDE's.** `showManagePanelLayouts` edits a copy of
+ `customPanelLayouts`, each entry `{layoutData, floatingData}` as JSON strings; its text
+ area shows `{docked, floating}`, and its `oninput` stores `JSON.stringify` of those two
+ members back and turns on Save Changes. The editor hides the text area, reads it, and
+ writes every change into it with an `input` event, as item 13 does; Picture / JSON at
+ the bottom shows the IDE's own text area again. Text that is not JSON is shown as text.
+ - **How a layout is read** (`restoreDockConfig`): `flexBasis` is `size` (`0%` when
+ missing) and `flexGrow` is 1 when `variableSize` is true, else 0. `vertical` makes a
+ `dockGroupVertical`, whose members are **side by side** (its splitter resizes widths);
+ `horizontal` puts them **one above another**. The editor names the directions in words,
+ never by the JSON's names, and shows one size choice that writes both fields: *Takes the
+ rest* (`true`, `0%`), *A share* (`false`, a percentage), *Fits its contents* (`false`,
+ `fit-content`; the toolbar is forced to it in a `horizontal` group).
+ - **The picture** is drawn at the IDE window's proportions (owner), from `rootTop`'s size;
+ floating panels at their pixels on the same scale. Tiles are selected by a click, a group
+ by the gap round it; splitters drag; the edit box sets direction and size, moves a member
+ earlier or later, floats it or removes it. A panel not in the layout is docked by
+ clicking an edge of a tile: into the tile's group when the direction matches, else into
+ a new group of the other direction round the two. A group left with one member is
+ replaced by it, which takes the group's size; a group with no member that takes the rest
+ gives it to its last member.
+ - **Use the current arrangement** (owner): a button for a layout of your own, which
+ replaces it with `getPanelsConfiguration()` as `saveCurrentPanelLayoutAs` stores it
+ (`docked[0]` and `floating`). Cancel undoes it, as any change.
+ - **Problems** (owner: a layout without the Editor is one), counted in the status line and
+ marked in the list: no `EDITOR`; a panel listed twice; an id that is neither a built-in
+ panel nor `ADDIN_...`, which `restorePanelConfiguration` reports with an *unknown panel
+ type* alert when docked, and `restoreFloatingConfig` turns into a numbered
+ `testDockedElement` when floating.
+ - **Add-in windows** (owner: offered). An add-in's tool window is `ADDIN_`, the id
+ being `ToolWindows.Add`'s second argument (ours `tbDocsHelpPane`). The loaded ones are
+ `toolWindowsById`, named by their header. An `ADDIN_` id no loaded add-in has is not a
+ problem: applying the layout makes a placeholder with `createToolWindowById`, which
+ shows *(currently unavailable)* until the add-in opens its window and takes the place.
+ Windows given no id all share `ADDIN_`, so the editor does not offer them.
+ - **The help's detached state is kept per layout, by the add-in** (owner), never in the
+ layout's JSON. A member at the top of the dialog's text is dropped at Save Changes; one
+ inside a panel's entry survives, and the restore ignores it. But
+ `saveCurrentPanelLayoutAs` and the current arrangement (`savePanelsConfiguration`,
+ setting `LAYOUTv2`, written at every panel change) are built again from the window by
+ `getDockedPanelConfig` and `getFloatingPanelsConfig`, which write only the id, the sizes
+ and the position, so anything extra is lost at the next save; and a later IDE may check
+ the JSON. So: a settings section per layout, `Layouts\`, with `Detached`, `Left`,
+ `Top`, `Width` and `Height`, the name as `enc()` in layouts.js writes it
+ (`encodeURIComponent` with `!'()*~.` encoded too, since a name may hold `\`; the add-in
+ takes only letters, digits, `%`, `-` and `_`). The `Window` section stays where the help
+ is now, whichever layout is in use (*Custom Layout (Unsaved)* included); a layout's
+ section changes only when it is saved or edited in the dialog.
+ - **layouts.js**, put in by `BuildPane` always (no settings row: it is the add-in's own
+ behaviour, not a fix), with the add-in's state in its `$STATE$` marker and later through
+ `update()` (`PushLayoutState`): the pane's id, `dpi`, `now` (detached, and the window's
+ place now or last left) and `records`. It wraps `setActivePanelLayoutName` and
+ `saveCurrentPanelLayoutAs` and sends `applied` or `saved` with the encoded name through
+ `tbDocsLayout` on its hidden element, as hover help does; its dialog adapter sends `ask`
+ when Manage Panel Layouts opens, and wraps `saveChanges` to send `records` (`keep` and
+ the names left, then a `set` line per record changed) ahead of the `applied` that the
+ IDE's Save Changes causes. `window.tbDocsHelpLayouts` (`record`, `edit`, `dialog`,
+ `onUpdate`) is what layouteditor.js reads and writes. The add-in: `saved` records
+ `Detached` and the window's place; `applied` with a record detaches (the window shown
+ without activating, at the record's place when it is on a monitor and the window is
+ neither minimized nor maximized) or attaches; with none it does nothing; `records`
+ writes the `set` lines and deletes every `Layouts\` section not kept (`SettingSections`
+ enumerates them with `RegEnumKeyExW`). Under the test switch it prints `layout saved
+ at L,T,W,H`, `layout applied ` and `layout records set , removed `.
+ - **Applying a layout closes every add-in's tool window** (`restorePanelLayout` calls
+ `closeAllAddinToolwindows`), and `Pane_OnClose` makes the pane again, which runs
+ layouts.js again: a message waits while the sink's tool window is no longer
+ `toolWindowsById`'s (`stale`), and the new run sends what the old one held. `BuildPane`
+ hides the new pane while the help is detached, since `createToolWindow` shows one a
+ layout docks. **Two IDE defects (BETA 1042), worked round in layouts.js:**
+ `removeAllFloatingPanels` first takes a floating add-in window that shows out of the page
+ as a built-in panel, and `restorePanelLayout` takes the dock out of the page, before
+ `closeAllAddinToolwindows`; closing such a window then throws inside `toolWindowClose`,
+ which swallows it, so the add-in never hears of the close and its window is gone until
+ the IDE restarts (a compiler restart hands the add-in the lost window again; a hidden
+ floating window is closed rightly). The wrapper closes
+ every add-in's window with `addInEvents.toolWindowClose` first, while all are in the
+ page, as long as the function's text still calls `removeAllFloatingPanels()`. And
+ `toolWindowSetVisible` gives a floating add-in window its suggested size whenever
+ `floatingToolWindowsData` has no place for it, which a layout's floating entry never
+ writes: the wrapper writes each `ADDIN_` entry of the applied layout there. Nothing else
+ in BETA 1042 writes there either (`saveFloatingToolWindowPosition` is called only from
+ `createToolWindow`'s dead `if (0)` branch), so a resize by hand is undone at the next
+ show as well, which the add-in does not work round. Both are in BUGS-TO-REPORT.md:
+ `layout-loses-addin-toolwindow` and `toolwindow-show-suggested-size`, asserted by
+ `addin-test.bat --only toolwindow-layouts` (its own probe add-in, not the help).
+ - **Pixels.** The add-in places its window in its process's pixels, which are physical:
+ the compiler's process is aware of the display's scaling (the help lane checks the
+ window's rectangle against Windows' at 144 dpi). `ProcessDpi` (`GetDpiForSystem`) goes
+ to the page as `dpi`, and the editor converts with `96 / dpi` and the page's
+ `screenX`/`screenY`, its top left corner on the screen in CSS pixels (measured: 571, 272
+ against a client area at 856, 408 physical at 150%). With monitors at different scales
+ this is approximate.
+ - **The With the Help Add-In box** sits under the heading of the help's panel, floating or
+ docked, and of its own window, which the picture draws (dashed, kept inside the
+ picture) when the record says *In its own window*; a click on it selects the help's tile
+ or floating panel, else `{kind: "own"}`, the box alone. *In this panel*, *In its own
+ window* (from the record, else `now`, else `FLOAT_AT`), neither pressed when there is no
+ record, and Left, Top, Width and Height. Changes go into `dialog.edits` and turn on Save
+ Changes; Cancel drops them. *Use the current arrangement* records `now` as well.
+ - **What Detach does to the pane:** `Pane.Visible = False` reaches
+ `toolWindowSetVisible`. A docked pane keeps its place, its body hidden and
+ *(currently unavailable)* shown, which the picture shows; a floating one is hidden, and
+ `getFloatingPanelsConfig` leaves out hidden floating panels, so a layout saved from the
+ window while the help is detached has no help pane. The add-in records where the pane
+ was.
+ - **Re-attaching in the editor floats the pane** (owner, 2026-11-12): choosing *In this
+ panel* for a layout whose help is in its own window takes the pane out of the dock (as
+ *Make it float* does), or adds it when the layout lacks it, and floats it at the window's
+ size, placed where the window was and kept inside the IDE window. The user can dock it
+ again.
**Lookup:**
diff --git a/WIP.md b/WIP.md
index a20df180d..7f51a8399 100644
--- a/WIP.md
+++ b/WIP.md
@@ -134,7 +134,7 @@ node scripts/tbbuild.mjs "$TEMP/probe/Thing.twinproj" # does it compile
node scripts/tbrun.mjs # what does it print
```
-- **Every IDE the tools start is given `--no-save-ide-settings` and `--no-update-recent-files`, and BETA 1007 is the oldest build any tool runs** (owner: "we never run anything before that"). The two flags are `IDE_FLAGS` in `scripts/lib/tb-ide.mjs`, passed by `launchIde` on both its branches; any new code that starts `twinBASIC.exe` passes them too. They keep the IDE from writing the user's options, panel layouts, recent list, remembered build targets and licence answers to the registry; what they leave is `ProjectState`, the `.twinproj` association, the `Window` key and `RemoveRecentsList`, which `scripts/lib/tb-registry.mjs` puts back or a test blocks in its page. **Never pass `--reset-ide-settings`** (it writes empty options to the real registry even after `--no-save-ide-settings`); an unknown `--` flag is ignored without a word; a second positional argument opens a modal box nobody can answer. An older install is passed over by `findIde`, and an older one named by `--ide` or `TB_IDE` is refused with exit 2 before an IDE starts (`MIN_BUILD` and `unsupportedIde` in `scripts/lib/tb-install.mjs`): there is no fallback and no switch to allow it, and the control for a probe is BETA 1007 itself. **The flags stop the IDE writing its settings, and a hook stops it reading them**: `launchIde` answers every IDE's `GetIDESetting` with "no saved value" for its options, panel layouts and keyboard groups, in the page only (`scripts/lib/tb-defaults.mjs`; the answer for `GENERAL` and `GENERAL2` must be `"{}"`, never `""`, which the IDE reads as a first run and opens its Options dialog), and drops its saves of those keys, because the flag does not guard two of them (`OBJECT_BROWSER`, `NEWFRONTPAGE`), so every tool's IDE runs with the defaults, and it answers `ALLOWERRORREPORTINGV3` no and refuses the error-report address, so **no tool's IDE reports its crashes to the developers**; `attachIde` fails the run when the page did not run the hook, and `userSettings: true` is the opt-out, passed by `try-help-addin` only. The reasons and the registry's details are in [WIP.Harness.md](WIP.Harness.md#what-a-run-leaves-in-the-registry-and-putting-it-back).
+- **Every IDE the tools start is given `--no-save-ide-settings` and `--no-update-recent-files`, and BETA 1007 is the oldest build any tool runs** (owner: "we never run anything before that"). The two flags are `IDE_FLAGS` in `scripts/lib/tb-ide.mjs`, passed by `launchIde` on both its branches; any new code that starts `twinBASIC.exe` passes them too. They keep the IDE from writing the user's options, panel layouts, recent list, remembered build targets and licence answers to the registry; what they leave is `ProjectState`, the `.twinproj` association, the `Window` key and `RemoveRecentsList`, which `scripts/lib/tb-registry.mjs` puts back or a test blocks in its page. **Never pass `--reset-ide-settings`** (it writes empty options to the real registry even after `--no-save-ide-settings`); an unknown `--` flag is ignored without a word; a second positional argument opens a modal box nobody can answer. An older install is passed over by `findIde`, and an older one named by `--ide` or `TB_IDE` is refused with exit 2 before an IDE starts (`MIN_BUILD` and `unsupportedIde` in `scripts/lib/tb-install.mjs`): there is no fallback and no switch to allow it, and the control for a probe is BETA 1007 itself. **The flags stop the IDE writing its settings, and a hook stops it reading them**: `launchIde` answers every IDE's `GetIDESetting` with "no saved value" for its options, panel layouts and keyboard groups, in the page only (`scripts/lib/tb-defaults.mjs`; the answer for `GENERAL` and `GENERAL2` must be `"{}"`, never `""`, which the IDE reads as a first run and opens its Options dialog), and drops its saves of those keys, because the flag does not guard two of them (`OBJECT_BROWSER`, `NEWFRONTPAGE`), so every tool's IDE runs with the defaults, and it answers `ALLOWERRORREPORTINGV3` no and refuses the error-report address, so **no tool's IDE reports its crashes to the developers**; `attachIde` fails the run when the page did not run the hook, and `userSettings: true` is the opt-out, passed by `try-help-addin` only. **The hook also fixes, in the page, the IDE defects listed in `IDE_FIXES`** (BETA 1042's *console-cleared-at-open*, which erased what an add-in prints as its project opens), each only where the build still has it; the lane that asserts such a defect passes `unfixed: []`, and a retired entry's fix leaves `IDE_FIXES` with that lane's `unfixed`. The reasons and the registry's details are in [WIP.Harness.md](WIP.Harness.md#what-a-run-leaves-in-the-registry-and-putting-it-back).
- **Pack and unpack projects with `impexp`, never with the compiler executable's `import` or `export` verbs.** The tooling does both in process, through `packTree` and `unpackProject` in `scripts/lib/tb-project.mjs`; by hand it is `node scripts/impexp.mjs`. The compiler's `import` refuses a project that embeds a package (exit 999, twinbasic/twinbasic#841), and both verbs exit 0 after the failures they report. The reasons, and the path and stdin rules for anything that does run the executable (`bug_repro`'s `cli` mode), are in [WIP.Harness.md](WIP.Harness.md#getting-at-the-twin-sources).
- **`tbbuild` exit codes:** 0 clean, 1 the project has errors, 2 the harness failed or the project file cannot be read (empty, cut short, not a project: it is read before an IDE starts), 3 the compile never settled or met its limit, 4 the project crashes the compiler, 5 the build failed after a clean compile (an LLVM refusal in its log included, an exe linked or not, and the build's limit). `--json` returns one object, `--keep` leaves the IDE running. **`--build` and `--llvm` (which implies it) build the project after a clean compile**, because LLVM code generation runs in a build and a compile never asks for it. They first stage a copy with an explicit build path (`%TEMP%\tbbuild\\`), so the given `.twinproj` is untouched. A plain `--build` is the control for an `--llvm` run. `--llvm` refuses a Community or Personal licence.
- **It runs the IDE on a private Windows desktop**, so it cannot seize focus. Set `TBBUILD_SHOW=1` while working interactively and leave it unset for unattended runs: a wedged IDE nobody can see is expensive to diagnose.
diff --git a/add-in/CHANGELOG.md b/add-in/CHANGELOG.md
index a296174aa..3f6a1011d 100644
--- a/add-in/CHANGELOG.md
+++ b/add-in/CHANGELOG.md
@@ -4,6 +4,57 @@ What changed in the twinBASIC Documentation Help add-in, newest first. The versi
DLL's (its file properties show it). The documentation the add-in shows and its index of
symbols change with every build of the documentation and are not listed here.
+## 1.4.0 (2026-11-13)
+
+- **Each panel layout keeps where the help is**: in its pane, or in its own window and where that
+ window is on the screen. **Save Current Panel Layout As** records where the help is now, and
+ choosing a layout puts the help back there, detaching it, attaching it or moving its window. A
+ layout saved before, and a built-in one, leave the help where it is.
+- In **Manage Panel Layouts**, the help's panel has a box, **With the Help Add-In**: *In this
+ panel* or *In its own window* for the layout, and the window's place on the screen. The window
+ is drawn in the picture too. Choosing *In this panel* for a layout whose help is in its own
+ window floats the pane where the window was, inside the IDE window. **Use the current
+ arrangement** takes where the help is now as well. **Save Changes** keeps the choice and forgets
+ the layouts deleted in the dialog; Cancel keeps nothing.
+- Choosing a layout no longer loses the help's pane when it floats or is docked: the IDE took it
+ out of the window without closing it, so the pane did not come back until the compiler
+ restarted. The tool windows of other add-ins come back too. A pane the layout floats keeps the
+ layout's size when it is shown, and while the help is in its own window, the pane no longer
+ shows in the layout beside the window.
+
+## 1.3.0 (2026-11-12)
+
+- **Window > Panel Layouts > Manage Panel Layouts** shows each layout as a picture of the IDE
+ window, at the IDE's own proportions, in place of its text: a tile for every docked panel, in
+ its groups, and every floating panel over them. Clicking a tile or a group shows a box beside
+ the picture where its size, its direction (side by side, or one above another) and its place
+ among its neighbours are changed, and where a panel is floated, docked again or taken out of the
+ layout. Splitters and floating panels are dragged. A panel the layout lacks, the tool window of
+ a loaded add-in included, is docked by clicking it and then an edge of a tile. **Use the current
+ arrangement** replaces the layout with the panels as the IDE shows them now. A layout with no
+ Editor, a panel in it twice, or an id that is not a panel is marked as a problem. The **JSON**
+ button shows the layout's text; Save Changes and Cancel are the IDE's.
+- The settings panel has a new box, ticked by default: **Panel layout editor**. Unticking it gives
+ Manage Panel Layouts its text back, at once.
+
+## 1.2.0 (2026-11-12)
+
+- **Window > Keyboard Shortcuts > Manage Keyboard Shortcuts** shows each group as a table of
+ every command of the IDE, with its keys and a line on what it does, in place of the IDE's
+ *Keyboard editor coming soon*. A row shows the keys earlier groups give the command, the keys
+ this group adds or removes, and when a later group changes them again. Clicking a row of a
+ group of your own opens its editor: press a key to bind it, choose whether the group keeps the
+ earlier keys or replaces them, and when the key runs (when pressed, also while held, or when
+ released). The table finds commands by name, description or key, or by the key you press, and
+ marks a key that another command also has, and one that can never run. The **JSON** button at
+ the bottom shows the group's text, as the IDE's own pane does; Save Changes and Cancel are the
+ IDE's. The dialog's text no longer ends with the line promising a proper editor. The table
+ looks like the rest of the IDE: its buttons are the dialog's own, in the shape the theme gives
+ them (rounded in Aurora, square in Dark and Light), and its other controls, headings and notes
+ are those of the IDE's options and Project Settings.
+- The settings panel has a new box, ticked by default: **Keyboard shortcut editor**. Unticking it
+ gives Manage Keyboard Shortcuts its own pane and text back, at once.
+
## 1.1.0 (2026-10-21)
- Ctrl+F finds text in the editors of **Window > Keyboard Shortcuts > Manage Keyboard
diff --git a/add-in/Resources/KEYS/commands.json b/add-in/Resources/KEYS/commands.json
new file mode 100644
index 000000000..b7a9995ea
--- /dev/null
+++ b/add-in/Resources/KEYS/commands.json
@@ -0,0 +1 @@
+{"tbBuild_Clean":"Cleans the project's build.","tbBuild_Fusion":"Builds the Fusion host program that a project with ActiveX controls may need, without building the project.","tbBuild_Start":"Builds the project.","tbBuild_SwitchToWin32":"Sets the build target to 32-bit Windows.","tbBuild_SwitchToWin64":"Sets the build target to 64-bit Windows.","tbCallStack_FocusPanel":"Moves the focus to the Call Stack panel.","tbCallStack_HidePanel":"Closes the Call Stack panel.","tbCallStack_ShowPanel":"Shows the Call Stack panel.","tbCompiler_Restart":"Restarts the compiler. With the Alt key held down, it also empties the LLVM compiler cache.","tbCompiler_RestartAndFlushLlvmCache":"Restarts the compiler and empties the LLVM compiler cache.","tbDebug_BreakInto":"Pauses the running program.","tbDebug_BreakpointsClear":"Removes every breakpoint from the project.","tbDebug_RunOrPreview":"Runs the procedure at the cursor, or shows a preview of the form when the active file is a form.","tbDebug_SetNextExecutionStatement":"At a breakpoint, makes the line at the cursor the next one to run.","tbDebug_StartOrContinue":"Starts the project, or continues it from a breakpoint.","tbDebug_StepInto":"At a breakpoint, runs the current statement and stops at the next, entering any procedure it calls.","tbDebug_StepOut":"At a breakpoint, runs on until the current procedure ends and stops in its caller.","tbDebug_StepOver":"At a breakpoint, runs the current statement and stops at the next, without entering any procedure it calls.","tbDebug_Stop":"Ends the running program.","tbDebug_ToggleBreakOnAllErrors":"Turns the project's Break On All Errors (this project) setting on or off.","tbDebug_ToggleBreakOnAllErrorsInPackages":"Turns the project's Break On All Errors (inside packages) setting on or off.","tbDebug_ToggleBreakpoint":"Sets a breakpoint on the cursor's line, or removes the one that is there.","tbDebug_ToggleDebuggable":"Turns the project's Allow Breakpoints (Debuggable) setting on or off.","tbDebugConsole_Clear":"Clears the Debug Console.","tbDebugConsole_ClipboardCopyAll":"Copies everything in the Debug Console to the clipboard.","tbDebugConsole_ClipboardCopyAllWithTimestamps":"Copies everything in the Debug Console to the clipboard, each line with its time.","tbDebugConsole_ExecuteCode":"Runs the line of code given as its argument in the Debug Console, as in `tbDebugConsole_ExecuteCode('? 6*7')`. It does nothing without an argument.","tbDebugConsole_ExecuteEnteredLine":"Runs the line typed in the Debug Console's entry box, or inserts the selected entry of the completion list.","tbDebugConsole_FocusPanel":"Moves the focus to the Debug Console's entry box.","tbDebugConsole_GoToDefinition":"Goes to the definition of the symbol selected in the Debug Console's completion list.","tbDebugConsole_HidePanel":"Closes the Debug Console panel.","tbDebugConsole_HistoryCycleNext":"In the Debug Console's entry box, shows the next line of its history.","tbDebugConsole_HistoryCyclePrevious":"In the Debug Console's entry box, shows the previous line of its history.","tbDebugConsole_SelectAllEntryBox":"Selects the whole text of the Debug Console's entry box.","tbDebugConsole_ShowPanel":"Shows the Debug Console panel.","tbDebugConsole_ToggleAutoScroll":"Turns the Debug Console's Auto Scroll on or off.","tbDebugConsole_ToggleInvertOutputDirection":"Turns the Debug Console's Invert Output Direction option on or off.","tbDebugConsole_ToggleShowTimestamps":"Turns the Debug Console's Show Timestamps option on or off.","tbDebugConsole_ToggleSmoothScrolling":"Turns the Debug Console's Smoother Scrolling option on or off.","tbDebugConsole_TurnAutoScrollOff":"Turns the Debug Console's Auto Scroll off.","tbDebugConsole_TurnAutoScrollOn":"Turns the Debug Console's Auto Scroll on.","tbDebugConsole_TurnInvertOutputDirectionOff":"Turns the Debug Console's Invert Output Direction option off.","tbDebugConsole_TurnInvertOutputDirectionOn":"Turns the Debug Console's Invert Output Direction option on.","tbDebugConsole_TurnShowTimestampsOff":"Turns the Debug Console's Show Timestamps option off.","tbDebugConsole_TurnShowTimestampsOn":"Turns the Debug Console's Show Timestamps option on.","tbEditor_ActivateNextTab":"Switches to the next editor tab.","tbEditor_ActivatePrevTab":"Switches to the previous editor tab.","tbEditor_AddCursorAbove":"Adds a cursor on the line above.","tbEditor_AddCursorBelow":"Adds a cursor on the line below.","tbEditor_AddCursorsAtLineEndsOfSelection":"Puts a cursor at the end of each line of the selection.","tbEditor_AddSelectionToNextFindMatch":"Adds the next occurrence of the selected text to the selection, with a cursor at each.","tbEditor_ChangeAllOccurrences":"Selects every occurrence of the word at the cursor, for changing all at once.","tbEditor_ClearBookmarks":"Removes every bookmark from the current document.","tbEditor_ClearBookmarksProject":"Removes every bookmark from the project.","tbEditor_ClipboardCopy":"Copies the selection to the clipboard, replacing tabs with spaces.","tbEditor_ClipboardCopyWithSyntaxHighlighting":"Copies the selection to the clipboard with its syntax colours.","tbEditor_ClipboardCut":"Cuts the selection to the clipboard, replacing tabs with spaces.","tbEditor_ClipboardCutPlain":"Cuts the selection to the clipboard as plain text, with the editor's own handling of tabs left out.","tbEditor_ClipboardPaste":"Pastes the clipboard into the code editor, re-indenting the pasted text.","tbEditor_ClipboardPasteAsComment":"Pastes the clipboard into the code editor as comment lines.","tbEditor_ClipboardPlainCopy":"Copies the selection to the clipboard as plain text, with the editor's own handling of tabs left out.","tbEditor_ClipboardPlainPaste":"Pastes the clipboard into the code editor exactly as it is, without re-indenting.","tbEditor_CloseTab":"Closes the current editor tab.","tbEditor_CodeSelector1_Dropdown":"Opens box 1 above the code editor, which lists the components of the file.","tbEditor_CodeSelector2_Dropdown":"Opens box 2 above the code editor, which lists the objects of the component.","tbEditor_CodeSelector3_Dropdown":"Opens box 3 above the code editor, which lists the procedures or events.","tbEditor_CommentSelection":"Turns the selected lines into comments.","tbEditor_ConvertIndentationToSpaces":"Replaces the tabs that indent the document's lines with spaces.","tbEditor_ConvertIndentationToTabs":"Replaces the spaces that indent the document's lines with tabs.","tbEditor_CopyLineDown":"Copies the current line, or the selected lines, below themselves.","tbEditor_CopyLineUp":"Copies the current line, or the selected lines, above themselves.","tbEditor_CursorMoveBottom":"Moves the cursor to the end of the document.","tbEditor_CursorMoveDown":"Moves the cursor down one line.","tbEditor_CursorMoveEndOfLine":"Moves the cursor to the end of the line.","tbEditor_CursorMoveLeft":"Moves the cursor one character to the left.","tbEditor_CursorMoveLeftWord":"Moves the cursor to the start of the previous word.","tbEditor_CursorMovePageDown":"Moves the cursor down by one page.","tbEditor_CursorMovePageUp":"Moves the cursor up by one page.","tbEditor_CursorMoveRight":"Moves the cursor one character to the right.","tbEditor_CursorMoveRightWord":"Moves the cursor to the start of the next word.","tbEditor_CursorMoveStartOfLine":"Moves the cursor to the first column of the line.","tbEditor_CursorMoveStartOfLineHome":"Moves the cursor to the first non-blank character of the line, or to the first column if it is already there.","tbEditor_CursorMoveTop":"Moves the cursor to the start of the document.","tbEditor_CursorMoveUp":"Moves the cursor up one line.","tbEditor_CursorRedo":"Redoes a cursor movement or selection change that Cursor Undo undid.","tbEditor_CursorSelectBottom":"Extends the selection to the end of the document.","tbEditor_CursorSelectDown":"Extends the selection down one line.","tbEditor_CursorSelectLeft":"Extends the selection one character to the left.","tbEditor_CursorSelectLeftWord":"Extends the selection to the start of the previous word.","tbEditor_CursorSelectLineEnd":"Extends the selection to the end of the line.","tbEditor_CursorSelectLineStart":"Extends the selection to the first column of the line.","tbEditor_CursorSelectLineStartHome":"Extends the selection to the first non-blank character of the line, or to the first column if it is already there.","tbEditor_CursorSelectPageDown":"Extends the selection down by one page.","tbEditor_CursorSelectPageUp":"Extends the selection up by one page.","tbEditor_CursorSelectRight":"Extends the selection one character to the right.","tbEditor_CursorSelectRightWord":"Extends the selection to the start of the next word.","tbEditor_CursorSelectTop":"Extends the selection to the start of the document.","tbEditor_CursorSelectUp":"Extends the selection up one line.","tbEditor_CursorUndo":"Undoes the last cursor movement or selection change, without undoing any text change.","tbEditor_DecreaseFontSize":"Makes the code editor's font one pixel smaller, down to a size of 8 pixels, and saves the size as the Code Editor Font Size option.","tbEditor_DeleteLeft":"Deletes the character before the cursor, or the selection.","tbEditor_DeleteLeftWord":"Deletes the word before the cursor.","tbEditor_DeleteLines":"Deletes the current line, or the selected lines.","tbEditor_DeleteRight":"Deletes the character after the cursor, or the selection.","tbEditor_DeleteRightWord":"Deletes the word after the cursor.","tbEditor_ExpandLineSelection":"Extends the selection to include the whole of the current line.","tbEditor_ExpandSelection":"Widens the selection to the next larger syntactic block.","tbEditor_Find":"Opens the Find and Replace panel, searching for the selected text, or the word at the cursor.","tbEditor_FindReplace":"Opens the Find and Replace panel, as the Find command does.","tbEditor_FindSelectedNext":"Moves to the next occurrence of the selected text.","tbEditor_FindSelectedPrev":"Moves to the previous occurrence of the selected text.","tbEditor_FindWidget_Next":"Moves to the next match of the current search.","tbEditor_FindWidget_Prev":"Moves to the previous match of the current search.","tbEditor_FindWidget_SelectAllMatches":"Selects every match of the current search in the editor.","tbEditor_FocusPanel":"Moves the focus to the code editor.","tbEditor_Fold":"Folds the block at the cursor.","tbEditor_FoldAll":"Folds every block in the document.","tbEditor_FoldProcedures":"Folds every procedure in the file except the one the cursor is in.","tbEditor_FormatDocument":"Formats the whole document.","tbEditor_FormatSelection":"Formats the selected code.","tbEditor_GoToDefinition":"Goes to the definition of the symbol at the cursor.","tbEditor_GotoLineColumn":"Opens the box for going to a line and column.","tbEditor_HidePanel":"Closes the code editor panel.","tbEditor_IncreaseFontSize":"Makes the code editor's font one pixel larger and saves the size as the Code Editor Font Size option.","tbEditor_Indent":"Indents the line or the selected lines, or inserts a tab at the cursor.","tbEditor_IndentLine":"Indents the selected lines.","tbEditor_InsertAmpersand":"Types an ampersand. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertBackslash":"Types a backslash. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertBracketClose":"Types a closing parenthesis.","tbEditor_InsertBracketOpen":"Types an opening parenthesis, or puts the selected text in parentheses.","tbEditor_InsertColon":"Types a colon. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertComma":"Types a comma. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertEquals":"Types an equals sign. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertExclamation":"Types an exclamation mark. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertLineAbove":"Inserts an empty line above the cursor's line and moves the cursor to it.","tbEditor_InsertLineBelow":"Inserts an empty line below the cursor's line and moves the cursor to it.","tbEditor_InsertLineBreak":"Breaks the line at the cursor, as the Enter key does. This is bound to the key so that the IDE can do its own work on the new line.","tbEditor_InsertMinus":"Types a minus sign. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertMultiply":"Types an asterisk. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertPeriod":"Types a full stop. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertPlus":"Types a plus sign. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertSlash":"Types a slash. The key is bound to a command so that the IDE can react to it.","tbEditor_InsertSpace":"Types a space. The key is bound to a command so that the IDE can react to it.","tbEditor_JumpToNextProblem":"Moves the cursor to the next error or warning in the document.","tbEditor_JumpToPrevProblem":"Moves the cursor to the previous error or warning in the document.","tbEditor_LastPosition":"Returns to the most recently recorded position, at the start of its line, opening its file if needed.","tbEditor_MoveLinesDown":"Moves the current line, or the selected lines, down one line.","tbEditor_MoveLinesUp":"Moves the current line, or the selected lines, up one line.","tbEditor_MoveToProcedureNext":"Moves the cursor to the start of the next procedure.","tbEditor_MoveToProcedurePrev":"Moves the cursor to the start of the previous procedure.","tbEditor_NextBookmark":"Moves the cursor to the next bookmark.","tbEditor_OpenTabsDropDown":"Opens the list of open editor tabs.","tbEditor_Outdent":"Outdents the line or the selected lines.","tbEditor_OutdentLine":"Outdents the selected lines.","tbEditor_PrevBookmark":"Moves the cursor to the previous bookmark.","tbEditor_Redo":"Redoes the last change that was undone in the current document.","tbEditor_RenameSymbol":"Renames the symbol at the cursor everywhere it is used.","tbEditor_ReopenLastClosedTab":"Reopens the editor tab that was closed last.","tbEditor_Save":"Never runs: saving a single document is turned off. Use the commands that save the project.","tbEditor_ScrollTabLeft":"Scrolls the row of editor tabs to the left. The left tab button runs it.","tbEditor_ScrollTabRight":"Scrolls the row of editor tabs to the right. The right tab button runs it.","tbEditor_SelectAll":"Selects the whole document.","tbEditor_SelectAllMatches":"Selects every occurrence of the word at the cursor, or of the selected text.","tbEditor_ShowContextMenu":"Opens the code editor's context menu at the top left of the editor.","tbEditor_ShowMonacoCommandPalette":"Opens the command palette of the Monaco code editor.","tbEditor_ShowPanel":"Shows the code editor panel.","tbEditor_ShrinkSelection":"Narrows the selection to the next smaller syntactic block.","tbEditor_SortLinesAscending":"Sorts the selected lines in ascending order.","tbEditor_SortLinesDescending":"Sorts the selected lines in descending order.","tbEditor_SwitchToCode":"Switches from a form designer to the code of the same file.","tbEditor_SwitchToFormDesign":"Switches from the code of a file to its form designer.","tbEditor_SwitchToggleFormDesignCode":"Switches between the form designer and the code of the same file.","tbEditor_ToggleAdvancedInfoOnHover":"Turns the Show Advanced Info On Hover option on or off.","tbEditor_ToggleAutoPrettifyCode":"Turns the project's Auto Prettify option on or off.","tbEditor_ToggleBlockComment":"Wraps the selection in a block comment, or removes the block comment around it.","tbEditor_ToggleBookmark":"Sets a bookmark on the cursor's line, or removes the one that is there.","tbEditor_ToggleCodeFoldingAlways":"Turns on or off showing the code folding arrows all the time, not only when the pointer is over the margin.","tbEditor_ToggleCodeFoldingVisibility":"Shows or hides the code folding arrows.","tbEditor_ToggleCodeHintsAlwaysVisible":"Turns the Code Hints Always Visible option on or off.","tbEditor_ToggleCodeLensShowProc":"Turns the project's Show CodeLens Run Procedure option on or off.","tbEditor_ToggleLineComment":"Comments the selected lines, or uncomments them if they are all comments already.","tbEditor_ToggleMiniMapVisibility":"Shows or hides the minimap.","tbEditor_ToggleShowCodeHints":"Shows or hides the inline code hints.","tbEditor_ToggleShowIndentGuides":"Shows or hides the indent guides.","tbEditor_ToggleShowLineNumbers":"Shows or hides the line numbers.","tbEditor_ToggleShowSingleRowOfTabs":"Turns the Show Single Row Of Tabs option on or off.","tbEditor_ToggleStickyScroll":"Turns the Sticky Scroll option on or off.","tbEditor_ToggleWordWrap":"Turns word wrap on or off in the code editor.","tbEditor_TransformToLowercase":"Changes the selected text to lower case.","tbEditor_TransformToSnakecase":"Changes the selected text to snake case.","tbEditor_TransformToTitlecase":"Changes the selected text to title case.","tbEditor_TransformToUppercase":"Changes the selected text to upper case.","tbEditor_TurnShowCodeHintsOff":"Hides the inline code hints. The Ctrl key runs it when it is released.","tbEditor_TurnShowCodeHintsOn":"Shows the inline code hints. The Ctrl key runs it when it goes down.","tbEditor_TurnWordWrapOff":"Turns word wrap off in the code editor.","tbEditor_TurnWordWrapOn":"Turns word wrap on in the code editor.","tbEditor_UncommentSelection":"Removes the comment marker from the selected lines.","tbEditor_Undo":"Undoes the last change in the current document.","tbEditor_Unfold":"Unfolds the block at the cursor.","tbEditor_UnfoldAll":"Unfolds every block in the document.","tbEditor_UnfoldProcedures":"Unfolds every procedure in the file.","tbFileSystem_AddClassCLS":"Adds a class in a .cls file to the project, with a name box for its name.","tbFileSystem_AddClassTWIN":"Adds a class in a .twin file to the project, with a name box for its name.","tbFileSystem_AddCustomControlsForm":"Adds a CustomControls form to the project, with a name box for its name. If the project does not reference the CustomControls package, asks to add it.","tbFileSystem_AddFolder":"Adds a folder to the project, with a name box for its name.","tbFileSystem_AddModuleBAS":"Adds a module in a .bas file to the project, with a name box for its name.","tbFileSystem_AddModuleTWIN":"Adds a module in a .twin file to the project, with a name box for its name.","tbFileSystem_AddOtherFile":"Adds a file of any other type to the project, with a name box for its name.","tbFileSystem_AddResourceMessageTable":"Adds a message table to the project's resources and opens it.","tbFileSystem_AddResourceStringTable":"Adds a string table to the project's resources and opens it.","tbFileSystem_AddResourceVisualStylesManifest":"Adds the Visual Styles manifest to the project's resources and opens it.","tbFileSystem_AddWindowsForm":"Adds a Windows form to the project, with a name box for its name. If the project does not reference the WinNativeForms package, asks to add it.","tbFileSystem_AddWindowsMDIForm":"Adds a Windows MDI form to the project, with a name box for its name. If the project does not reference the WinNativeForms package, asks to add it.","tbFileSystem_AddWindowsPropertyPage":"Adds a Windows property page to the project, with a name box for its name. If the project does not reference the WinNativeForms package, asks to add it.","tbFileSystem_AddWindowsReport":"Adds a Windows report to the project, with a name box for its name. If the project does not reference the WinNativeForms package, asks to add it.","tbFileSystem_AddWindowsUserControl":"Adds a Windows user control to the project, with a name box for its name. If the project does not reference the WinNativeForms package, asks to add it.","tbFileSystem_ImportFile":"Opens the dialog for choosing files to import into the project.","tbFindReplace_Cancel":"Closes the Find and Replace panel, or hides it if it is floating.","tbFindReplace_FocusCurrentModule":"Chooses the Current Module scope in the Find and Replace panel.","tbFindReplace_FocusCurrentProcedure":"Chooses the Current Procedure scope in the Find and Replace panel.","tbFindReplace_FocusCurrentProject":"Chooses the Current Project scope in the Find and Replace panel.","tbFindReplace_FocusDirection":"Moves the focus to the Direction box of the Find and Replace panel.","tbFindReplace_FocusFindWhat":"Moves the focus to the Find What box of the Find and Replace panel.","tbFindReplace_FocusMatchCaseToggle":"Turns the Match Case option of the Find and Replace panel on or off.","tbFindReplace_FocusNext":"Finds the next match in the Find and Replace panel.","tbFindReplace_FocusPanel":"Moves the focus to the Find and Replace panel.","tbFindReplace_FocusReplaceWith":"Moves the focus to the Replace With box of the Find and Replace panel.","tbFindReplace_FocusUsePatternMatchingToggle":"Turns the Use Pattern Matching option of the Find and Replace panel on or off.","tbFindReplace_FocusWholeWordOnlyToggle":"Turns the Whole Word Only option of the Find and Replace panel on or off.","tbFindReplace_HidePanel":"Closes the Find and Replace panel.","tbFindReplace_Next":"Finds the next match in the Find and Replace panel, or in the editor's quick find box when only that is showing.","tbFindReplace_Prev":"Finds the previous match in the Find and Replace panel.","tbFindReplace_ReplaceAll":"Replaces every match in the scope chosen in the Find and Replace panel.","tbFindReplace_ReplaceNext":"Replaces the current match in the Find and Replace panel and finds the next.","tbFindReplace_ShowPanel":"Shows the Find and Replace panel.","tbFindWidget_FindNext":"In the quick find box, moves to the next match.","tbFindWidget_FindNextAlways":"In the quick find box, moves to the next match. It has no default key.","tbFindWidget_FindNextInSelection":"In the quick find box, moves to the next occurrence of the selected text.","tbFindWidget_FindPrev":"In the quick find box, moves to the previous match. It has no default key.","tbFindWidget_FindPrevInSelection":"In the quick find box, moves to the previous occurrence of the selected text.","tbFindWidget_FindPrevious":"Has the default key Shift+Enter, but the IDE has no command of this name. The command that moves to the previous match in the quick find box is tbFindWidget_FindPrev.","tbFindWidget_Hide":"Closes the editor's quick find box.","tbFindWidget_HistoryCycleNext":"In the quick find box, shows the next entry of the search history.","tbFindWidget_HistoryCyclePrevious":"In the quick find box, shows the previous entry of the search history.","tbFindWidget_ShowFind":"Opens the editor's quick find box.","tbFindWidget_ShowReplace":"Opens the editor's quick find and replace box.","tbFormDesginer_DecreaseSpacingHorizontal":"Narrows the horizontal gaps between the selected controls by one grid step.","tbFormDesginer_DecreaseSpacingVertical":"Narrows the vertical gaps between the selected controls by one grid step.","tbFormDesginer_IncreaseSpacingHorizontal":"Widens the horizontal gaps between the selected controls by one grid step.","tbFormDesginer_IncreaseSpacingVertical":"Widens the vertical gaps between the selected controls by one grid step.","tbFormDesginer_MakeEqualSpacingHorizontal":"Spaces three or more selected controls evenly from left to right.","tbFormDesginer_MakeEqualSpacingVertical":"Spaces three or more selected controls evenly from top to bottom.","tbFormDesginer_RemoveSpacingHorizontal":"Removes the horizontal gaps between the selected controls.","tbFormDesginer_RemoveSpacingVertical":"Removes the vertical gaps between the selected controls.","tbFormDesigner_AlignSelectedControlsBottom":"Aligns the bottom edges of the selected controls.","tbFormDesigner_AlignSelectedControlsCenterHorizontal":"Aligns the horizontal centres of the selected controls.","tbFormDesigner_AlignSelectedControlsCenterVertical":"Aligns the vertical centres of the selected controls.","tbFormDesigner_AlignSelectedControlsLeft":"Aligns the left edges of the selected controls.","tbFormDesigner_AlignSelectedControlsRight":"Aligns the right edges of the selected controls.","tbFormDesigner_AlignSelectedControlsToGrid":"Moves the selected controls to the nearest grid points.","tbFormDesigner_AlignSelectedControlsTop":"Aligns the top edges of the selected controls.","tbFormDesigner_BringControlToFront":"Brings the selected controls to the front.","tbFormDesigner_CenterSelectedGroupInContainerHorizontal":"Centres the selected controls as a group, from left to right, in their container.","tbFormDesigner_CenterSelectedGroupInContainerVertical":"Centres the selected controls as a group, from top to bottom, in their container.","tbFormDesigner_ClipboardCopy":"Copies the selected controls to the clipboard.","tbFormDesigner_ClipboardCut":"Cuts the selected controls to the clipboard.","tbFormDesigner_ClipboardPaste":"Pastes the controls on the clipboard into the form designer.","tbFormDesigner_ClipboardPasteControlArray":"Pastes the controls on the clipboard with their names kept, so that they join the control arrays of the controls with those names.","tbFormDesigner_DeleteSelectedControls":"Deletes the selected controls.","tbFormDesigner_DuplicateControlsIntoControlArray":"Duplicates the selected controls as members of control arrays.","tbFormDesigner_DuplicateControlsWithNewNames":"Duplicates the selected controls, giving each copy a new name.","tbFormDesigner_LaunchPreview":"Runs a preview of the form being designed.","tbFormDesigner_LockAllControls":"Locks every control on the form.","tbFormDesigner_LockSelectedControls":"Locks the selected controls.","tbFormDesigner_MenuEditorCopy":"In the menu editor, copies the selected menu item to the clipboard.","tbFormDesigner_MenuEditorCut":"In the menu editor, cuts the selected menu item to the clipboard.","tbFormDesigner_MenuEditorDelete":"In the menu editor, deletes the selected menu item.","tbFormDesigner_MenuEditorInsertAbove":"In the menu editor, inserts a new item above the selected menu item.","tbFormDesigner_MenuEditorInsertBelow":"In the menu editor, inserts a new item below the selected menu item.","tbFormDesigner_MenuEditorInsertLeft":"In the menu editor, inserts a new menu to the left of the selected top-level menu.","tbFormDesigner_MenuEditorInsertRight":"In the menu editor, inserts a new menu to the right of the selected top-level menu.","tbFormDesigner_MenuEditorInsertSeperatorAfter":"In the menu editor, inserts a separator below the selected menu item.","tbFormDesigner_MenuEditorInsertSeperatorBefore":"In the menu editor, inserts a separator above the selected menu item.","tbFormDesigner_MenuEditorMoveDown":"In the menu editor, moves the selected menu item down one place.","tbFormDesigner_MenuEditorMoveLeft":"In the menu editor, moves the selected top-level menu one place to the left.","tbFormDesigner_MenuEditorMoveRight":"In the menu editor, moves the selected top-level menu one place to the right.","tbFormDesigner_MenuEditorMoveUp":"In the menu editor, moves the selected menu item up one place.","tbFormDesigner_MenuEditorPasteAfter":"In the menu editor, pastes the clipboard after the selected menu item.","tbFormDesigner_MenuEditorPasteBefore":"In the menu editor, pastes the clipboard before the selected menu item.","tbFormDesigner_MenuEditorPasteInto":"In the menu editor, pastes the clipboard into the selected menu item.","tbFormDesigner_MenuEditorRename":"In the menu editor, renames the selected menu item.","tbFormDesigner_MenuEditorToggleChecked":"In the menu editor, turns the Checked property of the selected menu item on or off.","tbFormDesigner_MenuEditorToggleEnabled":"In the menu editor, turns the Enabled property of the selected menu item on or off.","tbFormDesigner_MenuEditorToggleVisible":"In the menu editor, turns the Visible property of the selected menu item on or off.","tbFormDesigner_MoveSelectedControlsDown":"Moves the selected controls down by one grid step, or one pixel when the grid is off.","tbFormDesigner_MoveSelectedControlsLeft":"Moves the selected controls left by one grid step, or one pixel when the grid is off.","tbFormDesigner_MoveSelectedControlsRight":"Moves the selected controls right by one grid step, or one pixel when the grid is off.","tbFormDesigner_MoveSelectedControlsUp":"Moves the selected controls up by one grid step, or one pixel when the grid is off.","tbFormDesigner_Redo":"Redoes the last change that was undone in the form designer.","tbFormDesigner_ResizeSelectedControlsNarrower":"Makes the selected controls narrower by one grid step, or one pixel when the grid is off.","tbFormDesigner_ResizeSelectedControlsNarrowest":"Makes the selected controls as narrow as the narrowest of them.","tbFormDesigner_ResizeSelectedControlsShorter":"Makes the selected controls shorter by one grid step, or one pixel when the grid is off.","tbFormDesigner_ResizeSelectedControlsShortest":"Makes the selected controls as short as the shortest of them.","tbFormDesigner_ResizeSelectedControlsTaller":"Makes the selected controls taller by one grid step, or one pixel when the grid is off.","tbFormDesigner_ResizeSelectedControlsTallest":"Makes the selected controls as tall as the tallest of them.","tbFormDesigner_ResizeSelectedControlsWider":"Makes the selected controls wider by one grid step, or one pixel when the grid is off.","tbFormDesigner_ResizeSelectedControlsWidest":"Makes the selected controls as wide as the widest of them.","tbFormDesigner_SelectAllControls":"Selects every control on the form.","tbFormDesigner_SelectParentOfSelectedControl":"With a control selected, selects its container, or the form.","tbFormDesigner_SelectToolboxPointer":"With no control selected, returns to the pointer tool in the Toolbox.","tbFormDesigner_SendControlToBack":"Sends the selected controls to the back.","tbFormDesigner_ShowSelectedControlActiveXPropertyPage":"Opens the property page of the selected ActiveX control.","tbFormDesigner_ToggleAlignControlsToGrid":"Turns on or off snapping controls to the grid.","tbFormDesigner_ToggleControlOutlines":"Shows or hides the outlines of the controls.","tbFormDesigner_ToggleGridIndicators":"Shows or hides the grid in the form designer.","tbFormDesigner_ToggleInPlaceEditingToolbar":"Shows or hides the small in-place editing toolbar below a selected control.","tbFormDesigner_ToggleLockAllControls":"Locks every control on the form that is unlocked, and unlocks each one that is locked.","tbFormDesigner_ToggleLockSelectedControls":"Locks each selected control that is unlocked, and unlocks each one that is locked.","tbFormDesigner_ToggleMultiColouredGrabbers":"Turns the multi-coloured selection handles on or off.","tbFormDesigner_ToggleShowTabIndex":"Shows or hides the tab index of each control.","tbFormDesigner_TurnAlignControlsToGridOff":"Turns off snapping controls to the grid.","tbFormDesigner_TurnAlignControlsToGridOn":"Turns on snapping controls to the grid.","tbFormDesigner_TurnControlOutlinesOff":"Hides the outlines of the controls.","tbFormDesigner_TurnControlOutlinesOn":"Shows the outlines of the controls.","tbFormDesigner_TurnGridIndicatorsOff":"Hides the grid in the form designer.","tbFormDesigner_TurnGridIndicatorsOn":"Shows the grid in the form designer.","tbFormDesigner_TurnInPlaceEditingToolbarOff":"Hides the small in-place editing toolbar below a selected control.","tbFormDesigner_TurnInPlaceEditingToolbarOn":"Shows the small in-place editing toolbar below a selected control.","tbFormDesigner_TurnShowTabIndexOff":"Hides the tab index of each control. The Ctrl key runs it when it is released.","tbFormDesigner_TurnShowTabIndexOn":"Shows the tab index of each control. The Ctrl key runs it when it goes down.","tbFormDesigner_Undo":"Undoes the last change in the form designer.","tbFormDesigner_UnlockAllControls":"Unlocks every control on the form.","tbFormDesigner_UnlockSelectedControls":"Unlocks the selected controls.","tbFormDesigner_ZoomDecrease":"Moves to the next smaller zoom in the form designer's zoom list.","tbFormDesigner_ZoomDropDown":"Opens the zoom list of the form designer.","tbFormDesigner_ZoomIncrease":"Moves to the next larger zoom in the form designer's zoom list.","tbHelp_AskErrorReporting":"Opens the dialog that asks whether the IDE may report its errors automatically.","tbHelp_EnterLicenceKey":"Opens the dialog for entering a licence key.","tbHelp_OpenDiscordWebsite":"Opens the twinBASIC Discord invitation in the default web browser.","tbHelp_OpenGithubWebsite":"Opens the twinBASIC GitHub repository in the default web browser.","tbHelp_OpenKofiWebsite":"Opens the twinBASIC Ko-fi page in the default web browser.","tbHelp_OpenTwitterWebsite":"Opens the twinBASIC author's Twitter page in the default web browser.","tbHelp_PurchaseALicence":"Opens the twinBASIC licence purchase page in the default web browser.","tbHelp_ShowAboutWindow":"Opens the About window.","tbHelp_ShowLicenceAgreement":"Shows the licence agreement.","tbHelp_ToggleCompilerTraceMode":"Turns the compiler's trace mode on or off and restarts the compiler.","tbHelp_ToggleExpandSignatureHelp":"Expands or collapses the signature help that is showing.","tbHistory_FocusPanel":"Moves the focus to the History panel.","tbHistory_HidePanel":"Closes the History panel.","tbHistory_ShowPanel":"Shows the History panel.","tbIde_DecreaseFontSize":"Makes the IDE's font one pixel smaller, down to a size of 8 pixels.","tbIde_IncreaseFontSize":"Makes the IDE's font one pixel larger.","tbIde_ShowIDEOptions":"Opens the IDE Options dialog.","tbIdeDevTools_Show":"Opens the developer tools of the IDE's web view.","tbIdeWindow_Close":"Closes the IDE window.","tbIdeWindow_MaximizeOrRestore":"Maximises the IDE window, or restores it when it is already maximised.","tbIdeWindow_Minimize":"Minimises the IDE window.","tbIntellisense_AcceptSelectedEntry":"Inserts the selected entry of the completion list, then types the key that was pressed.","tbIntellisense_AcceptSelectedOrFirstEntry":"Inserts the selected entry of the completion list, or the first entry if none is selected.","tbIntellisense_Cancel":"Closes the completion list and the signature help.","tbIntellisense_SelectNext":"Selects the next entry of the open completion list.","tbIntellisense_SelectPrevious":"Selects the previous entry of the open completion list.","tbIntellisense_ShowAfterKeyPress":"Opens the completion list after any key that is not one of the keys its binding excludes, according to the IntelliSense mode option.","tbIntellisense_ShowNow":"Opens the completion list at the cursor.","tbKeyboardShortcuts_ShowManageKeyboardShortcuts":"Opens the dialog for managing keyboard shortcut groups.","tbKeyboardShortcuts_ShowWarningCannotDisableBuilinGroup":"Shows a message that the built-in keyboard shortcut group cannot be turned off, and says to override a command in a group of your own instead.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom1":"Turns on or off the keyboard shortcut group that is number 1 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom10":"Turns on or off the keyboard shortcut group that is number 10 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom2":"Turns on or off the keyboard shortcut group that is number 2 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom3":"Turns on or off the keyboard shortcut group that is number 3 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom4":"Turns on or off the keyboard shortcut group that is number 4 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom5":"Turns on or off the keyboard shortcut group that is number 5 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom6":"Turns on or off the keyboard shortcut group that is number 6 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom7":"Turns on or off the keyboard shortcut group that is number 7 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom8":"Turns on or off the keyboard shortcut group that is number 8 in the list of your own groups, if there is one.","tbKeyboardShortcuts_ToggleActiveKeyboardShortcutGroupCustom9":"Turns on or off the keyboard shortcut group that is number 9 in the list of your own groups, if there is one.","tbMenu_Cancel":"Closes the open menu.","tbMenu_ExecuteFocusedEntry":"While a menu is open, runs the focused entry.","tbMenu_FocusAdjacentDown":"While a menu is open, moves the focus to the entry below.","tbMenu_FocusAdjacentLeft":"While a menu is open, closes the open submenu, or moves to the menu on the left.","tbMenu_FocusAdjacentRight":"While a menu is open, opens the submenu of the focused entry, or moves to the menu on the right.","tbMenu_FocusAdjacentUp":"While a menu is open, moves the focus to the entry above.","tbMenu_ShowAddinsMenu":"Opens the Addins menu.","tbMenu_ShowDebugMenu":"Opens the Debug menu.","tbMenu_ShowEditMenu":"Opens the Edit menu.","tbMenu_ShowFileMenu":"Opens the File menu.","tbMenu_ShowFormatMenu":"Opens the Format menu.","tbMenu_ShowHelpMenu":"Opens the Help menu.","tbMenu_ShowProjectMenu":"Opens the Project menu.","tbMenu_ShowRunMenu":"Opens the Run menu.","tbMenu_ShowToolsMenu":"Opens the Tools menu.","tbMenu_ShowViewMenu":"Opens the View menu.","tbMenu_ShowWindowMenu":"Opens the Window menu.","tbMisc_AltKeyStateDown":"Records that the Alt key is held down, so that releasing it alone can open the File menu. The IDE uses it internally.","tbMisc_AltKeyStateUp":"Opens the File menu when the Alt key is released without another key having been pressed, or closes a menu that is open.","tbMisc_PreventDefaultKeyBehaviour":"Stops the web view's own handling of the key. The IDE binds it to keys whose default action it does not want.","tbMisc_SaveProjectMetaStateInTwinproj":"Saves the project's meta state to the project file and shows a message box.","tbMisc_ShiftKeyStateDown":"Records that the Shift key is held down. The IDE uses it internally.","tbMisc_ShiftKeyStateUp":"Records that the Shift key has been released. The IDE uses it internally.","tbMisc_ShowTestMessage":"Shows a test message box.","tbOpenEditors_FocusPanel":"Moves the focus to the Open Editors panel.","tbOpenEditors_HidePanel":"Closes the Open Editors panel.","tbOpenEditors_ShowPanel":"Shows the Open Editors panel.","tbOutline_FocusPanel":"Moves the focus to the Outline panel.","tbOutline_HidePanel":"Closes the Outline panel.","tbOutline_ShowPanel":"Shows the Outline panel.","tbPackagePublishing_FocusPanel":"Moves the focus to the Package Publishing panel.","tbPackagePublishing_HidePanel":"Closes the Package Publishing panel.","tbPackagePublishing_ShowPanel":"Shows the Package Publishing panel.","tbPanels_SaveCurrentPanelLayoutAs":"Asks for a name and saves the current panel layout under it.","tbPanels_SetActiveLayoutCustom1":"Switches to the panel layout that is number 1 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom10":"Switches to the panel layout that is number 10 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom2":"Switches to the panel layout that is number 2 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom3":"Switches to the panel layout that is number 3 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom4":"Switches to the panel layout that is number 4 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom5":"Switches to the panel layout that is number 5 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom6":"Switches to the panel layout that is number 6 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom7":"Switches to the panel layout that is number 7 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom8":"Switches to the panel layout that is number 8 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutCustom9":"Switches to the panel layout that is number 9 in the list of saved layouts, if there is one.","tbPanels_SetActiveLayoutDefault":"Switches to the default built-in panel layout.","tbPanels_SetActiveLayoutFullScreen":"Switches to the full screen editor panel layout.","tbPanels_ShowManagePanelLayouts":"Opens the dialog for managing the saved panel layouts.","tbPanels_TogglePreventDockedMove":"Turns on or off the option that stops docked panels from being moved.","tbPanels_TogglePreventDockedResize":"Turns on or off the option that stops docked panels from being resized.","tbPanels_TogglePreventDockedTearout":"Turns on or off the option that stops docked panels from being pulled out of their dock.","tbPanels_TogglePreventFloatingMove":"Turns on or off the option that stops floating panels from being moved.","tbPanels_TogglePreventFloatingResize":"Turns on or off the option that stops floating panels from being resized.","tbProblems_ClipboardCopyAll":"Copies everything in the Problems panel to the clipboard as a compilation error report.","tbProblems_ClipboardCopyAllErrors":"Copies the errors of the Problems panel to the clipboard as a compilation error report.","tbProblems_CollapseAll":"Collapses every entry in the Problems panel.","tbProblems_ExpandAll":"Expands every entry in the Problems panel.","tbProblems_FocusPanel":"Moves the focus to the Problems panel.","tbProblems_HidePanel":"Closes the Problems panel.","tbProblems_ShowPanel":"Shows the Problems panel.","tbProblems_ToggleShowErrors":"Shows or hides the errors in the Problems panel.","tbProblems_ToggleShowHints":"Shows or hides the hints in the Problems panel.","tbProblems_ToggleShowInfos":"Shows or hides the information messages in the Problems panel.","tbProblems_ToggleShowWarnings":"Shows or hides the warnings in the Problems panel.","tbProblems_TurnShowErrorsOff":"Hides the errors in the Problems panel.","tbProblems_TurnShowErrorsOn":"Shows the errors in the Problems panel.","tbProblems_TurnShowHintsOff":"Hides the hints in the Problems panel.","tbProblems_TurnShowHintsOn":"Shows the hints in the Problems panel.","tbProblems_TurnShowInfosOff":"Hides the information messages in the Problems panel.","tbProblems_TurnShowInfosOn":"Shows the information messages in the Problems panel.","tbProblems_TurnShowWarningsOff":"Hides the warnings in the Problems panel.","tbProblems_TurnShowWarningsOn":"Shows the warnings in the Problems panel.","tbProject_AddCustomControlsPackage":"Adds the CustomControls package to the project.","tbProject_AddWinNativeFormsPackage":"Adds the WinNativeForms package to the project.","tbProject_Close":"Closes the project.","tbProject_Export":"Exports the project's sources to a folder.","tbProject_FindInFiles":"Opens the Find and Replace panel with the Current Project scope chosen.","tbProject_New":"Opens the front page on the list of templates for a new project.","tbProject_Open":"Opens the dialog for choosing a project to open.","tbProject_OpenBuildFolder":"Opens the project's build folder in Windows Explorer. A project that has not been saved gets a message instead.","tbProject_OpenProjectFolder":"Opens the folder that holds the project file in Windows Explorer. A project that has not been saved gets a message instead.","tbProject_OpenRecent":"Opens the front page on the list of recent projects.","tbProject_SaveAllChanges":"Saves the project and every document with unsaved changes.","tbProject_SaveAs":"Asks for a new name and place for the project and saves it there.","tbProject_ShowReferences":"Opens the project's References list.","tbProject_ShowSettings":"Opens the project's Settings in an editor.","tbProjectExplorer_ClipboardPaste":"In the Project Explorer's file view, pastes the items on the clipboard.","tbProjectExplorer_FocusPanel":"Moves the focus to the Project Explorer.","tbProjectExplorer_HidePanel":"Closes the Project Explorer panel.","tbProjectExplorer_ObjectList_DeleteSelected":"Shows only a message box with its own name; deleting is not implemented.","tbProjectExplorer_ObjectList_RenameSelected":"Shows only a message box with its own name; renaming is not implemented.","tbProjectExplorer_ObjectList_ViewSelectedCode":"In the object view of the Project Explorer, opens the code of the selected object.","tbProjectExplorer_ObjectList_ViewSelectedObject":"In the object view of the Project Explorer, opens the form of the selected object.","tbProjectExplorer_Search":"Opens the search box of the Project Explorer's object view, or moves the focus to it.","tbProjectExplorer_SelectedItemsClipboardCopy":"In the Project Explorer's file view, copies the selected items to the clipboard.","tbProjectExplorer_SelectedItemsClipboardCopyName":"In the Project Explorer's file view, copies the names of the selected items to the clipboard.","tbProjectExplorer_SelectedItemsClipboardCopyPath":"In the Project Explorer's file view, copies the paths of the selected items to the clipboard.","tbProjectExplorer_SelectedItemsClipboardCut":"In the Project Explorer's file view, cuts the selected items to the clipboard.","tbProjectExplorer_SelectedItemsDeletePermanently":"In the Project Explorer's file view, deletes the selected items, after asking if the Ask Before Delete Files option is on.","tbProjectExplorer_SelectedItemsExport":"In the Project Explorer's file view, exports the selected items to a folder.","tbProjectExplorer_SelectedItemsRename":"In the Project Explorer's file view, renames the selected item.","tbProjectExplorer_SelectedItemsViewAsJSON":"In the Project Explorer's file view, opens the selected file as JSON.","tbProjectExplorer_SelectedItemsViewAsMarkdownPreview":"In the Project Explorer's file view, opens the selected file as a Markdown preview.","tbProjectExplorer_ShowAddMenu":"Opens the menu for adding a component to the project, below the Add button of the Project Explorer.","tbProjectExplorer_ShowPanel":"Shows the Project Explorer panel.","tbProjectExplorer_ToggleFileMode":"Switches the Project Explorer between its file view and its object view.","tbProjectExplorer_ToggleFileModeOff":"Switches the Project Explorer to its object view.","tbProjectExplorer_ToggleFileModeOn":"Switches the Project Explorer to its file view.","tbProperties_FocusPanel":"Moves the focus to the Properties panel.","tbProperties_HidePanel":"Closes the Properties panel.","tbProperties_Search":"Opens the search box of the Properties panel, or moves the focus to it.","tbProperties_ToggleAlphabeticSort":"Turns the alphabetic sort order of the Properties panel on or off.","tbProperties_ShowPanel":"Shows the Properties panel.","tbShowObjectBrowser":"Opens the Object Browser, for the text selected in the code editor.","tbSignatureHelpCancel":"Dismisses the signature help that is showing.","tbTheme_SwitchToDarkMode":"Switches the IDE to the dark colour theme.","tbTheme_SwitchToggle":"Switches the IDE between the dark and light colour themes.","tbTheme_SwitchToLightClassicMode":"Switches the IDE to the classic light colour theme.","tbTheme_SwitchToLightMode":"Switches the IDE to the light colour theme.","tbThemes_Reload":"Reloads the themes from their files on disk.","tbThemes_ShowList":"Opens the list of themes beside the colour mode button.","tbToolbar_HidePanel":"Closes the Toolbar panel.","tbToolbar_ShowPanel":"Shows the Toolbar panel.","tbToolbox_FocusPanel":"Moves the focus to the Toolbox panel.","tbToolbox_HidePanel":"Closes the Toolbox panel.","tbToolbox_Search":"Opens the search box of the Toolbox, or moves the focus to it.","tbToolbox_SelectNextTool":"In the Toolbox, selects the next tool.","tbToolbox_SelectPrevTool":"In the Toolbox, selects the previous tool.","tbToolbox_ShowMoreComponents":"Shows a message about adding components to the Toolbox, which says to add an ordinary COM reference to the ActiveX type library.","tbToolbox_ShowPanel":"Shows the Toolbox panel.","tbToolbox_ToggleShowControlNames":"Shows or hides the names of the controls in the Toolbox.","tbToolbox_TurnShowControlNamesOff":"Hides the names of the controls in the Toolbox, leaving their icons.","tbToolbox_TurnShowControlNamesOn":"Shows the names of the controls in the Toolbox.","tbTraceOutput_Clear":"Clears the Trace Output panel.","tbVariables_FocusPanel":"Moves the focus to the Variables panel.","tbVariables_HidePanel":"Closes the Variables panel.","tbVariables_ShowPanel":"Shows the Variables panel.","tbWatches_Add":"Adds a watch, starting from the text selected in the code editor.","tbWatches_Clear":"Removes every watch.","tbWatches_FocusPanel":"Moves the focus to the Watches panel.","tbWatches_HidePanel":"Closes the Watches panel.","tbWatches_ShowPanel":"Shows the Watches panel.","tbWebpage_FocusPanel":"Moves the focus to the Webpage panel.","tbWebpage_GoBack":"Goes back one page in the Webpage panel.","tbWebpage_GoForward":"Goes forward one page in the Webpage panel.","tbWebpage_HidePanel":"Closes the Webpage panel.","tbWebpage_Reload":"Reloads the page in the Webpage panel.","tbWebpage_ShowPanel":"Shows the Webpage panel.","tbWebpage_ToggleMobileMode":"Turns the Webpage panel's Use Mobile Mode option on or off.","tbWebpage_TurnMobileModeOff":"Turns the Webpage panel's Use Mobile Mode option off.","tbWebpage_TurnMobileModeOn":"Turns the Webpage panel's Use Mobile Mode option on."}
diff --git a/add-in/Resources/SCRIPTS/keyeditor.js b/add-in/Resources/SCRIPTS/keyeditor.js
new file mode 100644
index 000000000..73e06392b
--- /dev/null
+++ b/add-in/Resources/SCRIPTS/keyeditor.js
@@ -0,0 +1,1299 @@
+// A table editor for Window > Keyboard Shortcuts > Manage Keyboard Shortcuts,
+// where the IDE shows "Keyboard editor coming soon...." once Edit as JSON is
+// cleared. Every command of the IDE is a row with its keys and a line on what
+// it does; a row of a group of your own opens an editor for that command's
+// entry in the group. The group stays the IDE's: the table reads the group's
+// text from the IDE's own text area, which it hides, and writes every change
+// back into it as JSON with an input event, so that the IDE's own handler
+// keeps the dialog's copy and turns on Save Changes. Save, Cancel, Add New and
+// Delete are the IDE's. A JSON button at the bottom shows the text area again.
+//
+// It changes only the call of the global showConfigEditor for this dialog
+// (showManageKeyboardShortcuts calls it by name), through the one replacement
+// of that function the help add-in's scripts share (see hookOf), and is put
+// in only while the IDE has the "coming soon" pane. Running this again
+// takes out what an earlier run put in: the original function goes back, and an
+// open dialog gets its text area back. It puts in nothing when it is turned
+// off. The add-in puts the commands' descriptions, { command: text }, in place
+// of the marker below.
+var on = $ON$;
+var old = window.tbDocsKeyEditor;
+if (old) {
+ try {
+ old.off();
+ } catch (err) {
+ console.error(err);
+ }
+ window.tbDocsKeyEditor = null;
+}
+if (
+ on &&
+ typeof showConfigEditor === "function" &&
+ typeof showManageKeyboardShortcuts === "function" &&
+ String(showManageKeyboardShortcuts).indexOf("Keyboard editor coming soon") >= 0 &&
+ typeof builtInKeyboardShortcutGroups === "object" &&
+ typeof ideCommands === "object" &&
+ typeof VirtualKeyCodeLookup === "object"
+) {
+ (function () {
+ var commandText = $COMMANDS$;
+ var TITLE = "Manage Keyboard Shortcuts";
+ // The commands whose action reads an argument, written cmd('argument').
+ var ARG_COMMANDS = { tbDebugConsole_ExecuteCode: true };
+ var KM = {
+ ctrl: typeof monaco_KeyMod_CtrlCmd === "number" ? monaco_KeyMod_CtrlCmd : 2048,
+ alt: typeof monaco_KeyMod_Alt === "number" ? monaco_KeyMod_Alt : 512,
+ shift: typeof monaco_KeyMod_Shift === "number" ? monaco_KeyMod_Shift : 1024,
+ down: typeof monaco_KeyMod_KEYDOWN === "number" ? monaco_KeyMod_KEYDOWN : 4096,
+ repeat: typeof monaco_KeyMod_KEYDOWNREPEAT === "number" ? monaco_KeyMod_KEYDOWNREPEAT : 8192,
+ };
+ // The keys getKeyBindingCodeFromString lets match with or without Shift.
+ var SHIFTABLE = "!\"#$%&'()*+-./:;<=>?@[\\]^_`{|}~";
+ var KEY_NAMES = {
+ ARROWUP: "Up", ARROWDOWN: "Down", ARROWLEFT: "Left", ARROWRIGHT: "Right",
+ ESCAPE: "Esc", ENTER: "Enter", SPACE: "Space", " ": "Space", TAB: "Tab",
+ BACKSPACE: "Backspace", DELETE: "Delete", INSERT: "Insert", HOME: "Home",
+ END: "End", PAGEUP: "Page Up", PAGEDOWN: "Page Down", CANCEL: "Break",
+ CONTROL: "Ctrl", SHIFT: "Shift", ALT: "Alt", CAPSLOCK: "Caps Lock",
+ OTHERKEY: "any key with no name",
+ };
+ var TIMINGS = [
+ ["down", "When pressed"],
+ ["repeat", "When pressed, and while held"],
+ ["release", "When released"],
+ ["repeatonly", "Only while held"],
+ ];
+ var live = true;
+ var mounts = [];
+
+ var esc = function (s) {
+ return String(s).replace(/[&<>"']/g, function (c) {
+ return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c];
+ });
+ };
+ // A description: plain text with `code` in backticks.
+ var descHtml = function (s) {
+ return esc(s || "").replace(/`([^`]+)`/g, "$1");
+ };
+ var lower = function (s) {
+ return String(s).toLowerCase();
+ };
+ var byName = function (a, b) {
+ return a.localeCompare(b, "en", { sensitivity: "base" });
+ };
+ var prefixOf = function (id) {
+ return id.slice(0, id.indexOf("_") + 1);
+ };
+ var registered = function (cmd) {
+ return Object.prototype.hasOwnProperty.call(ideCommands, cmd) && !!ideCommands[cmd] && !!ideCommands[cmd].internalAction;
+ };
+ var isBuiltIn = function (g) {
+ return Object.prototype.hasOwnProperty.call(builtInKeyboardShortcutGroups, g);
+ };
+
+ // ---- key strings, read as getKeyBindingCodeFromString reads them ----
+
+ var parseKey = function (raw) {
+ var s = String(raw);
+ if (s.substr(0, 11) === "{ALLEXCEPT}") return { raw: raw, allExcept: true };
+ var u = s.toUpperCase();
+ var take = function (t) {
+ if (u.indexOf(t) === -1) return false;
+ u = u.replace(t, "");
+ return true;
+ };
+ var k = { raw: raw };
+ k.ctrl = take("{CTRL}");
+ k.alt = take("{ALT}");
+ k.shift = take("{SHIFT}");
+ k.down = take("{KEYDOWN}");
+ k.repeat = take("{KEYDOWNREPEAT}");
+ k.name = u;
+ return k;
+ };
+ // The codes the IDE files the binding under; none for a key it has no name for.
+ var codesOf = function (k) {
+ if (k.allExcept) return [];
+ var a = VirtualKeyCodeLookup[k.name];
+ if (!a) return [];
+ if (k.ctrl) a += KM.ctrl;
+ if (k.alt) a += KM.alt;
+ var s = false;
+ if (k.shift) a += KM.shift;
+ else if (SHIFTABLE.indexOf(k.name) !== -1) s = true;
+ if (k.down && k.repeat) {
+ return s
+ ? [a + KM.down, a + KM.repeat, a + KM.down + KM.shift, a + KM.repeat + KM.shift]
+ : [a + KM.down, a + KM.repeat];
+ }
+ if (k.down) a += KM.down;
+ if (k.repeat) a += KM.repeat;
+ return s ? [a, a + KM.shift] : [a];
+ };
+ // A code without when it runs: the key and its modifiers.
+ var baseOf = function (code) {
+ return code & ~(KM.down | KM.repeat);
+ };
+ var timingOf = function (k) {
+ if (k.down && k.repeat) return "repeat";
+ if (k.down) return "down";
+ if (k.repeat) return "repeatonly";
+ return "release";
+ };
+ var keyString = function (k, timing) {
+ return (
+ (timing === "down" || timing === "repeat" ? "{KEYDOWN}" : "") +
+ (timing === "repeat" || timing === "repeatonly" ? "{KEYDOWNREPEAT}" : "") +
+ (k.ctrl ? "{CTRL}" : "") +
+ (k.shift ? "{SHIFT}" : "") +
+ (k.alt ? "{ALT}" : "") +
+ k.name
+ );
+ };
+ var keyLabel = function (k) {
+ if (k.allExcept) return "every other key";
+ var name = Object.prototype.hasOwnProperty.call(KEY_NAMES, k.name) ? KEY_NAMES[k.name] : k.name;
+ return (k.ctrl ? "Ctrl+" : "") + (k.shift ? "Shift+" : "") + (k.alt ? "Alt+" : "") + (name === "" ? "(empty)" : name);
+ };
+ // Why a binding cannot run as written: { level: "dead" | "warn", text }, or null.
+ var problemOf = function (k) {
+ if (k.allExcept) return null;
+ if (k.name === "") return { level: "dead", text: "An empty key string binds nothing." };
+ if (!VirtualKeyCodeLookup[k.name])
+ return { level: "dead", text: "The IDE has no key named " + k.name + ", so this never runs." };
+ if (k.name === "OTHERKEY")
+ return { level: "warn", text: "OTHERKEY runs for every key the IDE has no name for." };
+ if (!k.down && !k.repeat && (k.ctrl || k.alt))
+ return {
+ level: "dead",
+ text: "A key bound for its release never runs with Ctrl or Alt: the IDE remembers a key for its release only when neither is held.",
+ };
+ if (!k.down && k.repeat)
+ return { level: "warn", text: "This runs only while the key repeats, not when it is first pressed." };
+ if (k.shift && /^[0-9]$/.test(k.name))
+ return {
+ level: "warn",
+ text: "With Shift held, a digit key arrives as its shifted symbol on most keyboard layouts, so this usually never runs.",
+ };
+ return null;
+ };
+
+ // ---- a group, read as applyKeyboardShortcutsLayering reads it ----
+
+ var unquote = function (e) {
+ if (e.startsWith("'") && e.endsWith("'")) e = e.substring(1, e.length - 1);
+ return e.replace(/\\'/g, "'");
+ };
+ var parseEntryName = function (o) {
+ var args;
+ var i = o.indexOf("(");
+ if (i !== -1) {
+ args = o.substr(i + 1).trim();
+ if (args.substr(args.length - 1, 1) === ")") args = args.substr(0, args.length - 1);
+ args = unquote(args);
+ o = o.substr(0, i);
+ }
+ var plus = o.charAt(0) === "+";
+ return { cmd: plus ? o.substr(1) : o, plus: plus, args: args, hasParen: i !== -1, additive: plus || !!args };
+ };
+ var entryName = function (cmd, mode, args) {
+ if (args !== undefined) return cmd + "('" + String(args).replace(/'/g, "\\'") + "')";
+ return (mode === "add" ? "+" : "") + cmd;
+ };
+ var parseGroup = function (text) {
+ if (typeof text !== "string") return null;
+ try {
+ var o = JSON.parse(text);
+ return o && typeof o === "object" && !Array.isArray(o) ? o : null;
+ } catch (err) {
+ return null;
+ }
+ };
+ // Applies a group to the merged keys, as the IDE does; false when the IDE
+ // would stop at an entry whose value is not a list, leaving the rest out.
+ var apply = function (map, g, obj) {
+ var names = Object.keys(obj);
+ for (var x = 0; x < names.length; x++) {
+ var p = parseEntryName(names[x]);
+ var n = obj[names[x]];
+ var a = [];
+ if (n) {
+ if (!Array.isArray(n)) return false;
+ for (var j = 0; j < n.length; j++) a.push({ key: n[j], args: p.args, g: g, cmd: p.cmd });
+ }
+ if (p.additive) {
+ if (!map[p.cmd]) map[p.cmd] = [];
+ map[p.cmd].push.apply(map[p.cmd], a);
+ } else {
+ map[p.cmd] = a;
+ }
+ }
+ return true;
+ };
+ var snap = function (map) {
+ var out = Object.create(null);
+ for (var c in map) out[c] = map[c].slice();
+ return out;
+ };
+ var sameList = function (a, b) {
+ a = a || [];
+ b = b || [];
+ if (a.length !== b.length) return false;
+ for (var i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
+ return true;
+ };
+
+ // ---- the state of one open dialog ----
+
+ var newSession = function (opts) {
+ return {
+ opts: opts,
+ texts: {}, // the text of each group shown in this dialog, as last seen
+ added: {}, // groups made with Add New in this dialog, which Save switches on
+ view: "table",
+ search: "",
+ keySearch: null, // { label, bases } while the list shows the commands of a key
+ filter: "all",
+ collapsed: {},
+ open: null, // the command whose editor is open
+ capture: null, // { kind: "key" | "arg" | "search", name?, args? }
+ argDraft: "",
+ message: "",
+ scrollTop: 0,
+ m: null, // the mount: the dialog's controller, the node and its elements
+ };
+ };
+
+ var groupObject = function (s, entry) {
+ if (entry.readonly) {
+ var b = builtInKeyboardShortcutGroups[entry.id];
+ return b && b.data && typeof b.data === "object" ? b.data : null;
+ }
+ var text;
+ if (s.m && entry.id === s.m.id) text = s.m.area.value;
+ else if (Object.prototype.hasOwnProperty.call(s.texts, entry.id)) text = s.texts[entry.id];
+ else if (typeof customKeyboardShortcutGroups === "object" && customKeyboardShortcutGroups[entry.id])
+ text = customKeyboardShortcutGroups[entry.id].data;
+ return parseGroup(text);
+ };
+ // Switched on in Window > Keyboard Shortcuts; the IDE keeps the names of
+ // those as |name|, and refuses a name with a bar in it.
+ var switchedOn = function (id) {
+ return typeof activeKeyboardShortcutGroupNames === "string" && activeKeyboardShortcutGroupNames.indexOf("|" + id + "|") > -1;
+ };
+ // Counted with the others: on, built in, shown, or added in this dialog.
+ var isActive = function (s, entry) {
+ return entry.readonly || entry.id === s.m.id || !!s.added[entry.id] || switchedOn(entry.id);
+ };
+ // The merged keys before the shown group, with it, and with every active
+ // group, each binding one object throughout, so that a binding the shown
+ // group keeps is the same object in all three.
+ var layering = function (s) {
+ var entries = s.opts.getEntries(s.m.ctl);
+ var map = Object.create(null);
+ var before = null;
+ var through = null;
+ var partial = {};
+ entries.forEach(function (en) {
+ if (!isActive(s, en)) return;
+ if (en.id === s.m.id) before = snap(map);
+ var obj = groupObject(s, en);
+ if (obj && !apply(map, en.id, obj)) partial[en.id] = true;
+ if (en.id === s.m.id) through = snap(map);
+ });
+ var finalSet = new Set();
+ var byCode = new Map();
+ // Each command's codes in the built-in group: a group of your own that
+ // binds a command again to a key the built-in group gives it adds no
+ // conflict, whatever else shares the key.
+ var builtInCodes = new Set();
+ entries.forEach(function (en) {
+ if (!en.readonly) return;
+ var obj = groupObject(s, en);
+ if (!obj) return;
+ var m = Object.create(null);
+ apply(m, en.id, obj);
+ for (var c in m)
+ m[c].forEach(function (b) {
+ codesOf(parseKey(b.key)).forEach(function (code) {
+ builtInCodes.add(c + "\u0000" + code);
+ });
+ });
+ });
+ for (var cmd in map) {
+ map[cmd].forEach(function (b) {
+ finalSet.add(b);
+ if (!registered(b.cmd)) return;
+ var k = parseKey(b.key);
+ if (k.allExcept) return;
+ codesOf(k).forEach(function (code) {
+ if (!byCode.has(code)) byCode.set(code, []);
+ byCode.get(code).push(b);
+ });
+ });
+ }
+ return {
+ entries: entries,
+ before: before || Object.create(null),
+ through: through || snap(map),
+ final: map,
+ finalSet: finalSet,
+ byCode: byCode,
+ builtInCodes: builtInCodes,
+ partial: partial,
+ };
+ };
+ // The other commands that share one of a binding's codes, when a group of
+ // your own gives one of them the code and the built-in group does not: the
+ // built-in group shares keys between commands that apply in different
+ // places on purpose, and keeping one of those keys adds no conflict.
+ var clashesOf = function (L, b) {
+ if (!L.finalSet.has(b) || !registered(b.cmd)) return [];
+ var seen = [];
+ var added = function (o, code) {
+ return !isBuiltIn(o.g) && !L.builtInCodes.has(o.cmd + "\u0000" + code);
+ };
+ codesOf(parseKey(b.key)).forEach(function (code) {
+ var others = (L.byCode.get(code) || []).filter(function (o) {
+ return o.cmd !== b.cmd;
+ });
+ if (!others.length) return;
+ if (!added(b, code) && !others.some(function (o) { return added(o, code); })) return;
+ others.forEach(function (o) {
+ if (seen.indexOf(o) < 0) seen.push(o);
+ });
+ });
+ return seen;
+ };
+
+ // The shown group's entries, in its order, each with its parsed name.
+ var groupEntries = function (obj) {
+ return Object.keys(obj).map(function (name) {
+ var p = parseEntryName(name);
+ p.name = name;
+ p.value = obj[name];
+ p.list = p.value === null || p.value === undefined || Array.isArray(p.value);
+ return p;
+ });
+ };
+
+ // ---- writing the group back through the IDE's text area ----
+
+ var write = function (s, obj) {
+ var text = JSON.stringify(obj, null, "\t");
+ var area = s.m.area;
+ area.value = text;
+ s.texts[s.m.id] = text;
+ area.dispatchEvent(new Event("input", { bubbles: true }));
+ render(s);
+ };
+ // A copy of the group with the entry `oldName` changed: given the name
+ // `newName` and the value, or left out when newName is null. A new entry
+ // goes at the end.
+ var withEntry = function (obj, oldName, newName, value) {
+ var out = {};
+ var done = false;
+ Object.keys(obj).forEach(function (n) {
+ if (n === oldName) {
+ if (newName !== null) out[newName] = value;
+ done = true;
+ } else if (n !== newName || oldName === null) {
+ out[n] = obj[n];
+ }
+ });
+ if (!done && newName !== null) out[newName] = value;
+ return out;
+ };
+
+ // ---- drawing ----
+
+ var chipHtml = function (L, b, cls, extraTitle) {
+ var k = parseKey(b.key);
+ var problem = problemOf(k);
+ var others = cls === "gone" ? [] : clashesOf(L, b);
+ var title = ["From " + b.g];
+ if (extraTitle) title.push(extraTitle);
+ if (k.allExcept) title.push("Every key that " + String(b.key).substr(11) + " does not name");
+ var timing = k.allExcept ? "release" : timingOf(k);
+ if (timing === "release") title.push("Runs when the key is released");
+ if (timing === "repeat") title.push("Runs again while the key is held");
+ if (problem) {
+ cls += problem.level === "dead" ? " tbKeDead" : " tbKeWarn";
+ title.push(problem.text);
+ } else if (others.length) {
+ cls += " tbKeClash";
+ title.push(
+ "Also " +
+ others
+ .map(function (o) {
+ return o.cmd + " (" + o.g + ")";
+ })
+ .join(", "),
+ );
+ }
+ var text = esc(keyLabel(k));
+ if (timing === "release" && !k.allExcept) text += ' released';
+ if (b.args !== undefined && b.args !== "") text += ' (' + esc("'" + b.args + "'") + ")";
+ return '' + text + "";
+ };
+
+ // What a row needs: its chips, the group's entries for its command, and
+ // whether the row has a problem.
+ var rowModel = function (s, L, cmd, mine) {
+ var before = L.before[cmd] || [];
+ var through = L.through[cmd] || [];
+ var throughSet = new Set(through);
+ var html = "";
+ var problems = [];
+ var custom = !s.m.readonly;
+ // A key the group binds again, with the same argument, is not shown as removed.
+ var same = function (b) {
+ return lower(b.key) + "\u0000" + (b.args === undefined ? "" : b.args);
+ };
+ var kept = new Set(through.map(same));
+ before.forEach(function (b) {
+ if (custom && !throughSet.has(b) && !kept.has(same(b))) html += chipHtml(L, b, "tbKeGone", "Removed by this group");
+ });
+ through.forEach(function (b) {
+ var own = custom && b.g === s.m.id;
+ html += chipHtml(L, b, own ? "tbKeMine" : "");
+ var k = parseKey(b.key);
+ var problem = problemOf(k);
+ var others = clashesOf(L, b);
+ if ((own || !custom) && (problem || others.length)) problems.push({ b: b, k: k, problem: problem, others: others });
+ });
+ var plain = mine.filter(function (p) {
+ return !p.args;
+ });
+ if (custom && !through.length && plain.some(function (p) { return !p.additive; }))
+ html += 'no keys';
+ // A later group that changes what this one left.
+ var later = "";
+ if (custom && mine.length && !sameList(through, L.final[cmd])) {
+ var by = [];
+ var past = false;
+ L.entries.forEach(function (en) {
+ if (en.id === s.m.id) past = true;
+ else if (past && isActive(s, en)) {
+ var obj = groupObject(s, en);
+ if (obj && Object.keys(obj).some(function (n) { return parseEntryName(n).cmd === cmd; })) by.push(en.id);
+ }
+ });
+ later = '
' + esc((by.length ? by.join(", ") : "A later group") + " changes this again") + "
";
+ }
+ return { html: html + later, problems: problems, changed: mine.length > 0, hasKeys: through.length > 0 };
+ };
+
+ var problemNotes = function (list) {
+ return list
+ .map(function (p) {
+ var label = esc(keyLabel(p.k));
+ if (p.problem)
+ return '
' + label + ": " + esc(p.problem.text) + "
";
+ return (
+ '
' +
+ label +
+ " is also " +
+ p.others
+ .map(function (o) {
+ return "" + esc(o.cmd) + " (" + esc(o.g) + ")";
+ })
+ .join(", ") +
+ ". The IDE runs each command bound to a key whose context applies, in its own order, until one of them ends the key's handling.
"
+ );
+ })
+ .join("");
+ };
+
+ var editorHtml = function (s, L, cmd, mine, model) {
+ var plain = mine.filter(function (p) {
+ return !p.args;
+ });
+ var withArgs = mine.filter(function (p) {
+ return !!p.args;
+ });
+ var h = '
';
+ var odd = plain.length > 1 || plain.some(function (p) { return p.hasParen || !p.list; });
+ if (odd) {
+ h +=
+ '
This group has ' +
+ (plain.length > 1 ? plain.length + " entries" : "an entry") +
+ " for this command that the table cannot edit. Edit " +
+ (plain.length > 1 ? "them" : "it") +
+ ' as JSON.
';
+ } else {
+ var p = plain[0];
+ var mode = p && !p.plus ? "replace" : "add";
+ var keys = p && Array.isArray(p.value) ? p.value : [];
+ h +=
+ '
Keys from earlier groups' +
+ '' +
+ '
';
+ h += '
This group';
+ keys.forEach(function (raw, i) {
+ h += keyEditHtml(s, raw, i, "key", p.name);
+ });
+ if (!keys.length) h += '' + (mode === "replace" ? "no keys: the command has none" : "none") + "";
+ h += captureHtml(s, { kind: "key" }) + "
";
+ }
+ if (ARG_COMMANDS[cmd] || withArgs.length) {
+ h += '
With an argument';
+ withArgs.forEach(function (a) {
+ var keys = Array.isArray(a.value) ? a.value : [];
+ h +=
+ '';
+ keys.forEach(function (raw, i) {
+ h += keyEditHtml(s, raw, i, "arg", a.name);
+ });
+ h += captureHtml(s, { kind: "arg", name: a.name });
+ h += '';
+ });
+ h +=
+ '' +
+ captureHtml(s, { kind: "arg", name: null }, "Add a key with this argument") +
+ "
";
+ }
+ h += problemNotes(model.problems.filter(function (q) { return q.b.g === s.m.id; }));
+ if (s.message) h += '
' + esc(s.message) + "
";
+ h += '
';
+ if (plain.length && !odd) h += '';
+ if (!odd) h += '';
+ h += '
';
+ return h;
+ };
+
+ var keyEditHtml = function (s, raw, i, kind, name) {
+ var k = parseKey(raw);
+ if (k.allExcept)
+ return '' + esc(keyLabel(k)) + "";
+ var t = timingOf(k);
+ var h = '' + esc(keyLabel(k)) + "";
+ h += '";
+ h += '';
+ return h;
+ };
+
+ var captureHtml = function (s, what, label) {
+ var c = s.capture;
+ var active = c && c.kind === what.kind && (what.kind !== "arg" || c.name === what.name);
+ if (active)
+ return '';
+ return (
+ '"
+ );
+ };
+
+ // The focused control, by what it is rather than by the element, so that
+ // the same control has the focus again after the list is drawn again.
+ var FOCUS_ATTRS = ["data-act", "data-mode", "data-kind", "data-name", "data-i", "data-prefix", "data-capture"];
+ var focusKey = function (list) {
+ var el = document.activeElement;
+ if (!el || !list.contains(el)) return null;
+ if (el.classList.contains("tbKeEditable")) return '.tbKeEditable[data-cmd="' + CSS.escape(el.getAttribute("data-cmd")) + '"]';
+ var sel = FOCUS_ATTRS.filter(function (a) {
+ return el.hasAttribute(a);
+ }).map(function (a) {
+ return "[" + a + '="' + CSS.escape(el.getAttribute(a)) + '"]';
+ });
+ return sel.length ? el.tagName.toLowerCase() + sel.join("") : null;
+ };
+
+ var render = function (s) {
+ var m = s.m;
+ if (!m) return;
+ var obj = parseGroup(m.area.value);
+ var table = s.view === "table" && !!obj;
+ m.top.style.display = table ? "" : "none";
+ m.area.style.display = table ? "none" : "";
+ m.label.style.display = "none";
+ m.viewTable.setAttribute("aria-pressed", String(s.view === "table"));
+ m.viewJson.setAttribute("aria-pressed", String(s.view !== "table"));
+ if (table && window.tbDocsTextFind && window.tbDocsTextFind.bar && m.node.contains(window.tbDocsTextFind.bar))
+ window.tbDocsTextFind.bar.remove();
+ var L = layering(s);
+ var state = "";
+ if (m.readonly) state = "The built-in group: read-only.";
+ else if (s.added[m.id]) state = "Switched on when the changes are saved.";
+ else if (!switchedOn(m.id)) state = "Off: switch it on in Window > Keyboard Shortcuts.";
+ if (!obj) {
+ m.status.textContent = (s.view === "table" ? "The text is not valid JSON, so the table cannot show it. " : "") + state;
+ m.status.className = s.view === "table" ? "tbKeStatus tbKeBad" : "tbKeStatus";
+ return;
+ }
+ var mine = groupEntries(obj);
+ var byCmd = Object.create(null);
+ var stray = [];
+ var cut = false;
+ mine.forEach(function (p) {
+ if (cut) {
+ stray.push({ p: p, why: "after an entry whose value is not a list: the IDE stops reading the group there" });
+ return;
+ }
+ if (!p.list) {
+ stray.push({ p: p, why: "its value is not a list of keys, and the IDE stops reading the group here" });
+ cut = true;
+ return;
+ }
+ if (!Object.prototype.hasOwnProperty.call(ideCommands, p.cmd)) {
+ stray.push({ p: p, why: "the IDE has no command of this name" });
+ return;
+ }
+ (byCmd[p.cmd] = byCmd[p.cmd] || []).push(p);
+ });
+ // The rows: every command of the IDE, by prefix and name.
+ var ids = Object.keys(ideCommands).sort(byName);
+ var q = lower(s.search.trim());
+ var counts = { all: 0, keys: 0, changed: 0, problems: 0 };
+ var groups = [];
+ var byPrefix = Object.create(null);
+ ids.forEach(function (cmd) {
+ var model = rowModel(s, L, cmd, byCmd[cmd] || []);
+ counts.all++;
+ if (model.hasKeys) counts.keys++;
+ if (model.changed) counts.changed++;
+ if (model.problems.length) counts.problems++;
+ if (s.filter === "keys" && !model.hasKeys) return;
+ if (s.filter === "changed" && !model.changed) return;
+ if (s.filter === "problems" && !model.problems.length) return;
+ if (s.keySearch) {
+ var hit = (L.through[cmd] || []).concat(L.before[cmd] || []).some(function (b) {
+ return codesOf(parseKey(b.key)).some(function (code) {
+ return s.keySearch.bases.indexOf(baseOf(code)) >= 0;
+ });
+ });
+ if (!hit) return;
+ } else if (q) {
+ var labels = (L.through[cmd] || [])
+ .map(function (b) {
+ return lower(keyLabel(parseKey(b.key)));
+ })
+ .join(" ");
+ if (lower(cmd).indexOf(q) < 0 && lower(commandText[cmd] || "").indexOf(q) < 0 && labels.indexOf(q) < 0) return;
+ }
+ var prefix = prefixOf(cmd);
+ if (!byPrefix[prefix]) {
+ byPrefix[prefix] = { prefix: prefix, rows: [] };
+ groups.push(byPrefix[prefix]);
+ }
+ byPrefix[prefix].rows.push({ cmd: cmd, model: model });
+ });
+ groups.sort(function (a, b) {
+ if (!a.prefix !== !b.prefix) return a.prefix ? -1 : 1;
+ return byName(a.prefix, b.prefix);
+ });
+ var filtering = !!(q || s.keySearch || s.filter !== "all");
+ var h = "";
+ if (m.readonly) h += '
The built-in group is read-only. Its keys come first, under every group of your own.
';
+ if (L.partial[m.id]) h += '
The IDE reads this group only up to an entry whose value is not a list of keys. The entries after it have no effect.
';
+ s.stray = stray;
+ if (stray.length) {
+ h += '
';
+ var scroll = m.list.scrollTop;
+ var focused = focusKey(m.list);
+ m.list.innerHTML = h;
+ m.list.scrollTop = scroll;
+ if (focused) {
+ var again = m.list.querySelector(focused);
+ if (again) again.focus();
+ }
+ // The filter buttons, with their counts.
+ var f = [["all", "All", counts.all], ["keys", "With keys", counts.keys]];
+ if (!m.readonly) f.push(["changed", "Changed here", counts.changed]);
+ f.push(["problems", "Problems", counts.problems]);
+ if (m.readonly && s.filter === "changed") s.filter = "all";
+ m.filters.innerHTML = f
+ .map(function (x) {
+ return (
+ '"
+ );
+ })
+ .join("");
+ m.keyButton.setAttribute("aria-pressed", String(!!(s.keySearch || (s.capture && s.capture.kind === "search"))));
+ m.search.placeholder = s.capture && s.capture.kind === "search" ? "Press the keys to find... (Esc to stop)" : "Find a command, a description or a key";
+ if (s.keySearch && m.search.value !== s.keySearch.label) m.search.value = s.keySearch.label;
+ m.status.className = "tbKeStatus";
+ m.status.textContent =
+ (m.readonly ? "" : mine.length + (mine.length === 1 ? " entry" : " entries") + ", ") +
+ counts.problems + (counts.problems === 1 ? " command" : " commands") + " with a problem across the active groups. " + state;
+ var cap = m.list.querySelector("[data-capture]");
+ if (cap) {
+ cap.onkeydown = function (e) {
+ captureKey(s, e);
+ };
+ cap.onblur = function () {
+ setTimeout(function () {
+ if (s.capture && s.capture.kind !== "search" && document.activeElement !== cap) {
+ s.capture = null;
+ render(s);
+ }
+ }, 0);
+ };
+ cap.focus();
+ } else if (s.capture && s.capture.kind === "search") {
+ m.search.focus();
+ }
+ };
+
+ // ---- key capture, as globalKeyDown names a key ----
+
+ var captureKey = function (s, e) {
+ e.preventDefault();
+ e.stopPropagation();
+ var plain = !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey;
+ if (plain && (e.key === "Escape" || e.key === "Tab")) {
+ s.capture = null;
+ s.message = "";
+ render(s);
+ return;
+ }
+ if (["Control", "Shift", "Alt", "Meta", "AltGraph", "OS"].indexOf(e.key) >= 0) return;
+ var fail = function (text) {
+ s.message = text;
+ render(s);
+ };
+ if (e.getModifierState && e.getModifierState("AltGraph"))
+ return fail("AltGr types a character here, so the IDE cannot take it as a shortcut.");
+ if (e.metaKey) return fail("The IDE does not read the Windows key.");
+ var o = e.key;
+ if (e.code && e.code.startsWith("Key") && !(typeof isSpecialKeyLookup === "object" && isSpecialKeyLookup[o])) o = e.code.substr(3);
+ var name = o.toUpperCase();
+ if (name === " ") name = "SPACE";
+ if (!VirtualKeyCodeLookup[name] || name === "OTHERKEY")
+ return fail("The IDE has no name for " + (e.key === "Dead" ? "this key" : e.key) + ", so it cannot be a shortcut. Plain Esc and Tab are bound in the JSON view.");
+ var k = { ctrl: e.ctrlKey, shift: e.shiftKey, alt: e.altKey, name: name };
+ var c = s.capture;
+ s.message = "";
+ if (c.kind === "search") {
+ var bases = codesOf(Object.assign({ down: true }, k)).map(baseOf);
+ s.keySearch = { label: keyLabel(k), bases: bases };
+ s.search = "";
+ s.capture = null;
+ s.m.search.value = s.keySearch.label;
+ render(s);
+ return;
+ }
+ var raw = keyString(k, "down");
+ var obj = parseGroup(s.m.area.value);
+ if (!obj) return;
+ var cmd = s.open;
+ s.capture = null;
+ if (c.kind === "key") {
+ var p = groupEntries(obj).filter(function (x) {
+ return x.cmd === cmd && !x.args;
+ })[0];
+ var keys = p && Array.isArray(p.value) ? p.value.slice() : [];
+ if (keys.indexOf(raw) < 0) keys.push(raw);
+ write(s, withEntry(obj, p ? p.name : null, p ? p.name : entryName(cmd, "add"), keys));
+ } else if (c.name) {
+ var list = Array.isArray(obj[c.name]) ? obj[c.name].slice() : [];
+ if (list.indexOf(raw) < 0) list.push(raw);
+ write(s, withEntry(obj, c.name, c.name, list));
+ } else {
+ var arg = s.argDraft.trim();
+ if (!arg) return fail("Type the argument first.");
+ var newName = entryName(cmd, null, arg);
+ var have = Array.isArray(obj[newName]) ? obj[newName].slice() : [];
+ if (have.indexOf(raw) < 0) have.push(raw);
+ s.argDraft = "";
+ write(s, withEntry(obj, newName, newName, have));
+ }
+ };
+
+ // ---- what the controls do ----
+
+ var act = function (s, el, e) {
+ var a = el.getAttribute("data-act");
+ var obj = parseGroup(s.m.area.value);
+ var cmd = s.open;
+ var plainOf = function () {
+ return groupEntries(obj).filter(function (x) {
+ return x.cmd === cmd && !x.args;
+ })[0];
+ };
+ s.message = "";
+ if (a === "fold") {
+ var name = el.getAttribute("data-prefix");
+ s.collapsed[name] = !s.collapsed[name];
+ return render(s);
+ }
+ if (a === "json") {
+ s.view = "json";
+ return render(s);
+ }
+ if (a === "close") {
+ s.open = null;
+ s.capture = null;
+ return render(s);
+ }
+ if (a === "capture") {
+ s.capture = { kind: el.getAttribute("data-kind"), name: el.getAttribute("data-name") };
+ if (s.capture.kind === "arg" && !s.capture.name && !s.argDraft.trim()) {
+ s.capture = null;
+ s.message = "Type the argument first.";
+ }
+ return render(s);
+ }
+ if (!obj || s.m.readonly) return;
+ if (a === "strayremove") {
+ var x = s.stray[Number(el.getAttribute("data-i"))];
+ if (x) write(s, withEntry(obj, x.p.name, null));
+ return;
+ }
+ var p = plainOf();
+ if (a === "mode") {
+ var mode = el.getAttribute("data-mode");
+ var keys = p && Array.isArray(p.value) ? p.value : [];
+ // Keeping the earlier keys and adding none is what no entry does.
+ if (mode === "add" && !keys.length) return p ? write(s, withEntry(obj, p.name, null)) : render(s);
+ return write(s, withEntry(obj, p ? p.name : null, entryName(cmd, mode), keys));
+ }
+ if (a === "reset") return p ? write(s, withEntry(obj, p.name, null)) : undefined;
+ if (a === "nokeys") return write(s, withEntry(obj, p ? p.name : null, entryName(cmd, "replace"), []));
+ if (a === "remove") {
+ var ename = el.getAttribute("data-name");
+ var list = Array.isArray(obj[ename]) ? obj[ename].slice() : [];
+ list.splice(Number(el.getAttribute("data-i")), 1);
+ // An entry that adds nothing does nothing, so it goes.
+ var gone = !list.length && (el.getAttribute("data-kind") === "arg" || parseEntryName(ename).plus);
+ return write(s, withEntry(obj, ename, gone ? null : ename, list));
+ }
+ if (a === "argremove") return write(s, withEntry(obj, el.getAttribute("data-name"), null));
+ if (e && e.type === "change") {
+ if (a === "timing") {
+ var tname = el.getAttribute("data-name");
+ var tlist = Array.isArray(obj[tname]) ? obj[tname].slice() : [];
+ var i = Number(el.getAttribute("data-i"));
+ var k = parseKey(tlist[i]);
+ tlist[i] = keyString(k, el.value);
+ return write(s, withEntry(obj, tname, tname, tlist));
+ }
+ if (a === "argtext") {
+ var from = el.getAttribute("data-name");
+ var text = el.value.trim();
+ if (!text) {
+ s.message = "An argument cannot be empty: an entry with an empty argument replaces the command's other keys.";
+ return render(s);
+ }
+ var to = entryName(cmd, null, text);
+ if (to !== from && Object.prototype.hasOwnProperty.call(obj, to)) {
+ s.message = "This group already binds a key to the command with that argument.";
+ return render(s);
+ }
+ return write(s, withEntry(obj, from, to, obj[from]));
+ }
+ }
+ };
+
+ // ---- putting the table into the IDE's pane ----
+
+ var mount = function (s, ctl, node) {
+ var area = node.querySelector("textarea");
+ var label = node.querySelector("label");
+ if (!area || !label) return;
+ var m = {
+ ctl: ctl,
+ node: node,
+ area: area,
+ label: label,
+ id: ctl.selectedEntryId,
+ readonly: area.hasAttribute("readonly"),
+ };
+ if (!m.readonly) s.texts[m.id] = area.value;
+ area.addEventListener("input", function () {
+ if (!m.readonly) s.texts[m.id] = area.value;
+ });
+ if (s.m && s.m.id !== m.id) {
+ s.open = null;
+ s.capture = null;
+ s.message = "";
+ }
+ s.m = m;
+ var top = document.createElement("div");
+ top.className = "tbKe tbKeTop";
+ top.innerHTML =
+ '
' +
+ '' +
+ '
' +
+ '';
+ var foot = document.createElement("div");
+ foot.className = "tbKe tbKeFoot";
+ foot.innerHTML =
+ '' +
+ '';
+ node.insertBefore(top, area);
+ node.appendChild(foot);
+ m.top = top;
+ m.foot = foot;
+ m.list = top.querySelector(".tbKeList");
+ m.search = top.querySelector(".tbKeSearch");
+ m.filters = top.querySelector(".tbKeFilters");
+ m.keyButton = top.querySelector(".tbKeKeyFind");
+ m.viewTable = foot.querySelector('[data-view="table"]');
+ m.viewJson = foot.querySelector('[data-view="json"]');
+ m.status = foot.querySelector(".tbKeStatus");
+ m.search.value = s.keySearch ? s.keySearch.label : s.search;
+
+ m.search.addEventListener("input", function () {
+ s.keySearch = null;
+ s.search = m.search.value;
+ render(s);
+ });
+ m.search.addEventListener("keydown", function (e) {
+ if (s.capture && s.capture.kind === "search") captureKey(s, e);
+ });
+ m.search.addEventListener("blur", function () {
+ if (s.capture && s.capture.kind === "search") {
+ s.capture = null;
+ render(s);
+ }
+ });
+ m.keyButton.addEventListener("click", function () {
+ if (s.keySearch || (s.capture && s.capture.kind === "search")) {
+ s.keySearch = null;
+ s.capture = null;
+ s.search = "";
+ m.search.value = "";
+ } else {
+ s.capture = { kind: "search" };
+ m.search.value = "";
+ }
+ render(s);
+ });
+ m.filters.addEventListener("click", function (e) {
+ var b = e.target.closest("[data-filter]");
+ if (!b) return;
+ s.filter = b.getAttribute("data-filter");
+ render(s);
+ });
+ m.viewTable.addEventListener("click", function () {
+ s.view = "table";
+ render(s);
+ });
+ m.viewJson.addEventListener("click", function () {
+ s.view = "json";
+ render(s);
+ });
+ m.list.addEventListener("scroll", function () {
+ s.scrollTop = m.list.scrollTop;
+ });
+ m.list.addEventListener("click", function (e) {
+ var el = e.target.closest("[data-act]");
+ if (el && el.tagName !== "SELECT" && el.tagName !== "INPUT") return act(s, el, e);
+ if (e.target.closest(".tbKeEditor")) return;
+ var row = e.target.closest(".tbKeEditable");
+ if (!row) return;
+ var cmd = row.getAttribute("data-cmd");
+ s.open = s.open === cmd ? null : cmd;
+ s.capture = null;
+ s.message = "";
+ render(s);
+ });
+ m.list.addEventListener("change", function (e) {
+ var el = e.target.closest("[data-act]");
+ if (el) act(s, el, e);
+ });
+ m.list.addEventListener("input", function (e) {
+ if (e.target.getAttribute("data-act") === "argdraft") s.argDraft = e.target.value;
+ });
+ // The dialog's own key handler (on its container) presses its focused
+ // button on Enter, cancels the dialog on Esc outside a text box, and
+ // keeps Tab and the arrow keys from moving the focus: none of it reaches
+ // past the table.
+ var keys = function (e) {
+ e.stopPropagation();
+ if (e.ctrlKey && !e.altKey && e.code === "KeyF") {
+ e.preventDefault();
+ m.search.focus();
+ m.search.select();
+ return;
+ }
+ if (e.key === "Escape") {
+ e.preventDefault();
+ if (s.capture) s.capture = null;
+ else if (s.open) s.open = null;
+ else if (s.keySearch || s.search) {
+ s.keySearch = null;
+ s.search = "";
+ m.search.value = "";
+ } else return;
+ s.message = "";
+ render(s);
+ return;
+ }
+ var t = e.target;
+ if ((e.key === "Enter" || e.key === " ") && t.getAttribute && (t.classList.contains("tbKeEditable") || t.getAttribute("data-act") === "fold")) {
+ e.preventDefault();
+ t.click();
+ }
+ };
+ top.addEventListener("keydown", keys);
+ foot.addEventListener("keydown", keys);
+ var record = {
+ node: node,
+ undo: function () {
+ top.remove();
+ foot.remove();
+ area.style.display = "";
+ label.style.display = "";
+ var outer = node.closest(".configEditorRootOuter");
+ var header = outer && outer.querySelector(".configEditorInfoHeader");
+ if (header && typeof s.info === "string") header.innerHTML = s.info;
+ },
+ };
+ mounts = mounts.filter(function (r) {
+ return r.node.isConnected;
+ });
+ mounts.push(record);
+ // The IDE puts the node into the dialog after this returns; the list
+ // has a height, and its scroll position, only then.
+ render(s);
+ setTimeout(function () {
+ if (s.m === m) m.list.scrollTop = s.scrollTop;
+ }, 0);
+ };
+
+ // The header's last line promises an editor, which this is: it is left out
+ // while the table is on, and put back when it is turned off.
+ var PROMISE = / \s*ps\.\s+in future we'll have a proper editor[^<]*$/i;
+
+ // Changes the options of the one dialog, and passes every other call on.
+ var adapt = function (opts) {
+ var s = newSession(opts);
+ if (typeof opts.info === "string") {
+ s.info = opts.info;
+ opts.info = opts.info.replace(PROMISE, "");
+ }
+ var getNode = opts.getEntryEditorDomNode;
+ var addNew = opts.addNewEntry;
+ var del = opts.deleteEntry;
+ var ids = function (ctl) {
+ var out = {};
+ opts.getEntries(ctl).forEach(function (en) {
+ out[en.id] = true;
+ });
+ return out;
+ };
+ opts.getEntryEditorDomNode = function (ctl) {
+ var node = getNode.apply(this, arguments);
+ if (!live) return node;
+ try {
+ mount(s, ctl, node);
+ } catch (err) {
+ console.error(err);
+ }
+ return node;
+ };
+ opts.addNewEntry = function (ctl, name) {
+ var had = live ? ids(ctl) : null;
+ var r = addNew.apply(this, arguments);
+ if (live) {
+ try {
+ if (!had[name] && ids(ctl)[name]) s.added[name] = true;
+ render(s);
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ return r;
+ };
+ opts.deleteEntry = function (ctl, id) {
+ var r = del.apply(this, arguments);
+ if (live) {
+ try {
+ delete s.texts[id];
+ delete s.added[id];
+ render(s);
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ return r;
+ };
+ };
+
+ // ---- the one replacement of showConfigEditor ----
+ // Each script of the add-in that changes a dialog of showConfigEditor
+ // puts its adapter here under the dialog's title, or the title, "|" and a
+ // name of its own; the replacement calls every adapter for the dialog's
+ // title, then the IDE's function. layouteditor.js and layouts.js have the
+ // same two functions.
+ var hookOf = function () {
+ var h = window.tbDocsConfigEditors;
+ if (h && window.showConfigEditor === h.dispatch) return h;
+ var current = window.showConfigEditor;
+ var nh = { original: current.tbDocsOriginal || current, adapters: (h && h.adapters) || {} };
+ nh.dispatch = function (opts) {
+ var title = opts && typeof opts.title === "string" ? opts.title : null;
+ if (title !== null)
+ Object.keys(nh.adapters).forEach(function (k) {
+ if (k !== title && k.indexOf(title + "|") !== 0) return;
+ try {
+ nh.adapters[k](opts);
+ } catch (err) {
+ console.error(err);
+ }
+ });
+ return nh.original.apply(this, arguments);
+ };
+ nh.dispatch.tbDocsOriginal = nh.original;
+ window.showConfigEditor = nh.dispatch;
+ window.tbDocsConfigEditors = nh;
+ return nh;
+ };
+ var unhook = function (title) {
+ var h = window.tbDocsConfigEditors;
+ if (!h) return;
+ delete h.adapters[title];
+ if (Object.keys(h.adapters).length) return;
+ if (window.showConfigEditor === h.dispatch) window.showConfigEditor = h.original;
+ window.tbDocsConfigEditors = null;
+ };
+ var hook = hookOf();
+ hook.adapters[TITLE] = function (opts) {
+ if (live) adapt(opts);
+ };
+
+ var style = document.getElementById("tbDocsKeyEditorStyle");
+ if (!style) {
+ style = document.createElement("style");
+ style.id = "tbDocsKeyEditorStyle";
+ document.head.appendChild(style);
+ }
+ // The look is the IDE's own. Buttons are the dialog's buttons, from the
+ // theme's variables, so that they take each theme's shape (square in Dark
+ // and Light, rounded in Aurora). Everything else follows the IDE Options
+ // and Project Settings dialogs (tips_injectCss and tbps_injectCss in
+ // main.js), whose accent, controls and section titles are the same in
+ // every theme. The pane the table is in is white whatever the theme
+ // (styles.css, .configEditorRHS), so its text and fields are dark on white.
+ var ACCENT = "#4271ae";
+ var BTN =
+ "background:var(--themeDialogButtonsBackColor,#fbfdff);color:var(--themeDialogButtonForeColor,#000);" +
+ "border-top:var(--themeDialogButtonBorderTop,1px solid #9b9b9b);border-left:var(--themeDialogButtonBorderLeft,1px solid #9b9b9b);" +
+ "border-right:var(--themeDialogButtonBorderRight,1px solid #5e5e5e);border-bottom:var(--themeDialogButtonBorderBottom,1px solid #5e5e5e);" +
+ "border-radius:var(--themeDialogButtonBorderRadius,0);box-shadow:var(--themeDialogButtonBoxShadow,2px 2px 3px #7c7c7c78)";
+ var FOCUS = "var(--themeDialogButtonFocusWidth,2px) solid var(--themeDialogButtonFocusRectColor,#6d6dc3)";
+ var MONO = "font-family:Consolas,Menlo,monospace";
+ style.textContent = [
+ ".tbKe{color:#1e1e1e;font-size:inherit}",
+ ".tbKeTop{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;background:#fff}",
+ ".tbKeBar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:8px;border-bottom:1px solid rgba(128,128,128,.35)}",
+ // Text boxes and drop-downs, as the settings dialogs draw them.
+ ".tbKe input.tbKeSearch,.tbKe input.tbKeArgText,.tbKe input.tbKeCapture,.tbKe select.tbKeTiming{box-sizing:border-box;height:26px;padding:0 6px;border:1px solid #999;border-radius:4px;background:#fff;color:#1e1e1e;font:inherit;outline:none}",
+ ".tbKe input.tbKeSearch{flex:1 1 200px;min-width:140px;padding:0 10px}",
+ ".tbKe input.tbKeArgText{width:12em;" + MONO + "}",
+ ".tbKe input.tbKeCapture{width:16em;border-color:" + ACCENT + ";background:#eef3ff;box-shadow:0 0 0 2px rgba(66,113,174,.25)}",
+ ".tbKe input.tbKeSearch:focus,.tbKe input.tbKeArgText:focus,.tbKe select.tbKeTiming:focus{border-color:" + ACCENT + ";box-shadow:0 0 0 2px rgba(66,113,174,.25)}",
+ // Buttons: the dialog's own.
+ ".tbKeBtn{box-sizing:border-box;height:26px;padding:0 10px;margin:0 2px 2px 0;font:inherit;cursor:pointer;white-space:nowrap;" + BTN + "}",
+ ".tbKeBtn:hover{background-color:#ebeff5;filter:brightness(1.3)}",
+ ".tbKeBtn[aria-pressed=true]{background:" + ACCENT + ";color:#fff}",
+ ".tbKe .tbKeBtn:focus-visible{outline:" + FOCUS + ";outline-offset:2px}",
+ // A choice of one: the settings dialogs' No / Yes control.
+ ".tbKeSeg{display:inline-flex;flex-wrap:wrap;border:1px solid #999;border-radius:4px;overflow:hidden;background:#fff}",
+ ".tbKeSegBtn{box-sizing:border-box;height:24px;padding:0 10px;margin:0;border:0;border-right:1px solid #999;border-radius:0;background:#fff;color:#1e1e1e;font:inherit;cursor:pointer;white-space:nowrap;user-select:none}",
+ ".tbKeSegBtn:last-child{border-right:0}",
+ ".tbKeSegBtn:hover{background:rgba(128,128,128,.15)}",
+ ".tbKeSegBtn[aria-pressed=true]{background:" + ACCENT + ";color:#fff}",
+ ".tbKe .tbKeSegBtn:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var(--themeDialogButtonFocusRectColor,#6d6dc3),inset 0 0 0 3px #fff}",
+ ".tbKeCount{font-size:80%;opacity:.6;font-weight:normal}",
+ ".tbKeSegBtn[aria-pressed=true] .tbKeCount{opacity:.8}",
+ ".tbKeList{flex:1 1 auto;min-height:0;overflow:auto}",
+ // A prefix's heading: the settings dialogs' section title.
+ ".tbKeHead{position:sticky;top:0;z-index:1;display:flex;align-items:center;gap:4px;padding:4px 8px 4px 4px;border-left:4px solid " + ACCENT + ";background:#f5f5f5;font-weight:600;cursor:pointer;user-select:none}",
+ ".tbKeHeadName{" + MONO + "}.tbKeHead .tbKeCount{margin-left:auto}",
+ ".tbKeFold{font-size:14px;opacity:.7}",
+ ".tbKeStrayHead{position:static;display:block;padding-left:8px;border-left-color:#c62828;cursor:default}",
+ // The rows: the settings dialogs' option rows.
+ ".tbKeRow{display:grid;grid-template-columns:minmax(0,34%) minmax(0,26%) minmax(0,1fr);gap:8px;padding:6px 8px;border-bottom:var(--themeDialogConfigRowBorderBottom,1px solid rgba(128,128,128,.25));align-items:start}",
+ ".tbKeEditable{cursor:pointer}.tbKeEditable:hover{background:rgba(128,128,128,.06)}",
+ ".tbKeChanged{box-shadow:inset 3px 0 rgba(66,113,174,.5)}",
+ ".tbKeOpen,.tbKeOpen:hover{background:rgba(128,128,128,.09)}",
+ ".tbKeCmd{" + MONO + ";overflow-wrap:anywhere}.tbKePre{opacity:.5}",
+ ".tbKeDesc{color:#5a5a5a}.tbKeDesc code{" + MONO + "}",
+ // A key: plain as the dialog's
, and in colour when it says something.
+ ".tbKeKey{display:inline-block;margin:1px 3px 1px 0;padding:0 4px;border:1px solid transparent;border-radius:3px;background:rgba(127,127,127,.2);color:#1e1e1e;" + MONO + ";font-size:90%;white-space:nowrap}",
+ ".tbKeMine{background:rgba(66,113,174,.14);border-color:" + ACCENT + ";color:#2b4f80}",
+ ".tbKeGone{background:transparent;border:1px dashed #999;color:#888;text-decoration:line-through}",
+ ".tbKeClash{background:#fff3cd;border-color:#b8860b;color:#6b4e00}",
+ ".tbKeWarn{background:#fff3cd;border:1px dashed #b8860b;color:#6b4e00}",
+ ".tbKeDead{background:#fdecea;border-color:#c62828;color:#8e1c1c;text-decoration:line-through}",
+ ".tbKeWhen,.tbKeArg{opacity:.75}",
+ ".tbKeNone{color:#777;font-style:italic}",
+ ".tbKeLater{margin-top:2px;color:#6b4e00;font-size:90%}",
+ ".tbKeEditor{grid-column:1/-1;margin:6px 0 2px;padding:10px;border:1px solid rgba(128,128,128,.45);border-radius:4px;background:#fff;cursor:default}",
+ ".tbKeLine{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-bottom:8px}",
+ ".tbKeEnd{margin:8px 0 0}.tbKeGrow{flex:1}",
+ ".tbKeLabel{flex:0 0 13em;align-self:flex-start;line-height:26px;font-weight:600}",
+ ".tbKeVals{display:flex;flex:1 1 0;min-width:0;gap:6px;align-items:center;flex-wrap:wrap}",
+ ".tbKeKeyEdit{display:inline-flex;align-items:center;gap:3px;margin-right:8px}",
+ ".tbKeX{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:4px;background:transparent;color:#c62828;cursor:pointer}",
+ ".tbKeX:hover{background:rgba(128,128,128,.15)}",
+ ".tbKe .tbKeX:focus-visible{outline:" + FOCUS + ";outline-offset:0}",
+ ".tbKeArgs{display:flex;flex-direction:column;gap:4px}.tbKeArgLine{display:flex;gap:6px;align-items:center;flex-wrap:wrap}",
+ // Notes: the settings dialogs' banner, and their error line for an error.
+ ".tbKeNote{margin:6px 0;padding:6px 10px;border:1px dashed #b8860b;border-radius:4px;background:#fff3cd;color:#3d2e00;font-size:95%}",
+ ".tbKeInfo{border:1px solid rgba(128,128,128,.35);background:rgba(128,128,128,.08);color:#1e1e1e}",
+ ".tbKeError{border:0;background:#c62828;color:#fff}.tbKeError code{color:#fff}",
+ ".tbKeTop>.tbKeList>.tbKeNote{margin:8px}",
+ ".tbKeEmpty{padding:16px;color:#777}",
+ // The foot: the grey of the IDE's own Edit as JSON bar.
+ ".tbKeFoot{display:flex;gap:10px;align-items:center;padding:6px 8px;background:#b5b5b5}",
+ ".tbKeStatus{color:#1e1e1e}.tbKeBad{color:#8e1c1c;font-weight:bold}",
+ ".tbKe [role=button]:focus-visible{outline:" + FOCUS + ";outline-offset:-2px}",
+ ].join("\n");
+
+ window.tbDocsKeyEditor = {
+ original: hook.original,
+ off: function () {
+ live = false;
+ unhook(TITLE);
+ mounts.forEach(function (r) {
+ if (r.node.isConnected) r.undo();
+ });
+ mounts = [];
+ var st = document.getElementById("tbDocsKeyEditorStyle");
+ if (st) st.remove();
+ },
+ };
+ })();
+}
diff --git a/add-in/Resources/SCRIPTS/layouteditor.js b/add-in/Resources/SCRIPTS/layouteditor.js
new file mode 100644
index 000000000..266ecfda5
--- /dev/null
+++ b/add-in/Resources/SCRIPTS/layouteditor.js
@@ -0,0 +1,1303 @@
+// A picture editor for Window > Panel Layouts > Manage Panel Layouts, where the
+// IDE shows each layout as JSON in a plain text area. The selected layout is
+// drawn as a small IDE window: every docked panel a tile in its groups, every
+// floating panel a window over them, at the IDE window's proportions. A tile
+// or a group is edited in a box beside the picture: its direction, its size,
+// its place among its neighbours, floating or docked, or out of the layout; a
+// panel the layout lacks, an add-in's tool window included, is docked at an
+// edge of a tile. The layout stays the IDE's: the editor reads it from the
+// IDE's own text area, which it hides, and writes every change back into it
+// with an input event, so that the IDE's own handler keeps the dialog's copy
+// and turns on Save Changes. Save, Cancel, Add New and Delete are the IDE's. A
+// JSON button at the bottom shows the text area again. The help add-in's own
+// pane has a box more, With the Help Add-In: whether the layout puts the help
+// in its pane or in its own window, and where that window is, which the add-in
+// keeps for the layout and layouts.js gives the page; that window is drawn in
+// the picture too.
+//
+// It changes only the call of showConfigEditor for this dialog, through the
+// one replacement of that function the help add-in's scripts share (see
+// hookOf), and is put in only while the dialog still edits a plain text area.
+// Running this again takes out what an earlier run put in, and an open dialog
+// gets its text area back. It puts in nothing when it is turned off.
+var on = $ON$;
+var old = window.tbDocsLayoutEditor;
+if (old) {
+ try {
+ old.off();
+ } catch (err) {
+ console.error(err);
+ }
+ window.tbDocsLayoutEditor = null;
+}
+if (
+ on &&
+ typeof showConfigEditor === "function" &&
+ typeof showManagePanelLayouts === "function" &&
+ String(showManagePanelLayouts).indexOf("genericMonospaceTextArea") >= 0 &&
+ typeof builtInPanelLayouts === "object" &&
+ typeof customPanelLayouts === "object" &&
+ typeof getPanelsConfiguration === "function"
+) {
+ (function () {
+ var TITLE = "Manage Panel Layouts";
+ // The panels restorePanelConfiguration knows, in the order the editor
+ // offers them, with the names their headers show.
+ var PANELS = [
+ ["TOOLBAR", "Toolbar"],
+ ["TOOLBOX", "Toolbox"],
+ ["EDITOR", "Editor"],
+ ["PROJECT EXPLORER", "Project Explorer"],
+ ["PROPERTIES", "Properties"],
+ ["DEBUG CONSOLE", "Debug Console"],
+ ["PROBLEMS", "Diagnostics"],
+ ["CALL STACK", "Call Stack"],
+ ["VARIABLES", "Variables"],
+ ["WATCHES", "Watches"],
+ ["OUTLINE", "Outline"],
+ ["HISTORY", "History"],
+ ["OPEN EDITORS", "Open Editors"],
+ ["FIND REPLACE", "Find and Replace"],
+ ["PACKAGE PUBLISHING", "Package Publishing"],
+ ["WEBPAGE1", "Webpage"],
+ ["MEMORY 1", "Memory"],
+ ["IDE TRACE OUTPUT", "IDE Trace Output"],
+ ];
+ var NAMES = {};
+ PANELS.forEach(function (p) {
+ NAMES[p[0]] = p[1];
+ });
+ var ADDIN = "ADDIN_";
+ // Where the IDE puts a panel shown with its show command and in no layout.
+ var FLOAT_AT = { left: 100, top: 100, width: 300, height: 500 };
+ var live = true;
+ var mounts = [];
+ var has = function (o, k) {
+ return Object.prototype.hasOwnProperty.call(o, k);
+ };
+ var esc = function (s) {
+ return String(s).replace(/[&<>"']/g, function (c) {
+ return { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[c];
+ });
+ };
+
+ // ---- the one replacement of showConfigEditor ----
+ // Each script of the add-in that changes a dialog of showConfigEditor
+ // puts its adapter here under the dialog's title, or the title, "|" and a
+ // name of its own; the replacement calls every adapter for the dialog's
+ // title, then the IDE's function. keyeditor.js and layouts.js have the
+ // same two functions.
+ var hookOf = function () {
+ var h = window.tbDocsConfigEditors;
+ if (h && window.showConfigEditor === h.dispatch) return h;
+ var current = window.showConfigEditor;
+ var nh = { original: current.tbDocsOriginal || current, adapters: (h && h.adapters) || {} };
+ nh.dispatch = function (opts) {
+ var title = opts && typeof opts.title === "string" ? opts.title : null;
+ if (title !== null)
+ Object.keys(nh.adapters).forEach(function (k) {
+ if (k !== title && k.indexOf(title + "|") !== 0) return;
+ try {
+ nh.adapters[k](opts);
+ } catch (err) {
+ console.error(err);
+ }
+ });
+ return nh.original.apply(this, arguments);
+ };
+ nh.dispatch.tbDocsOriginal = nh.original;
+ window.showConfigEditor = nh.dispatch;
+ window.tbDocsConfigEditors = nh;
+ return nh;
+ };
+ var unhook = function (title) {
+ var h = window.tbDocsConfigEditors;
+ if (!h) return;
+ delete h.adapters[title];
+ if (Object.keys(h.adapters).length) return;
+ if (window.showConfigEditor === h.dispatch) window.showConfigEditor = h.original;
+ window.tbDocsConfigEditors = null;
+ };
+
+ // ---- a layout, read as restoreDockConfig and restoreFloatingConfig read it ----
+
+ var isGroup = function (n) {
+ return !!n && (n.type === "vertical" || n.type === "horizontal") && Array.isArray(n.content);
+ };
+ var isPanel = function (n) {
+ return !!n && !isGroup(n) && typeof n.id === "string";
+ };
+ // "vertical" lays its members out side by side, "horizontal" one above another.
+ var sideBySide = function (g) {
+ return g.type === "vertical";
+ };
+ var isAddin = function (id) {
+ return String(id).indexOf(ADDIN) === 0;
+ };
+ var addinWindows = function () {
+ var out = {};
+ try {
+ if (typeof toolWindowsById === "object" && toolWindowsById)
+ Object.keys(toolWindowsById).forEach(function (k) {
+ if (k !== "") out[ADDIN + k] = toolWindowsById[k];
+ });
+ } catch (err) {
+ console.error(err);
+ }
+ return out;
+ };
+ // What an add-in's tool window shows in its header.
+ var addinTitle = function (w) {
+ try {
+ var h = w && w.sectionHeader;
+ var t = h && (h.querySelector(".sectionHeaderInner") || h);
+ var s = t && String(t.innerText || t.textContent || "").trim();
+ if (s && s !== "AddIn Panel") return s;
+ } catch (err) {
+ /* no title */
+ }
+ return "";
+ };
+ var known = function (id) {
+ return has(NAMES, id) || id === "debug-console";
+ };
+ var nameOf = function (s, id) {
+ if (has(NAMES, id)) return NAMES[id];
+ if (id === "debug-console") return NAMES["DEBUG CONSOLE"];
+ if (isAddin(id)) return (s.addins[id] && addinTitle(s.addins[id])) || id.slice(ADDIN.length) || "(no id)";
+ return String(id);
+ };
+ var sizeKind = function (n) {
+ if (n.variableSize) return "rest";
+ if (n.size === "fit-content") return "fit";
+ return "share";
+ };
+ var sizeLabel = function (n) {
+ var k = sizeKind(n);
+ if (k === "rest") return "takes the rest";
+ if (k === "fit") return "fits its contents";
+ var v = parseFloat(n.size);
+ return isNaN(v) ? String(n.size || "0%") : Math.round(v * 10) / 10 + "%";
+ };
+ var parseLayout = function (text) {
+ try {
+ var o = JSON.parse(text);
+ return o && typeof o === "object" && !Array.isArray(o) ? o : null;
+ } catch (err) {
+ return null;
+ }
+ };
+ var at = function (obj, path) {
+ var n = obj.docked;
+ for (var i = 0; i < path.length; i++) n = n.content[path[i]];
+ return n;
+ };
+ var pathKey = function (p) {
+ return p.join(",");
+ };
+ var pathOf = function (key) {
+ return key === "" ? [] : key.split(",").map(Number);
+ };
+ // Every panel of the layout, docked and floating, with where it is.
+ var panelsOf = function (obj) {
+ var out = [];
+ var walk = function (n, p) {
+ if (isGroup(n))
+ n.content.forEach(function (c, i) {
+ walk(c, p.concat(i));
+ });
+ else if (isPanel(n)) out.push({ id: n.id, path: p });
+ };
+ if (obj.docked && typeof obj.docked === "object") walk(obj.docked, []);
+ if (Array.isArray(obj.floating))
+ obj.floating.forEach(function (f, i) {
+ if (f && typeof f.id === "string") out.push({ id: f.id, floating: i });
+ });
+ return out;
+ };
+ var problemsOf = function (obj) {
+ if (!obj) return ["the text is not valid JSON"];
+ var out = [];
+ if (!obj.docked || typeof obj.docked !== "object")
+ out.push("it has no docked panels, so the IDE applies instead");
+ if (has(obj, "floating") && !Array.isArray(obj.floating))
+ out.push("its floating panels are not a list, so the IDE warns and shows none");
+ var count = {};
+ var odd = 0;
+ var walk = function (n) {
+ if (isGroup(n)) n.content.forEach(walk);
+ else if (isPanel(n)) count[n.id] = (count[n.id] || 0) + 1;
+ else odd++;
+ };
+ if (obj.docked && typeof obj.docked === "object") walk(obj.docked);
+ if (Array.isArray(obj.floating))
+ obj.floating.forEach(function (f) {
+ if (f && typeof f.id === "string") count[f.id] = (count[f.id] || 0) + 1;
+ else odd++;
+ });
+ if (out.length === 0 && !count.EDITOR) out.push("it has no Editor");
+ Object.keys(count).forEach(function (id) {
+ if (count[id] > 1) out.push((NAMES[id] || id) + " is in it " + count[id] + " times");
+ if (!known(id) && !isAddin(id)) out.push('"' + id + '" is not a panel of the IDE');
+ });
+ if (odd) out.push(odd === 1 ? "an entry is neither a panel nor a group" : odd + " entries are neither panels nor groups");
+ return out;
+ };
+
+ // ---- changes to a layout ----
+
+ var newPanel = function (id, size) {
+ return { id: id, variableSize: false, size: size };
+ };
+ // Takes the member at path out of its group. A group left with one member
+ // is replaced by it, which takes the group's size; a group with no member
+ // that takes the rest gives it to its last member.
+ var takeOut = function (obj, path) {
+ var gp = path.slice(0, -1);
+ var g = at(obj, gp);
+ var n = g.content.splice(path[path.length - 1], 1)[0];
+ if (g.content.length && !g.content.some(function (c) {
+ return c.variableSize;
+ })) {
+ var last = g.content[g.content.length - 1];
+ last.variableSize = true;
+ last.size = "0%";
+ }
+ if (g.content.length === 1 && gp.length) {
+ var only = g.content[0];
+ only.variableSize = g.variableSize;
+ only.size = g.size;
+ at(obj, gp.slice(0, -1)).content[gp[gp.length - 1]] = only;
+ } else if (g.content.length === 0 && gp.length) {
+ takeOut(obj, gp);
+ }
+ return n;
+ };
+ // Docks the panel id at a side of the member at path: into its group when
+ // the direction matches, else into a new group round the two.
+ var dockAt = function (obj, path, side, id) {
+ var row = side === "left" || side === "right";
+ var before = side === "left" || side === "top";
+ var p = newPanel(id, "25%");
+ if (!path.length && !isGroup(obj.docked)) {
+ var one = obj.docked;
+ obj.docked = { type: row ? "vertical" : "horizontal", variableSize: true, size: "0%", content: before ? [p, one] : [one, p] };
+ one.variableSize = true;
+ one.size = "0%";
+ return;
+ }
+ if (!path.length) {
+ var root = obj.docked;
+ if (sideBySide(root) === row) root.content.splice(before ? 0 : root.content.length, 0, p);
+ else {
+ var inner = { type: root.type, variableSize: true, size: "0%", content: root.content };
+ obj.docked = { type: row ? "vertical" : "horizontal", variableSize: root.variableSize, size: root.size, content: before ? [p, inner] : [inner, p] };
+ }
+ return;
+ }
+ var g = at(obj, path.slice(0, -1));
+ var i = path[path.length - 1];
+ var t = g.content[i];
+ if (sideBySide(g) === row) {
+ g.content.splice(before ? i : i + 1, 0, p);
+ } else {
+ var grp = { type: row ? "vertical" : "horizontal", variableSize: t.variableSize, size: t.size, content: before ? [p, t] : [t, p] };
+ t.variableSize = true;
+ t.size = "0%";
+ g.content[i] = grp;
+ }
+ };
+ var floatAt = function (obj, id, rect) {
+ if (!Array.isArray(obj.floating)) obj.floating = [];
+ var f = { id: id, left: rect.left, top: rect.top, width: rect.width, height: rect.height };
+ obj.floating.push(f);
+ return obj.floating.length - 1;
+ };
+
+ // ---- the help add-in's own window (layouts.js) ----
+ // The help add-in keeps, for each layout, whether its help is in its pane or in a window of
+ // its own, and where that window is; layouts.js gives the page what it keeps. Without it
+ // (the add-in's scripts put in by hand) the editor shows no box for it.
+ var helpApi = function () {
+ var h = window.tbDocsHelpLayouts;
+ return h && typeof h.record === "function" && typeof h.edit === "function" && h.pane ? h : null;
+ };
+ var isHelp = function (id) {
+ var h = helpApi();
+ return !!h && id === h.pane;
+ };
+ // Whether the help is in its own window for the layout the dialog shows.
+ var helpOwn = function (s) {
+ var h = helpApi();
+ var r = h && s.m ? h.record(s.m.id) : null;
+ return !!(r && r.detached);
+ };
+ // A window's place as the add-in keeps it, on the screen in its pixels, as a place in the
+ // page in CSS pixels, and back. The add-in's pixels are at api.dpi dots per inch (the
+ // display's: the compiler's process is aware of its scaling), the page's CSS pixels at 96;
+ // the page's top left corner is at screenX, screenY in CSS pixels.
+ var toPage = function (api, r) {
+ var f = 96 / (api.dpi || 96);
+ return { left: r.left * f - (window.screenX || 0), top: r.top * f - (window.screenY || 0), width: r.width * f, height: r.height * f };
+ };
+ var fromPage = function (api, r) {
+ var f = (api.dpi || 96) / 96;
+ return {
+ left: Math.round((r.left + (window.screenX || 0)) * f),
+ top: Math.round((r.top + (window.screenY || 0)) * f),
+ width: Math.round(r.width * f),
+ height: Math.round(r.height * f),
+ };
+ };
+ var clamp = function (v, lo, hi) {
+ return Math.max(lo, Math.min(Math.max(lo, hi), v));
+ };
+ var enableSave = function (s) {
+ try {
+ s.m.ctl.setSaveChangesEnabled(true);
+ } catch (err) {
+ console.error(err);
+ }
+ };
+ // What selecting the help selects: its tile or its floating panel, else its own window.
+ var helpSel = function (s, obj) {
+ var h = helpApi();
+ var p = h
+ ? panelsOf(obj).filter(function (x) {
+ return x.id === h.pane;
+ })[0]
+ : null;
+ if (p && p.floating !== undefined) return { kind: "float", i: p.floating };
+ if (p) return { kind: "node", key: pathKey(p.path) };
+ return { kind: "own" };
+ };
+
+ // ---- the editor ----
+
+ var newSession = function (opts) {
+ return { opts: opts, view: "picture", texts: {}, sel: null, placing: null, m: null };
+ };
+ var ideSize = function () {
+ var b = document.body;
+ return { w: Math.max(1, b.clientWidth), h: Math.max(1, b.clientHeight) };
+ };
+ var dockRect = function () {
+ var r = document.getElementById("rootTop");
+ var b = document.body.getBoundingClientRect();
+ if (!r) return null;
+ var q = r.getBoundingClientRect();
+ if (!q.width || !q.height) return null;
+ return { left: q.left - b.left, top: q.top - b.top, width: q.width, height: q.height };
+ };
+
+ var write = function (s, obj) {
+ var m = s.m;
+ var text = JSON.stringify(obj, null, "\t");
+ m.area.value = text;
+ s.texts[m.id] = text;
+ m.area.dispatchEvent(new Event("input", { bubbles: true }));
+ render(s);
+ };
+ var textOf = function (s, id) {
+ if (s.m && s.m.id === id) return s.m.area.value;
+ if (has(s.texts, id)) return s.texts[id];
+ var e = has(builtInPanelLayouts, id) ? builtInPanelLayouts[id] : has(customPanelLayouts, id) ? customPanelLayouts[id] : null;
+ if (!e) return null;
+ try {
+ return JSON.stringify({ docked: JSON.parse(e.layoutData), floating: e.floatingData ? JSON.parse(e.floatingData) : [] });
+ } catch (err) {
+ return "";
+ }
+ };
+
+ var tileHtml = function (s, n, path) {
+ var key = pathKey(path);
+ var sel = s.sel && s.sel.kind === "node" && s.sel.key === key;
+ var id = n.id;
+ var cls = "tbLeTile";
+ if (id === "EDITOR") cls += " tbLeEd";
+ if (isAddin(id)) cls += " tbLeAddin";
+ var gone = isAddin(id) ? !s.addins[id] : !known(id);
+ if (gone) cls += " tbLeGone";
+ if (sel) cls += " tbLeSel";
+ var notes = [];
+ if (gone) notes.push(isAddin(id) ? "not loaded" : "not a panel");
+ if (isHelp(id) && helpOwn(s)) notes.push("in its own window");
+ return (
+ '
"
+ );
+ };
+ var flexOf = function (n) {
+ if (n.size === "fit-content" && !n.variableSize) return "0 0 auto";
+ return (n.variableSize ? "1 1 " : "0 0 ") + esc(n.size || "0%");
+ };
+ var treeHtml = function (s, n, path) {
+ if (!isGroup(n)) return isPanel(n) ? tileHtml(s, n, path) : '
not a panel
';
+ var key = pathKey(path);
+ var sel = s.sel && s.sel.kind === "node" && s.sel.key === key;
+ var h = '
';
+ n.content.forEach(function (c, i) {
+ if (i) {
+ var fixed = s.ro || (c && c.size === "fit-content") || (n.content[i - 1] && n.content[i - 1].size === "fit-content");
+ h += '';
+ }
+ h += treeHtml(s, c, path.concat(i));
+ });
+ return h + "
";
+ };
+ var floatsHtml = function (s, obj, k) {
+ if (!Array.isArray(obj.floating)) return "";
+ var h = "";
+ obj.floating.forEach(function (f, i) {
+ if (!f || typeof f.id !== "string") return;
+ var sel = s.sel && s.sel.kind === "float" && s.sel.i === i;
+ var gone = isAddin(f.id) ? !s.addins[f.id] : !known(f.id);
+ h +=
+ '
' + esc(nameOf(s, f.id)) + '
' + (gone ? (isAddin(f.id) ? "not loaded " : "not a panel ") : "") +
+ (isHelp(f.id) && helpOwn(s) ? "in its own window " : "") + esc(f.width) + " × " + esc(f.height) + "
";
+ });
+ return h;
+ };
+ // The help's own window, where the add-in's record for the layout puts it on the screen,
+ // drawn over the picture on its scale and kept inside it, so that it can be clicked.
+ var ownHtml = function (s, obj, k) {
+ var api = helpApi();
+ var r = api && api.record(s.m.id);
+ if (!r || !r.detached) return "";
+ var pw = s.m.pic.clientWidth;
+ var ph = s.m.pic.clientHeight;
+ var placed = r.width > 0 && r.height > 0;
+ var at = placed ? toPage(api, r) : FLOAT_AT;
+ var w = clamp(at.width * k, 40, pw);
+ var hh = clamp(at.height * k, 24, ph);
+ var x = clamp((at.left || 0) * k, 0, pw - w);
+ var y = clamp((at.top || 0) * k, 0, ph - hh);
+ // Selected with the help's tile or floating panel, which a click on it selects.
+ var p = helpSel(s, obj);
+ var sel = !!s.sel && p.kind === s.sel.kind && (p.kind === "own" || (p.kind === "float" ? p.i === s.sel.i : p.key === s.sel.key));
+ return (
+ '
Help: its own window
' +
+ (placed ? esc(r.width) + " × " + esc(r.height) + " at " + esc(r.left) + ", " + esc(r.top) + " on the screen" : "where it is not known") + "
"
+ );
+ };
+
+ var segHtml = function (act, value, choices, ro) {
+ return (
+ '' +
+ choices
+ .map(function (c) {
+ return '";
+ })
+ .join("") +
+ ""
+ );
+ };
+ var crumbsHtml = function (s, obj, path) {
+ var out = [];
+ for (var j = 0; j < path.length; j++) {
+ var g = at(obj, path.slice(0, j));
+ out.push('' + (j ? "" : "Window: ") + (sideBySide(g) ? "side by side" : "one above another") + "");
+ }
+ return out.join(" › ");
+ };
+ var inspHtml = function (s, obj) {
+ var ro = s.ro;
+ if (!s.sel) return '
Nothing selected
Click a panel or a group in the picture to change it' + (ro ? "." : ", or a panel above to add it.") + "
";
+ var h;
+ var note = function (id) {
+ if (isAddin(id))
+ return s.addins[id] ? "" : '
No loaded add-in has this window. The IDE keeps its place, empty and marked (currently unavailable), until the add-in opens it.
';
+ return known(id) ? "" : '
This is not a panel of the IDE: applying the layout shows an error.
';
+ };
+ if (s.sel.kind === "own") {
+ var api = helpApi();
+ return (
+ '
' + esc(nameOf(s, api.pane)) + ' in its own window
' +
+ '
Not among this layout\'s panels.
' + helpBoxHtml(s)
+ );
+ }
+ if (s.sel.kind === "float") {
+ var f = obj.floating[s.sel.i];
+ h = '
';
+ ["left", "top", "width", "height"].forEach(function (k) {
+ h += '";
+ });
+ h += "
";
+ if (!ro) h += '';
+ return h;
+ }
+ var path = pathOf(s.sel.key);
+ var n = at(obj, path);
+ var grp = isGroup(n);
+ var root = !path.length;
+ var par = root ? null : at(obj, path.slice(0, -1));
+ if (grp) h = '
' + (root ? "The whole window" : "A group of " + n.content.length) + " " + esc(n.type) + "
";
+ else h = '
' + esc(nameOf(s, n.id)) + " " + esc(n.id) + "
" + note(n.id) + (isHelp(n.id) ? helpBoxHtml(s) : "");
+ if (!root) h += '
";
+ if (!root) {
+ var dim = sideBySide(par) ? "width" : "height";
+ var k = sizeKind(n);
+ h += '
Its ' + dim + '
' + segHtml("size", k, [["rest", "The rest"], ["share", "A share"], ["fit", "To fit"]], ro) + "
";
+ if (k === "share")
+ h += '
% of the group's " + dim + "
";
+ if (!ro) {
+ var i = path[path.length - 1];
+ h += '
";
+ h += '
";
+ if (!grp) h += '';
+ }
+ }
+ return h;
+ };
+ // The grey box under the help's panel: in this panel or in its own window, and where that
+ // window is, which the help add-in keeps for the layout (layouts.js). Applying a layout the
+ // add-in has no record for leaves the help where it is, until one is chosen here or the
+ // layout is saved again; no built-in layout has the help's panel.
+ var helpBoxHtml = function (s) {
+ var api = helpApi();
+ if (!api) return "";
+ var r = api.record(s.m.id);
+ var own = !!(r && r.detached);
+ var out = '
With the Help Add-In
';
+ out +=
+ '
' +
+ segHtml(
+ "helpwhere",
+ r ? (own ? "own" : "panel") : "",
+ [
+ ["panel", "In this panel"],
+ ["own", "In its own window"],
+ ],
+ s.ro,
+ ) +
+ "
";
+ if (!r) out += '
Not chosen for this layout: applying it leaves the help where it is.
';
+ if (own) {
+ out += '
';
+ ["left", "top", "width", "height"].forEach(function (k) {
+ out +=
+ "";
+ });
+ out +=
+ '
Pixels on the screen. Back in this panel, the pane floats where the window was, inside the IDE window; dock it again if you wish.
';
+ }
+ return out + '
Kept by the add-in for this layout, not in its JSON.
';
+ };
+ // In this panel or in its own window, chosen in the box. Back in this panel from its own
+ // window, the pane floats where the window was, at its size, kept inside the IDE window:
+ // taken out of the dock, or added when the layout lacks it.
+ var helpWhere = function (s, obj, where) {
+ var api = helpApi();
+ if (!api) return;
+ var id = s.m.id;
+ var r = api.record(id);
+ var was = !!(r && r.detached);
+ var place = r && r.width > 0 ? r : api.now && api.now.width > 0 ? api.now : fromPage(api, FLOAT_AT);
+ var rec = { detached: where === "own", left: place.left | 0, top: place.top | 0, width: place.width | 0, height: place.height | 0 };
+ api.edit(id, rec);
+ var at = panelsOf(obj).filter(function (p) {
+ return p.id === api.pane;
+ })[0];
+ if (where === "panel" && was && !(at && at.floating === undefined && !at.path.length)) {
+ var size = ideSize();
+ var p = rec.width > 0 && rec.height > 0 ? toPage(api, rec) : FLOAT_AT;
+ var w = Math.round(Math.min(p.width, size.w));
+ var hh = Math.round(Math.min(p.height, size.h));
+ var rect = { left: Math.round(clamp(p.left, 0, size.w - w)), top: Math.round(clamp(p.top, 0, size.h - hh)), width: w, height: hh };
+ if (at && at.floating !== undefined) {
+ var f = obj.floating[at.floating];
+ f.left = rect.left;
+ f.top = rect.top;
+ f.width = rect.width;
+ f.height = rect.height;
+ s.sel = { kind: "float", i: at.floating };
+ } else {
+ if (at) takeOut(obj, at.path);
+ s.sel = { kind: "float", i: floatAt(obj, api.pane, rect) };
+ }
+ return write(s, obj);
+ }
+ if (where === "panel" && s.sel && s.sel.kind === "own") s.sel = null;
+ enableSave(s);
+ render(s);
+ };
+
+ var barHtml = function (s, obj, free) {
+ if (s.placing)
+ return (
+ 'Click near an edge of a panel to dock ' + esc(nameOf(s, s.placing.id)) + " on that side." +
+ (s.placing.from === undefined ? '' : "") +
+ ''
+ );
+ var h = '' + (free.length ? "Not in this layout:" : "Every panel is in this layout.") + "";
+ free.forEach(function (id) {
+ h +=
+ '";
+ });
+ if (!s.ro) h += '';
+ return h;
+ };
+
+ var markEntries = function (s) {
+ var m = s.m;
+ if (!m || !m.node.isConnected) return;
+ var outer = m.node.closest(".configEditorRoot");
+ if (!outer) return;
+ var entries = [];
+ try {
+ entries = s.opts.getEntries(m.ctl);
+ } catch (err) {
+ return;
+ }
+ var els = outer.querySelectorAll(".configEditorLHS .configEditorEntry");
+ entries.forEach(function (en, i) {
+ var el = els[i];
+ if (!el) return;
+ var mark = el.querySelector(".tbLeMark");
+ var t = textOf(s, en.id);
+ var p = t === null ? [] : problemsOf(parseLayout(t));
+ if (!p.length) {
+ if (mark) mark.remove();
+ return;
+ }
+ if (!mark) {
+ mark = document.createElement("span");
+ mark.className = "tbLeMark";
+ var txt = el.querySelector(".configEditorEntryText");
+ if (txt) txt.appendChild(mark);
+ else el.appendChild(mark);
+ }
+ mark.textContent = " !";
+ mark.title = p.join("; ");
+ });
+ };
+
+ var render = function (s) {
+ var m = s.m;
+ if (!m) return;
+ s.addins = addinWindows();
+ var obj = parseLayout(m.area.value);
+ var picture = s.view === "picture" && !!obj && !!obj.docked && typeof obj.docked === "object";
+ m.top.style.display = picture ? "" : "none";
+ m.area.style.display = picture ? "none" : "";
+ m.viewPic.setAttribute("aria-pressed", String(s.view === "picture"));
+ m.viewJson.setAttribute("aria-pressed", String(s.view !== "picture"));
+ if (picture && window.tbDocsTextFind && window.tbDocsTextFind.bar && m.node.contains(window.tbDocsTextFind.bar)) window.tbDocsTextFind.bar.remove();
+ setTimeout(function () {
+ markEntries(s);
+ }, 0);
+ var problems = problemsOf(obj);
+ var state = m.readonly ? "A built-in layout: read-only. " : "";
+ if (!picture) {
+ var why = !obj ? "The text is not valid JSON, so the picture cannot show it. " : s.view === "picture" ? "The layout has no docked panels, so the picture cannot show it. " : "";
+ m.status.innerHTML = esc(why + state) + (obj && problems.length ? '' + esc(problemLine(problems)) + "" : "");
+ m.status.className = "tbLeStatus" + (why ? " tbLeBad" : "");
+ s.obj = obj;
+ return;
+ }
+ s.obj = obj;
+ if (s.sel && s.sel.kind === "float" && !(Array.isArray(obj.floating) && obj.floating[s.sel.i])) s.sel = null;
+ if (s.sel && s.sel.kind === "own" && !helpOwn(s)) s.sel = null;
+ if (s.sel && s.sel.kind === "node") {
+ try {
+ if (!at(obj, pathOf(s.sel.key))) s.sel = null;
+ } catch (err) {
+ s.sel = null;
+ }
+ }
+ var listed = {};
+ panelsOf(obj).forEach(function (p) {
+ listed[p.id] = true;
+ if (p.id === "debug-console") listed["DEBUG CONSOLE"] = true;
+ });
+ var free = PANELS.map(function (p) {
+ return p[0];
+ })
+ .concat(Object.keys(s.addins))
+ .filter(function (id) {
+ return !listed[id];
+ });
+ m.banner.style.display = m.readonly ? "" : "none";
+ m.bar.innerHTML = barHtml(s, obj, free);
+ // The IDE window: its size, the dock where rootTop is, and the floating
+ // panels in its pixels.
+ var size = ideSize();
+ var dr = dockRect() || { left: 0, top: 0, width: size.w, height: size.h };
+ m.pic.style.aspectRatio = size.w + " / " + size.h;
+ var k = m.pic.clientWidth / size.w || 0;
+ var dock = '
' + treeHtml(s, obj.docked, []) + "
";
+ m.pic.className = "tbLePic" + (s.placing ? " tbLePlacing" : "");
+ m.pic.innerHTML = '' + dock + floatsHtml(s, obj, k) + ownHtml(s, obj, k);
+ m.insp.innerHTML = inspHtml(s, obj);
+ var docked = 0;
+ var floating = 0;
+ panelsOf(obj).forEach(function (p) {
+ if (p.floating === undefined) docked++;
+ else floating++;
+ });
+ m.status.className = "tbLeStatus";
+ m.status.innerHTML =
+ esc(state + docked + (docked === 1 ? " panel" : " panels") + " docked, " + floating + " floating, " + free.length + " not in this layout. ") +
+ (problems.length ? '' + esc(problemLine(problems)) + "" : "");
+ };
+ var problemLine = function (p) {
+ var s = p.join("; ");
+ return (p.length === 1 ? "1 problem: " : p.length + " problems: ") + s.charAt(0).toUpperCase() + s.slice(1) + ".";
+ };
+
+ // What a click on an element with data-act does.
+ var act = function (s, el, e) {
+ var a = el.getAttribute("data-act");
+ var obj = s.obj;
+ if (!obj) return;
+ if (e) e.preventDefault();
+ if (a === "select") {
+ if (s.placing) return;
+ s.sel = { kind: "node", key: el.getAttribute("data-key") };
+ return render(s);
+ }
+ if (a === "selectfloat") {
+ if (s.placing) return;
+ s.sel = { kind: "float", i: Number(el.getAttribute("data-i")) };
+ return render(s);
+ }
+ if (a === "selectown") {
+ if (s.placing) return;
+ s.sel = helpSel(s, obj);
+ return render(s);
+ }
+ if (a === "placecancel") {
+ s.placing = null;
+ return render(s);
+ }
+ if (s.ro) return;
+ var n = s.sel && s.sel.kind === "node" ? at(obj, pathOf(s.sel.key)) : null;
+ var path = s.sel && s.sel.kind === "node" ? pathOf(s.sel.key) : null;
+ switch (a) {
+ case "place":
+ s.placing = { id: el.getAttribute("data-id") };
+ return render(s);
+ case "placefloat":
+ s.sel = { kind: "float", i: floatAt(obj, s.placing.id, FLOAT_AT) };
+ s.placing = null;
+ return write(s, obj);
+ case "current": {
+ // As Save Current Layout As stores it, where the help is now included.
+ var cfg = getPanelsConfiguration();
+ var api = helpApi();
+ if (api && api.now)
+ api.edit(s.m.id, {
+ detached: !!api.now.detached,
+ left: api.now.left | 0,
+ top: api.now.top | 0,
+ width: api.now.width | 0,
+ height: api.now.height | 0,
+ });
+ s.sel = null;
+ return write(s, { docked: cfg.docked[0], floating: cfg.floating });
+ }
+ case "helpwhere":
+ return helpWhere(s, obj, el.getAttribute("data-v"));
+ case "dir":
+ n.type = el.getAttribute("data-v");
+ return write(s, obj);
+ case "size": {
+ var v = el.getAttribute("data-v");
+ if (v === "rest") {
+ n.variableSize = true;
+ n.size = "0%";
+ } else if (v === "fit") {
+ n.variableSize = false;
+ n.size = "fit-content";
+ } else if (sizeKind(n) !== "share") {
+ n.variableSize = false;
+ n.size = shareOf(s, path) + "%";
+ }
+ return write(s, obj);
+ }
+ case "move": {
+ var g = at(obj, path.slice(0, -1));
+ var i = path[path.length - 1];
+ var j = i + Number(el.getAttribute("data-d"));
+ if (j < 0 || j >= g.content.length) return;
+ var t = g.content[i];
+ g.content[i] = g.content[j];
+ g.content[j] = t;
+ path[path.length - 1] = j;
+ s.sel = { kind: "node", key: pathKey(path) };
+ return write(s, obj);
+ }
+ case "float": {
+ var id = n.id;
+ takeOut(obj, path);
+ s.sel = { kind: "float", i: floatAt(obj, id, FLOAT_AT) };
+ return write(s, obj);
+ }
+ case "remove":
+ takeOut(obj, path);
+ s.sel = null;
+ return write(s, obj);
+ case "dockfloat":
+ s.placing = { id: obj.floating[s.sel.i].id, from: s.sel.i };
+ return render(s);
+ case "removefloat":
+ obj.floating.splice(s.sel.i, 1);
+ s.sel = null;
+ return write(s, obj);
+ }
+ };
+ // The share a member has now, in per cent of its group, for A share.
+ var shareOf = function (s, path) {
+ var m = s.m;
+ var el = m.pic.querySelector('[data-key="' + pathKey(path) + '"]');
+ var g = el && el.parentElement;
+ if (!el || !g) return 25;
+ var row = g.classList.contains("tbLeRow");
+ var a = el.getBoundingClientRect();
+ var b = g.getBoundingClientRect();
+ var v = row ? a.width / b.width : a.height / b.height;
+ return v > 0 && v < 1 ? Number((v * 100).toFixed(4)) : 25;
+ };
+ var change = function (s, el) {
+ var a = el.getAttribute("data-act");
+ var obj = s.obj;
+ if (!obj || s.ro) return;
+ if (a === "pct") {
+ var v = parseFloat(el.value);
+ if (isNaN(v)) return render(s);
+ var n = at(obj, pathOf(s.sel.key));
+ n.variableSize = false;
+ n.size = Math.max(0, Math.min(100, v)).toFixed(4) + "%";
+ return write(s, obj);
+ }
+ if (a === "floatnum") {
+ var f = obj.floating[s.sel.i];
+ var w = parseInt(el.value, 10);
+ if (isNaN(w)) return render(s);
+ f[el.getAttribute("data-k")] = w;
+ return write(s, obj);
+ }
+ if (a === "helpnum") {
+ var api = helpApi();
+ var r = api && api.record(s.m.id);
+ var x = parseInt(el.value, 10);
+ if (!r || isNaN(x)) return render(s);
+ var k = el.getAttribute("data-k");
+ var rec = { detached: !!r.detached, left: r.left | 0, top: r.top | 0, width: r.width | 0, height: r.height | 0 };
+ rec[k] = k === "width" || k === "height" ? Math.max(1, x) : x;
+ api.edit(s.m.id, rec);
+ enableSave(s);
+ return render(s);
+ }
+ };
+
+ // The side of a tile nearest the pointer, and its half shown.
+ var sideAt = function (tile, e) {
+ var r = tile.getBoundingClientRect();
+ var x = (e.clientX - r.left) / r.width;
+ var y = (e.clientY - r.top) / r.height;
+ var d = { left: x, right: 1 - x, top: y, bottom: 1 - y };
+ return Object.keys(d).sort(function (a, b) {
+ return d[a] - d[b];
+ })[0];
+ };
+ var showZone = function (s, tile, side) {
+ var z = s.m.pic.querySelector(".tbLeZone");
+ if (!tile) {
+ if (z) z.remove();
+ return;
+ }
+ if (!z || z.parentElement !== tile) {
+ if (z) z.remove();
+ z = document.createElement("div");
+ z.className = "tbLeZone";
+ tile.appendChild(z);
+ }
+ z.style.left = side === "right" ? "50%" : "0";
+ z.style.top = side === "bottom" ? "50%" : "0";
+ z.style.width = side === "left" || side === "right" ? "50%" : "100%";
+ z.style.height = side === "top" || side === "bottom" ? "50%" : "100%";
+ };
+ var dropAt = function (s, tile, side) {
+ var obj = s.obj;
+ var p = s.placing;
+ s.placing = null;
+ var path = pathOf(tile.getAttribute("data-key"));
+ if (p.from !== undefined) obj.floating.splice(p.from, 1);
+ dockAt(obj, path, side, p.id);
+ s.sel = null;
+ write(s, obj);
+ };
+
+ // A splitter, dragged: the member before it takes the pointer's place, or
+ // the one after it when the one before takes the rest.
+ var dragSplit = function (s, sp, e) {
+ var obj = s.obj;
+ var g = at(obj, pathOf(sp.getAttribute("data-split")));
+ var i = Number(sp.getAttribute("data-i"));
+ var ge = sp.parentElement;
+ var kids = Array.prototype.filter.call(ge.children, function (c) {
+ return !c.classList.contains("tbLeSplit");
+ });
+ var row = ge.classList.contains("tbLeRow");
+ var gr = ge.getBoundingClientRect();
+ var total = row ? gr.width : gr.height;
+ var ra = kids[i].getBoundingClientRect();
+ var rb = kids[i + 1].getBoundingClientRect();
+ var a = g.content[i];
+ var b = g.content[i + 1];
+ var moved = false;
+ sp.setPointerCapture(e.pointerId);
+ sp.classList.add("tbLeDrag");
+ var pc = function (v) {
+ return Math.max(2, Math.min(96, (v / total) * 100)).toFixed(4) + "%";
+ };
+ sp.onpointermove = function (ev) {
+ var pos = row ? ev.clientX : ev.clientY;
+ moved = true;
+ if (!a.variableSize || b.variableSize) {
+ a.size = pc(pos - (row ? ra.left : ra.top));
+ a.variableSize = false;
+ } else {
+ b.size = pc((row ? rb.right : rb.bottom) - pos);
+ }
+ kids[i].style.flex = flexOf(a);
+ kids[i + 1].style.flex = flexOf(b);
+ };
+ sp.onpointerup = sp.onpointercancel = function () {
+ sp.onpointermove = sp.onpointerup = sp.onpointercancel = null;
+ sp.classList.remove("tbLeDrag");
+ if (moved) write(s, obj);
+ };
+ };
+ var dragFloat = function (s, ft, e) {
+ var obj = s.obj;
+ var i = Number(ft.getAttribute("data-drag"));
+ var f = obj.floating[i];
+ var win = ft.parentElement;
+ var k = s.m.pic.clientWidth / ideSize().w;
+ var x0 = e.clientX;
+ var y0 = e.clientY;
+ var l0 = f.left || 0;
+ var t0 = f.top || 0;
+ var moved = false;
+ ft.setPointerCapture(e.pointerId);
+ ft.onpointermove = function (ev) {
+ moved = true;
+ f.left = Math.round(l0 + (ev.clientX - x0) / k);
+ f.top = Math.round(t0 + (ev.clientY - y0) / k);
+ win.style.left = Math.round(f.left * k) + "px";
+ win.style.top = Math.round(f.top * k) + "px";
+ };
+ ft.onpointerup = ft.onpointercancel = function () {
+ ft.onpointermove = ft.onpointerup = ft.onpointercancel = null;
+ s.sel = { kind: "float", i: i };
+ if (moved) write(s, obj);
+ else render(s);
+ };
+ };
+
+ // Puts the editor round the IDE's text area: the node returned in its
+ // place holds the picture, the text area and the foot.
+ var mount = function (s, ctl, area) {
+ if (!area || area.tagName !== "TEXTAREA") return area;
+ var node = document.createElement("div");
+ node.className = "tbLe tbLeRoot";
+ var top = document.createElement("div");
+ top.className = "tbLeTop";
+ top.innerHTML =
+ '
A built-in layout cannot be changed. Add New... makes a copy of <DEFAULT> that you can change.
' +
+ '
' +
+ '
Drawn at the IDE window\'s proportions. Drag a splitter to resize, or a floating panel by its title. Click a panel to change it, or the gap round a group to change the group.
' +
+ '
';
+ var foot = document.createElement("div");
+ foot.className = "tbLe tbLeFoot";
+ foot.innerHTML =
+ '' +
+ '';
+ node.appendChild(top);
+ node.appendChild(area);
+ node.appendChild(foot);
+ var m = {
+ node: node,
+ ctl: ctl,
+ id: ctl.selectedEntryId,
+ area: area,
+ readonly: area.hasAttribute("readonly"),
+ top: top,
+ banner: top.querySelector(".tbLeBanner"),
+ bar: top.querySelector(".tbLeBar"),
+ pic: top.querySelector(".tbLePic"),
+ insp: top.querySelector(".tbLeInsp"),
+ foot: foot,
+ viewPic: foot.querySelector('[data-view="picture"]'),
+ viewJson: foot.querySelector('[data-view="json"]'),
+ status: foot.querySelector(".tbLeStatus"),
+ };
+ if (s.m && s.m.id !== m.id) s.sel = null;
+ s.m = m;
+ s.ro = m.readonly;
+ s.placing = null;
+ area.addEventListener("input", function (e) {
+ if (!e.isTrusted) return;
+ s.texts[m.id] = area.value;
+ setTimeout(function () {
+ markEntries(s);
+ }, 0);
+ });
+ m.viewPic.addEventListener("click", function () {
+ s.view = "picture";
+ render(s);
+ });
+ m.viewJson.addEventListener("click", function () {
+ s.view = "json";
+ render(s);
+ });
+ top.addEventListener("click", function (e) {
+ if (s.placing) {
+ var tile = e.target.closest(".tbLeTile[data-key]");
+ if (tile && m.pic.contains(tile)) return dropAt(s, tile, sideAt(tile, e));
+ }
+ var el = e.target.closest("[data-act]");
+ if (!el || el.tagName === "INPUT") return;
+ if (el.classList.contains("tbLeG") && e.target !== el) return;
+ act(s, el, e);
+ });
+ top.addEventListener("change", function (e) {
+ var el = e.target.closest("[data-act]");
+ if (el) change(s, el);
+ });
+ m.pic.addEventListener("pointermove", function (e) {
+ if (!s.placing) return;
+ var tile = e.target.closest(".tbLeTile[data-key]");
+ showZone(s, tile, tile ? sideAt(tile, e) : null);
+ });
+ m.pic.addEventListener("pointerleave", function () {
+ showZone(s, null);
+ });
+ m.pic.addEventListener("pointerdown", function (e) {
+ if (s.ro || s.placing || e.button !== 0) return;
+ var sp = e.target.closest(".tbLeSplit:not(.tbLeFixed)");
+ if (sp) {
+ e.preventDefault();
+ return dragSplit(s, sp, e);
+ }
+ var ft = e.target.closest("[data-drag]");
+ if (ft) {
+ e.preventDefault();
+ return dragFloat(s, ft, e);
+ }
+ });
+ // The dialog's own key handler (on its container) presses its focused
+ // button on Enter, cancels the dialog on Esc outside a text box, and
+ // keeps Tab and the arrow keys from moving the focus: none of it reaches
+ // past the editor.
+ var keys = function (e) {
+ e.stopPropagation();
+ if (e.key === "Escape") {
+ e.preventDefault();
+ if (s.placing) s.placing = null;
+ else if (s.sel) s.sel = null;
+ else return;
+ render(s);
+ return;
+ }
+ var t = e.target;
+ if ((e.key === "Enter" || e.key === " ") && t.getAttribute && t.getAttribute("role") === "button") {
+ e.preventDefault();
+ t.click();
+ }
+ };
+ top.addEventListener("keydown", keys);
+ foot.addEventListener("keydown", keys);
+ mounts = mounts.filter(function (r) {
+ return r.node.isConnected;
+ });
+ mounts.push({
+ node: node,
+ undo: function () {
+ area.style.display = "";
+ if (node.parentNode) node.parentNode.replaceChild(area, node);
+ s.m = null;
+ },
+ });
+ // The IDE puts the node into the dialog after this returns; the picture
+ // has a width only then.
+ render(s);
+ setTimeout(function () {
+ if (s.m === m) render(s);
+ }, 0);
+ return node;
+ };
+
+ // Changes the options of the one dialog.
+ var adapt = function (opts) {
+ var s = newSession(opts);
+ // The help add-in answers the dialog's question where its help is now after the
+ // dialog shows; the picture is drawn again with the answer.
+ var api = helpApi();
+ if (api)
+ api.onUpdate = function () {
+ if (live && s.m && s.m.node.isConnected) render(s);
+ };
+ var getNode = opts.getEntryEditorDomNode;
+ var addNew = opts.addNewEntry;
+ var del = opts.deleteEntry;
+ opts.getEntryEditorDomNode = function (ctl) {
+ var area = getNode.apply(this, arguments);
+ if (!live) return area;
+ try {
+ return mount(s, ctl, area);
+ } catch (err) {
+ console.error(err);
+ return area;
+ }
+ };
+ opts.addNewEntry = function () {
+ var r = addNew.apply(this, arguments);
+ if (live)
+ setTimeout(function () {
+ markEntries(s);
+ }, 0);
+ return r;
+ };
+ opts.deleteEntry = function (ctl, id) {
+ var r = del.apply(this, arguments);
+ if (live) {
+ delete s.texts[id];
+ setTimeout(function () {
+ markEntries(s);
+ }, 0);
+ }
+ return r;
+ };
+ };
+ hookOf().adapters[TITLE] = function (opts) {
+ if (live) adapt(opts);
+ };
+
+ var style = document.getElementById("tbDocsLayoutEditorStyle");
+ if (!style) {
+ style = document.createElement("style");
+ style.id = "tbDocsLayoutEditorStyle";
+ document.head.appendChild(style);
+ }
+ // The look is the keyboard shortcut editor's (keyeditor.js), which is the
+ // IDE's own: the dialog's buttons from the theme's variables, the rest
+ // from the IDE Options and Project Settings dialogs. The pane is white in
+ // every theme (styles.css, .configEditorRHS).
+ var ACCENT = "#4271ae";
+ var BTN =
+ "background:var(--themeDialogButtonsBackColor,#fbfdff);color:var(--themeDialogButtonForeColor,#000);" +
+ "border-top:var(--themeDialogButtonBorderTop,1px solid #9b9b9b);border-left:var(--themeDialogButtonBorderLeft,1px solid #9b9b9b);" +
+ "border-right:var(--themeDialogButtonBorderRight,1px solid #5e5e5e);border-bottom:var(--themeDialogButtonBorderBottom,1px solid #5e5e5e);" +
+ "border-radius:var(--themeDialogButtonBorderRadius,0);box-shadow:var(--themeDialogButtonBoxShadow,2px 2px 3px #7c7c7c78)";
+ var FOCUS = "var(--themeDialogButtonFocusWidth,2px) solid var(--themeDialogButtonFocusRectColor,#6d6dc3)";
+ var MONO = "font-family:Consolas,Menlo,monospace";
+ style.textContent = [
+ ".tbLe{color:#1e1e1e;font-size:inherit}",
+ ".tbLeRoot{display:flex;flex-direction:column;width:100%;height:100%;min-height:0}",
+ ".tbLeRoot>textarea{flex:1 1 auto;min-height:0}",
+ ".tbLeTop{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;overflow:auto;background:#fff}",
+ ".tbLeBar{display:flex;gap:6px;align-items:center;flex-wrap:wrap;padding:8px;border-bottom:1px solid rgba(128,128,128,.35)}",
+ ".tbLeGrow{flex:1}",
+ ".tbLeMuted{color:#5a5a5a}",
+ ".tbLeBtn{box-sizing:border-box;height:26px;padding:0 10px;margin:0 2px 2px 0;font:inherit;cursor:pointer;white-space:nowrap;" + BTN + "}",
+ ".tbLeBtn:hover:not(:disabled){background-color:#ebeff5;filter:brightness(1.3)}",
+ ".tbLeBtn:disabled{opacity:.5;cursor:default;box-shadow:none}",
+ ".tbLe .tbLeBtn:focus-visible{outline:" + FOCUS + ";outline-offset:2px}",
+ ".tbLeChip{box-sizing:border-box;height:22px;padding:0 6px;border:1px solid #999;border-radius:3px;background:#f3f3f3;color:#1e1e1e;font-size:90%;" + MONO + ";cursor:pointer;white-space:nowrap}",
+ ".tbLeChip:hover:not(:disabled){border-color:" + ACCENT + "}.tbLeChip:disabled{cursor:default}",
+ ".tbLeChipAddin{background:rgba(66,113,174,.1)}",
+ ".tbLe .tbLeChip:focus-visible{outline:" + FOCUS + ";outline-offset:1px}",
+ ".tbLeSeg{display:inline-flex;flex-wrap:wrap;border:1px solid #999;border-radius:4px;overflow:hidden;background:#fff}",
+ ".tbLeSegBtn{box-sizing:border-box;height:24px;padding:0 10px;margin:0;border:0;border-right:1px solid #999;border-radius:0;background:#fff;color:#1e1e1e;font:inherit;cursor:pointer;white-space:nowrap;user-select:none}",
+ ".tbLeSegBtn:last-child{border-right:0}",
+ ".tbLeSegBtn:hover:not(:disabled){background:rgba(128,128,128,.15)}",
+ ".tbLeSegBtn[aria-pressed=true]{background:" + ACCENT + ";color:#fff}",
+ ".tbLeSegBtn:disabled{cursor:default}.tbLeSegBtn:disabled:not([aria-pressed=true]){color:#888}",
+ ".tbLe .tbLeSegBtn:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var(--themeDialogButtonFocusRectColor,#6d6dc3),inset 0 0 0 3px #fff}",
+ ".tbLeMain{display:flex;gap:10px;align-items:flex-start;padding:10px}",
+ ".tbLeLeft{flex:1 1 auto;min-width:0}",
+ ".tbLeLegend{margin:6px 0 0;font-size:90%}",
+ // The picture: the IDE window, its title and menu bars, the dock and
+ // the floating panels.
+ ".tbLePic{position:relative;width:100%;border:1px solid #777;background:#cfd4da;overflow:hidden;user-select:none}",
+ ".tbLeChrome{position:absolute;left:0;right:0;top:0;background:#8a8f96}",
+ ".tbLeDock{position:absolute;display:flex}",
+ ".tbLeG{display:flex;min-width:0;min-height:0;padding:2px;border:1px dashed transparent;box-sizing:border-box;cursor:pointer}",
+ ".tbLeRow{flex-direction:row}.tbLeCol{flex-direction:column}",
+ ".tbLeG.tbLeSel{border-color:" + ACCENT + ";background:rgba(66,113,174,.15)}",
+ ".tbLeSplit{flex:0 0 4px;cursor:pointer}",
+ ".tbLeRow>.tbLeSplit:not(.tbLeFixed){cursor:col-resize}.tbLeCol>.tbLeSplit:not(.tbLeFixed){cursor:row-resize}",
+ ".tbLeSplit:not(.tbLeFixed):hover,.tbLeSplit.tbLeDrag{background:" + ACCENT + "}",
+ ".tbLeFixed{flex-basis:2px;pointer-events:none}",
+ ".tbLeTile{position:relative;box-sizing:border-box;min-width:14px;min-height:16px;background:#eef1f5;border:1px solid #9aa6b5;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;cursor:pointer;text-align:center;line-height:1.2;font-size:85%;padding:1px}",
+ ".tbLeEd{background:#fff}",
+ ".tbLeTile.tbLeSel{outline:2px solid " + ACCENT + ";outline-offset:-2px;background:#dbe6f5}",
+ ".tbLeTile:focus-visible{outline:" + FOCUS + ";outline-offset:-2px}",
+ ".tbLeNm{font-weight:600;overflow-wrap:anywhere}",
+ ".tbLeAddin .tbLeNm::after{content:' (add-in)';font-weight:normal;color:#5a5a5a}",
+ ".tbLeSz{color:#5a5a5a;font-size:90%}",
+ ".tbLeGone{background:#f4f4f4;border-style:dashed;color:#777}",
+ ".tbLePlacing .tbLeTile{cursor:copy}",
+ ".tbLeZone{position:absolute;box-sizing:border-box;background:rgba(66,113,174,.35);border:2px solid " + ACCENT + ";pointer-events:none}",
+ ".tbLeFloat{position:absolute;box-sizing:border-box;background:#fff;border:1px solid #666;box-shadow:2px 2px 4px rgba(0,0,0,.3);display:flex;flex-direction:column;font-size:85%;cursor:pointer}",
+ ".tbLeFloat.tbLeSel{outline:2px solid " + ACCENT + "}",
+ ".tbLeFloat.tbLeGone{border-style:dashed}",
+ ".tbLeFt{background:#e3e3e3;padding:0 4px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:move}",
+ ".tbLeFb{flex:1;display:flex;align-items:center;justify-content:center;text-align:center;color:#5a5a5a;font-size:90%;overflow:hidden}",
+ // The box beside it: the settings dialogs' section title and fields.
+ ".tbLeInsp{flex:0 0 270px;box-sizing:border-box;padding:0 10px 10px;border:1px solid rgba(128,128,128,.45);border-radius:4px}",
+ ".tbLeHead{margin:0 -10px 8px;padding:4px 8px;border-left:4px solid " + ACCENT + ";background:#f5f5f5;font-weight:600;overflow-wrap:anywhere}",
+ ".tbLeHead code{" + MONO + ";font-weight:normal;color:#5a5a5a;font-size:90%}",
+ ".tbLeLabel{font-weight:600;margin:8px 0 4px}",
+ ".tbLeLine{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-bottom:6px}",
+ ".tbLeNums label{display:inline-flex;gap:4px;align-items:center}",
+ ".tbLe input.tbLeNum{box-sizing:border-box;width:5.5em;height:24px;padding:0 6px;border:1px solid #999;border-radius:4px;background:#fff;color:#1e1e1e;font:inherit;outline:none}",
+ ".tbLe input.tbLeNum:focus{border-color:" + ACCENT + ";box-shadow:0 0 0 2px rgba(66,113,174,.25)}",
+ ".tbLeCrumb{color:" + ACCENT + "}",
+ ".tbLeNote{margin:6px 0;padding:6px 10px;border:1px dashed #b8860b;border-radius:4px;background:#fff3cd;color:#3d2e00;font-size:95%}",
+ ".tbLeInfo{border:1px solid rgba(128,128,128,.35);background:rgba(128,128,128,.08);color:#1e1e1e}",
+ ".tbLeTop>.tbLeBanner{margin:8px 8px 0}",
+ ".tbLeError{border:0;background:#c62828;color:#fff}",
+ // The foot: the grey of the IDE's own Edit as JSON bar.
+ ".tbLeFoot{display:flex;gap:10px;align-items:center;padding:6px 8px;background:#b5b5b5}",
+ ".tbLeStatus{color:#1e1e1e}.tbLeBad{color:#8e1c1c;font-weight:bold}",
+ ".tbLeMark{color:#c62828;font-weight:bold}",
+ // The help add-in's box and its own window: grey, as an add-in's box on the IDE's pages.
+ ".tbLeAddin{margin:6px 0 8px;padding:0 10px 4px;border:1px solid rgba(128,128,128,.45);border-radius:4px;background:#f3f3f3}",
+ ".tbLeAddinTitle{margin:0 -10px 6px;padding:4px 8px;border-bottom:1px solid rgba(128,128,128,.35);background:#e4e4e4;font-weight:600}",
+ ".tbLeAddin p{margin:4px 0 6px;font-size:95%}",
+ ".tbLeOwn{border-style:dashed;background:#f7f7f7}.tbLeOwn .tbLeFt{cursor:pointer;background:#d4d4d4}",
+ ].join("\n");
+
+ window.tbDocsLayoutEditor = {
+ off: function () {
+ live = false;
+ unhook(TITLE);
+ mounts.forEach(function (r) {
+ if (r.node.isConnected) r.undo();
+ });
+ mounts = [];
+ var st = document.getElementById("tbDocsLayoutEditorStyle");
+ if (st) st.remove();
+ var api = helpApi();
+ if (api) api.onUpdate = null;
+ Array.prototype.forEach.call(document.querySelectorAll(".tbLeMark"), function (e) {
+ e.remove();
+ });
+ },
+ };
+ })();
+}
diff --git a/add-in/Resources/SCRIPTS/layouts.js b/add-in/Resources/SCRIPTS/layouts.js
new file mode 100644
index 000000000..c2771b142
--- /dev/null
+++ b/add-in/Resources/SCRIPTS/layouts.js
@@ -0,0 +1,268 @@
+// Tells the help add-in which panel layout the IDE applied or saved, so that it can keep, for
+// each layout, where the help is: in its pane or in its own window, and where that window is on
+// the screen. The add-in keeps that itself, by layout name, never in the layout's JSON, which
+// the IDE builds again from the window at every save. Window > Panel Layouts and its commands
+// apply a layout with setActivePanelLayoutName, and Save Current Layout As saves one with
+// saveCurrentPanelLayoutAs: both are wrapped here. Save Changes in Manage Panel Layouts sends
+// the records edited in the dialog (the panel layout editor's With the Help Add-In box) and the
+// names of the layouts that remain, through the one replacement of showConfigEditor the
+// add-in's scripts share (see hookOf).
+//
+// Applying a layout closes every add-in's tool window, and the add-in makes its pane again,
+// which runs this script again: a message waits until the pane it would be sent through is the
+// IDE's again (stale), and the new run sends what the old one held. The add-in gives the page
+// what it keeps in place of the marker below, and later through update(): the pane's id, the
+// dots per inch of its pixels, where the help is now, and the record of each layout, by its
+// name as enc() writes it.
+var sink = this.parentNode;
+var state = $STATE$;
+var held = [];
+var old = window.tbDocsHelpLayouts;
+if (old) {
+ try {
+ held = old.off() || [];
+ } catch (err) {
+ console.error(err);
+ }
+ window.tbDocsHelpLayouts = null;
+}
+if (
+ typeof setActivePanelLayoutName === "function" &&
+ typeof saveCurrentPanelLayoutAs === "function" &&
+ typeof showConfigEditor === "function" &&
+ typeof customPanelLayouts === "object"
+) {
+ (function () {
+ var TITLE = "Manage Panel Layouts";
+ // This script's adapter for the dialog, beside the panel layout editor's (hookOf).
+ var KEY = TITLE + "|help";
+ var has = function (o, k) {
+ return Object.prototype.hasOwnProperty.call(o, k);
+ };
+ var apply = setActivePanelLayoutName.tbDocsOriginal || setActivePanelLayoutName;
+ var save = saveCurrentPanelLayoutAs.tbDocsOriginal || saveCurrentPanelLayoutAs;
+ var pending = held.slice();
+ var timer = null;
+ var live = true;
+
+ // ---- the one replacement of showConfigEditor ----
+ // Each script of the add-in that changes a dialog of showConfigEditor puts its adapter
+ // here under the dialog's title, or the title, "|" and a name of its own; the replacement
+ // calls every adapter for the dialog's title, then the IDE's function. keyeditor.js and
+ // layouteditor.js have the same two functions.
+ var hookOf = function () {
+ var h = window.tbDocsConfigEditors;
+ if (h && window.showConfigEditor === h.dispatch) return h;
+ var current = window.showConfigEditor;
+ var nh = { original: current.tbDocsOriginal || current, adapters: (h && h.adapters) || {} };
+ nh.dispatch = function (opts) {
+ var title = opts && typeof opts.title === "string" ? opts.title : null;
+ if (title !== null)
+ Object.keys(nh.adapters).forEach(function (k) {
+ if (k !== title && k.indexOf(title + "|") !== 0) return;
+ try {
+ nh.adapters[k](opts);
+ } catch (err) {
+ console.error(err);
+ }
+ });
+ return nh.original.apply(this, arguments);
+ };
+ nh.dispatch.tbDocsOriginal = nh.original;
+ window.showConfigEditor = nh.dispatch;
+ window.tbDocsConfigEditors = nh;
+ return nh;
+ };
+ var unhook = function (key) {
+ var h = window.tbDocsConfigEditors;
+ if (!h) return;
+ delete h.adapters[key];
+ if (Object.keys(h.adapters).length) return;
+ if (window.showConfigEditor === h.dispatch) window.showConfigEditor = h.original;
+ window.tbDocsConfigEditors = null;
+ };
+
+ // A layout's name as the add-in keeps it: a settings section of its own, so nothing but
+ // letters, digits and %, - and _ (a name may hold \, which would make a key of the
+ // registry inside another).
+ var enc = function (name) {
+ return encodeURIComponent(String(name)).replace(/[!'()*~.]/g, function (c) {
+ return "%" + c.charCodeAt(0).toString(16).toUpperCase();
+ });
+ };
+ // Whether the pane this run's messages go through is gone: closed with every add-in's tool
+ // window when a layout is applied, before the add-in makes it again. A sink outside any
+ // tool window (the tests' own) is gone only once it leaves the page.
+ var stale = function () {
+ if (!sink.isConnected) return true;
+ var root = sink.getRootNode ? sink.getRootNode() : null;
+ var host = root && root.host;
+ if (!host || typeof host.persistenceId !== "string") return false;
+ return typeof toolWindowsById !== "object" || toolWindowsById[host.persistenceId] !== host;
+ };
+ var flush = function () {
+ timer = null;
+ if (!live || stale()) return;
+ while (pending.length) {
+ var m = pending.shift();
+ try {
+ sink.tbDocsLayout(m);
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ };
+ // Sends a message once the code that asked for it has returned; with first, before any
+ // that wait.
+ var send = function (verb, layout, value, first) {
+ var m = { verb: verb, layout: layout || "", value: value || "" };
+ if (first) pending.unshift(m);
+ else pending.push(m);
+ if (!timer) timer = setTimeout(flush, 0);
+ };
+
+ // BETA 1042: applying a layout closes every add-in's tool window (closeAllAddinToolwindows),
+ // so that each add-in makes its window again, but only after it has taken a floating window
+ // that shows out of the page as a built-in panel (removeAllFloatingPanels) and the dock out
+ // of the page (restorePanelLayout). Closing such a window then throws inside
+ // toolWindowClose, which swallows the error: the add-in never hears of it and never makes
+ // it again, and the help's pane is gone until the IDE restarts. A hidden floating
+ // window is closed as it should be. Every add-in's window is closed here first, while all
+ // are in the page, as closeAllAddinToolwindows closes them, as long as a build's
+ // setActivePanelLayoutName still starts by removing the floating panels. The IDE defect is
+ // BUGS-TO-REPORT.md's layout-loses-addin-toolwindow.
+ var closesLate = /removeAllFloatingPanels\(\)/.test(String(apply)) && typeof addInEvents === "object";
+ var closeAddinWindows = function () {
+ if (!closesLate || typeof toolWindowsById !== "object") return;
+ Object.keys(toolWindowsById).forEach(function (k) {
+ try {
+ var w = toolWindowsById[k];
+ if (w && w.shadowDom && w.shadowDom.host && w.shadowDom.host.isConnected) addInEvents.toolWindowClose({ id: w.toolWindowId });
+ } catch (err) {
+ console.error(err);
+ }
+ });
+ };
+ // BETA 1042: an add-in's window that a layout floats is put at the layout's place, but
+ // showing it later (the help's pane once it is attached) gives it its add-in's suggested
+ // size, unless the IDE has a place for it in floatingToolWindowsData, which nothing the IDE
+ // runs writes (BUGS-TO-REPORT.md's toolwindow-show-suggested-size; a resize by hand is lost
+ // the same way, and is not worked round). The layout's place is written there.
+ var keepFloatingPlaces = function (name) {
+ if (typeof floatingToolWindowsData !== "object" || !floatingToolWindowsData) return;
+ var e = has(builtInPanelLayouts, name) ? builtInPanelLayouts[name] : has(customPanelLayouts, name) ? customPanelLayouts[name] : null;
+ var list = [];
+ try {
+ list = e && e.floatingData ? JSON.parse(e.floatingData) : [];
+ } catch (err) {
+ return;
+ }
+ if (!Array.isArray(list)) return;
+ list.forEach(function (f) {
+ if (!f || typeof f.id !== "string" || f.id.indexOf("ADDIN_") !== 0 || f.id.length === 6) return;
+ if (!(f.width > 0 && f.height > 0)) return;
+ floatingToolWindowsData[f.id.slice(6)] = { left: f.left | 0, top: f.top | 0, width: f.width | 0, height: f.height | 0 };
+ });
+ };
+ var applied = function (name) {
+ if (live) closeAddinWindows();
+ var r = apply.apply(this, arguments);
+ if (live) keepFloatingPlaces(name);
+ if (live) send("applied", enc(name));
+ return r;
+ };
+ applied.tbDocsOriginal = apply;
+ var saved = function (name) {
+ var r = save.apply(this, arguments);
+ if (live) send("saved", enc(name));
+ return r;
+ };
+ saved.tbDocsOriginal = save;
+ window.setActivePanelLayoutName = applied;
+ window.saveCurrentPanelLayoutAs = saved;
+
+ var api = {
+ // The help pane's id in a layout.
+ pane: String(state.pane || ""),
+ // The dots per inch of the pixels the add-in keeps a window's place in: the display's
+ // (the compiler's process is aware of its scaling), 96 at 100%.
+ dpi: Number(state.dpi) || 96,
+ // Where the help is now: detached or not, and the window's place in screen pixels
+ // (width 0 when it has none yet).
+ now: state.now || null,
+ // Each layout's record, by enc(name): { detached, left, top, width, height }.
+ records: state.records || {},
+ enc: enc,
+ // The records changed in Manage Panel Layouts, by enc(name), while it is open; kept
+ // only at Save Changes.
+ dialog: null,
+ // Called after update(); the panel layout editor draws its picture again.
+ onUpdate: null,
+ update: function (st) {
+ if (!st || typeof st !== "object") return;
+ if (st.pane) api.pane = String(st.pane);
+ if (st.dpi) api.dpi = Number(st.dpi) || 96;
+ api.now = st.now || null;
+ api.records = st.records || {};
+ if (typeof api.onUpdate === "function") {
+ try {
+ api.onUpdate();
+ } catch (err) {
+ console.error(err);
+ }
+ }
+ },
+ // A layout's record: the dialog's change, else the add-in's; null when it has none.
+ record: function (name) {
+ var k = enc(name);
+ if (api.dialog && has(api.dialog.edits, k)) return api.dialog.edits[k];
+ return has(api.records, k) ? api.records[k] : null;
+ },
+ // Changes a layout's record in the open dialog.
+ edit: function (name, rec) {
+ if (api.dialog) api.dialog.edits[enc(name)] = rec;
+ },
+ // Takes out what this run put in, and returns the messages it still holds.
+ off: function () {
+ live = false;
+ if (timer) clearTimeout(timer);
+ timer = null;
+ if (window.setActivePanelLayoutName === applied) window.setActivePanelLayoutName = apply;
+ if (window.saveCurrentPanelLayoutAs === saved) window.saveCurrentPanelLayoutAs = save;
+ unhook(KEY);
+ var rest = pending;
+ pending = [];
+ return rest;
+ },
+ };
+
+ // The dialog: the add-in is asked where the help is now, for the editor's box, and Save
+ // Changes sends the records changed in it and the names of the layouts it keeps. The IDE's
+ // Save Changes applies the active layout again, which this run sends after them.
+ hookOf().adapters[KEY] = function (opts) {
+ if (!live) return;
+ var dialog = { edits: {} };
+ api.dialog = dialog;
+ send("ask");
+ var saveChanges = opts.saveChanges;
+ if (typeof saveChanges !== "function") return;
+ opts.saveChanges = function () {
+ var r = saveChanges.apply(this, arguments);
+ if (!live) return r;
+ var keep = Object.keys(customPanelLayouts).map(enc);
+ var lines = ["keep " + keep.join(" ")];
+ Object.keys(dialog.edits).forEach(function (k) {
+ var e = dialog.edits[k];
+ if (keep.indexOf(k) < 0 || !e) return;
+ lines.push(["set", k, e.detached ? 1 : 0, e.left | 0, e.top | 0, e.width | 0, e.height | 0].join(" "));
+ });
+ send("records", "", lines.join("\n"), true);
+ if (api.dialog === dialog) api.dialog = null;
+ return r;
+ };
+ };
+
+ window.tbDocsHelpLayouts = api;
+ if (pending.length) timer = setTimeout(flush, 0);
+ })();
+}
diff --git a/add-in/Resources/SHELL/shell.html b/add-in/Resources/SHELL/shell.html
index 4f704859b..1aa015a36 100644
--- a/add-in/Resources/SHELL/shell.html
+++ b/add-in/Resources/SHELL/shell.html
@@ -20,6 +20,8 @@
+
+
diff --git a/add-in/Resources/SHELL/shell.js b/add-in/Resources/SHELL/shell.js
index 9523d7662..ff861d6c9 100644
--- a/add-in/Resources/SHELL/shell.js
+++ b/add-in/Resources/SHELL/shell.js
@@ -3,12 +3,12 @@
// way is "verb:payload", split at the first colon.
//
// Page to add-in: ready, search:, enter, pick:, hover:<1|0>,
-// allpackages:<1|0>, addinkeys:<1|0>, textfind:<1|0>, attach, browser, frame: (the frame has loaded src),
+// allpackages:<1|0>, addinkeys:<1|0>, textfind:<1|0>, keyeditor:<1|0>, layouteditor:<1|0>, attach, browser, frame: (the frame has loaded src),
// and from the title bar drag (start moving the window), minimize, maxrestore,
// close.
// Add-in to page: theme: a line break and , search:,
// results:, page:, summary:, hover:<1|0>, hoverdisabled:<1|0>,
-// allpackages:<1|0>, addinkeys:<1|0>, textfind:<1|0>, browser:<1|0 enabled>, focus:, chrome:
+// allpackages:<1|0>, addinkeys:<1|0>, textfind:<1|0>, keyeditor:<1|0>, layouteditor:<1|0>, browser:<1|0 enabled>, focus:, chrome:
// (whether the page draws the title bar), state: (the window's).
(function () {
var host = window.chrome.webview;
@@ -23,6 +23,8 @@
var allPackages = byId("helpAllPackages");
var keysOn = byId("helpKeysOn");
var findOn = byId("helpFindOn");
+ var keyEditorOn = byId("helpKeyEditorOn");
+ var layoutEditorOn = byId("helpLayoutEditorOn");
var settings = byId("helpSettings");
var settingsWrap = byId("helpSettingsWrap");
var settingsPanel = byId("helpSettingsPanel");
@@ -86,6 +88,8 @@
});
keysOn.addEventListener("change", function () { post("addinkeys:" + (keysOn.checked ? "1" : "0")); });
findOn.addEventListener("change", function () { post("textfind:" + (findOn.checked ? "1" : "0")); });
+ keyEditorOn.addEventListener("change", function () { post("keyeditor:" + (keyEditorOn.checked ? "1" : "0")); });
+ layoutEditorOn.addEventListener("change", function () { post("layouteditor:" + (layoutEditorOn.checked ? "1" : "0")); });
// The settings panel opens under the gear, with the shade over the rest of
// the window so that a click anywhere else closes it. A press over the
@@ -178,6 +182,8 @@
case "allpackages": allPackages.checked = payload === "1"; break;
case "addinkeys": keysOn.checked = payload === "1"; break;
case "textfind": findOn.checked = payload === "1"; break;
+ case "keyeditor": keyEditorOn.checked = payload === "1"; break;
+ case "layouteditor": layoutEditorOn.checked = payload === "1"; break;
case "browser": browser.disabled = payload !== "1"; break;
case "focus": search.focus(); break;
case "chrome": setChrome(payload); break;
diff --git a/add-in/Resources/STYLESHEETS/pane.css b/add-in/Resources/STYLESHEETS/pane.css
index caee3c02a..67cf6813f 100644
--- a/add-in/Resources/STYLESHEETS/pane.css
+++ b/add-in/Resources/STYLESHEETS/pane.css
@@ -65,7 +65,9 @@
#helpHoverLabel,
#helpAllPackagesLabel,
#helpKeysLabel,
-#helpFindLabel {
+#helpFindLabel,
+#helpKeyEditorLabel,
+#helpLayoutEditorLabel {
display: flex;
align-items: center;
gap: 4px;
diff --git a/add-in/Settings b/add-in/Settings
index b46e86408..bff15c61a 100644
--- a/add-in/Settings
+++ b/add-in/Settings
@@ -68,7 +68,7 @@
"project.versionAutoIncrement": "None",
"project.versionBuild": 0,
"project.versionMajor": 1,
- "project.versionMinor": 1,
+ "project.versionMinor": 4,
"project.versionRevision": 0,
"project.warnings": {
"errors": [],
diff --git a/add-in/Sources/HelpAddIn.twin b/add-in/Sources/HelpAddIn.twin
index 01474bb7d..80e15a47c 100644
--- a/add-in/Sources/HelpAddIn.twin
+++ b/add-in/Sources/HelpAddIn.twin
@@ -23,8 +23,12 @@
' hidden window stays hidden after a compiler restart. When the IDE's option
' "Show real OS titlebar" is on, the window has the Windows title bar instead,
' dark or light with the theme, and the page draws none; the option is read
-' each time the window is shown. Every line it prints to the DEBUG CONSOLE
-' starts "[tbDocsHelp] ", except "open " (see OpenUrl).
+' each time the window is shown. Where the help is, in the pane or in the
+' window and where that window is, is kept for each panel layout as well: saving
+' a layout records it, and applying one with a record puts the help there
+' (layouts.js tells the add-in which layout was saved or applied). Every line it
+' prints to the DEBUG CONSOLE starts "[tbDocsHelp] ", except "open " (see
+' OpenUrl).
Private Class HelpAddIn
Implements AddIn
Private WithEvents Host As Host
@@ -51,8 +55,14 @@ Private Class HelpAddIn
Private AllBox As HtmlElement ' the pane's All packages checkbox
Private KeysBox As HtmlElement ' the pane's Ctrl or Alt shortcuts checkbox
Private FindBox As HtmlElement ' the pane's Find in the shortcut editors checkbox
+ Private EditorBox As HtmlElement ' the pane's Keyboard shortcut editor checkbox
Private KeysHost As HtmlElement ' where addinkeys.js is put in
Private FindHost As HtmlElement ' where textfind.js is put in
+ Private EditorHost As HtmlElement ' where keyeditor.js is put in
+ Private LayoutBox As HtmlElement ' the pane's Panel layout editor checkbox
+ Private LayoutHost As HtmlElement ' where layouteditor.js is put in
+ Private LayoutsHost As HtmlElement ' where layouts.js is put in, and its messages come
+ Private CommandText As String ' the commands' descriptions, for keyeditor.js; "" until first needed
Private Referenced As Collection ' the project's packages, keyed by name; Nothing if unknown
Private DetachButton As HtmlElement
Private SettingsButton As HtmlElement ' the gear at the bar's right end
@@ -70,6 +80,8 @@ Private Class HelpAddIn
Private AllPackages As Boolean ' what the All packages box holds, in either view
Private KeysOn As Boolean ' what the Ctrl or Alt shortcuts box holds, in either view
Private FindOn As Boolean ' what the Find in the shortcut editors box holds, in either view
+ Private EditorOn As Boolean ' what the Keyboard shortcut editor box holds, in either view
+ Private LayoutOn As Boolean ' what the Panel layout editor box holds, in either view
Private SummaryHtml As String ' what ShowSummary shows
Private ShowingSummary As Boolean ' the summary shows in place of the page
@@ -89,8 +101,16 @@ Private Class HelpAddIn
' The window's settings: whether it is detached, whether it is shown, and
' where it is, in pixels.
Private Const WINDOW_SECTION As String = "Window"
- ' The settings of the two page-side fixes: addinkeys.js and textfind.js.
+ ' The settings of the page-side fixes: addinkeys.js, textfind.js,
+ ' keyeditor.js and layouteditor.js.
Private Const FIXES_SECTION As String = "Fixes"
+ ' Where the help is for each panel layout: a section inside this one for
+ ' each layout, named as layouts.js writes the layout's name (LayoutKey),
+ ' with Detached and the window's place, as the Window section has them.
+ ' The Window section is where the help is now, whichever layout that is.
+ Private Const LAYOUTS_SECTION As String = "Layouts"
+ ' What layouts.js sends.
+ Private Const LAYOUT_EVENT As String = "tbDocsLayout"
Public Sub New(ByVal Host As Host)
Set Me.Host = Host
@@ -288,6 +308,8 @@ Private Class HelpAddIn
HoverOn = GetSetting(SETTINGS_APP, "Hover", "On", "0") = "1"
KeysOn = GetSetting(SETTINGS_APP, FIXES_SECTION, "AddinKeys", "1") = "1"
FindOn = GetSetting(SETTINGS_APP, FIXES_SECTION, "TextFind", "1") = "1"
+ EditorOn = GetSetting(SETTINGS_APP, FIXES_SECTION, "KeyEditor", "1") = "1"
+ LayoutOn = GetSetting(SETTINGS_APP, FIXES_SECTION, "LayoutEditor", "1") = "1"
Set Pane = Host.ToolWindows.Add("tbDocsHelp", PANE_ID)
Pane.Title = "TWINBASIC HELP"
Pane.ApplyCss StrConv(LoadResDataInternal("pane.css", "STYLESHEETS"), VbStrConv.vbFromUTF8)
@@ -354,6 +376,20 @@ Private Class HelpAddIn
FindBox.AddEventListener("change", AddressOf FindToggled)
.ChildDomElements.Add("helpFindText", "span").Properties.innerText = "Find in the shortcut editors"
End With
+ With SettingsPanel.ChildDomElements.Add("helpKeyEditorLabel", "label")
+ Set EditorBox = .ChildDomElements.Add("helpKeyEditorOn", "input")
+ EditorBox.Properties.type = "checkbox"
+ EditorBox.Properties.checked = EditorOn
+ EditorBox.AddEventListener("change", AddressOf EditorToggled)
+ .ChildDomElements.Add("helpKeyEditorText", "span").Properties.innerText = "Keyboard shortcut editor"
+ End With
+ With SettingsPanel.ChildDomElements.Add("helpLayoutEditorLabel", "label")
+ Set LayoutBox = .ChildDomElements.Add("helpLayoutEditorOn", "input")
+ LayoutBox.Properties.type = "checkbox"
+ LayoutBox.Properties.checked = LayoutOn
+ LayoutBox.AddEventListener("change", AddressOf LayoutToggled)
+ .ChildDomElements.Add("helpLayoutEditorText", "span").Properties.innerText = "Panel layout editor"
+ End With
End With
End With
Set SettingsShade = .ChildDomElements.Add("helpSettingsShade", "div")
@@ -393,6 +429,23 @@ Private Class HelpAddIn
Set FindHost = .ChildDomElements.Add("helpTextFind", "div")
FindHost.Properties.style.display = "none"
ApplyFix FindHost, "textfind.js", FindOn
+ ' A table of every command in place of the "Keyboard editor
+ ' coming soon" pane of Manage Keyboard Shortcuts (keyeditor.js).
+ Set EditorHost = .ChildDomElements.Add("helpKeyEditor", "div")
+ EditorHost.Properties.style.display = "none"
+ ApplyFix EditorHost, "keyeditor.js", EditorOn
+ ' A picture of each layout in place of the text of Manage
+ ' Panel Layouts (layouteditor.js).
+ Set LayoutHost = .ChildDomElements.Add("helpLayoutEditor", "div")
+ LayoutHost.Properties.style.display = "none"
+ ApplyFix LayoutHost, "layouteditor.js", LayoutOn
+ ' Which panel layout the IDE applies or saves (layouts.js),
+ ' always: where the help is is kept for each layout.
+ Set LayoutsHost = .ChildDomElements.Add("helpLayouts", "div")
+ LayoutsHost.Properties.style.display = "none"
+ LayoutsHost.AddEventListener(LAYOUT_EVENT, AddressOf LayoutMessage)
+ Dim layoutsJs As String = StrConv(LoadResDataInternal("layouts.js", "SCRIPTS"), VbStrConv.vbFromUTF8)
+ LayoutsHost.Properties.innerHTML = PageScript(Replace(layoutsJs, "$STATE$", LayoutState()))
End With
End With
Set ResultIds = New Collection
@@ -405,6 +458,10 @@ Private Class HelpAddIn
LoadedFrame = FrameUrl(PageUrl)
Frame.Properties.src = LoadedFrame
End If
+ ' The IDE shows a pane made again where a layout docks it (applying a
+ ' layout closes every add-in's tool window, and Pane_OnClose makes the
+ ' pane again); while the help is in the window, the pane stays hidden.
+ If Detached Then Pane.Visible = False
End Sub
' Hover help is off until the box is ticked, and stays as it was left.
@@ -430,7 +487,15 @@ Private Class HelpAddIn
' and takes out what an earlier run or instance put in.
Private Sub ApplyFix(ByVal Target As HtmlElement, ByVal script As String, ByVal isOn As Boolean)
Dim js As String = StrConv(LoadResDataInternal(script, "SCRIPTS"), VbStrConv.vbFromUTF8)
- Target.Properties.innerHTML = PageScript(Replace(js, "$ON$", IIf(isOn, "true", "false")))
+ js = Replace(js, "$ON$", IIf(isOn, "true", "false"))
+ ' keyeditor.js shows each command's description: the documentation's
+ ' own lines (scripts/ide-js/command-text.json), one JSON object.
+ If InStr(js, "$COMMANDS$") > 0 Then
+ If Len(CommandText) = 0 Then CommandText = Trim$(StrConv(LoadResDataInternal("commands.json", "KEYS"), VbStrConv.vbFromUTF8))
+ CommandText = Replace(Replace(CommandText, vbCr, ""), vbLf, "")
+ js = Replace(js, "$COMMANDS$", CommandText)
+ End If
+ Target.Properties.innerHTML = PageScript(js)
End Sub
Private Sub KeysToggled(ByVal eventInfo As HtmlEventProperties)
@@ -469,6 +534,44 @@ Private Class HelpAddIn
If Detached Then PostToWindow "textfind:" & IIf(isOn, "1", "0")
End Sub
+ Private Sub EditorToggled(ByVal eventInfo As HtmlEventProperties)
+ On Error GoTo Failed
+ SetEditor EditorBox.Properties.checked
+ Exit Sub
+ Failed:
+ Host.DebugConsole.PrintText TAG & "error " & Err.Number & ": " & Err.Description
+ End Sub
+
+ ' Turns the keyboard shortcut editor on or off, from the pane's box or the
+ ' window's, and shows it in both. Off, an open Manage Keyboard Shortcuts
+ ' dialog gets the IDE's text area back.
+ Private Sub SetEditor(ByVal isOn As Boolean)
+ EditorOn = isOn
+ SaveSetting SETTINGS_APP, FIXES_SECTION, "KeyEditor", IIf(isOn, "1", "0")
+ ApplyFix EditorHost, "keyeditor.js", isOn
+ EditorBox.Properties.checked = isOn
+ If Detached Then PostToWindow "keyeditor:" & IIf(isOn, "1", "0")
+ End Sub
+
+ Private Sub LayoutToggled(ByVal eventInfo As HtmlEventProperties)
+ On Error GoTo Failed
+ SetLayoutEditor LayoutBox.Properties.checked
+ Exit Sub
+ Failed:
+ Host.DebugConsole.PrintText TAG & "error " & Err.Number & ": " & Err.Description
+ End Sub
+
+ ' Turns the panel layout editor on or off, from the pane's box or the
+ ' window's, and shows it in both. Off, an open Manage Panel Layouts dialog
+ ' gets the IDE's text area back.
+ Private Sub SetLayoutEditor(ByVal isOn As Boolean)
+ LayoutOn = isOn
+ SaveSetting SETTINGS_APP, FIXES_SECTION, "LayoutEditor", IIf(isOn, "1", "0")
+ ApplyFix LayoutHost, "layouteditor.js", isOn
+ LayoutBox.Properties.checked = isOn
+ If Detached Then PostToWindow "layouteditor:" & IIf(isOn, "1", "0")
+ End Sub
+
' Only the packages the project references are offered until the box is
' ticked, and it stays as it was left.
Private Sub AllPackagesToggled(ByVal eventInfo As HtmlEventProperties)
@@ -832,12 +935,13 @@ Private Class HelpAddIn
' Hides the pane and shows the window, which is made the first time and
' kept after, with the page it has. The page says "ready" once it has
' loaded, and is sent the state then; a window already loaded is sent it
- ' now.
- Private Sub Detach()
+ ' now. A window that is not made here is activated only when activate says
+ ' so (OpenWindow).
+ Private Sub Detach(Optional ByVal activate As Boolean = True)
On Error GoTo Failed
Detached = True
Pane.Visible = False
- OpenWindow True
+ OpenWindow activate
SaveSetting SETTINGS_APP, WINDOW_SECTION, "Detached", "1"
If HelpWin.IsReady Then SendWindowState
If TestSwitchOn() Then Host.DebugConsole.PrintText TAG & "detached"
@@ -985,6 +1089,10 @@ Private Class HelpAddIn
SetKeys payload = "1"
Case "textfind"
SetFind payload = "1"
+ Case "keyeditor"
+ SetEditor payload = "1"
+ Case "layouteditor"
+ SetLayoutEditor payload = "1"
Case "attach"
Attach
Case "close"
@@ -1022,6 +1130,8 @@ Private Class HelpAddIn
HelpWin.Post "allpackages:" & IIf(AllPackages, "1", "0")
HelpWin.Post "addinkeys:" & IIf(KeysOn, "1", "0")
HelpWin.Post "textfind:" & IIf(FindOn, "1", "0")
+ HelpWin.Post "keyeditor:" & IIf(EditorOn, "1", "0")
+ HelpWin.Post "layouteditor:" & IIf(LayoutOn, "1", "0")
HelpWin.Post "search:" & SearchText
PostResults
If ShowingSummary Then
@@ -1059,6 +1169,241 @@ Private Class HelpAddIn
If w > 0 And h > 0 And IsOnScreen(x, y, w, h) Then PlaceWindow HelpWin.hWnd, x, y, w, h
End Sub
+ ' ------------------------------------------------------------ the panel layouts
+
+ ' What layouts.js sends: "applied" or "saved" with a layout's name as it
+ ' writes it, "records" with what Save Changes in Manage Panel Layouts
+ ' keeps, and "ask" when that dialog opens, for where the help is now.
+ Private Sub LayoutMessage(ByVal eventInfo As HtmlEventProperties)
+ On Error GoTo Failed
+ Dim verb As String = eventInfo.verb
+ Dim key As String = eventInfo.layout
+ Select Case verb
+ Case "applied"
+ If IsLayoutKey(key) Then LayoutApplied key
+ Case "saved"
+ If IsLayoutKey(key) Then LayoutSaved key
+ Case "records"
+ LayoutRecords eventInfo.value
+ Case "ask"
+ PushLayoutState
+ End Select
+ Exit Sub
+ Failed:
+ Host.DebugConsole.PrintText TAG & "error " & Err.Number & ": " & Err.Description
+ End Sub
+
+ ' Whether text is a layout's name as layouts.js writes it: letters, digits
+ ' and %, - and _ only, so that it names one section of the settings.
+ Private Function IsLayoutKey(ByVal text As String) As Boolean
+ If Len(text) = 0 Or Len(text) > 200 Then Return False
+ Dim i As Long
+ For i = 1 To Len(text)
+ Select Case AscW(Mid$(text, i, 1))
+ Case 48 To 57, 65 To 90, 97 To 122, 37, 45, 95
+ Case Else
+ Return False
+ End Select
+ Next
+ Return True
+ End Function
+
+ Private Function LayoutSection(ByVal key As String) As String
+ Return LAYOUTS_SECTION & "\" & key
+ End Function
+
+ ' Where the window is, in pixels: where it is now when it has a place
+ ' there, else where it was last left (the Window section). False when
+ ' neither is known.
+ Private Function CurrentPlace(ByRef x As Long, ByRef y As Long, ByRef w As Long, ByRef h As Long) As Boolean
+ If Not HelpWin Is Nothing Then
+ If WindowPlace(HelpWin.hWnd, x, y, w, h) Then Return True
+ End If
+ x = CLng(Val(GetSetting(SETTINGS_APP, WINDOW_SECTION, "Left", "0")))
+ y = CLng(Val(GetSetting(SETTINGS_APP, WINDOW_SECTION, "Top", "0")))
+ w = CLng(Val(GetSetting(SETTINGS_APP, WINDOW_SECTION, "Width", "0")))
+ h = CLng(Val(GetSetting(SETTINGS_APP, WINDOW_SECTION, "Height", "0")))
+ Return w > 0 And h > 0
+ End Function
+
+ Private Function PlaceJson(ByVal isDetached As Boolean, ByVal x As Long, ByVal y As Long, _
+ ByVal w As Long, ByVal h As Long) As String
+ Return "{""detached"":" & IIf(isDetached, "true", "false") & ",""left"":" & x & ",""top"":" & y & _
+ ",""width"":" & w & ",""height"":" & h & "}"
+ End Function
+
+ ' A layout's record as JSON (PlaceJson), or "" when it has none.
+ Private Function RecordJson(ByVal key As String) As String
+ Dim section As String = LayoutSection(key)
+ Dim d As String = GetSetting(SETTINGS_APP, section, "Detached", "")
+ If Len(d) = 0 Then Return ""
+ Return PlaceJson(d = "1", CLng(Val(GetSetting(SETTINGS_APP, section, "Left", "0"))), _
+ CLng(Val(GetSetting(SETTINGS_APP, section, "Top", "0"))), _
+ CLng(Val(GetSetting(SETTINGS_APP, section, "Width", "0"))), _
+ CLng(Val(GetSetting(SETTINGS_APP, section, "Height", "0"))))
+ End Function
+
+ ' What layouts.js is given, as one JSON object: the pane's id in a layout,
+ ' the dots per inch of the pixels the window's place is in, where the help
+ ' is now, and the record of each layout that has one.
+ Private Function LayoutState() As String
+ Dim x As Long, y As Long, w As Long, h As Long
+ If Not CurrentPlace(x, y, w, h) Then
+ x = 0
+ y = 0
+ w = 0
+ h = 0
+ End If
+ Dim json As String = "{""pane"":""ADDIN_" & PANE_ID & """,""dpi"":" & ProcessDpi() & _
+ ",""now"":" & PlaceJson(Detached, x, y, w, h) & ",""records"":{"
+ Dim first As Boolean = True
+ Dim v As Variant
+ For Each v In SettingSections(SETTINGS_APP, LAYOUTS_SECTION)
+ Dim key As String = v
+ If IsLayoutKey(key) Then
+ Dim record As String = RecordJson(key)
+ If Len(record) > 0 Then
+ json = json & IIf(first, "", ",") & """" & key & """:" & record
+ first = False
+ End If
+ End If
+ Next
+ Return json & "}}"
+ End Function
+
+ ' Gives layouts.js what LayoutState holds now; the panel layout editor
+ ' draws its picture again with it.
+ Private Sub PushLayoutState()
+ If LayoutsHost Is Nothing Then Exit Sub
+ LayoutsHost.Properties.innerHTML = PageScript("if (window.tbDocsHelpLayouts) window.tbDocsHelpLayouts.update(" & _
+ LayoutState() & ");")
+ End Sub
+
+ ' For the tests: a layout's record, "detached" or "attached" and its place.
+ Private Function RecordText(ByVal key As String) As String
+ Dim section As String = LayoutSection(key)
+ Dim d As String = GetSetting(SETTINGS_APP, section, "Detached", "")
+ If Len(d) = 0 Then Return "unrecorded"
+ Return IIf(d = "1", "detached", "attached") & " at " & GetSetting(SETTINGS_APP, section, "Left", "0") & "," & _
+ GetSetting(SETTINGS_APP, section, "Top", "0") & "," & GetSetting(SETTINGS_APP, section, "Width", "0") & "," & _
+ GetSetting(SETTINGS_APP, section, "Height", "0")
+ End Function
+
+ ' Save Current Layout As: the layout's record is where the help is now,
+ ' and where the window is, or was last left.
+ Private Sub LayoutSaved(ByVal key As String)
+ Dim section As String = LayoutSection(key)
+ Dim x As Long, y As Long, w As Long, h As Long
+ Dim known As Boolean = CurrentPlace(x, y, w, h)
+ SaveSetting SETTINGS_APP, section, "Detached", IIf(Detached, "1", "0")
+ If known Then
+ SaveSetting SETTINGS_APP, section, "Left", CStr(x)
+ SaveSetting SETTINGS_APP, section, "Top", CStr(y)
+ SaveSetting SETTINGS_APP, section, "Width", CStr(w)
+ SaveSetting SETTINGS_APP, section, "Height", CStr(h)
+ End If
+ PushLayoutState
+ If TestSwitchOn() Then Host.DebugConsole.PrintText TAG & "layout saved " & key & " " & RecordText(key)
+ End Sub
+
+ ' A layout was applied: the help goes where the layout's record puts it,
+ ' into the pane, or into the window, shown without taking the focus and
+ ' put at its place when that is on a monitor. A layout with no record, a
+ ' built-in one among them, leaves the help where it is. Applying a layout
+ ' closed the pane, and BuildPane made it again, hidden while detached.
+ Private Sub LayoutApplied(ByVal key As String)
+ Dim section As String = LayoutSection(key)
+ Dim d As String = GetSetting(SETTINGS_APP, section, "Detached", "")
+ If Len(d) = 0 Then
+ If TestSwitchOn() Then Host.DebugConsole.PrintText TAG & "layout applied " & key & " unrecorded"
+ Exit Sub
+ End If
+ If d = "1" Then
+ If Not Detached Then
+ Detach False
+ ElseIf Not WindowShown Then
+ OpenWindow False
+ End If
+ If Not Detached Then Exit Sub
+ Dim x As Long = CLng(Val(GetSetting(SETTINGS_APP, section, "Left", "0")))
+ Dim y As Long = CLng(Val(GetSetting(SETTINGS_APP, section, "Top", "0")))
+ Dim w As Long = CLng(Val(GetSetting(SETTINGS_APP, section, "Width", "0")))
+ Dim h As Long = CLng(Val(GetSetting(SETTINGS_APP, section, "Height", "0")))
+ If w > 0 And h > 0 And StateOfWindow(HelpWin.hWnd) = "normal" Then
+ If IsOnScreen(x, y, w, h) Then
+ PlaceWindow HelpWin.hWnd, x, y, w, h
+ SaveWindowPlace
+ End If
+ End If
+ ElseIf Detached Then
+ Attach
+ End If
+ If TestSwitchOn() Then
+ Dim where As String = IIf(Detached, "detached", "attached")
+ Dim px As Long, py As Long, pw As Long, ph As Long
+ If Detached Then
+ If WindowPlace(HelpWin.hWnd, px, py, pw, ph) Then where = where & " at " & px & "," & py & "," & pw & "," & ph
+ End If
+ Host.DebugConsole.PrintText TAG & "layout applied " & key & " " & where
+ End If
+ End Sub
+
+ ' Save Changes in Manage Panel Layouts: a line "keep" and the names of the
+ ' layouts the dialog keeps, then a line "set
+ ' " for each record changed in it. The records of
+ ' layouts it no longer has go.
+ Private Sub LayoutRecords(ByVal text As String)
+ Dim lines() As String = Split(Replace(text, vbCr, ""), vbLf)
+ Dim parts() As String
+ Dim keep As New Collection
+ Dim i As Long, j As Long
+ For i = 0 To UBound(lines)
+ parts = Split(Trim$(lines(i)), " ")
+ If UBound(parts) >= 0 Then
+ If parts(0) = "keep" Then
+ For j = 1 To UBound(parts)
+ If IsLayoutKey(parts(j)) Then
+ If Not keep.Exists(parts(j)) Then keep.Add parts(j), parts(j)
+ End If
+ Next
+ End If
+ End If
+ Next
+ Dim removed As String
+ Dim v As Variant
+ For Each v In SettingSections(SETTINGS_APP, LAYOUTS_SECTION)
+ If Not keep.Exists(CStr(v)) Then
+ RemoveSection LayoutSection(CStr(v))
+ removed = removed & " " & v
+ End If
+ Next
+ Dim changed As Long
+ For i = 0 To UBound(lines)
+ parts = Split(Trim$(lines(i)), " ")
+ If UBound(parts) = 6 Then
+ If parts(0) = "set" And keep.Exists(parts(1)) Then
+ Dim section As String = LayoutSection(parts(1))
+ SaveSetting SETTINGS_APP, section, "Detached", IIf(parts(2) = "1", "1", "0")
+ SaveSetting SETTINGS_APP, section, "Left", CStr(CLng(Val(parts(3))))
+ SaveSetting SETTINGS_APP, section, "Top", CStr(CLng(Val(parts(4))))
+ SaveSetting SETTINGS_APP, section, "Width", CStr(CLng(Val(parts(5))))
+ SaveSetting SETTINGS_APP, section, "Height", CStr(CLng(Val(parts(6))))
+ changed = changed + 1
+ End If
+ End If
+ Next
+ PushLayoutState
+ If TestSwitchOn() Then
+ Host.DebugConsole.PrintText TAG & "layout records set " & changed & ", removed" & IIf(Len(removed) = 0, " none", removed)
+ End If
+ End Sub
+
+ ' Deletes a section of the settings, if it is there.
+ Private Sub RemoveSection(ByVal section As String)
+ On Error Resume Next
+ DeleteSetting SETTINGS_APP, section
+ End Sub
+
' The selection when it is on one line, line then -1; else the name under
' the cursor, with line and character the place of its character there
' that the compiler is asked about, both counted from 0, as it counts.
diff --git a/add-in/Sources/WindowApi.twin b/add-in/Sources/WindowApi.twin
index accdaa45c..1703cb161 100644
--- a/add-in/Sources/WindowApi.twin
+++ b/add-in/Sources/WindowApi.twin
@@ -1,7 +1,7 @@
' The Win32 calls the detached help window needs: where the compiler is, the
' window's place, state and frame, the move loop its title bar starts, the IDE's
-' "Show real OS titlebar" setting, and the compiler's environment, so that no
-' other file declares a Win32 function.
+' "Show real OS titlebar" setting, the compiler's environment, and the sections
+' of the add-in's own settings, so that no other file declares a Win32 function.
Module WindowApi
Private Type RECT
Left As Long
@@ -66,6 +66,14 @@ Module WindowApi
ByVal lpValue As LongPtr, ByVal dwFlags As Long, ByVal pdwType As LongPtr, ByVal pvData As LongPtr, _
ByRef pcbData As Long) As Long
+ Private Declare PtrSafe Function RegOpenKeyExW Lib "advapi32" (ByVal hKey As LongPtr, ByVal lpSubKey As LongPtr, _
+ ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As LongPtr) As Long
+ Private Declare PtrSafe Function RegEnumKeyExW Lib "advapi32" (ByVal hKey As LongPtr, ByVal dwIndex As Long, _
+ ByVal lpName As LongPtr, ByRef lpcchName As Long, ByVal lpReserved As LongPtr, ByVal lpClass As LongPtr, _
+ ByVal lpcchClass As LongPtr, ByVal lpftLastWriteTime As LongPtr) As Long
+ Private Declare PtrSafe Function RegCloseKey Lib "advapi32" (ByVal hKey As LongPtr) As Long
+ Private Declare PtrSafe Function GetDpiForSystem Lib "user32" () As Long
+
Private Declare PtrSafe Function GetClientRect Lib "user32" (ByVal hWnd As LongPtr, ByRef lpRect As RECT) As Long
Private Declare PtrSafe Function ClientToScreen Lib "user32" (ByVal hWnd As LongPtr, ByRef lpPoint As POINTAPI) As Long
@@ -99,6 +107,9 @@ Module WindowApi
Private Const DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 As Long = 19
Private Const HKEY_CURRENT_USER As Long = &H80000001
Private Const RRF_RT_REG_SZ As Long = &H2
+ Private Const KEY_READ As Long = &H20019
+ ' Where SaveSetting keeps an application's sections, each a key of its own.
+ Private Const SETTINGS_ROOT As String = "Software\VB and VBA Program Settings\"
' Where the IDE keeps its options: one value, GENERAL, a JSON object.
Private Const IDE_SETTINGS_KEY As String = "Software\VB and VBA Program Settings\twinBASIC_IDE\IDESettings"
@@ -357,6 +368,40 @@ Module WindowApi
Return i
End Function
+ ' The dots per inch of the pixels this process places windows in: the
+ ' display's, as the compiler's process is aware of its scaling, or 96 in a
+ ' process that is not, whose places Windows scales.
+ Public Function ProcessDpi() As Long
+ On Error GoTo Failed
+ Dim dpi As Long = GetDpiForSystem()
+ If dpi > 0 Then Return dpi
+ Failed:
+ Return 96
+ End Function
+
+ ' The names of the sections SaveSetting has made inside an application's
+ ' section, such as "Layouts\Mine" inside "Layouts": the keys of the
+ ' registry inside its key, which GetAllSettings does not list. Empty when
+ ' the section is not there.
+ Public Function SettingSections(ByVal app As String, ByVal section As String) As Collection
+ Dim found As New Collection
+ Dim key As LongPtr
+ If RegOpenKeyExW(HKEY_CURRENT_USER, StrPtr(SETTINGS_ROOT & app & "\" & section), 0, KEY_READ, key) <> 0 Then
+ Return found
+ End If
+ Dim i As Long
+ Do
+ ' A key's name is at most 255 characters.
+ Dim size As Long = 256
+ Dim buffer As String = String$(size, vbNullChar)
+ If RegEnumKeyExW(key, i, StrPtr(buffer), size, 0, 0, 0, 0) <> 0 Then Exit Do
+ found.Add Left$(buffer, size)
+ i = i + 1
+ Loop
+ RegCloseKey key
+ Return found
+ End Function
+
' The text of the IDE's GENERAL option value, or "" if the IDE has not
' saved it.
Private Function ReadIdeOptions() As String
diff --git a/bugs/find-panel-keys-outside-panel/repro.json b/bugs/find-panel-keys-outside-panel/repro.json
new file mode 100644
index 000000000..4a70aceb4
--- /dev/null
+++ b/bugs/find-panel-keys-outside-panel/repro.json
@@ -0,0 +1,11 @@
+{
+ "mode": "lane",
+ "lane": "ide:quick-find-keys",
+ "tests": [
+ "with the panel closed, Alt+A in the code deletes every banana, the panel's Replace All, and selects no apple",
+ "with the panel closed, Alt+R in the code selects the next banana, and a second Alt+R deletes it",
+ "in Quick Find with apple and pear, Alt+R twice deletes a banana and replaces no apple",
+ "in Quick Find with apple and pear, Alt+A deletes every banana and replaces no apple"
+ ],
+ "steps": "1. Open a module that holds apple four times and banana four times. Put the caret inside a banana and press Ctrl+F: the Find / Replace panel floats with banana in Find What and Replace With empty. Press Esc to close it.\n2. Put the caret inside an apple and press Alt+A (Edit -> Select All Matches): a box says The specified region has been searched. 4 replacements were made., every banana is gone, and only the one cursor is left.\n3. Undo, put the caret inside an apple and press Alt+R twice: the first press selects the next banana, the second deletes it.\n4. Undo, press Alt+H, type apple in the box to find and pear in the replace box, and press Alt+R twice in the box to find: a banana is deleted and no apple is replaced. Alt+A there deletes every banana, with the same box."
+}
diff --git a/bugs/layout-loses-addin-toolwindow/layout-loses-addin-toolwindow.twinproj b/bugs/layout-loses-addin-toolwindow/layout-loses-addin-toolwindow.twinproj
new file mode 100644
index 000000000..cde714263
Binary files /dev/null and b/bugs/layout-loses-addin-toolwindow/layout-loses-addin-toolwindow.twinproj differ
diff --git a/bugs/layout-loses-addin-toolwindow/repro.json b/bugs/layout-loses-addin-toolwindow/repro.json
new file mode 100644
index 000000000..e7b057838
--- /dev/null
+++ b/bugs/layout-loses-addin-toolwindow/repro.json
@@ -0,0 +1,9 @@
+{
+ "mode": "lane",
+ "lane": "addin:toolwindow-layouts",
+ "tests": [
+ "applying a layout while the window floats shown takes it out of the page, keeps it in toolWindowsById, and the add-in hears no OnClose",
+ "applying a layout while the window is docked takes it out of the page, keeps it in toolWindowsById, and the add-in hears no OnClose"
+ ],
+ "steps": "This is an add-in project: building it makes a DLL that the IDE's compiler loads on every start until the DLL is removed. Install it knowingly, in an IDE you can restart, and remove it afterwards.\n1. Open layout-loses-addin-toolwindow.twinproj and build it for Win32. Copy Build\\LayoutLosesAddinToolwindow_win32.dll into %APPDATA%\\twinBASIC\\addins\\win32\\ and restart the IDE. Open any project: the toolbar has a button, Show the tool window.\n2. Control: with the window hidden, choose Window > Panel Layouts > Default Built-in Layout. The DEBUG CONSOLE prints OnClose: the IDE closed the window, and the add-in made it again.\n3. Click Show the tool window. The window REPRO WINDOW floats over the editor.\n4. Choose Window > Panel Layouts > Default Built-in Layout again. The window disappears, and the DEBUG CONSOLE prints no OnClose. Clicking Show the tool window prints shown, and no window appears; a compiler restart does not bring it back either, only a new IDE.\n5. Close the IDE and delete LayoutLosesAddinToolwindow_win32.dll from %APPDATA%\\twinBASIC\\addins\\win32\\.\nThe same happens to a window a layout docks. Asserted on BETA 1042 by `addin-test.bat --only toolwindow-layouts` (the LayoutsProbe add-in in test/addin/probes/layouts, of which this project is a cut-down copy)."
+}
diff --git a/bugs/layout-loses-addin-toolwindow/src/Settings b/bugs/layout-loses-addin-toolwindow/src/Settings
new file mode 100644
index 000000000..f23405ada
--- /dev/null
+++ b/bugs/layout-loses-addin-toolwindow/src/Settings
@@ -0,0 +1,46 @@
+{
+ "configuration.inherits": "Defaults",
+ "project.appTitle": "LayoutLosesAddinToolwindow",
+ "project.buildPath": "${SourcePath}\\Build\\${ProjectName}_${Architecture}.${FileExtension}",
+ "project.buildType": "Standard DLL",
+ "project.description": "Reproduces: Applying a panel layout loses an add-in's tool window that floats shown or is docked: it leaves the page, and the add-in's OnClose never runs",
+ "project.exportPathIsV2": true,
+ "project.id": "{985B5BC9-6711-478E-8A5E-09704E77DBD5}",
+ "project.name": "LayoutLosesAddinToolwindow",
+ "project.optionExplicit": true,
+ "project.references": [
+ {
+ "id": "{00020430-0000-0000-C000-000000000046}",
+ "lcid": 0,
+ "name": "OLE Automation",
+ "path32": "C:\\Windows\\SysWOW64\\stdole2.tlb",
+ "path64": "C:\\Windows\\System32\\stdole2.tlb",
+ "symbolId": "stdole",
+ "versionMajor": 2,
+ "versionMinor": 0
+ },
+ {
+ "id": "{99DEC38C-75F6-4488-8EE7-2D52D83881D2}",
+ "isCompilerPackage": true,
+ "licence": "MIT",
+ "name": "[COMPILER PACKAGE] twinBASIC IDE Extensibility Package",
+ "path32": "",
+ "path64": "",
+ "publisher": "TWINBASIC-COMPILER",
+ "symbolId": "tbIDE",
+ "versionBuild": 0,
+ "versionMajor": 0,
+ "versionMinor": 0,
+ "versionRevision": 1
+ }
+ ],
+ "project.settingsVersion": 1,
+ "project.warnings": {
+ "errors": [],
+ "hints": [],
+ "ignored": [],
+ "info": [],
+ "warnings": []
+ },
+ "runtime.useUnicodeStandardLibrary": true
+}
diff --git a/bugs/layout-loses-addin-toolwindow/src/Sources/Startup.twin b/bugs/layout-loses-addin-toolwindow/src/Sources/Startup.twin
new file mode 100644
index 000000000..7524a856a
--- /dev/null
+++ b/bugs/layout-loses-addin-toolwindow/src/Sources/Startup.twin
@@ -0,0 +1,49 @@
+' An add-in with one tool window, hidden, and a toolbar button that shows it.
+' When the IDE closes the window, as applying a panel layout does, OnClose prints
+' "OnClose" to the DEBUG CONSOLE and the add-in adds the window again, hidden, as
+' an add-in that keeps its window does. On BETA 1042, applying a layout while the
+' window floats shown, or is docked, takes the window out of the page, and OnClose
+' never runs: the window is gone, and the add-in does not know.
+Module Startup
+ [DllExport]
+ Public Function tbCreateCompilerAddin(ByVal Host As Host) As AddIn
+ Return New ReproAddin(Host)
+ End Function
+End Module
+
+Private Class ReproAddin
+ Implements AddIn
+ Private WithEvents Host As Host
+ Private WithEvents ShowButton As Button
+ Private WithEvents Pane As ToolWindow
+
+ Public Sub New(ByVal Host As Host)
+ Set Me.Host = Host
+ End Sub
+
+ Private Property Get AddIn_Name() As String
+ Return "LayoutLosesAddinToolwindow AddIn"
+ End Property
+
+ Private Sub Host_OnProjectLoaded()
+ Set ShowButton = Host.Toolbars(0).AddButton("ReproShow", "Show the tool window")
+ MakePane
+ Host.DebugConsole.PrintText "loaded"
+ End Sub
+
+ Private Sub MakePane()
+ Set Pane = Host.ToolWindows.Add("Repro", "ReproPane")
+ Pane.Title = "REPRO WINDOW"
+ Pane.RootDomElement.ChildDomElements.Add("reproText", "div").Properties.innerText = "the add-in's tool window"
+ End Sub
+
+ Private Sub ShowButton_OnClick()
+ Pane.Visible = True
+ Host.DebugConsole.PrintText "shown"
+ End Sub
+
+ Private Sub Pane_OnClose()
+ Host.DebugConsole.PrintText "OnClose"
+ MakePane
+ End Sub
+End Class
diff --git a/bugs/quick-find-enter-in-replace-box/repro.json b/bugs/quick-find-enter-in-replace-box/repro.json
new file mode 100644
index 000000000..5e82c63d6
--- /dev/null
+++ b/bugs/quick-find-enter-in-replace-box/repro.json
@@ -0,0 +1,8 @@
+{
+ "mode": "lane",
+ "lane": "ide:quick-find-keys",
+ "tests": [
+ "Enter in Quick Find's replace box adds a line break to the replacement, which Replace All writes into the code"
+ ],
+ "steps": "1. Open a module that holds apple four times. Press Alt+H, type apple in the box to find, press Tab and type pear in the replace box.\n2. Press Enter in the replace box: nothing is replaced, and the box grows to two lines; the replacement is now pear and a line break.\n3. Click Replace All: each apple becomes pear followed by a line break, and the module has four lines more."
+}
diff --git a/bugs/toolwindow-show-suggested-size/repro.json b/bugs/toolwindow-show-suggested-size/repro.json
new file mode 100644
index 000000000..40128c061
--- /dev/null
+++ b/bugs/toolwindow-show-suggested-size/repro.json
@@ -0,0 +1,9 @@
+{
+ "mode": "lane",
+ "lane": "addin:toolwindow-layouts",
+ "tests": [
+ "hidden and shown again, a window the layout floats takes the add-in's suggested size, not the layout's",
+ "a window resized by hand with the mouse takes the suggested size too when hidden and shown"
+ ],
+ "steps": "This is an add-in project: building it makes a DLL that the IDE's compiler loads on every start until the DLL is removed. Install it knowingly, in an IDE you can restart, and remove it afterwards.\n1. Open toolwindow-show-suggested-size.twinproj and build it for Win32. Copy Build\\ToolwindowShowSuggestedSize_win32.dll into %APPDATA%\\twinBASIC\\addins\\win32\\ and restart the IDE. Open any project: the toolbar has a button, Show or hide the tool window.\n2. Click the button. The window REPRO WINDOW floats in the middle of the IDE, 500 by 600 pixels, the size the add-in suggests.\n3. Drag the window's right edge to the left and its bottom edge up, to make it about half that size.\n4. Click the button twice: the window hides, then shows again at 500 by 600.\n5. Close the IDE and delete ToolwindowShowSuggestedSize_win32.dll from %APPDATA%\\twinBASIC\\addins\\win32\\.\nThe same happens to a window a panel layout floats at its own size. Asserted on BETA 1042 by `addin-test.bat --only toolwindow-layouts` (the LayoutsProbe add-in in test/addin/probes/layouts, of which this project is a cut-down copy)."
+}
diff --git a/bugs/toolwindow-show-suggested-size/src/Settings b/bugs/toolwindow-show-suggested-size/src/Settings
new file mode 100644
index 000000000..a7407c80a
--- /dev/null
+++ b/bugs/toolwindow-show-suggested-size/src/Settings
@@ -0,0 +1,46 @@
+{
+ "configuration.inherits": "Defaults",
+ "project.appTitle": "ToolwindowShowSuggestedSize",
+ "project.buildPath": "${SourcePath}\\Build\\${ProjectName}_${Architecture}.${FileExtension}",
+ "project.buildType": "Standard DLL",
+ "project.description": "Reproduces: Showing a floating add-in tool window again gives it the add-in's suggested size, losing the size a panel layout or a resize by hand gave it",
+ "project.exportPathIsV2": true,
+ "project.id": "{8E605D2E-2E90-4F65-876B-12B7CFC87383}",
+ "project.name": "ToolwindowShowSuggestedSize",
+ "project.optionExplicit": true,
+ "project.references": [
+ {
+ "id": "{00020430-0000-0000-C000-000000000046}",
+ "lcid": 0,
+ "name": "OLE Automation",
+ "path32": "C:\\Windows\\SysWOW64\\stdole2.tlb",
+ "path64": "C:\\Windows\\System32\\stdole2.tlb",
+ "symbolId": "stdole",
+ "versionMajor": 2,
+ "versionMinor": 0
+ },
+ {
+ "id": "{99DEC38C-75F6-4488-8EE7-2D52D83881D2}",
+ "isCompilerPackage": true,
+ "licence": "MIT",
+ "name": "[COMPILER PACKAGE] twinBASIC IDE Extensibility Package",
+ "path32": "",
+ "path64": "",
+ "publisher": "TWINBASIC-COMPILER",
+ "symbolId": "tbIDE",
+ "versionBuild": 0,
+ "versionMajor": 0,
+ "versionMinor": 0,
+ "versionRevision": 1
+ }
+ ],
+ "project.settingsVersion": 1,
+ "project.warnings": {
+ "errors": [],
+ "hints": [],
+ "ignored": [],
+ "info": [],
+ "warnings": []
+ },
+ "runtime.useUnicodeStandardLibrary": true
+}
diff --git a/bugs/toolwindow-show-suggested-size/src/Sources/Startup.twin b/bugs/toolwindow-show-suggested-size/src/Sources/Startup.twin
new file mode 100644
index 000000000..78ffd5af7
--- /dev/null
+++ b/bugs/toolwindow-show-suggested-size/src/Sources/Startup.twin
@@ -0,0 +1,42 @@
+' An add-in with one tool window, hidden, which suggests a size of 500 by 600
+' pixels, and a toolbar button that shows the window and hides it again. On BETA
+' 1042, each time the button shows the floating window it is 500 by 600 again,
+' whatever size it was resized to, by hand or by a panel layout.
+Module Startup
+ [DllExport]
+ Public Function tbCreateCompilerAddin(ByVal Host As Host) As AddIn
+ Return New ReproAddin(Host)
+ End Function
+End Module
+
+Private Class ReproAddin
+ Implements AddIn
+ Private WithEvents Host As Host
+ Private WithEvents ToggleButton As Button
+ Private Pane As ToolWindow
+ Private Shown As Boolean
+
+ Public Sub New(ByVal Host As Host)
+ Set Me.Host = Host
+ End Sub
+
+ Private Property Get AddIn_Name() As String
+ Return "ToolwindowShowSuggestedSize AddIn"
+ End Property
+
+ Private Sub Host_OnProjectLoaded()
+ Set ToggleButton = Host.Toolbars(0).AddButton("ReproToggle", "Show or hide the tool window")
+ Set Pane = Host.ToolWindows.Add("Repro", "ReproPane")
+ Pane.Title = "REPRO WINDOW"
+ With Pane.RootDomElement
+ .Properties.suggestedWidth = "500px"
+ .Properties.suggestedHeight = "600px"
+ .ChildDomElements.Add("reproText", "div").Properties.innerText = "the add-in's tool window"
+ End With
+ End Sub
+
+ Private Sub ToggleButton_OnClick()
+ Shown = Not Shown
+ Pane.Visible = Shown
+ End Sub
+End Class
diff --git a/bugs/toolwindow-show-suggested-size/toolwindow-show-suggested-size.twinproj b/bugs/toolwindow-show-suggested-size/toolwindow-show-suggested-size.twinproj
new file mode 100644
index 000000000..d573d2ba1
Binary files /dev/null and b/bugs/toolwindow-show-suggested-size/toolwindow-show-suggested-size.twinproj differ
diff --git a/builder/page-baseline.json b/builder/page-baseline.json
index c10561351..1f96fae93 100644
--- a/builder/page-baseline.json
+++ b/builder/page-baseline.json
@@ -1,5 +1,5 @@
{
"src": "docs",
"pages": 1517,
- "staticFiles": 1233
+ "staticFiles": 1245
}
diff --git a/builder/render.mjs b/builder/render.mjs
index 0d625c14b..141b18bdd 100644
--- a/builder/render.mjs
+++ b/builder/render.mjs
@@ -1981,7 +1981,7 @@ const ADMONITION_TYPES = {
// per-line anchor on the body lines.
// The rest of the `[!TYPE]` line is the callout's label (lib/callout-labels.mjs).
const ADMONITION_RE =
- /(^|\n)([ \t]*)>[ \t]*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]([^\n]*)\n((?:\2[ \t]*>[ \t]*[^\n]*(?:\n|$))(?:(?![ \t]*>[ \t]*\[!)\2[ \t]*>[ \t]*[^\n]*(?:\n|$))*)?/g;
+ /(^|\n)([ \t]*)>[ \t]*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|ADDIN)\]([^\n]*)\n((?:\2[ \t]*>[ \t]*[^\n]*(?:\n|$))(?:(?![ \t]*>[ \t]*\[!)\2[ \t]*>[ \t]*[^\n]*(?:\n|$))*)?/g;
// An admonition written inside a code region is a sample of the syntax, and is
// left as it is. This rewrite runs outside the mask, so it asks lib/markdown
// where the regions are, with the site's parser for the reason
@@ -2019,6 +2019,8 @@ export function rewriteAdmonitions(src, md, { packageVersion } = {}) {
if (inCode[line]) return match;
const type = typeRaw.toLowerCase();
+ const stripRe = indent ? new RegExp(`^${escapeRegExp(indent)}[ \\t]*>[ \\t]?`, "gm") : /^[ \t]*>[ \t]?/gm;
+ if (type === "addin") return `${leading}${addinBox(labelRaw, bodyRaw, stripRe)}`;
const meta = ADMONITION_TYPES[type];
const label = parseCalloutLabel(labelRaw);
const problem =
@@ -2047,7 +2049,6 @@ export function rewriteAdmonitions(src, md, { packageVersion } = {}) {
// A fence inside an admonition is stripped with the rest of the body, so
// this runs over real code samples: a literal mirror leaves If/ElseIf/Else
// bodies flush left and loses blank lines between examples.
- const stripRe = indent ? new RegExp(`^${escapeRegExp(indent)}[ \\t]*>[ \\t]?`, "gm") : /^[ \t]*>[ \t]?/gm;
const body = (bodyRaw ?? "").replace(stripRe, "").trimEnd();
// The gem emits the replacement
at column 0 regardless of how
@@ -2062,6 +2063,29 @@ export function rewriteAdmonitions(src, md, { packageVersion } = {}) {
});
}
+// What an add-in adds to the IDE, on a page that documents the IDE itself:
+//
+// > [!ADDIN] With the Help Add-In
+// > The add-in replaces this pane with a table of every command...
+//
+// It is written as a callout is, but it is none: no label, no icon, and the tools that read
+// callouts (lib/callout-labels.mjs) do not see it. The rest of the `[!ADDIN]` line is its
+// title, as plain text, and is required. It renders as a grey box (`.ide-addin`, admonitions.scss
+// and print.css) holding a that is open, so that a reader who does not use the add-in
+// can fold it away. The book unwraps and (book.mjs, bookChapterTransform),
+// and keeps the box and its title, which is why the title is a span of its own inside the
+// summary.
+function addinBox(titleRaw, bodyRaw, stripRe) {
+ const title = titleRaw.trim();
+ if (!title) throw new Error("callout [!ADDIN] needs a title on its line: > [!ADDIN] With the Help Add-In");
+ const body = (bodyRaw ?? "").replace(stripRe, "").trimEnd();
+ return (
+ `
\n\n`
+ );
+}
+
// ---------- markdown="1" attribute strip -----------------------------------
//
// With `html: true`, markdown-it already parses blank-line-separated
@@ -2433,6 +2457,37 @@ function remoteImagePlugin(md, ctx) {
// this).
const RASTER_FORMATS = { png: "PNG", jpg: "JPEG", jpeg: "JPEG", gif: "GIF", webp: "WebP" };
+// A picture marked `secondary` in its attribute block, `{:width="1016" height="723" secondary}`,
+// is shown at SECONDARY_SCALE of the size it would otherwise have in the content column: a
+// picture of something the page mentions in passing, such as what an add-in adds to the IDE.
+// The page keeps the picture's own size, which the screenshot tools write and
+// check_shot_sizes.mjs checks; the build scales the width and height it writes, each image of a
+// pair by the same factor, and puts the factor on the figure as `data-scale`, so that Zoom
+// (figure.js) shows the picture as large as it would show it unmarked.
+const SECONDARY_SCALE = 0.75;
+
+function dropAttr(token, name) {
+ token.attrs = token.attrs.filter(([n]) => n !== name);
+}
+
+// The images of a figure, `kids`, with `secondary` taken out and their sizes scaled when any of
+// them has it; returns the factor Zoom divides by, or null for a figure not marked.
+function shrinkSecondary(kids) {
+ if (!kids.some((k) => k.attrGet("secondary") !== null)) return null;
+ for (const k of kids) dropAttr(k, "secondary");
+ const dark = kids[kids.length - 1];
+ const w = Number(dark.attrGet("width"));
+ if (!(w > 0)) return SECONDARY_SCALE;
+ const scale = SECONDARY_SCALE * Math.min(1, FIGURE_COLUMN / w);
+ for (const k of kids) {
+ for (const attr of ["width", "height"]) {
+ const v = Number(k.attrGet(attr));
+ if (v > 0) k.attrSet(attr, String(Math.round(v * scale)));
+ }
+ }
+ return SECONDARY_SCALE;
+}
+
function figurePlugin(md, ctx) {
const orig = md.renderer.rules.image;
const prefix = `${ctx.baseurl || ""}/`;
@@ -2464,11 +2519,17 @@ function figurePlugin(md, ctx) {
toks[i].hidden = true;
toks[i + 2].hidden = true;
const open = new state.Token("figure_open", "div", 1);
- open.meta = { images: kids.slice() };
+ open.meta = { images: kids.slice(), secondary: shrinkSecondary(kids) };
if (kids.length === 1 && inlinableSvgRel(kids[0])) kids[0].meta = { ...(kids[0].meta || {}), figureInline: true };
kids.unshift(open);
kids.push(new state.Token("figure_close", "div", -1));
}
+ // `secondary` on an image that is no figure (text beside it, or inside a link) does
+ // nothing; the word is taken out all the same, as `png` is.
+ for (const t of toks) {
+ if (t.type !== "inline" || !t.children) continue;
+ for (const k of t.children) if (k.type === "image" && k.attrGet("secondary") !== null) dropAttr(k, "secondary");
+ }
});
md.renderer.rules.figure_open = (tokens, idx, options, env, self) => {
@@ -2488,7 +2549,12 @@ function figurePlugin(md, ctx) {
// and the page's width and height are the dark one's.
const dark = images[images.length - 1];
const src = dark.attrGet("src") ?? "";
- return pictureFigureOpen(resolveVendoredAttachment(src, ctx) ?? src, dark.attrGet("width"), dark.attrGet("height"));
+ return pictureFigureOpen(
+ resolveVendoredAttachment(src, ctx) ?? src,
+ dark.attrGet("width"),
+ dark.attrGet("height"),
+ tokens[idx].meta.secondary,
+ );
};
md.renderer.rules.figure_close = () => `
`;
@@ -2614,7 +2680,7 @@ function diagramFigureOpen(svgContent, alt, stem, srcRel) {
// The opening of a picture's or an image's figure. A picture drawn as SVG offers both
// formats, its PNG being beside it; a raster image offers its own format, copied as PNG,
// the one image format a clipboard takes. An image of any other kind gets Zoom alone.
-function pictureFigureOpen(src, width, height) {
+function pictureFigureOpen(src, width, height, secondary = null) {
const ext = /\.([a-z0-9]+)(?:[?#]|$)/i.exec(src)?.[1]?.toLowerCase() ?? "";
const raster = ext === "svg" ? "PNG" : RASTER_FORMATS[ext];
const groups = [];
@@ -2639,7 +2705,7 @@ function pictureFigureOpen(src, width, height) {
}
groups.push(zoomGroup());
return (
- `
` +
+ `
` +
`
` +
groups.join("") +
`
` +
diff --git a/docs/Documentation/Authoring.md b/docs/Documentation/Authoring.md
index b59f28f3a..44f4b98f8 100644
--- a/docs/Documentation/Authoring.md
+++ b/docs/Documentation/Authoring.md
@@ -829,6 +829,8 @@ An image that stands alone in its paragraph is shown as a *figure*: the image wi
Give a picture its `{:width="..." height="..."}`. A figure at least as tall as the bar stood on end gets the bar beside it, in the margin of a wide window and in view while the figure scrolls past. A shorter figure gets the bar above it or at its top right. A picture with no stated size is treated as short, however tall it is.
+A picture of something the page mentions only in passing --- on an IDE page, what an add-in adds to the IDE --- can be shown smaller: put `secondary` in its attribute block, `{:width="1016" height="723" secondary}`. The page keeps the picture's own size, and the build shows it at three quarters of the size it would otherwise have in the column. **Zoom** shows it as large as it would show it without the word. The build takes the word out of the page.
+
### A picture in both themes
A screenshot of the IDE shows one of its themes, and the site has two. To give a picture a version for the light theme, save it beside the first one under the same name with `.light` before the extension:
@@ -994,6 +996,19 @@ A search that backtracks without end gives up instead of hanging.
A region may hold paragraphs, lists, tables and samples, and regions do not nest. The folder's README says how to write a case, and [`check_package_tests.mjs`](Tools-Toolchain-Tests#check-package-tests), in `test.bat`, fails a callout with neither a marker nor a region, a region left open, and a case no marker names. [`package-tests.bat`](Tools#package-testsbat) runs the cases. The section's landing page ends with a short **Test cases** section that links to the project the build publishes, `-tests.twinproj`. [Updating a Contributed Package](Contributed-Packages) lists the steps that move a section to a new version of its package.
+### What an add-in adds to the IDE
+
+A page about the IDE documents the IDE as it ships. Where an add-in changes what the page describes, such as the [Help Add-In](../../tB/IDE/AddIns/Help) giving **Manage Keyboard Shortcuts** a table of commands, say so after the IDE's own behaviour, in a box of its own:
+
+```markdown
+> [!ADDIN] With the Help Add-In
+> The [Help Add-In](../AddIns/Help#the-keyboard-shortcut-editor) replaces this pane with a table of every command.
+>
+> {:width="1016" height="723" secondary}
+```
+
+It is written as a callout is, but it is none. The rest of the `[!ADDIN]` line is its title, as plain text, and the build stops on a box without one. The website and the offline copy show it on a grey background, as a disclosure that is open until the reader folds it; the PDF book shows the grey box and its title. Keep the box short: link to the section of the add-in's own page that has the details, and mark a picture in it `secondary` (see [A figure's buttons](#a-figures-buttons)).
+
## Document the product as it is
twinBASIC is in a long beta, and names still move. **When one does, document the current
diff --git a/docs/IDE/AddIns/Help.md b/docs/IDE/AddIns/Help.md
index 842d30dc1..549497006 100644
--- a/docs/IDE/AddIns/Help.md
+++ b/docs/IDE/AddIns/Help.md
@@ -80,7 +80,7 @@ Without a **Description** attribute, the summary says *No description*. **Open i
The gear opens the settings. A click anywhere else, or Esc, closes them.
-{:width="480" height="200"}
+{:width="480" height="234"}
**Hover help**
: Adds the links described under [Hover help](#hover-help). Off by default.
@@ -94,6 +94,12 @@ The gear opens the settings. A click anywhere else, or Esc, closes them.
**Find in the shortcut editors**
: Ctrl+F and F3 in the text of **Manage Keyboard Shortcuts** and **Manage Panel Layouts**: see [Finding text in the shortcut editors](#finding-text-in-the-shortcut-editors). On by default.
+**Keyboard shortcut editor**
+: Shows the groups of **Manage Keyboard Shortcuts** as a table of commands: see [The keyboard shortcut editor](#the-keyboard-shortcut-editor). On by default. Turned off, the dialog shows the IDE's own pane again at once.
+
+**Panel layout editor**
+: Shows the layouts of **Manage Panel Layouts** as a picture: see [The panel layout editor](#the-panel-layout-editor). On by default. Turned off, the dialog shows the layout's text again at once.
+
The settings, the last page shown and the help window's place are kept in the registry, under `HKEY_CURRENT_USER\Software\VB and VBA Program Settings\tbDocsHelp`. After the IDE restarts, the pane shows the page it showed last.
## The help window
@@ -115,6 +121,10 @@ The gear
The window is open again the next time the IDE starts, if it was open when the IDE closed. With **Show real OS titlebar** turned on in the IDE's options, the window has an ordinary Windows title bar instead, in the IDE's dark or light colours, and **Attach** and the gear move next to the search box.
+### The help window in panel layouts
+
+Each [panel layout](../Customising/Panel-Layouts) also keeps where the help is: in its pane, or in its own window and where that window is on the screen. **Window > Panel Layouts > Save Current Panel Layout As...** records where the help is at that moment. Choosing the layout later puts the help back there: it detaches the help into its window at the recorded place, or attaches it to its pane. A built-in layout, and a layout saved while the add-in was not loaded, leave the help where it is. The add-in keeps this itself, by the layout's name, and not in the layout's text. In **Manage Panel Layouts**, the help's panel has a box to change it: see [The panel layout editor](#the-panel-layout-editor).
+
## Other add-ins' shortcuts
While this add-in is loaded, the keyboard shortcuts that other add-ins register with Ctrl or Alt work. Without it, the IDE does not run an add-in's shortcut that includes Ctrl or Alt: see [KeyboardShortcuts](../../Packages/tbIDE/KeyboardShortcuts). The IDE's own command on the same keys still runs as well. The setting **Ctrl and Alt shortcuts of add-ins** turns this off.
@@ -139,6 +149,96 @@ The search goes round past the end, and ignores case. The text scrolls to show e
{:width="795" height="184"}
+## The keyboard shortcut editor
+
+On its own, **Window > Keyboard Shortcuts > Manage Keyboard Shortcuts** shows each group of shortcuts as JSON text, and with **Edit as JSON** cleared only the line *Keyboard editor coming soon*. While this add-in is loaded, the dialog shows the selected group as a table instead, with a row for every command of the IDE. [Keyboard shortcuts](../Customising/Keyboard-Shortcuts) explains the groups and how they are layered.
+
+{:width="1016" height="723"}
+
+A row has the command's name, its keys, and a line on what the command does, from the [keyboard shortcuts reference](../Reference/Keyboard-Shortcuts). The rows are grouped by the prefix of the command's name; clicking a prefix folds its rows. In a group of your own, the keys of a row show what the earlier groups give the command and what this group changes:
+
+- a grey key comes from an earlier group;
+- a blue key is set by this group;
+- a dashed key that is struck through is one this group removes;
+- a yellow key is also bound to another command, and a group of your own made one of the two bindings. Its tooltip names the other command and the group. The IDE runs each command bound to a key whose context applies, in its own order, until one of them ends the key's handling. Keys that the built-in group gives to several commands are not marked, since those commands apply in different places;
+- a red key that is struck through can never run, such as a key the IDE has no name for, or a key with Ctrl or Alt that runs when released. Its tooltip says why.
+
+The conflicts are found across every group that is switched on, the group shown and any group added in the dialog included. A row also says when a later group changes the command again, since this group's keys are then not the ones that apply.
+
+The box at the top finds commands by name, by description, or by the name of a key, such as `ctrl+d`. **Find a key** waits for a key and finds the commands bound to it. The buttons beside it show every command, only those with keys, only those this group changes, or only those with a problem.
+
+Clicking a row of a group of your own opens its editor:
+
+Keys from earlier groups
+: **Keep them, and add these** writes the entry as `+command`, and **Replace them with these** as `command`, so that only this group's keys apply.
+
+Add a key
+: Waits for a key: press it with its modifiers. Esc stops waiting. Esc and Tab on their own, and keys the IDE has no name for, such as `;`, cannot be added here; the JSON view takes any key string.
+
+When a key runs
+: **When pressed**, **When pressed, and while held**, or **When released**. A key with Ctrl or Alt never runs when released, so that choice is not offered for it.
+
+With an argument
+: For `tbDebugConsole_ExecuteCode`, a key that runs the command with an argument, such as `? Now`. Type the argument, then add its key.
+
+Reset to earlier groups
+: Removes the group's entry for the command.
+
+No keys
+: Gives the command no keys, whatever the earlier groups give it.
+
+Each change is written into the group's text: **Save Changes** saves it, and **Cancel** discards it. The built-in group is read-only, and its rows open no editor. The **JSON** button at the bottom shows the group's text, as the IDE shows it with **Edit as JSON** ticked, and **Table** shows the table again. A group whose text is not valid JSON is shown as text until it is corrected. Entries for a command the IDE does not have are listed at the top of the table, where a group of your own can remove them.
+
+In the table, Esc closes the open editor, then clears the search, and never closes the dialog. Ctrl+F goes to the search box. While the table is on, the dialog's text leaves out its last line, which promises a proper editor. The setting **Keyboard shortcut editor** turns the table off, and gives the dialog its own pane and text back.
+
+## The panel layout editor
+
+On its own, **Window > Panel Layouts > Manage Panel Layouts** shows each layout as JSON text. While this add-in is loaded, the dialog shows the selected layout as a picture instead: a small IDE window, at the proportions of the IDE's own, with every docked panel in its place and every floating panel over them. [Panel layouts](../Customising/Panel-Layouts) explains the layouts and their text.
+
+{:width="1016" height="642"}
+
+Each tile shows the panel's name and its size: a share of its group, *takes the rest* or *fits its contents*. Clicking a tile selects it, and clicking the gap round a group selects the group. The box beside the picture then shows what can be changed:
+
+Where
+: The groups that hold the panel, from the whole window inwards. Clicking one selects it.
+
+Its members are
+: For a group: **Side by side** or **One above another**. In the layout's text these are `vertical` and `horizontal`.
+
+Its width, Its height
+: **The rest** gives the panel the room its neighbours leave, **A share** a percentage of its group, and **To fit** as much as its contents need.
+
+Move left, Move right, Move up, Move down
+: Swaps the panel with its neighbour.
+
+Make it float
+: Takes the panel out of its group and floats it where the IDE floats a panel it shows: 100 pixels from the left and from the top, 300 wide and 500 high. A group left with one member is replaced by it.
+
+Remove from this layout
+: Takes the panel out of the layout.
+
+A floating panel's box has its place in the IDE window, in pixels, and **Dock it...**. Dragging a splitter between two tiles resizes them, and dragging a floating panel by its title moves it.
+
+The panels the layout lacks are listed above the picture, the tool windows of the add-ins that are loaded among them. Clicking one, or **Dock it...**, then clicking near an edge of a tile docks the panel on that side of it: in the tile's group when the group's members run that way, or in a new group of the two. **Make it float** floats it instead.
+
+**Use the current arrangement** replaces the layout with the panels as the IDE shows them now, and with where the help is now.
+
+The help's own panel, **TWINBASIC HELP**, has one more box, **With the Help Add-In**, for [where the layout puts the help](#the-help-window-in-panel-layouts):
+
+**In this panel**
+: Choosing the layout attaches the help to its pane. Chosen for a layout whose help was in its own window, it also floats the pane where the window was, at the window's size and inside the IDE window, and adds the pane to the layout if it lacked it. Dock it again if you wish.
+
+**In its own window**
+: Choosing the layout detaches the help into its window, placed at **Left** and **Top** and sized to **Width** and **Height**: pixels on the screen. The window is drawn in the picture at that place, inside the picture if it is outside the IDE window. Clicking it selects the help's panel, or shows the box alone when the layout has no pane for the help.
+
+{:width="1016" height="642"}
+
+A layout for which neither has been chosen leaves the help where it is. Like every other change, the choice is kept by **Save Changes** and discarded by **Cancel**. **Save Changes** also forgets what the add-in kept for the layouts deleted in the dialog.
+
+A tile of an add-in's window that no loaded add-in has is marked *not loaded*. That is no problem: the IDE keeps the window's place, empty and marked *(currently unavailable)*, until the add-in opens it. The line under the picture counts the layout's panels and its problems: a layout with no Editor, a panel in it twice, or an id that is not a panel of the IDE. A layout with a problem is marked with **!** in the list.
+
+Each change is written into the layout's text: **Save Changes** saves it, and **Cancel** discards it. The built-in layouts are read-only. The **JSON** button at the bottom shows the layout's text, and **Picture** shows the picture again. A layout whose text is not valid JSON is shown as text until it is corrected. In the picture, Esc ends what is being done --- docking a panel, then the selection --- and never closes the dialog. The setting **Panel layout editor** turns the picture off, and gives the dialog its text back.
+
## Getting the add-in
The add-in is a twinBASIC project, which the IDE builds into two DLLs, one for each bitness.
diff --git a/docs/IDE/AddIns/Images/Help_KeyEditor.light.png b/docs/IDE/AddIns/Images/Help_KeyEditor.light.png
new file mode 100644
index 000000000..649f01dbc
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_KeyEditor.light.png differ
diff --git a/docs/IDE/AddIns/Images/Help_KeyEditor.light.svg b/docs/IDE/AddIns/Images/Help_KeyEditor.light.svg
new file mode 100644
index 000000000..6a8a3859c
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_KeyEditor.light.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_KeyEditor.png b/docs/IDE/AddIns/Images/Help_KeyEditor.png
new file mode 100644
index 000000000..f702623eb
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_KeyEditor.png differ
diff --git a/docs/IDE/AddIns/Images/Help_KeyEditor.svg b/docs/IDE/AddIns/Images/Help_KeyEditor.svg
new file mode 100644
index 000000000..7bbe932d8
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_KeyEditor.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_LayoutEditor.light.png b/docs/IDE/AddIns/Images/Help_LayoutEditor.light.png
new file mode 100644
index 000000000..08f760c41
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_LayoutEditor.light.png differ
diff --git a/docs/IDE/AddIns/Images/Help_LayoutEditor.light.svg b/docs/IDE/AddIns/Images/Help_LayoutEditor.light.svg
new file mode 100644
index 000000000..696142878
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_LayoutEditor.light.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_LayoutEditor.png b/docs/IDE/AddIns/Images/Help_LayoutEditor.png
new file mode 100644
index 000000000..c654c4eaa
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_LayoutEditor.png differ
diff --git a/docs/IDE/AddIns/Images/Help_LayoutEditor.svg b/docs/IDE/AddIns/Images/Help_LayoutEditor.svg
new file mode 100644
index 000000000..adf193a35
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_LayoutEditor.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_LayoutHelp.light.png b/docs/IDE/AddIns/Images/Help_LayoutHelp.light.png
new file mode 100644
index 000000000..04fb915c1
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_LayoutHelp.light.png differ
diff --git a/docs/IDE/AddIns/Images/Help_LayoutHelp.light.svg b/docs/IDE/AddIns/Images/Help_LayoutHelp.light.svg
new file mode 100644
index 000000000..5e3dd3eb9
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_LayoutHelp.light.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_LayoutHelp.png b/docs/IDE/AddIns/Images/Help_LayoutHelp.png
new file mode 100644
index 000000000..92d72899f
Binary files /dev/null and b/docs/IDE/AddIns/Images/Help_LayoutHelp.png differ
diff --git a/docs/IDE/AddIns/Images/Help_LayoutHelp.svg b/docs/IDE/AddIns/Images/Help_LayoutHelp.svg
new file mode 100644
index 000000000..9991b73d2
--- /dev/null
+++ b/docs/IDE/AddIns/Images/Help_LayoutHelp.svg
@@ -0,0 +1 @@
+
diff --git a/docs/IDE/AddIns/Images/Help_Settings.light.png b/docs/IDE/AddIns/Images/Help_Settings.light.png
index 70fbe94d4..66bf1c326 100644
Binary files a/docs/IDE/AddIns/Images/Help_Settings.light.png and b/docs/IDE/AddIns/Images/Help_Settings.light.png differ
diff --git a/docs/IDE/AddIns/Images/Help_Settings.light.svg b/docs/IDE/AddIns/Images/Help_Settings.light.svg
index 0aeead650..12ca64839 100644
--- a/docs/IDE/AddIns/Images/Help_Settings.light.svg
+++ b/docs/IDE/AddIns/Images/Help_Settings.light.svg
@@ -1 +1 @@
-
+MainMiscellaneousPackagesReferencesResourcesSourcesInventory.twinTWINBASIC HELPOpen in browserDetachSearch the documentation/Packages/Default Packages/VBA Package/Interaction ModuleMsgBoxDisplays a message in a modal dialog with a chosen set ofbuttons, waits for the user to click a button, and returns aVbMsgBoxResult value identifying that button.Syntax: MsgBox(prompt [ ,buttons ] [ ,title ] [ ,helpfile,contextMsgBoxHover helpAll packagesCtrl and Alt shortcuts of add-insFind in the shortcut editorsKeyboard shortcut editorPanel layout editor
diff --git a/docs/IDE/AddIns/Images/Help_Settings.png b/docs/IDE/AddIns/Images/Help_Settings.png
index 3dc37c28c..d50f0cf1d 100644
Binary files a/docs/IDE/AddIns/Images/Help_Settings.png and b/docs/IDE/AddIns/Images/Help_Settings.png differ
diff --git a/docs/IDE/AddIns/Images/Help_Settings.svg b/docs/IDE/AddIns/Images/Help_Settings.svg
index e81d14918..ce28a8e63 100644
--- a/docs/IDE/AddIns/Images/Help_Settings.svg
+++ b/docs/IDE/AddIns/Images/Help_Settings.svg
@@ -1 +1 @@
-MainMiscellaneousPackagesReferencesResourcesSourcesInventory.twinTWINBASIC HELPOpen in browserDetachSearch the documentation/Packages/Default Packages/VBA Package/Interaction ModuleMsgBoxDisplays a message in a modal dialog with a chosen set ofbuttons, waits for the user to click a button, and returns aVbMsgBoxResult value identifying that button.MsgBoxHover helpAll packagesCtrl and Alt shortcuts of add-insFind in the shortcut editors
+MainMiscellaneousPackagesReferencesResourcesSourcesInventory.twinTWINBASIC HELPOpen in browserDetachSearch the documentation/Packages/Default Packages/VBA Package/Interaction ModuleMsgBoxDisplays a message in a modal dialog with a chosen set ofbuttons, waits for the user to click a button, and returns aVbMsgBoxResult value identifying that button.Syntax: MsgBox(prompt [ ,buttons ] [ ,title ] [ ,helpfile,contextMsgBoxHover helpAll packagesCtrl and Alt shortcuts of add-insFind in the shortcut editorsKeyboard shortcut editorPanel layout editor
diff --git a/docs/IDE/Code/Editor.md b/docs/IDE/Code/Editor.md
index c84c36a31..99f81120e 100644
--- a/docs/IDE/Code/Editor.md
+++ b/docs/IDE/Code/Editor.md
@@ -346,6 +346,9 @@ The palette also lists **Rename Symbol** (see [above](#rename-symbol-and-change-
The key beside an action in the palette is the key Monaco gives it. It is not always a key that works in the IDE. The IDE stops every key press with Ctrl held from reaching the editor, apart from the commands it binds itself. So a palette action that shows a key with Ctrl does not respond to that key. The Monaco keys F1, F8, Shift+F8 and Shift+Alt+F do nothing. F1 does not open the palette, so open it from the menu.
+> [!ADDIN] With the Help Add-In
+> F1 opens the page of this documentation that describes the name at the cursor: see [F1 and the help pane](../AddIns/Help#f1-and-the-help-pane).
+
{:width="736" height="235"}
## Save often
diff --git a/docs/IDE/Code/Finding.md b/docs/IDE/Code/Finding.md
index 03fd3c4ea..c881f3237 100644
--- a/docs/IDE/Code/Finding.md
+++ b/docs/IDE/Code/Finding.md
@@ -158,7 +158,7 @@ If **Find What** is not in the `/pattern/flags` form, a box says **Invalid forma
> [!NOTE] BETA 1042
-> A regular expression whose match spans a line break, such as `/^\s+end sub$/`, selects nothing. The selection is an empty one at the end of the line before the match, and **Find Next** stays there. Search for one line at a time.
+> A regular expression whose match spans a line break, such as `/^\s+end sub$/`, selects nothing. The selection is an empty one at the end of the line before the match, and **Find Next** stays there. Search for one line at a time, or use [Quick Find](#regular-expressions-in-quick-find), which can match across lines.
> [!NOTE] BETA 1042
@@ -196,18 +196,59 @@ The Quick Find widget searches the file you are in, with a small box at the top
| Show an earlier search | Up |
| Show a later search | Down |
-The widget opens with the selected text in its box, and with the count of the matches, such as *1 of 10*. Its toggles are **Match Case**, **Match Whole Word**, **Use Regular Expression** and **Find in Selection**, and the replace row has **Preserve Case**. Shift+Enter does nothing. The IDE does not remember the toggles between uses.
+The widget opens with the selected text in its box, and with the count of the matches, such as *1 of 10*. Its toggles are **Match Case**, **Match Whole Word**, **Use Regular Expression** and **Find in Selection**, and the replace row has **Preserve Case**. The toggles have no keys: click them. Shift+Enter does nothing. The IDE does not remember the toggles between uses.
{:width="752" height="430"}
With a word selected, Ctrl+F3 in the code goes to its next occurrence and shows the widget.
+
+> [!NOTE] BETA 1042
+> Enter in the replace box replaces nothing. It adds a line break to the replacement, and the box grows to two lines; **Replace All** then writes that line break into the code after each replacement. Take the line break out with Backspace, and click **Replace** or **Replace All** instead.
+
+### Regular expressions in Quick Find
+
+With **Use Regular Expression** on, the text in the box is a JavaScript regular expression, written without slashes: `/total/` looks for the slashes too. A pattern with capital letters finds text in any case unless **Match Case** is on.
+
+Quick Find reads the file one line at a time, so a match never spans a line break, unless the pattern holds `\n`, `\r` or `\W`. Then it reads the whole file, with each line break as `\n`:
+
+- Write `\n` where a line breaks. `\r\n` finds nothing.
+- `\s` and `[\s\S]` on their own keep the search on one line. `Info[\s\S]*Name` finds nothing when `Info` and `Name` are on different lines.
+- In a pattern that holds `\n`, `\s` matches a line break too. Match the spaces at the start of the next line with `[ \t]*` rather than `\s*`, which can also take in blank lines.
+
+In the replace row, `$1`, `$2` and so on put back the text that each group in brackets matched, and `\n` starts a new line. For example, to change each pair of lines such as
+
+```text
+s.Enum_Info "Red"
+s.Enum_Info 1
+```
+
+into
+
+```text
+s.Enum_Name "Red"
+s.Enum_Value 1
+```
+
+open Quick Replace with Alt+H, click **Use Regular Expression** to turn it on, fill in the two boxes, and click **Replace All**:
+
+| Box | Text |
+|---|---|
+| Find | `s\.Enum_Info(.*)\n([ \t]*)s\.Enum_Info` |
+| Replace | `s.Enum_Name$1\n$2s.Enum_Value` |
+
+`(.*)` takes the rest of the first line, and `([ \t]*)` the spaces in front of the second.
+
### Select all matches
**Edit → Select All Matches** (Alt+A) opens the widget, gives a cursor to every match of the text in it, and closes the widget. You can then type to change every match at once; see [several cursors](Editor#several-cursors-at-once). Ctrl+Shift+L does the same with the word at the caret, with no widget.
While the focus is in the Find / Replace panel, Alt+A is **Replace All** and Alt+F goes to **Find What**. In the editor they run Select All Matches and Quick Find.
+
+> [!WARNING] BETA 1042
+> Once the panel's **Find What** holds text, as it does after any search with the panel, Alt+A and Alt+R run the panel's **Replace All** and **Replace** in the code and in Quick Find too, even with the panel closed. They use the panel's **Find What** and **Replace With**, not the text in Quick Find. Alt+A in the code then selects nothing, replaces every match of **Find What** in the file, and a box says how many; Ctrl+F empties **Replace With**, so the matches are deleted. Alt+R selects the panel's next match, and a second press replaces it with no message. To select every match, use Ctrl+Shift+L on the word, and press neither Alt+A nor Alt+R in the code or in Quick Find.
+
## See Also
- [Edit menu](../Reference/Menu/Edit) -- the menu that holds the find commands
diff --git a/docs/IDE/Code/IntelliSense.md b/docs/IDE/Code/IntelliSense.md
index cdb17e5db..0333d749a 100644
--- a/docs/IDE/Code/IntelliSense.md
+++ b/docs/IDE/Code/IntelliSense.md
@@ -81,6 +81,9 @@ Under the signature is the first line of the procedure's documentation. For a pr
F1 expands the box to the whole documentation, shown as formatted text. F1 again collapses it. The fold icon at the left of the box does the same when you click it.
+> [!ADDIN] With the Help Add-In
+> F1 on a name also opens the name's page of this documentation in a tool window, whether or not the box is open: see [F1 and the help pane](../AddIns/Help#f1-and-the-help-pane).
+
{:width="1400" height="306"}
Esc, Up, Down and Backspace close the box. Typing `)` over the closing bracket that the editor added with `(` leaves the box open, and so does Enter.
@@ -103,6 +106,11 @@ Hovering over a wavy underline shows the compiler's message, as `TBnnnn:` follow
While a program is stopped in the debugger, the popup also evaluates the expression under the pointer.
+> [!ADDIN] With the Help Add-In
+> The popup can start with a link to the page of this documentation that describes the name: see [Hover help](../AddIns/Help#hover-help).
+>
+> {:width="889" height="495" secondary}
+
The hover text is in English whatever the [language of the IDE](../Customising/#the-language-of-the-ide) is.
## Inline code hints
diff --git a/docs/IDE/Customising/Keyboard-Shortcuts.md b/docs/IDE/Customising/Keyboard-Shortcuts.md
index 94e3f556c..aa08c02c4 100644
--- a/docs/IDE/Customising/Keyboard-Shortcuts.md
+++ b/docs/IDE/Customising/Keyboard-Shortcuts.md
@@ -52,6 +52,11 @@ The **Edit as JSON** box is ticked. If you clear it, the pane shows only the tex
{:width="1016" height="740"}
+> [!ADDIN] With the Help Add-In
+> The [Help Add-In](../AddIns/Help#the-keyboard-shortcut-editor) replaces this pane with a table of every command, where a group's keys are changed by pressing them, and conflicts between commands are marked. It also adds Ctrl+F and F3 to search the JSON text, which has no find of its own: see [Finding text in the shortcut editors](../AddIns/Help#finding-text-in-the-shortcut-editors).
+>
+> {:width="1016" height="723" secondary}
+
**Add New...**
: Asks for a name, then creates a group that holds one sample entry, `{"tbMisc_ShowTestMessage":["{KEYDOWN}{CTRL}0"]}`. Ctrl+0 then opens a test dialog that reads *This is just a test modal dialog.* A name that starts with `<` is refused with a message that says *Custom panel name cannot begin with '<'*, although it means a group name. A name that contains a vertical bar is refused with *Group name cannot contain '|'*, because the IDE saves the list of groups that are on as their names, each between two bars, such as `|Mine||Other|`. A name already in use is refused with *Group already exists*.
diff --git a/docs/IDE/Customising/Panel-Layouts.md b/docs/IDE/Customising/Panel-Layouts.md
index 3f1c92ce6..52a1de80a 100644
--- a/docs/IDE/Customising/Panel-Layouts.md
+++ b/docs/IDE/Customising/Panel-Layouts.md
@@ -63,6 +63,11 @@ Choose **Window → Panel Layouts → Manage Panel Layouts...** to add and delet
The list on the left holds ` (built-in)` and ` (built-in)`, which are read-only, and then your layouts. Each of yours has a close icon that removes it. The pane on the right shows the selected layout as text, which you can edit unless it is a built-in layout.
+> [!ADDIN] With the Help Add-In
+> The [Help Add-In](../AddIns/Help#the-panel-layout-editor) shows each layout as a picture of the IDE window instead of text, where a panel is resized, moved, floated or docked by clicking and dragging, and a layout without the Editor is marked. Each layout also keeps [whether the help is in its pane or in its own window](../AddIns/Help#the-help-window-in-panel-layouts), and where that window is. The text has no find of its own: the add-in also adds Ctrl+F and F3 to search it, as described in [Finding text in the shortcut editors](../AddIns/Help#finding-text-in-the-shortcut-editors).
+>
+> {:width="1016" height="642" secondary}
+
**Add New...**
: Asks for a name in a box that reads *<new name>*. Enter creates a layout that is a copy of the Default layout, and Esc cancels. A name that starts with `<` is refused with the message *Custom panel name cannot begin with '<'*. A name that contains a vertical bar is refused with *Group name cannot contain '|'*, and a name already in use with *Group already exists*.
diff --git a/docs/IDE/Menu/Window.md b/docs/IDE/Menu/Window.md
index e3d0f6271..2deb7be1f 100644
--- a/docs/IDE/Menu/Window.md
+++ b/docs/IDE/Menu/Window.md
@@ -29,6 +29,9 @@ Switches the arrangement of the panels, and saves and manages arrangements. See
Opens a dialog that lists the built-in layouts, which are read-only, and the saved ones. See [Manage layouts](../../Customising/Panel-Layouts#manage-layouts).
+> [!ADDIN] With the Help Add-In
+> The dialog shows each layout as a picture of the IDE window instead of text: see [The panel layout editor](../../AddIns/Help#the-panel-layout-editor). The [Help Add-In](../../AddIns/Help#finding-text-in-the-shortcut-editors) also adds a find to the dialog's text.
+
## Panel Features
Five switches decide what can be done to panels. A tick means the action is allowed. See [Panel Features](../../Customising/Panel-Layouts#panel-features).
@@ -45,6 +48,9 @@ Switches groups of keyboard shortcuts on and off. See [Keyboard shortcuts](../..
Opens a dialog that lists the built-in group, which is read-only, and the groups that have been created, and shows each as JSON text. See [Manage keyboard shortcuts](../../Customising/Keyboard-Shortcuts#manage-keyboard-shortcuts) and [The text of a group](../../Customising/Keyboard-Shortcuts#the-text-of-a-group).
+> [!ADDIN] With the Help Add-In
+> The dialog shows each group as a table of commands instead of JSON text: see [The keyboard shortcut editor](../../AddIns/Help#the-keyboard-shortcut-editor).
+
[Keyboard shortcuts](../Keyboard-Shortcuts) lists the built-in group in tables.
## Theme
diff --git a/docs/_sass/custom/admonitions.scss b/docs/_sass/custom/admonitions.scss
index 938fe5428..8b4dbb381 100644
--- a/docs/_sass/custom/admonitions.scss
+++ b/docs/_sass/custom/admonitions.scss
@@ -89,6 +89,34 @@ $alert-colors-dark: (
@include alert-palette($alert-colors-light);
}
+// What an add-in adds to the IDE, on a page that documents the IDE itself
+// (`> [!ADDIN] title`, render.mjs's addinBox): a grey box holding a ,
+// open until the reader folds it. The tint is the text colour's, as a figure's
+// bar is (custom.scss, .fig-group), so it darkens the page in the light theme
+// and lightens it in the dark one with no rule per theme, and every colour
+// inside it keeps the contrast it has on the page. The summary keeps the UA's
+// `list-item` display: its triangle is what says it folds (see .section-links
+// in custom.scss).
+.ide-addin {
+ margin-bottom: 1rem;
+ padding: 0.5rem 1rem;
+ border-radius: 6px;
+ background: color-mix(in srgb, currentColor 6%, transparent);
+
+ > details > summary {
+ cursor: pointer;
+ font-weight: 500;
+ }
+
+ > details[open] > summary {
+ margin-bottom: 0.5rem;
+ }
+
+ > details > :last-child {
+ margin-bottom: 0;
+ }
+}
+
// custom.scss is emitted once at root level -- just-the-docs-dark.scss
// deliberately does not @use it -- so the dark variants are scoped here
// rather than inherited from a dark-theme compilation pass. The dark-theme
diff --git a/docs/_sass/custom/custom.scss b/docs/_sass/custom/custom.scss
index c42ae718d..31cf82c95 100644
--- a/docs/_sass/custom/custom.scss
+++ b/docs/_sass/custom/custom.scss
@@ -912,7 +912,9 @@ div.highlight:focus-visible,
// heading, a paragraph, a `.download-meta` line and a `.download-actions` row
// of `.btn` links (the theme's, styled in both themes) and one
// `.download-doc` link. The grid takes as many 18rem columns as fit, and one
-// at phone width. The actions row follows the text directly.
+// at phone width. Each card is a column the height of its grid row, and the
+// actions row's top margin takes the slack, so the buttons of the cards in one
+// row line up along the bottom whatever the length of the text above them.
//
// The heading's top margin is the theme's `.main-content h3`, which the dark
// re-emission raises to (0,2,2); `> :first-child` here is (0,3,0) and wins in
@@ -925,6 +927,8 @@ div.highlight:focus-visible,
}
.download-card {
+ display: flex;
+ flex-direction: column;
padding: 1rem 1.25rem;
border: 1px solid #e6e1e8; // $grey-lt-300
border-radius: 6px;
@@ -938,6 +942,12 @@ div.highlight:focus-visible,
margin-top: 0;
}
+// A flex column does not collapse margins, so the meta line's top margin would
+// add to the paragraph's bottom one; collapsed, the paragraph's was the gap.
+.main-content .download-card > .download-meta {
+ margin-top: 0;
+}
+
@include dark-theme {
.download-card {
border-color: #44434d; // dark $border-color
@@ -953,7 +963,7 @@ div.highlight:focus-visible,
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
- margin: 0;
+ margin: auto 0 0;
}
.download-size {
diff --git a/docs/assets/css/print.css b/docs/assets/css/print.css
index 715f60dcb..011ef9b26 100644
--- a/docs/assets/css/print.css
+++ b/docs/assets/css/print.css
@@ -767,5 +767,23 @@ blockquote {
.markdown-alert-tip { border-left-color: #1a7f37; }
.markdown-alert-tip .markdown-alert-title { color: #1a7f37; }
+/* What an add-in adds to the IDE (`> [!ADDIN] title`, render.mjs's addinBox). Its
+ and are unwrapped for the book (book.mjs), which leaves the box
+ and the title's own span. No break-inside: avoid, since the box may hold a picture. */
+.ide-addin {
+ background: #f3f3f3;
+ border-radius: 3pt;
+ margin: 0.8em 0;
+ padding: 0.4em 0.8em 0.5em;
+}
+
+.ide-addin-title {
+ display: block;
+ font-weight: 700;
+ margin: 0 0 0.3em;
+}
+
+.ide-addin > :last-child { margin-bottom: 0; }
+
/* A command's name on the Keyboard Shortcuts page: custom.scss says why. */
.command-prefix { font-size: 0; }
diff --git a/docs/assets/js/figure.js b/docs/assets/js/figure.js
index afdb7b29c..6160a6f50 100644
--- a/docs/assets/js/figure.js
+++ b/docs/assets/js/figure.js
@@ -291,7 +291,10 @@
// size is known. The element's own inline style is kept to be put back
// as it was: an SVG may carry its size there.
el._pageStyle = el.getAttribute("style");
- el.style.width = zoomWidth(el, rect.width, rect.height / rect.width, container) + "px";
+ // A picture marked secondary (render.mjs, SECONDARY_SCALE) is shown smaller on the
+ // page by this factor; zoomed, it is as large as it would be unmarked.
+ var scale = parseFloat(container.closest(".fig-wrap").dataset.scale) || 1;
+ el.style.width = zoomWidth(el, rect.width / scale, rect.height / rect.width, container) + "px";
el.style.height = "auto";
el.style.maxWidth = "none";
}
diff --git a/scripts/ide-js/lib.mjs b/scripts/ide-js/lib.mjs
index a7c418fe9..9af6b7adf 100644
--- a/scripts/ide-js/lib.mjs
+++ b/scripts/ide-js/lib.mjs
@@ -685,6 +685,13 @@ export function commandTextProblems(ids, text) {
};
}
+/**
+ * The help add-in's copy of the data file (`add-in/Resources/KEYS/commands.json`), which its
+ * keyboard shortcut editor shows beside each command: the same object, on one line, since the
+ * add-in puts it into the IDE's page inside a script.
+ */
+export const addinCommandText = (text) => `${JSON.stringify(text)}\n`;
+
/** The prefix of a command's name, its underscore included; "" for a name with no underscore. */
const commandPrefix = (id) => id.slice(0, id.indexOf("_") + 1);
diff --git a/scripts/ide_js.mjs b/scripts/ide_js.mjs
index 401463c67..9b9340d8a 100644
--- a/scripts/ide_js.mjs
+++ b/scripts/ide_js.mjs
@@ -20,6 +20,7 @@ import path from "node:path";
import { die, exitOnCrash, parseCli, printHelpAndExit, withUsageError } from "../lib/cli.mjs";
import { REPO_ROOT } from "../lib/repo-paths.mjs";
import {
+ addinCommandText,
buildOf,
builtInCommandIds,
builtInKeymap,
@@ -52,6 +53,7 @@ exitOnCrash();
const DEFAULT_MAP = path.join(REPO_ROOT, "scripts", "ide-js", "names.json");
const KEYMAP_PAGE = path.join(REPO_ROOT, "docs", "IDE", "Reference", "Keyboard-Shortcuts.md");
const COMMAND_TEXT = path.join(REPO_ROOT, "scripts", "ide-js", "command-text.json");
+const ADDIN_COMMAND_TEXT = path.join(REPO_ROOT, "add-in", "Resources", "KEYS", "commands.json");
const USAGE = `usage: node scripts/ide_js.mjs [arguments] [--ide ] [--map ] [--out ] [--copy-to ] [--all] [--json] [--check] [--update] [-h, --help]
@@ -91,7 +93,9 @@ Commands:
--check compares the page with them and also fails
for a command with no description, or a description
for a command the build lacks; --update writes the
- page
+ page; both do the same for the help add-in's copy
+ of the descriptions, add-in/Resources/KEYS/
+ commands.json
Options:
--ide the install: its twinBASIC.exe, its folder or a main.js
@@ -414,15 +418,25 @@ if (command === "keymap") {
const page = readFileSync(KEYMAP_PAGE, "utf8");
const { current, expected, text: updated } = pageKeymap(page, sections);
const name = path.relative(REPO_ROOT, KEYMAP_PAGE);
+ // The help add-in's copy of the descriptions, which its shortcut editor shows.
+ const copyName = path.relative(REPO_ROOT, ADDIN_COMMAND_TEXT);
+ const copy = addinCommandText(text);
+ const copyNow = existsSync(ADDIN_COMMAND_TEXT) ? readFileSync(ADDIN_COMMAND_TEXT, "utf8") : null;
if (values.update) {
writeFileSync(KEYMAP_PAGE, updated);
console.log(`${name}: ${current === expected ? "unchanged" : `written from ${build ?? "the build"}`}`);
+ if (copyNow !== copy) {
+ mkdirSync(path.dirname(ADDIN_COMMAND_TEXT), { recursive: true });
+ writeFileSync(ADDIN_COMMAND_TEXT, copy);
+ }
+ console.log(`${copyName}: ${copyNow === copy ? "unchanged" : `written from ${dataName}`}`);
process.exit(0);
}
const diff = lineDiff(current, expected, { context: 0 });
if (diff) console.log(diff);
console.log(`${name}: ${diff ? `differs from ${build ?? "the build"}` : `the same as ${build ?? "the build"}`}`);
- process.exit(diff || missing.length || extra.length ? 1 : 0);
+ console.log(`${copyName}: ${copyNow === copy ? `the same as ${dataName}` : `differs from ${dataName}`}`);
+ process.exit(diff || missing.length || extra.length || copyNow !== copy ? 1 : 0);
}
// patch and shape
diff --git a/scripts/lib/tb-defaults.mjs b/scripts/lib/tb-defaults.mjs
index 5e8a6f278..9e1fbb49f 100644
--- a/scripts/lib/tb-defaults.mjs
+++ b/scripts/lib/tb-defaults.mjs
@@ -52,19 +52,47 @@ export const BLANKED_KEYS = {
ALLOWERRORREPORTINGV3: "DISAGREED_TOOLS",
};
+// Defects of the IDE itself that every tool's IDE has fixed in its page, each named by the slug of
+// its entry in BUGS-TO-REPORT.md, whose own fix (bugs//fix.js) this applies at run time
+// rather than to the install. A fix acts only where the build still has the defect, so a build
+// that ships the fix leaves it nothing to do. The lane that asserts the defect leaves it unfixed
+// (launchIde's `unfixed`), so the entry is still checked against the plain build; and when the
+// entry is retired, its fix goes from here, and that lane's `unfixed` then fails until it goes too.
+// console-cleared-at-open: BETA 1042 empties the DEBUG CONSOLE a second time as the first project
+// opens, erasing what an add-in prints as it loads. The console's list (createListView) starts
+// with its useCachedItemHeights unset, and the first setUseCachedItemHeights(false) empties it. The
+// page sets the flag false as main.js assigns the list to `debugConsoleContent`, a `var` of
+// main.js with no initialiser, so the setter put on window here stays and sees the assignment.
+export const IDE_FIXES = ["console-cleared-at-open"];
+
// Runs in the page, in every document of the IDE's browser; only main.htm does anything.
-// `window.__tbDefaults` is the marker that it ran, and its `keys` the keys it answered
-// (never their values). A key it answers is never saved either: IDE_FLAGS stop every save of
+// `window.__tbDefaults` is the marker that it ran, its `keys` the keys it answered
+// (never their values), and its `fixes` the IDE_FIXES that found their defect and fixed it. A key it answers is never saved either: IDE_FLAGS stop every save of
// these keys but two, OBJECT_BROWSER's and NEWFRONTPAGE's, which test no flag (BETA 1034), so
// that merely closing the New / Open Project dialog would write the user's registry. Every
// function of the host object is bound to the real object: the proxy of a WebView2 host object
// refuses to be called with another `this`. A request for the error-report address is answered
// here and counted in `reports`, never sent, whatever g_ErrorReporting says: a page that turns
// reporting on (the question's YES) stays a page of a tool.
-export function pageHook(answers) {
+export function pageHook(answers, fixes = []) {
if (!/main\.htm$/i.test(location.pathname)) return;
- const marker = { keys: [], reports: 0 };
+ const marker = { keys: [], reports: 0, fixes: [] };
window.__tbDefaults = marker;
+ if (fixes.includes("console-cleared-at-open")) {
+ let list;
+ Object.defineProperty(window, "debugConsoleContent", {
+ configurable: true,
+ enumerable: true,
+ get: () => list,
+ set: (v) => {
+ if (v && typeof v === "object" && v.useCachedItemHeights === undefined) {
+ v.useCachedItemHeights = false;
+ if (!marker.fixes.includes("console-cleared-at-open")) marker.fixes.push("console-cleared-at-open");
+ }
+ list = v;
+ },
+ });
+ }
const send = window.fetch;
window.fetch = function (resource, ...rest) {
if (!/\/\/(www\.)?twinbasic\.com\/notify\b/i.test(String(resource?.url ?? resource))) {
@@ -132,7 +160,25 @@ export function pageHook(answers) {
});
}
-export const hookSource = () => `(${pageHook})(${JSON.stringify(BLANKED_KEYS)})`;
+export const hookSource = (fixes = IDE_FIXES) =>
+ `(${pageHook})(${JSON.stringify(BLANKED_KEYS)}, ${JSON.stringify(fixes)})`;
+
+/**
+ * The IDE_FIXES an IDE gets when `unfixed` are left out. Throws on a slug that is not one, so a
+ * caller still naming a fix that was removed with its retired entry fails rather than passes.
+ *
+ * @param {string[]} unfixed
+ * @returns {string[]}
+ */
+export function fixesWithout(unfixed = []) {
+ const unknown = unfixed.filter((s) => !IDE_FIXES.includes(s));
+ if (unknown.length) {
+ throw new Error(
+ `unfixed names no IDE fix: ${unknown.join(", ")} (tb-defaults.mjs IDE_FIXES: ${IDE_FIXES.join(", ")})`,
+ );
+ }
+ return IDE_FIXES.filter((s) => !unfixed.includes(s));
+}
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -152,6 +198,7 @@ const LOOK = "({ main: /main\\.htm$/i.test(location.pathname), ran: !!window.__t
* @param {object} o
* @param {string} o.profile the IDE's WEBVIEW2_USER_DATA_FOLDER
* @param {number} o.since when it was started; a DevToolsActivePort older than 2 s before is left over
+ * @param {string[]} [o.fixes] the IDE_FIXES its page makes (default all; fixesWithout)
* @returns {{ error: Error | null, closed: Promise, ready: Promise, stop: () => void }}
* `error` is why no hook was installed (set once known); `failures` the pages it could not
* prepare; `ready` settles once the hook is installed with every page then known prepared,
@@ -159,9 +206,11 @@ const LOOK = "({ main: /main\\.htm$/i.test(location.pathname), ran: !!window.__t
* connection, and is called when the IDE ends or fails to start. A hook that was installed leaves
* the page's `window.__tbDefaults`, which attachIde checks.
*/
-export function installDefaultsHook({ profile, since }) {
+export function installDefaultsHook({ profile, since, fixes = IDE_FIXES }) {
let markReady;
const hook = {
+ // The page's script, which checkDefaults adds again before a reload.
+ source: hookSource(fixes),
error: null,
failures: [],
trace: [],
@@ -203,7 +252,7 @@ export function installDefaultsHook({ profile, since }) {
client = await connect(`ws://127.0.0.1:${port}${wsPath}`, { what: `the IDE's browser on port ${port}` });
note("connected");
client.onClose(() => note("the connection closed"));
- const source = hookSource();
+ const { source } = hook;
// Every page prepared while the hook is set up, which `ready` waits for. A page that existed
// before the auto-attach (the case checkDefaults reloads for) is attached by setAutoAttach
// itself and prepared from its event: a reload before its script is added loads it unhooked
@@ -304,7 +353,7 @@ export async function checkDefaults(c, hook) {
// The script is added on this connection too, which stays open while the page reloads, so the
// reload is hooked whatever became of the hook's own session: a shoot_docs run of ten IDEs at
// once on BETA 1033 still reloaded a page unhooked once the hook waited for its pages.
- await c.send("Page.addScriptToEvaluateOnNewDocument", { source: hookSource() }).then(
+ await c.send("Page.addScriptToEvaluateOnNewDocument", { source: hook.source ?? hookSource() }).then(
() => step("the script added to the page"),
(e) => step(`adding the script to the page failed: ${e.message}`),
);
diff --git a/scripts/lib/tb-ide.mjs b/scripts/lib/tb-ide.mjs
index 1e8319dac..449e8303f 100644
--- a/scripts/lib/tb-ide.mjs
+++ b/scripts/lib/tb-ide.mjs
@@ -17,7 +17,7 @@ import { secondsText, timeoutMs } from "./harness-settings.mjs";
import { connectBroker } from "./tb-broker.mjs";
import { attach } from "./tb-cdp.mjs";
import { click, pagePicture } from "./tb-click.mjs";
-import { checkDefaults, installDefaultsHook } from "./tb-defaults.mjs";
+import { checkDefaults, fixesWithout, installDefaultsHook } from "./tb-defaults.mjs";
import { removeTree, removeTreeAsync } from "./tb-ide-copy.mjs";
import { consoleMark, keepClears, keptClears, linesSince, readConsole } from "./tb-ide-console.mjs";
import { unsupportedIde } from "./tb-install.mjs";
@@ -251,6 +251,10 @@ export async function leaseSlot({ tag = "", port = false } = {}) {
* layouts and keyboard groups, in the page only, so it runs with
* the defaults; tb-defaults.mjs). Only a tool that is the user's own
* IDE in all but its project passes true: try-help-addin
+ * @param {string[]} [o.unfixed] slugs of IDE_FIXES (tb-defaults.mjs) to leave out: the page
+ * fixes every defect named there unless told otherwise. Only the
+ * lane that asserts a defect leaves its fix out; a slug that is not
+ * one throws. With userSettings nothing is fixed
* @returns {Promise<{pid: number, launcher: import("node:child_process").ChildProcess | null, folders: string[], port: number | null, slot: number, desktop: string | null, hook: object | null}>}
* `pid` is the IDE's own. `folders` are its temp folder and WebView2 profile,
* which shutdownIde removes. `port` is its DevTools port, for attachIde, or
@@ -269,17 +273,32 @@ export async function launchIde({
browserArgs = "",
flags = IDE_FLAGS,
userSettings = false,
+ unfixed = [],
}) {
// Before anything starts: an IDE older than the flags would write the user's settings.
const tooOld = unsupportedIde(exe);
if (tooOld) throw new Error(tooOld);
+ const fixes = fixesWithout(unfixed);
if (port != null) await waitForPort(port);
const t0 = Date.now();
const own = slot ? null : await leaseSlot({ tag: `IDE ${path.basename(project || exe)}` });
const s = slot ?? own;
try {
const leased = Date.now();
- const started = await startIde({ exe, project, s, own, port, show, keep, env, browserArgs, flags, userSettings });
+ const started = await startIde({
+ exe,
+ project,
+ s,
+ own,
+ port,
+ show,
+ keep,
+ env,
+ browserArgs,
+ flags,
+ userSettings,
+ fixes,
+ });
timing("launch", {
project: project ? path.resolve(project) : null,
leaseMs: leased - t0,
@@ -293,7 +312,7 @@ export async function launchIde({
}
// launchIde once the slot is settled; `own` is the slot when it is launchIde's own to hand on.
-async function startIde({ exe, project, s, own, port, show, keep, env, browserArgs, flags, userSettings }) {
+async function startIde({ exe, project, s, own, port, show, keep, env, browserArgs, flags, userSettings, fixes }) {
const exeWin = exe.split("/").join("\\");
const target = project ? path.resolve(project).split("/").join("\\") : "";
// Each IDE has a temp folder of its own, emptied at each launch in its slot
@@ -336,7 +355,7 @@ async function startIde({ exe, project, s, own, port, show, keep, env, browserAr
// Started before the IDE is, since main.htm commits a fraction of a second after its port file
// is written; attachIde checks the hook ran, by the port. The hook's connection lives as long
// as this process, so a kept IDE (`keep`) is hooked only until this process ends.
- const hook = userSettings ? null : installDefaultsHook({ profile: ideProfile, since: started });
+ const hook = userSettings ? null : installDefaultsHook({ profile: ideProfile, since: started, fixes });
const hooked = async (pid, launcher) => {
const p = await found(pid);
if (hook && p) defaultsHooks.set(p, hook);
diff --git a/scripts/lib/tb-lane.mjs b/scripts/lib/tb-lane.mjs
index b6af19bf5..416b20479 100644
--- a/scripts/lib/tb-lane.mjs
+++ b/scripts/lib/tb-lane.mjs
@@ -206,10 +206,13 @@ export class Lane {
* @param {string} [o.arch] the build target, "win32" (the default) or "win64"
* @param {boolean} [o.show] build on the user's desktop; by default where the
* lane opens its IDEs
+ * @param {number} [o.timeout] milliseconds for the compile phase (default
+ * waitForCompile's: test/harness.json's compile), for an add-in whose compile
+ * is known to take longer, with the reason at the call
* @returns {Promise<{dll: string, arch: string, diagnostics: string[], log: string[]}>}
* buildAddin's result; it throws, with an exitCode, when the add-in does not build
*/
- async buildAddin(src, { arch = "win32", show = this.show } = {}) {
+ async buildAddin(src, { arch = "win32", show = this.show, timeout } = {}) {
if (this.run) throw new Error(`lane ${this.name}: close the open project before building an add-in`);
return buildAddin({
ide: this.copy(),
@@ -219,6 +222,7 @@ export class Lane {
arch,
show,
appdata: this.appdataDir(),
+ timeout,
});
}
@@ -231,11 +235,12 @@ export class Lane {
* @param {object} [o]
* @param {string} [o.arch] as for buildAddin
* @param {boolean} [o.show] as for buildAddin
+ * @param {number} [o.timeout] as for buildAddin
* @returns {Promise<{dll: string, arch: string, diagnostics: string[], log: string[]}>}
* as buildAddin
*/
- async addAddin(src, { arch = "win32", show = this.show } = {}) {
- const built = await this.buildAddin(src, { arch, show });
+ async addAddin(src, { arch = "win32", show = this.show, timeout } = {}) {
+ const built = await this.buildAddin(src, { arch, show, timeout });
this.placeAddin(built.dll, { arch });
return built;
}
@@ -285,9 +290,14 @@ export class Lane {
* (default IDE_FLAGS)
* @param {{ width: number, height: number } | null} [o.page] the page's size for this
* IDE (default the lane's `page`); null leaves the window's own
+ * @param {string[]} [o.unfixed] IDE defects the page leaves as the build has them, as
+ * launchIde takes them: only a lane that asserts one
* @returns {Promise