How would I best go about importing a disk-based plain text file to a texteditor.gadget? I mean, other than read text from the file and copy it to a memory buffer.
The autodoc says that GA_TEXTEDITOR_Contents can take a filehandle when I set my own GA_TEXTEDITOR_ImportHook, but a comment to the latter tag says that custom import hooks are currently not supported.
Also, the autodoc mentions "GM_TEXTEDITOR_Import" (and "GM_TEXTEDITOR_Export" as well) without any other reference.
So I'm a bit puzzled here.
Through trial and error, I have used the Reaction TextEditor in the GuideMaker program I wrote.
FWIW, here is my experience - this is with SDK 53.20, texteditor.gadget 53.15, texteditor.h, v1.22 2008/07/30 (texteditor.gadget v52.1 was bad news, with a freeze bug in it).
I think you are going to have to read the file into memory. At least that is what I ended up doing, and presenting an AmigaGuide node at a time to the user for editing.
You can use a SetGadgetAttrsA() with the TEXTEDITOR_Contents tag to start off or replace all the text. Other tags that seem to work ok were:
TEXTEDITOR_VertScroller, at least on creation of the text editor object. Just make a Reaction scroller object first for it.
GATextAttr, to set the font on creation of the text editor object.
TEXTEDITOR_AreaMarked, get it to tell if any text is currently marked.
also methods, via a call to DoGadgetMethodA()
GMTextEditorInsertText, and I think the .pos specification of the message.
GMTextEditorExportText, DoGadgetMethodA returns a pointer to a null delimited string.
GMTextEditorBlockInfo, fills the message with the limits of the marked area.
GMTextEditorMarkText, works, though I had to add 1 to the .stopcrsrx field in the message to include that column in the marking
GMTextEditorReplace, to replace the marked block with your own text.
I don't think I ever got these to work:
TEXTEDITOR_CursorX/Y to get or set
GMTextEditorARexxCmd
the rest of the features I just left alone, though if they all got implemented and were reliable, it would be a pretty nice gadget.
Tom
TBH, the autodocs for this gadget are sketchy, to say the least. I just checked the NotePad sources, and it loads the file into a memory block before setting the GA_TEXTEDITOR_Contents attribute.
Because the gadget maintains the text buffer internally, once the OM_SET method returns, you can free your loading buffer, as it's no longer required unless you want to do a "restore" type feature.
Simon
@tbreeden
That's what I feared :-( Another unimplemented feature, sadly.
@Rigo
We're doomed! :-)
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2