Hello there! I would like to help improving blender’s text editor and I’ve been playing with it to see if I could build a simple auto close relevant characters like brackets and parenthesis. At the moment I have it working like this:
It also has the functionality of deleting the closing pair if it’s empty:
Any feedback or suggestions would be really appreciated!
Just make sure, before spending time on coding stuff, that the Text Editor module owner, @ideasman42 agrees to it, so you’ll not end up wasting your time.
Now the auto close option is also available as a user pref on the Editing tab. Since I’d like to add more functionalities, I created a new panel to group them.
This is great! The better the native text editor gets the easier it is to get people into trying python scripting. Looking forward to seeing where you take this project
It would be nice to improve Toggle Comments, right now it just puts a # at the beginning of the line, while it should keep the current indentation level. And the indentation itself can also be improved, I would like to use Cmd+[ and Cmd+] for this, but the current implementation of the text.indent does not allow this.
I would need to understand a bit better how that works, but I can try improving it as well! At the moment I’m trying to get a better indent when pressing enter inside empty brackets and also the surround of selected text shown in the gif above.
It probably also has something to do with TEXT_OT_indent_or_autocomplete.
You can just add ot->invoke to know which key the operator is called with and make an exception for Tab, well, or some smarter way. I mean that any other key could indent/un-indent regardless of whether there is a selection or not.
For comments, it’s a little more complicated, you need to look at txt_select_prefix and txt_select_unprefix. But I think it should be simple.
Etc. but since the Text Editor is officially in maintenance mode, again, ensure the greenlight of the module owner before you invest in implementing a new feature or a fix in the Text Editor.
Imagine if you got rid of Blender’s existing text editor engine, and replaced it with an embedded copy of Emacs. Then you would have instant access to a customization/automation engine that has been refined and extended for over half a century.