Here is a demo that shows the new text editor widget for Dear ImGui added in GeeXlab 0.31. It’s a real text editor with all essential functions to edit code: text selection, copy, paste and even coloration for some languages like Lua and GLSL!
The demo is available in the OpenGL 2.1 demopack:
To play with the demo, just load it (main.xml) in GeeXlab 0.31+.
This text editor widget is based on this project: ImGuiColorTextEdit. Functionalities of ImGuiColorTextEdit are accessible in Lua and Python via gh_imgui.color_text_editor_xxxxxx() functions.
Why did I add this text editor widget? Simply because I saw this cool screenshot. Merci Anatole! Twitter is a great source of ideas and inspiration but at the same time, it prevents me from starting ray tracing in Vulkan!
The demo renders a fullscreen quad with a vertex and pixel shader. The demo allows to live-code the pixel shader and the Lua script that manages the quad rendering. I wont’ detail how the text editor works, I let you see how the gh_imgui.color_text_editor_xxxxxx() functions are used in the demo source code. In short, two text editor widgets (one for the GLSL and one for the Lua) are created in the INIT script and are updated in the FRAME script (mainly in frame_03.lua). The text editor widget is a low level component: it has many functions that control all sides of the widget. Common operations like copy, paste, cut, text selection have their own functions. Text editor properties have also some dedicated functions. And creation / destruction and rendering have functions too.
There is also a simpler demo in the geexlab-demopack-gl-21/d29-imgui/imgui-text-edit/ folder: