How to simulate a shift-double click on a file to allow it to be edited
Andrew Rawnsley (492) 1445 posts |
I’d like to have a button in a program which would effective “shift double click” a file to allow it to be edited. The obvious solution would have been some variant of filer_run but I can’t find what I’m looking for. What is the recommended way to trigger such an operation from with a C application? |
Alan Adams (2486) 1149 posts |
I think it’s a DataLoad message, probably broadcast. |
Stuart Swales (8827) 1357 posts |
Broadcast a Message_DataOpen with filetype set to 0xFFF |
Jean-Michel BRUCK (3009) 359 posts |
he button being a button action. via the default vent, I get this one in a toolbox handler
GdirPath is the application’path |
David J. Ruck (33) 1635 posts |
You might want to put in < pre>< code> < /code>< /pre>
|
Jean-Michel BRUCK (3009) 359 posts |
Thank you, for the advice, it’s much more readable. |
Chris Hall (132) 3554 posts |
A broadcast DataOpen message is what the OS does when you double-click on a file, after which (if it was ignored) it does the Run action for that type of file, probably just Run filename or Filer_Run filename. Shift-double-click is different – for example for a BASIC file it would run BASIC and load the file (rather than run the file) using the Alias..Load action for that type of file. Where no load action is specified it would have to resort to a broadcast message and then a Run? So you may know more about what sort of file you are trying to open in an editor, but a broadcast DataOpen might just run the file. |
Matthew Phillips (473) 721 posts |
Edited because Textile made part of my reply disappear. Not sure you’ve got that right, Chris. The To simulate shift-double-click on a file first broadcast a DataOpen message with the filetype set to FFF, as a recorded message, as Stuart suggests above. If that bounces back to you, then issue the command @RunType_FFF <filename> having first checked that |
Chris Hall (132) 3554 posts |
The PRM directs me to the chapter titled ‘Editors’ in the Style Guide – there is no such chapter. Firstly shift-double-click cannot simply be a double-click with shift held down. Otherwise a BASIC programme would not load into !Zap or !Edit on a shift-double-click, it would run. In fact shift-double-click does not use Alias$@LoadType_xxx at all. If you broadcasr a DataOpen message with the filetype set to FFF then I do not think a BASIC programme would be loaded into an editor correctly. I’m stumped. |
Matthew Harris (1462) 36 posts |
Looking into the Filer source would seem to suggest DataOpen with filetype == &FFF is what the Filer does: https://gitlab.riscosopen.org/RiscOS/Sources/Desktop/Filer/-/blob/master/s/Clicks#L527 Further up this routine, ‘initshiftstate’ is set to &FF when SHIFT held down or Double-Click-and-Hold happens and, if its a file being acted upon, broadcasts a DataOpen message with FileType &FFF |
Matthew Phillips (473) 721 posts |
If you use WimpMon or a similar tool to eavesdrop on all the messages passing between tasks, you’ll find that’s what happens. You’re right to be surprised, though. There is clearly code in the text editor, whether Zap, StrongEd, Edit or SrcEdit, which recognises that the file is BASIC and does something special. But that’s also the case for other file types when you shift-double-click. Absolute files will be shown using Zap’s code mode, Perl scripts will be shown in an appropriate mode, etc. Remember that on receiving a DataOpen message, the application is responsible for opening the file, and can check the real filetype then. It’s not like DataSave and the RAM transfer protocol where the editor only has the filetype in the message to go on. |
Stuart Swales (8827) 1357 posts |
The idea behind shift double-click was to allow arbitrary text – and binary – files to be easily loaded into Edit. The fact that Zap etc choose to have a peek at the actual file info and say ooh BASIC, let’s load it as BASIC and detokenise is…interesting. The less said about the -Shift etc options to Filer_Run the better. Who thought of that crap? |
Matthew Phillips (473) 721 posts |
But Edit also loads BASIC in a form in which you can edit it, when you shift-double-click. It doesn’t display it like a binary. |
Stuart Swales (8827) 1357 posts |
It does these days Matthew! I would guess that RISC OS 2 !Edit didn’t. Anyone care to try that? No, I thought not. |
Stuart Painting (5389) 714 posts |
(fires up !ArcEm) You’re right, it doesn’t :-) |
Matthew Phillips (473) 721 posts |
I vaguely remember having to load a BASIC editor on RISC OS 2, which had been built in to Arthur. I had forgotten that Edit did not handle BASIC back then. |
Steve Drain (222) 1620 posts |
That was probably ArmBE, but might have been Twin. With RO2 came a rash of BASIC to Text converters, too. |
Andrew Rawnsley (492) 1445 posts |
Thanks for all this, everyone :) The irony is that I did it in reverse for HTMLEdit (to allow it to open shift-double-clicked HTML files), but that was 20+ years ago now! |
GavinWraith (26) 1563 posts |
I think Joe Taylor and I were the first people to be using classrooms of Archimedes, conected to a central server. We encouraged students to write and save BASIC programs as text files. We downplayed line numbers and GOTOs, and encouraged use of the desktop. Later I got a site licence for StrongED, which replaced Edit. Joe wrote his Throwback application which became part of the general setup. All in all, I think it provided students with quite a handy programming environment. |