python editor in game: is it possible to use godot editor component?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By meigel

I would need an in-game code editor for having the player write python code. Is it possible to use godot editor components for this? If yes, how? Important features would be syntax highlighting and indentation. Suggestions are appreciated.

:bust_in_silhouette: Reply From: ConnyOnny

Here is how the definition of the code editor component: https://github.com/godotengine/godot/blob/master/editor/code_editor.h
I found no evidence for scripting bindings to it though. So you could try to write an engine plugin to use the built-in editor. But I think it will probably be easier to implement the highlighting and indentation logic yourself. I’m afraid this is a task at which Godot does not especially shine.

I also thought about using one of the many JS highlighting frameworks and it really is a shame that we have no way to build some UI portions of our Godot games with web technologies, but it really seems undoable at the moment: Reddit - Dive into anything

EDIT: If you need to include a python runtime anyway, maybe you can use http://pygments.org/ ?

Thanks for the suggestions. Since I also need off-screen rendering, I might go with C++ QtSyntaxHighlighter and gdnative. Too complicated for my liking but unfortunately don’t see any other option yet.

meigel | 2018-08-14 20:54