# interface

The first time you run pwa/p2js you should get a placeholder text as shown above.
[BUG: The automated tests are being added when they should not, and killing that placeholder text...]
Subsequent runs start on whatever file was open the last time it was closed, as shown in the following image.
The online repl has an additional output panel (image below to be updated, right now it’s just pwa/js/poc/drop.html)
Note the main area is not a full-fledged editor: this is designed to work both on the desktop and in the browser.
In particular it has no save function, you’ll have to make do with Ctrl C, and the syntax colouring is both a somewhat slow single-shot-whole-file affair (you can/must key Ctrl S to re-apply, see also technicalia below), and completely generic - it colours JavaScript and Phix code in exactly the same manner and does not attempt anything at all on any html fragments.
I will also state that showing line numbers is decidedly non-trivial and completely beyond my abilities. (xpGUI should fix that)
The Choose File button opens a standard file dialog.
To the right of that is a dropdown of recent files (desktop only, in the browser it is just a label).
[actually... the online version should ask the server for a directory listing...]
Top right is a source type selector which should be set automatically on open/drop but needs manual setting for paste/type.
Setting the source type dropdown automatically mirrors in the output dropdown at the bottom of the screen, ie phix<==>js/html.
The main text area has the limitations above, also notice how IupMainLoop() is coloured red, to remind/warn you it cannot be invoked in the browser, in this case it’s fine because of the enclosing platform() test.
The tokens and parse tree buttons can be hidden via the options, since they are only useful for development of pwa/p2js itself.
The [incomplete] violations button is intended to show [a summary of] unsupported or incompatible items.
The output dropdown fairly obviously controls what will be generated (changes do not alter the input dropdown, unlike vice versa).
Show opens a new window with the generated source, Copy places the generated source in the system clipboard.
Run is only possible for js/html output in the browser, on the desktop it can run phix or fire up the browser.
Options [will] include show/hide tokens/parse, preserve comments, minify, embed (aka all-in-one single file), etc.
Help shows a single short popup which can fairly obviously only scratch the surface of what is here and in the source code.
Exit is I would hope entirely self-explanatory.
It is also [DEV will be] possible to run pwa/p2js in command-line mode without showing the gui, eg

> `p pwa\p2js -norun -src test.exw -out test.html`

The various command-line options are...
TBC...

Technicalia | Note that the syntax colouring for the "Show" pop-up will interrupt/"stack" any still in progress on the main window, and resume when it can, and possibly vice-versa. Also, while it is in progress, each "chunk" resets the mle to line 1 column 1, preventing attempts to scroll. Obviously a proper editor would only bother to syntax colour what is actually on-screen, and therefore be done in a flash, but that’s just not possible with a simple mle using ADDFORMATTAG_HANDLE. Even though, say, demo\pGUI\sample.exw is only just over 700 lines, it needs nearly 15,000 separate fragments, which is why it takes so long. The idle handler limits processing to 1000 at a time to keep the GUI responsive. Update: it should be significantly faster, near-instant in fact, using a gList... If/when this is ever ported to xpGUI, that should therefore be fixed. The Ctrl S handling is only applicable to the main window, since the Show pop-up is read-only.