pluma like "External Tools" in my gambas :) :)
Posted
#1
(In Topic #807)
Guru

I added External tools to my ScriptEd editor as it's really useful.
now i've finally managed to do the same with Gambas
https://gitlab.com/bsteers4/gambas/-/tree/External-Tools
It works well
it creates a dir to store the scripts in $HOME/.local/share/gambas3/
Data can be passed to the scripts with tokens…
Tokens
"$GB_FILEPATH": "Full File path",
"$GB_FILENAME": "The file name",
"$GB_DIRECTORY": "The files Directory",
"$GB_SELECTED": "Selected text",
"$GB_ALLTEXT": "All Text"
results from the script can be inserted into document or replace the whole text if it's been processed.
Undo will still work if you error
Here it is in action translating my selected text to French
(Tokens are prefixed SE_ in clip, i changed it to GB_)
<VIDEO content="https://bws.org.uk/screenrecord-2022-01-20_04.32.05.mp4">[video]
it needs a bit of error handling , it currently pops a warning if the active document is a form but that is all. I want it to work on most type of opened documents. (not sure how many other workspace views might not be text)
But dang this will be useful.
Posted
Trainee
How does it integrate into the ide, will i have to do a merge every time the IDE is updated?
It is something I have been looking for, How are the plugins executed from the IDE?
Thanks for your work on this!
Posted
Guru

I added a menu to FMain.form
I added an action for the menu click in FMain.class
Code (gambas)
- Case "external-tools"
- FExternalTools.Run
I added 2 commands to the FEditor.class _init() method to load the tools config and make the menus on startup.
Code (gambas)
- CExternalTools.GetTools
- CExternalTools.AddMenus
Everything else is dealt with by the added FExternalTools.class and CExternlalTools.class
To have it you'd need to modify your own git branch. Just set the upstream to the main gambas gitlab (i assume you know how to do that?) then you can 'git pull upstream master' to keep up to date with Bens changes.
Make a branch from master and i can send a merge request if you like. then you could examine the diff and apply the changes in your own way.
Posted
Guru

justlostintime said
Hi Bruce,
How does it integrate into the ide, will i have to do a merge every time the IDE is updated?
It is something I have been looking for, How are the plugins executed from the IDE?
Thanks for your work on this!
To add further to integration.
My last explanation says how it adds the Tools manager to the gambas IDE,
this is how it runs the tools…
Each tool set saves as a script file in the settings folder.
When a tool is run the Project.ActiveWindow is checked for either a FEditor (gambas code) object or a FTextEditor (other text).
with access to that i have access to many functions. that's how it gets the file name/text/selected text/etc and is the object to use .Insert() on to insert any text. also with this pointer i have been able to add some options like Save document first, Format code and reload.
When run a tool script file is read and any tokens replaced in the text with the data then saved as a temp file and executed/then deleted.
if option to insert results is used then result is inserted.
Posted
Trainee
Once loaded as a plugin the scripts would have direct access to all parts of the ide.
Posted
Guru

justlostintime said
Have you thought about loading gambas scripts as plugins for the tools.
Once loaded as a plugin the scripts would have direct access to all parts of the ide.
I think that's going a bit high tech , i like this low-brow thing i have done, it's not too invasive on the IDE, just a menu and a way to export/import to and from the source text.
i think plugins with direct access to the ide will screw Bens life up with problems/bugs that are out of his control/understanding because of sketchy code (like mine lol
Not saying it's not a good idea m8, i've shown you how to integrate something like this into the IDE here but you probably know more about integrating scripts into already running apps than i do so I'll leave it with you
I think a side-goal here , as well as having a really handy feature for custom actions, is to help ease Bens load, the External Tools feature could turn a whole lot of "can you make gambas do this?" requests into , "Yes, it already can, just make an External Tool command"
But i sense he is VERY reluctant to have things that mess about with IDE at a code level , I do it, my bruces-patched branch has the Bonus-Tweaks / custom component launcher feature (pretty sure Ben hates it, but i love it) that shows custom components as they look in the IDE as opposed to the normal just a box with it's name. But when working on a component it causes various problems especially when adding/removing properties, the properties change in the loaded project but the IDE still has the old version loaded so raises errors. you just have to compile the control and re-start gambas.
Going off point a bit there though, the point was as i'm mucking around with the IDE i am causing problems that someone who didn't understand might get on the bugtracker and report a bug to Ben. So wouldn't want that.
Just something i think to be aware of if adding things to customize the IDE, especially things that access internal objects.
I could push this to a merge request and see if Ben likes it or not (the concept, not the code, pretty sure he'll be horrified at my code lol, he just understands how to do things properly better than all of us)
But he could take the merge and clean it up to be all gambas perfect, who knows eh?
Posted
Guru

Posted
Guru

I also made it detect if your script is bash or gambas and the editor is a TextEditor with highlighting and stuff.
now I can use the $GB_CLIPBOARD token to use the clipboard contents in the script.
Also the result of the script can be copied to the clipboard.
8-)
I just wrote a quick gbs script…
And have set the tool to use the Selected text.
So now I can select some text like…
Settings["MycheckValue"] = cbxMyValue.Value
Then selecting the external tool spins it around and copies it to the clipboard so i can pop up to Form_Open() and paste…
cbxMyValue.Value = Settings["MycheckValue"]
(been wanting something like that for a while, every time i'm writing my options code)
Aah the possibilities
Posted
Guru

Posted
Guru

Changed many things like a Treeview now and you can add folders/submenus
GUI looks lush , it adopts your IDE Theme for the text editor.
Getting ready to submit for merge now
(attachment removed)
That gives me this menu…
(attachment removed)
Posted
Guru

(my External-Tools branch is master+external tools mod)
let me know your fork/test branch details.
All the best
Posted
Guru

Although..
He is interested in a possible "plugin" type thing similar to what i have done here but on a more intricate level, something able to properly monkey around with things using gambas written plugins.
Personally I think if he does all i'm going to want a a script launching plugin like this as I want to make my own quick scripts in bash or gbs and not have to work out some complicated plugin API , or have a limited choice of functions.
but here's hoping it won't take long to convert this mod into a plugin it it becomes an option.
Plugins could e awesome, Bens wish is that tay be gambas applications soall sorts could be possible.
Charlie,, an InFile.plugin ?
(Ps. i can now use InFile with my gambas through the External Tools mod like i could my Editor
Just FYI for this External Tools mod of master branch i have added the following…
Drag-n-drop..
menu order can now be re-arranged with dragging them around ,
New scripts can be added to the menu by dropping them directly on the manager list.
Added key shortcut Ctrl+E
Ctrl+Alt+E opens the script manager window.
Ctrl+E pops open the menu at mouse pos for quick access.
1 guest and 0 members have just viewed this.



