zep icon indicating copy to clipboard operation
zep copied to clipboard

How is Zep's current input handling done?

Open gamagan opened this issue 4 years ago • 7 comments

Hello,

Zep is looking like a really nice, embeddable, editor. Thanks for working on it.

I'm trying to embed Zep in my Vulkan-based app, to use it as the Console input and the Log output window. I'm using ImGui for the ui. I tried embedding it by following this file: https://github.com/Rezonality/zep/blob/master/demos/demo_imgui/main.cpp

I think that file may be out of date. I managed to get Zep to display a line of text, but can't get it to respond to inputs. This line, in the above demo file, calls a method which doesn't exist to handle input. zep.spEditor->HandleInput();

What's the current way to do input management with Zep?

Btw, not a huge deal, but I notice that Zep displays an extra line # that it's not in the source text.

Thanks

image

gamagan avatar Feb 28 '22 16:02 gamagan

Hi, You should probably look at the sister project to see an integration example (it is actually a vulkan + imgui app): https://github.com/cmaughan/zep_imgui

The CL here is an example of adding Zep https://github.com/cmaughan/zep_imgui/commit/0f623e8b38f725473e9b7e34a3abdad5c0d92e74

The idea of the integration is to include and create an editor; the one in zep you need is this: It implements HandleInput for an ImGui App.... https://github.com/Rezonality/zep/blob/master/include/zep/imgui/editor_imgui.h

cmaughan avatar Feb 28 '22 16:02 cmaughan

You mentioned this file: https://github.com/Rezonality/zep/blob/master/demos/demo_imgui/main.cpp FYI, it isn't out of date and forms the basis of the Zep Editor Demo using ImGui. The zep_imgui integration example should help you get going; it was just fixed/updated this weekend.

cmaughan avatar Feb 28 '22 16:02 cmaughan

Thank you very much for the quick reply. I'll start looking at the code that you mentioned right away.

The reason I mentioned the file might have been out of date is because that line zep.spEditor->HandleInput(); doesn't seem to be in the header that I downloaded, which should be latest'ish master branch. No biggie; maybe something I'm not doing correctly.

gamagan avatar Feb 28 '22 17:02 gamagan

Ok, I see what was happening. The GetEditor() function in ZepContainer was returning a base editor, instead of ZepEditor_ImGui.

Unfortunately, now that I got passed that part, I get an assertion error from ImGui. It's because I'm using their lastest version from the Docking branch, and they updated their input handling code.

image

The assertion is triggered on line 136 of editor_imgui.h. if (ImGui::IsKeyPressed(usbKey.first))

I'll see if there's any way to work around it.

gamagan avatar Feb 28 '22 18:02 gamagan

Here's the code from the ImGui demo; it is in demo_imgui\main.cpp; it returns a ZepEditor_ImGui; perhaps you copied this code but swapped out the ImGui part?

struct ZepContainerImGui : public IZepComponent, public IZepReplProvider { ZepContainerImGui(const std::string& startupFilePath, const std::string& configPath) : spEditor(std::make_unique<ZepEditor_ImGui>(configPath, GetPixelScale()))

The change in ImGui is interesting; I will have a look; certainly the one that comes with vcpkg doesn't have this problem, so this must be quite a recent change.

cmaughan avatar Mar 01 '22 08:03 cmaughan

I just built against the latest ImGui 1.87, and I don't see any input problems. Perhaps you are working with a customized ImGui, and old one, or a custom ZepEditor_ImGui?

cmaughan avatar Mar 01 '22 08:03 cmaughan

OK: looking through the code, I suspect you have set: #define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor You will probably have to remove that until the ImGui backend for Zep has support for it; or you can fix it up yourself. That's the reason that imgui_editor & imgui_display are there; to enable any backend to support Zep. I will have a look at it when I get time....

cmaughan avatar Mar 01 '22 08:03 cmaughan

Since we don't support OBSOLETE_KEYIO in the demo, I'm closing this for now. It is really up to the backend to choose how to implement keystrokes. The example ImGui backend will probably get moved over at some point to do this, but it's not a requirement.

cmaughan avatar Mar 24 '23 14:03 cmaughan