diff --git a/.gitmodules b/.gitmodules index 92c94d3f..2aadfa68 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ url = https://github.com/epezent/implot.git [submodule "include/ImGuiColorTextEdit"] path = include/ImGuiColorTextEdit - url = https://github.com/BalazsJako/ImGuiColorTextEdit + url = https://github.com/goossens/ImGuiColorTextEdit [submodule "include/ImGuiFileDialog"] path = include/ImGuiFileDialog url = https://github.com/aiekick/ImGuiFileDialog diff --git a/README.md b/README.md index 6551f4cb..a3d72484 100644 --- a/README.md +++ b/README.md @@ -324,7 +324,7 @@ See examples in the `example` module for more information about how to use them. Immediate mode 3D gizmo for scene editing and other controls based on Dear ImGui. - [implot](https://github.com/epezent/implot/tree/v1.0) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImPlot.java)
Advanced 2D Plotting for Dear ImGui. -- [ImGuiColorTextEdit](https://github.com/BalazsJako/ImGuiColorTextEdit/tree/0a88824f7de8d0bd11d8419066caa7d3469395c4) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiColorTextEdit.java)
+- [ImGuiColorTextEdit](https://github.com/goossens/ImGuiColorTextEdit/tree/0a88824f7de8d0bd11d8419066caa7d3469395c4) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiColorTextEdit.java)
Syntax highlighting text editor for ImGui. - [ImGuiFileDialog](https://github.com/aiekick/ImGuiFileDialog/tree/4d42dfba125cbd4780a90fbc5f75e7dfbae64060) | [Example](https://github.com/SpaiR/imgui-java/blob/main/example/src/main/java/ExampleImGuiFileDialog.java)
A file selection dialog built for ImGui. diff --git a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy index 47e79684..d6dd666c 100644 --- a/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy +++ b/buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy @@ -18,7 +18,7 @@ class GenerateLibs extends DefaultTask { 'include/imgui-node-editor', 'include/imguizmo', 'include/implot', -// 'include/ImGuiColorTextEdit', + 'include/ImGuiColorTextEdit', // 'include/ImGuiFileDialog', 'include/imgui_club/imgui_memory_editor', 'include/imgui-knobs' @@ -80,6 +80,12 @@ class GenerateLibs extends DefaultTask { spec.into(jniDir) } + // Ensure the active ImGuiColorTextEdit snapshot wins even if a stale TextEditor.* exists in the JNI dir. + project.copy { CopySpec spec -> + spec.from(project.rootProject.file('include/ImGuiColorTextEdit')) { CopySpec s -> s.include('TextEditor.h', 'TextEditor.cpp') } + spec.into(jniDir) + } + if (withFreeType) { project.copy { CopySpec spec -> spec.from(project.rootProject.file('include/imgui/misc/freetype')) { CopySpec it -> it.include('*.h', '*.cpp') } @@ -108,12 +114,14 @@ class GenerateLibs extends DefaultTask { if (forWindows) { def win64 = BuildTarget.newDefaultTarget(Os.Windows, Architecture.Bitness._64) + requireCpp17(win64) addFreeTypeIfEnabled(win64) buildTargets += win64 } if (forLinux) { def linux64 = BuildTarget.newDefaultTarget(Os.Linux, Architecture.Bitness._64) + requireCpp17(linux64) addFreeTypeIfEnabled(linux64) buildTargets += linux64 } @@ -166,13 +174,20 @@ class GenerateLibs extends DefaultTask { def minMacOsVersion = '10.15' def macTarget = BuildTarget.newDefaultTarget(Os.MacOsX, Architecture.Bitness._64, arch) macTarget.libName = "libimgui-java64.dylib" // Lib for arm64 will be named the same for consistency. - macTarget.cppFlags += ' -std=c++14' + requireCpp17(macTarget) macTarget.cppFlags = macTarget.cppFlags.replace('10.7', minMacOsVersion) macTarget.linkerFlags = macTarget.linkerFlags.replace('10.7', minMacOsVersion) addFreeTypeIfEnabled(macTarget) return macTarget } + void requireCpp17(BuildTarget target) { + target.cppFlags = target.cppFlags.replace(' -std=c++14', '') + if (!target.cppFlags.contains('-std=c++17')) { + target.cppFlags += ' -std=c++17' + } + } + void addFreeTypeIfEnabled(BuildTarget target) { if (!withFreeType) { return diff --git a/buildSrc/src/main/kotlin/tool/generator/api/jni_content.kt b/buildSrc/src/main/kotlin/tool/generator/api/jni_content.kt index 9169ea5d..37d15fb4 100644 --- a/buildSrc/src/main/kotlin/tool/generator/api/jni_content.kt +++ b/buildSrc/src/main/kotlin/tool/generator/api/jni_content.kt @@ -97,7 +97,7 @@ private fun convertParams2jni(f: Factory, params: List>, defaults setType>(f.createTypeParam("double")) setSimpleName("${p.simpleName}MaxY") } - } else if (p.isType("TextEditorCoordinates")) { + } else if (p.isType("TextEditorCursorPosition")) { result += f.createParameter().apply { setType>(f.createTypeParam("int")) setSimpleName("${p.simpleName}Line") @@ -167,8 +167,8 @@ private fun joinInBodyParams(params: List>, defaults: IntArray): "ImPlotRect(${p.simpleName}MinX, ${p.simpleName}MinY, ${p.simpleName}MaxX, ${p.simpleName}MaxY)" } - "TextEditorCoordinates" -> { - "TextEditor::Coordinates(${p.simpleName}Line, ${p.simpleName}Column)" + "TextEditorCursorPosition" -> { + "TextEditor::CursorPosition(${p.simpleName}Line, ${p.simpleName}Column)" } else -> p.simpleName diff --git a/buildSrc/src/main/kotlin/tool/generator/api/jvm_content.kt b/buildSrc/src/main/kotlin/tool/generator/api/jvm_content.kt index 2e05225c..05f6d747 100644 --- a/buildSrc/src/main/kotlin/tool/generator/api/jvm_content.kt +++ b/buildSrc/src/main/kotlin/tool/generator/api/jvm_content.kt @@ -42,7 +42,7 @@ private fun joinInBodyParams(params: List>, defaults: IntArray): "ImPlotRange" -> "${p.simpleName}.min, ${p.simpleName}.max" "ImPlotRect" -> "${p.simpleName}.x.min, ${p.simpleName}.y.min, ${p.simpleName}.x.max, ${p.simpleName}.y.max" - "TextEditorCoordinates" -> "${p.simpleName}.mLine, ${p.simpleName}.mColumn" + "TextEditorCursorPosition" -> "${p.simpleName}.line, ${p.simpleName}.column" "String[]" -> "${p.simpleName}, ${p.simpleName}.length" @@ -425,7 +425,7 @@ private fun methodCoordinatesUnwrappedContent(method: CtMethod<*>, fromIndex: In val paramNames = mutableSetOf() for ((idx, p) in newMethod.parameters.withIndex()) { - if (p.isType("TextEditorCoordinates") && idx >= fromIndex) { + if (p.isType("TextEditorCursorPosition") && idx >= fromIndex) { paramNames += p.simpleName val paramX = p.factory.createParameter() @@ -529,7 +529,7 @@ private fun transformMethodToContent( if (params.find { it.isType("ImPlotRect") } != null) { methodPlotLimitsUnwrappedContent(method, fromIndex).takeIf(String::isNotEmpty)?.run(result::add) } - if (params.find { it.isType("TextEditorCoordinates") } != null) { + if (params.find { it.isType("TextEditorCursorPosition") } != null) { methodCoordinatesUnwrappedContent(method, fromIndex).takeIf(String::isNotEmpty)?.run(result::add) } return result diff --git a/buildSrc/src/main/kotlin/tool/generator/api/util.kt b/buildSrc/src/main/kotlin/tool/generator/api/util.kt index 8d39911d..3d6a983b 100644 --- a/buildSrc/src/main/kotlin/tool/generator/api/util.kt +++ b/buildSrc/src/main/kotlin/tool/generator/api/util.kt @@ -81,7 +81,8 @@ val DST_RETURN_TYPE_SET = setOf( "ImPlotPoint", "ImPlotRange", "ImPlotRect", - "TextEditorCoordinates", + "TextEditorCursorPosition", + "TextEditorCursorSelection", ) fun CtElement.hasAnnotation(annotationName: String): Boolean { diff --git a/buildSrc/src/main/resources/generator/api/ast/ast-TextEditor.json b/buildSrc/src/main/resources/generator/api/ast/ast-TextEditor.json index 80b8811b..a9f699af 100644 --- a/buildSrc/src/main/resources/generator/api/ast/ast-TextEditor.json +++ b/buildSrc/src/main/resources/generator/api/ast/ast-TextEditor.json @@ -2,7 +2,7 @@ "info" : { "source" : "include/ImGuiColorTextEdit/TextEditor.h", "hash" : "1e5c6cd321f415c393ab30d4800a0dc2", - "url" : "https://github.com/BalazsJako/ImGuiColorTextEdit", + "url" : "https://github.com/goossens/ImGuiColorTextEdit", "revision" : "0a88824f7de8d0bd11d8419066caa7d3469395c4" }, "decls" : [ { diff --git a/example/src/main/java/ExampleImGuiColorTextEdit.java b/example/src/main/java/ExampleImGuiColorTextEdit.java index 19a4e888..dcfd43de 100644 --- a/example/src/main/java/ExampleImGuiColorTextEdit.java +++ b/example/src/main/java/ExampleImGuiColorTextEdit.java @@ -1,82 +1,49 @@ -/* import imgui.ImGui; import imgui.extension.texteditor.TextEditor; -import imgui.extension.texteditor.TextEditorCoordinates; -import imgui.extension.texteditor.TextEditorLanguageDefinition; +import imgui.extension.texteditor.TextEditorCursorPosition; +import imgui.extension.texteditor.TextEditorLanguage; +import imgui.extension.texteditor.flag.TextEditorColor; +import imgui.extension.texteditor.flag.TextEditorScroll; +import imgui.flag.ImGuiCond; import imgui.flag.ImGuiWindowFlags; import imgui.type.ImBoolean; -import java.util.HashMap; -import java.util.Map; - public class ExampleImGuiColorTextEdit { private static final TextEditor EDITOR = new TextEditor(); + private static final String DEMO_TEXT = + "// Demo C++ Code\n" + + "\n" + + "#include \n" + + "#include \n" + + "#include \n" + + "\n" + + "int main(int, char**) {\n" + + " std::random_device rd;\n" + + " std::mt19937 gen(rd());\n" + + " std::uniform_int_distribution<> distrib(0, 1000);\n" + + " std::vector numbers;\n" + + "\n" + + " for (int i = 0; i < 100; i++) {\n" + + " numbers.emplace_back(distrib(gen));\n" + + " }\n" + + "\n" + + " for (auto n : numbers) {\n" + + " std::cout << n << std::endl;\n" + + " }\n" + + "\n" + + " return 0;\n" + + "}\n"; + static { - TextEditorLanguageDefinition lang = TextEditorLanguageDefinition.C(); - - String[] ppnames = { - "NULL", "PM_REMOVE", - "ZeroMemory", "DXGI_SWAP_EFFECT_DISCARD", "D3D_FEATURE_LEVEL", "D3D_DRIVER_TYPE_HARDWARE", "WINAPI", "D3D11_SDK_VERSION", "assert"}; - String[] ppvalues = { - "#define NULL ((void*)0)", - "#define PM_REMOVE (0x0001)", - "Microsoft's own memory zapper function\n(which is a macro actually)\nvoid ZeroMemory(\n\t[in] PVOID Destination,\n\t[in] SIZE_T Length\n); ", - "enum DXGI_SWAP_EFFECT::DXGI_SWAP_EFFECT_DISCARD = 0", - "enum D3D_FEATURE_LEVEL", - "enum D3D_DRIVER_TYPE::D3D_DRIVER_TYPE_HARDWARE = ( D3D_DRIVER_TYPE_UNKNOWN + 1 )", - "#define WINAPI __stdcall", - "#define D3D11_SDK_VERSION (7)", - " #define assert(expression) (void)( \n" + - " (!!(expression)) || \n" + - " (_wassert(_CRT_WIDE(#expression), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)), 0) \n" + - " )" - }; - - // Adding custom preproc identifiers - Map preprocIdentifierMap = new HashMap<>(); - for (int i = 0; i < ppnames.length; ++i) { - preprocIdentifierMap.put(ppnames[i], ppvalues[i]); - } - lang.setPreprocIdentifiers(preprocIdentifierMap); - - String[] identifiers = { - "HWND", "HRESULT", "LPRESULT","D3D11_RENDER_TARGET_VIEW_DESC", "DXGI_SWAP_CHAIN_DESC","MSG","LRESULT","WPARAM", "LPARAM","UINT","LPVOID", - "ID3D11Device", "ID3D11DeviceContext", "ID3D11Buffer", "ID3D11Buffer", "ID3D10Blob", "ID3D11VertexShader", "ID3D11InputLayout", "ID3D11Buffer", - "ID3D10Blob", "ID3D11PixelShader", "ID3D11SamplerState", "ID3D11ShaderResourceView", "ID3D11RasterizerState", "ID3D11BlendState", "ID3D11DepthStencilState", - "IDXGISwapChain", "ID3D11RenderTargetView", "ID3D11Texture2D", "TextEditor" }; - String[] idecls = { - "typedef HWND_* HWND", "typedef long HRESULT", "typedef long* LPRESULT", "struct D3D11_RENDER_TARGET_VIEW_DESC", "struct DXGI_SWAP_CHAIN_DESC", - "typedef tagMSG MSG\n * Message structure","typedef LONG_PTR LRESULT","WPARAM", "LPARAM","UINT","LPVOID", - "ID3D11Device", "ID3D11DeviceContext", "ID3D11Buffer", "ID3D11Buffer", "ID3D10Blob", "ID3D11VertexShader", "ID3D11InputLayout", "ID3D11Buffer", - "ID3D10Blob", "ID3D11PixelShader", "ID3D11SamplerState", "ID3D11ShaderResourceView", "ID3D11RasterizerState", "ID3D11BlendState", "ID3D11DepthStencilState", - "IDXGISwapChain", "ID3D11RenderTargetView", "ID3D11Texture2D", "class TextEditor" }; - - // Adding custom identifiers - Map identifierMap = new HashMap<>(); - for (int i = 0; i < ppnames.length; ++i) { - identifierMap.put(identifiers[i], idecls[i]); - } - lang.setIdentifiers(identifierMap); - - EDITOR.setLanguageDefinition(lang); - - // Adding error markers - Map errorMarkers = new HashMap<>(); - errorMarkers.put(1, "Expected '>'"); - EDITOR.setErrorMarkers(errorMarkers); - - EDITOR.setTextLines(new String[]{ - "#include (palette.size()); + jintArray result = env->NewIntArray(size); + std::vector values(static_cast(size)); + for (size_t i = 0; i < palette.size(); ++i) { + values[i] = static_cast(palette[i]); + } + env->SetIntArrayRegion(result, 0, size, values.data()); + return result; + } + + static void TextEditorArrayToPalette(JNIEnv* env, jintArray source, TextEditor::Palette& destination) { + const auto maxCount = static_cast(destination.size()); + auto valueCount = env->GetArrayLength(source); + valueCount = valueCount < maxCount ? valueCount : maxCount; + std::vector values(static_cast(valueCount)); + env->GetIntArrayRegion(source, 0, valueCount, values.data()); + for (jsize i = 0; i < valueCount; ++i) { + destination[static_cast(i)] = static_cast(values[static_cast(i)]); + } + } + */ + + private native long nCreate(); /* + return (uintptr_t)(new TextEditor()); + */ + + public void setTabSize(final int value) { + nSetTabSize(value); + } + + private native void nSetTabSize(int value); /* + THIS->SetTabSize(value); + */ + + public void setLanguage(final TextEditorLanguage language) { + nSetLanguage(language == null ? 0 : language.ptr); + } + + private native void nSetLanguage(long languagePtr); /* + THIS->SetLanguage(reinterpret_cast(languagePtr)); + */ + + public int getTabSize() { + return nGetTabSize(); + } + + private native int nGetTabSize(); /* + return THIS->GetTabSize(); + */ + + public void setInsertSpacesOnTabs(final boolean value) { + nSetInsertSpacesOnTabs(value); + } + + private native void nSetInsertSpacesOnTabs(boolean value); /* + THIS->SetInsertSpacesOnTabs(value); + */ + + public boolean isInsertSpacesOnTabs() { + return nIsInsertSpacesOnTabs(); + } + + private native boolean nIsInsertSpacesOnTabs(); /* + return THIS->IsInsertSpacesOnTabs(); + */ + + public void setLineSpacing(final float value) { + nSetLineSpacing(value); + } + + private native void nSetLineSpacing(float value); /* + THIS->SetLineSpacing(value); + */ + + public float getLineSpacing() { + return nGetLineSpacing(); + } + + private native float nGetLineSpacing(); /* + return THIS->GetLineSpacing(); + */ + + public void setReadOnlyEnabled(final boolean value) { + nSetReadOnlyEnabled(value); + } + + private native void nSetReadOnlyEnabled(boolean value); /* + THIS->SetReadOnlyEnabled(value); + */ + + public boolean isReadOnlyEnabled() { + return nIsReadOnlyEnabled(); + } + + private native boolean nIsReadOnlyEnabled(); /* + return THIS->IsReadOnlyEnabled(); + */ + + public void setAutoIndentEnabled(final boolean value) { + nSetAutoIndentEnabled(value); + } + + private native void nSetAutoIndentEnabled(boolean value); /* + THIS->SetAutoIndentEnabled(value); + */ + + public boolean isAutoIndentEnabled() { + return nIsAutoIndentEnabled(); + } + + private native boolean nIsAutoIndentEnabled(); /* + return THIS->IsAutoIndentEnabled(); + */ + + public void setShowWhitespacesEnabled(final boolean value) { + nSetShowWhitespacesEnabled(value); + } + + private native void nSetShowWhitespacesEnabled(boolean value); /* + THIS->SetShowWhitespacesEnabled(value); + */ + + public boolean isShowWhitespacesEnabled() { + return nIsShowWhitespacesEnabled(); + } + + private native boolean nIsShowWhitespacesEnabled(); /* + return THIS->IsShowWhitespacesEnabled(); + */ + + public void setShowSpacesEnabled(final boolean value) { + nSetShowSpacesEnabled(value); + } + + private native void nSetShowSpacesEnabled(boolean value); /* + THIS->SetShowSpacesEnabled(value); + */ + + public boolean isShowSpacesEnabled() { + return nIsShowSpacesEnabled(); + } + + private native boolean nIsShowSpacesEnabled(); /* + return THIS->IsShowSpacesEnabled(); + */ + + public void setShowTabsEnabled(final boolean value) { + nSetShowTabsEnabled(value); + } + + private native void nSetShowTabsEnabled(boolean value); /* + THIS->SetShowTabsEnabled(value); + */ + + public boolean isShowTabsEnabled() { + return nIsShowTabsEnabled(); + } + + private native boolean nIsShowTabsEnabled(); /* + return THIS->IsShowTabsEnabled(); + */ + + public void setShowLineNumbersEnabled(final boolean value) { + nSetShowLineNumbersEnabled(value); + } + + private native void nSetShowLineNumbersEnabled(boolean value); /* + THIS->SetShowLineNumbersEnabled(value); + */ + + public boolean isShowLineNumbersEnabled() { + return nIsShowLineNumbersEnabled(); + } + + private native boolean nIsShowLineNumbersEnabled(); /* + return THIS->IsShowLineNumbersEnabled(); + */ + + public void setShowScrollbarMiniMapEnabled(final boolean value) { + nSetShowScrollbarMiniMapEnabled(value); + } + + private native void nSetShowScrollbarMiniMapEnabled(boolean value); /* + THIS->SetShowScrollbarMiniMapEnabled(value); + */ + + public boolean isShowScrollbarMiniMapEnabled() { + return nIsShowScrollbarMiniMapEnabled(); + } + + private native boolean nIsShowScrollbarMiniMapEnabled(); /* + return THIS->IsShowScrollbarMiniMapEnabled(); + */ + + public void setShowPanScrollIndicatorEnabled(final boolean value) { + nSetShowPanScrollIndicatorEnabled(value); + } + + private native void nSetShowPanScrollIndicatorEnabled(boolean value); /* + THIS->SetShowPanScrollIndicatorEnabled(value); + */ + + public boolean isShowPanScrollIndicatorEnabled() { + return nIsShowPanScrollIndicatorEnabled(); + } + + private native boolean nIsShowPanScrollIndicatorEnabled(); /* + return THIS->IsShowPanScrollIndicatorEnabled(); + */ + + public void setShowMatchingBrackets(final boolean value) { + nSetShowMatchingBrackets(value); + } + + private native void nSetShowMatchingBrackets(boolean value); /* + THIS->SetShowMatchingBrackets(value); + */ + + public boolean isShowingMatchingBrackets() { + return nIsShowingMatchingBrackets(); + } + + private native boolean nIsShowingMatchingBrackets(); /* + return THIS->IsShowingMatchingBrackets(); + */ + + public void setCompletePairedGlyphs(final boolean value) { + nSetCompletePairedGlyphs(value); + } + + private native void nSetCompletePairedGlyphs(boolean value); /* + THIS->SetCompletePairedGlyphs(value); + */ + + public boolean isCompletingPairedGlyphs() { + return nIsCompletingPairedGlyphs(); + } + + private native boolean nIsCompletingPairedGlyphs(); /* + return THIS->IsCompletingPairedGlyphs(); + */ + + public void setOverwriteEnabled(final boolean value) { + nSetOverwriteEnabled(value); + } + + private native void nSetOverwriteEnabled(boolean value); /* + THIS->SetOverwriteEnabled(value); + */ + + public boolean isOverwriteEnabled() { + return nIsOverwriteEnabled(); + } + + private native boolean nIsOverwriteEnabled(); /* + return THIS->IsOverwriteEnabled(); + */ + + public void setMiddleMousePanMode() { + nSetMiddleMousePanMode(); + } + + private native void nSetMiddleMousePanMode(); /* + THIS->SetMiddleMousePanMode(); + */ + + public void setMiddleMouseScrollMode() { + nSetMiddleMouseScrollMode(); + } + + private native void nSetMiddleMouseScrollMode(); /* + THIS->SetMiddleMouseScrollMode(); + */ + + public boolean isMiddleMousePanMode() { + return nIsMiddleMousePanMode(); + } + + private native boolean nIsMiddleMousePanMode(); /* + return THIS->IsMiddleMousePanMode(); + */ + + public void setText(final String text) { + nSetText(text); + } + + private native void nSetText(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SetText(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public String getText() { + return nGetText(); + } + + private native String nGetText(); /* + return env->NewStringUTF(THIS->GetText().c_str()); + */ + + public String getCursorText(final long cursor) { + return nGetCursorText(cursor); + } + + private native String nGetCursorText(long cursor); /* + return env->NewStringUTF(THIS->GetCursorText(cursor).c_str()); + */ + + public String getLineText(final int line) { + return nGetLineText(line); + } + + private native String nGetLineText(int line); /* + return env->NewStringUTF(THIS->GetLineText(line).c_str()); + */ + + public String getSectionText(final int startLine, final int startColumn, final int endLine, final int endColumn) { + return nGetSectionText(startLine, startColumn, endLine, endColumn); + } + + private native String nGetSectionText(int startLine, int startColumn, int endLine, int endColumn); /* + return env->NewStringUTF(THIS->GetSectionText(startLine, startColumn, endLine, endColumn).c_str()); + */ + + public void replaceSectionText(final int startLine, final int startColumn, final int endLine, final int endColumn, final String text) { + nReplaceSectionText(startLine, startColumn, endLine, endColumn, text); + } + + private native void nReplaceSectionText(int startLine, int startColumn, int endLine, int endColumn, String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->ReplaceSectionText(startLine, startColumn, endLine, endColumn, text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void clearText() { + setText(""); + } + + public boolean isEmpty() { + return nIsEmpty(); + } + + private native boolean nIsEmpty(); /* + return THIS->IsEmpty(); + */ + + public int getLineCount() { + return nGetLineCount(); + } + + private native int nGetLineCount(); /* + return THIS->GetLineCount(); + */ + + public void render(final String title) { + nRender(title); + } + + public void render(final String title, final ImVec2 size) { + nRender(title, size.x, size.y); + } + + public void render(final String title, final float sizeX, final float sizeY) { + nRender(title, sizeX, sizeY); + } + + public void render(final String title, final ImVec2 size, final boolean border) { + nRender(title, size.x, size.y, border); + } + + public void render(final String title, final float sizeX, final float sizeY, final boolean border) { + nRender(title, sizeX, sizeY, border); + } + + private native void nRender(String title); /*MANUAL + auto title = obj_title == NULL ? NULL : (char*)env->GetStringUTFChars(obj_title, JNI_FALSE); + THIS->Render(title); + if (title != NULL) env->ReleaseStringUTFChars(obj_title, title); + */ + + private native void nRender(String title, float sizeX, float sizeY); /*MANUAL + auto title = obj_title == NULL ? NULL : (char*)env->GetStringUTFChars(obj_title, JNI_FALSE); + ImVec2 size = ImVec2(sizeX, sizeY); + THIS->Render(title, size); + if (title != NULL) env->ReleaseStringUTFChars(obj_title, title); + */ + + private native void nRender(String title, float sizeX, float sizeY, boolean border); /*MANUAL + auto title = obj_title == NULL ? NULL : (char*)env->GetStringUTFChars(obj_title, JNI_FALSE); + ImVec2 size = ImVec2(sizeX, sizeY); + THIS->Render(title, size, border); + if (title != NULL) env->ReleaseStringUTFChars(obj_title, title); + */ + + public void render(final String title, final boolean border) { + render(title, new ImVec2(), border); + } + + public void setFocus() { + nSetFocus(); + } + + private native void nSetFocus(); /* + THIS->SetFocus(); + */ + + public void cut() { + nCut(); + } + + private native void nCut(); /* + THIS->Cut(); + */ + + public void copy() { + nCopy(); + } + + private native void nCopy(); /* + THIS->Copy(); + */ + + public void paste() { + nPaste(); + } + + private native void nPaste(); /* + THIS->Paste(); + */ + + public void undo() { + nUndo(); + } + + private native void nUndo(); /* + THIS->Undo(); + */ + + public void redo() { + nRedo(); + } + + private native void nRedo(); /* + THIS->Redo(); + */ + + public boolean canUndo() { + return nCanUndo(); + } + + private native boolean nCanUndo(); /* + return THIS->CanUndo(); + */ + + public boolean canRedo() { + return nCanRedo(); + } + + private native boolean nCanRedo(); /* + return THIS->CanRedo(); + */ + + public long getUndoIndex() { + return nGetUndoIndex(); + } + + private native long nGetUndoIndex(); /* + return THIS->GetUndoIndex(); + */ + + public void setCursor(final int line, final int column) { + nSetCursor(line, column); + } + + private native void nSetCursor(int line, int column); /* + THIS->SetCursor(line, column); + */ + + public void selectAll() { + nSelectAll(); + } + + private native void nSelectAll(); /* + THIS->SelectAll(); + */ + + public void selectLine(final int line) { + nSelectLine(line); + } + + private native void nSelectLine(int line); /* + THIS->SelectLine(line); + */ + + public void selectLines(final int start, final int end) { + nSelectLines(start, end); + } + + private native void nSelectLines(int start, int end); /* + THIS->SelectLines(start, end); + */ + + public void selectRegion(final int startLine, final int startColumn, final int endLine, final int endColumn) { + nSelectRegion(startLine, startColumn, endLine, endColumn); + } + + private native void nSelectRegion(int startLine, int startColumn, int endLine, int endColumn); /* + THIS->SelectRegion(startLine, startColumn, endLine, endColumn); + */ + + public void selectToBrackets() { + nSelectToBrackets(); + } + + public void selectToBrackets(final boolean includeBrackets) { + nSelectToBrackets(includeBrackets); + } + + private native void nSelectToBrackets(); /* + THIS->SelectToBrackets(); + */ + + private native void nSelectToBrackets(boolean includeBrackets); /* + THIS->SelectToBrackets(includeBrackets); + */ + + public void growSelectionsToCurlyBrackets() { + nGrowSelectionsToCurlyBrackets(); + } + + private native void nGrowSelectionsToCurlyBrackets(); /* + THIS->GrowSelectionsToCurlyBrackets(); + */ + + public void shrinkSelectionsToCurlyBrackets() { + nShrinkSelectionsToCurlyBrackets(); + } + + private native void nShrinkSelectionsToCurlyBrackets(); /* + THIS->ShrinkSelectionsToCurlyBrackets(); + */ + + public void addNextOccurrence() { + nAddNextOccurrence(); + } + + private native void nAddNextOccurrence(); /* + THIS->AddNextOccurrence(); + */ + + public void selectAllOccurrences() { + nSelectAllOccurrences(); + } + + private native void nSelectAllOccurrences(); /* + THIS->SelectAllOccurrences(); + */ + + public boolean anyCursorHasSelection() { + return nAnyCursorHasSelection(); + } + + private native boolean nAnyCursorHasSelection(); /* + return THIS->AnyCursorHasSelection(); + */ + + public boolean allCursorsHaveSelection() { + return nAllCursorsHaveSelection(); + } + + private native boolean nAllCursorsHaveSelection(); /* + return THIS->AllCursorsHaveSelection(); + */ + + public boolean currentCursorHasSelection() { + return nCurrentCursorHasSelection(); + } + + private native boolean nCurrentCursorHasSelection(); /* + return THIS->CurrentCursorHasSelection(); + */ + + public void clearCursors() { + nClearCursors(); + } + + private native void nClearCursors(); /* + THIS->ClearCursors(); + */ + + public long getNumberOfCursors() { + return nGetNumberOfCursors(); + } + + private native long nGetNumberOfCursors(); /* + return THIS->GetNumberOfCursors(); + */ + + public TextEditorCursorPosition getMainCursorPosition() { + final TextEditorCursorPosition dst = new TextEditorCursorPosition(); + nGetMainCursorPosition(dst); + return dst; + } + + public void getMainCursorPosition(final TextEditorCursorPosition dst) { + nGetMainCursorPosition(dst); + } + + private native void nGetMainCursorPosition(TextEditorCursorPosition dst); /* + Jni::TextEditorCursorPositionCpy(env, THIS->GetMainCursorPosition(), dst); + */ + + public TextEditorCursorPosition getCurrentCursorPosition() { + final TextEditorCursorPosition dst = new TextEditorCursorPosition(); + nGetCurrentCursorPosition(dst); + return dst; + } + + public void getCurrentCursorPosition(final TextEditorCursorPosition dst) { + nGetCurrentCursorPosition(dst); + } + + private native void nGetCurrentCursorPosition(TextEditorCursorPosition dst); /* + Jni::TextEditorCursorPositionCpy(env, THIS->GetCurrentCursorPosition(), dst); + */ + + public TextEditorCursorPosition getCursorPosition(final long cursor) { + final TextEditorCursorPosition dst = new TextEditorCursorPosition(); + nGetCursorPosition(dst, cursor); + return dst; + } + + public void getCursorPosition(final TextEditorCursorPosition dst, final long cursor) { + nGetCursorPosition(dst, cursor); + } + + private native void nGetCursorPosition(TextEditorCursorPosition dst, long cursor); /* + Jni::TextEditorCursorPositionCpy(env, THIS->GetCursorPosition(cursor), dst); + */ + + public TextEditorCursorSelection getCursorSelection(final long cursor) { + final TextEditorCursorSelection dst = new TextEditorCursorSelection(); + nGetCursorSelection(dst, cursor); + return dst; + } + + public void getCursorSelection(final TextEditorCursorSelection dst, final long cursor) { + nGetCursorSelection(dst, cursor); + } + + private native void nGetCursorSelection(TextEditorCursorSelection dst, long cursor); /* + Jni::TextEditorCursorSelectionCpy(env, THIS->GetCursorSelection(cursor), dst); + */ + + public TextEditorCursorSelection getMainCursorSelection() { + final TextEditorCursorSelection dst = new TextEditorCursorSelection(); + nGetMainCursorSelection(dst); + return dst; + } + + public void getMainCursorSelection(final TextEditorCursorSelection dst) { + nGetMainCursorSelection(dst); + } + + private native void nGetMainCursorSelection(TextEditorCursorSelection dst); /* + Jni::TextEditorCursorSelectionCpy(env, THIS->GetMainCursorSelection(), dst); + */ + + public String getWordAtScreenPos(final ImVec2 screenPos) { + return nGetWordAtScreenPos(screenPos.x, screenPos.y); + } + + public String getWordAtScreenPos(final float screenPosX, final float screenPosY) { + return nGetWordAtScreenPos(screenPosX, screenPosY); + } + + private native String nGetWordAtScreenPos(float screenPosX, float screenPosY); /*MANUAL + ImVec2 screenPos = ImVec2(screenPosX, screenPosY); + auto _result = env->NewStringUTF(THIS->GetWordAtScreenPos(screenPos).c_str()); + return _result; + */ + + public void scrollToLine(final int line, final int alignment) { + nScrollToLine(line, alignment); + } + + private native void nScrollToLine(int line, int alignment); /* + THIS->ScrollToLine(line, static_cast(alignment)); + */ + + public void scrollToLine(final int line, final TextEditorScroll alignment) { + scrollToLine(line, alignment.value); + } + + public int getFirstVisibleLine() { + return nGetFirstVisibleLine(); + } + + private native int nGetFirstVisibleLine(); /* + return THIS->GetFirstVisibleLine(); + */ + + public int getLastVisibleLine() { + return nGetLastVisibleLine(); + } + + private native int nGetLastVisibleLine(); /* + return THIS->GetLastVisibleLine(); + */ + + public int getFirstVisibleColumn() { + return nGetFirstVisibleColumn(); + } + + private native int nGetFirstVisibleColumn(); /* + return THIS->GetFirstVisibleColumn(); + */ + + public int getLastVisibleColumn() { + return nGetLastVisibleColumn(); + } + + private native int nGetLastVisibleColumn(); /* + return THIS->GetLastVisibleColumn(); + */ + + public float getLineHeight() { + return nGetLineHeight(); + } + + private native float nGetLineHeight(); /* + return THIS->GetLineHeight(); + */ + + public float getGlyphWidth() { + return nGetGlyphWidth(); + } + + private native float nGetGlyphWidth(); /* + return THIS->GetGlyphWidth(); + */ + + public void selectFirstOccurrenceOf(final String text) { + nSelectFirstOccurrenceOf(text); + } + + public void selectFirstOccurrenceOf(final String text, final boolean caseSensitive) { + nSelectFirstOccurrenceOf(text, caseSensitive); + } + + public void selectFirstOccurrenceOf(final String text, final boolean caseSensitive, final boolean wholeWord) { + nSelectFirstOccurrenceOf(text, caseSensitive, wholeWord); + } + + private native void nSelectFirstOccurrenceOf(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectFirstOccurrenceOf(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectFirstOccurrenceOf(String text, boolean caseSensitive); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectFirstOccurrenceOf(text, caseSensitive); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectFirstOccurrenceOf(String text, boolean caseSensitive, boolean wholeWord); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectFirstOccurrenceOf(text, caseSensitive, wholeWord); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void selectNextOccurrenceOf(final String text) { + nSelectNextOccurrenceOf(text); + } + + public void selectNextOccurrenceOf(final String text, final boolean caseSensitive) { + nSelectNextOccurrenceOf(text, caseSensitive); + } + + public void selectNextOccurrenceOf(final String text, final boolean caseSensitive, final boolean wholeWord) { + nSelectNextOccurrenceOf(text, caseSensitive, wholeWord); + } + + private native void nSelectNextOccurrenceOf(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectNextOccurrenceOf(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectNextOccurrenceOf(String text, boolean caseSensitive); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectNextOccurrenceOf(text, caseSensitive); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectNextOccurrenceOf(String text, boolean caseSensitive, boolean wholeWord); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectNextOccurrenceOf(text, caseSensitive, wholeWord); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void selectAllOccurrencesOf(final String text) { + nSelectAllOccurrencesOf(text); + } + + public void selectAllOccurrencesOf(final String text, final boolean caseSensitive) { + nSelectAllOccurrencesOf(text, caseSensitive); + } + + public void selectAllOccurrencesOf(final String text, final boolean caseSensitive, final boolean wholeWord) { + nSelectAllOccurrencesOf(text, caseSensitive, wholeWord); + } + + private native void nSelectAllOccurrencesOf(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectAllOccurrencesOf(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectAllOccurrencesOf(String text, boolean caseSensitive); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectAllOccurrencesOf(text, caseSensitive); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + private native void nSelectAllOccurrencesOf(String text, boolean caseSensitive, boolean wholeWord); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->SelectAllOccurrencesOf(text, caseSensitive, wholeWord); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void replaceTextInCurrentCursor(final String text) { + nReplaceTextInCurrentCursor(text); + } + + private native void nReplaceTextInCurrentCursor(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->ReplaceTextInCurrentCursor(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void replaceTextInAllCursors(final String text) { + nReplaceTextInAllCursors(text); + } + + private native void nReplaceTextInAllCursors(String text); /*MANUAL + auto text = obj_text == NULL ? NULL : (char*)env->GetStringUTFChars(obj_text, JNI_FALSE); + THIS->ReplaceTextInAllCursors(text); + if (text != NULL) env->ReleaseStringUTFChars(obj_text, text); + */ + + public void openFindReplaceWindow() { + nOpenFindReplaceWindow(); + } + + private native void nOpenFindReplaceWindow(); /* + THIS->OpenFindReplaceWindow(); + */ + + public void closeFindReplaceWindow() { + nCloseFindReplaceWindow(); + } + + private native void nCloseFindReplaceWindow(); /* + THIS->CloseFindReplaceWindow(); + */ + + public void setFindButtonLabel(final String label) { + nSetFindButtonLabel(label); + } + + private native void nSetFindButtonLabel(String label); /*MANUAL + auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE); + THIS->SetFindButtonLabel(label); + if (label != NULL) env->ReleaseStringUTFChars(obj_label, label); + */ + + public void setFindAllButtonLabel(final String label) { + nSetFindAllButtonLabel(label); + } + + private native void nSetFindAllButtonLabel(String label); /*MANUAL + auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE); + THIS->SetFindAllButtonLabel(label); + if (label != NULL) env->ReleaseStringUTFChars(obj_label, label); + */ + + public void setReplaceButtonLabel(final String label) { + nSetReplaceButtonLabel(label); + } + + private native void nSetReplaceButtonLabel(String label); /*MANUAL + auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE); + THIS->SetReplaceButtonLabel(label); + if (label != NULL) env->ReleaseStringUTFChars(obj_label, label); + */ + + public void setReplaceAllButtonLabel(final String label) { + nSetReplaceAllButtonLabel(label); + } + + private native void nSetReplaceAllButtonLabel(String label); /*MANUAL + auto label = obj_label == NULL ? NULL : (char*)env->GetStringUTFChars(obj_label, JNI_FALSE); + THIS->SetReplaceAllButtonLabel(label); + if (label != NULL) env->ReleaseStringUTFChars(obj_label, label); + */ + + public boolean hasFindString() { + return nHasFindString(); + } + + private native boolean nHasFindString(); /* + return THIS->HasFindString(); + */ + + public void findNext() { + nFindNext(); + } + + private native void nFindNext(); /* + THIS->FindNext(); + */ + + public void findAll() { + nFindAll(); + } + + private native void nFindAll(); /* + THIS->FindAll(); + */ + + public void addMarker(final int line, final int lineNumberColor, final int textColor, final String lineNumberTooltip, final String textTooltip) { + nAddMarker(line, lineNumberColor, textColor, lineNumberTooltip, textTooltip); + } + + private native void nAddMarker(int line, int lineNumberColor, int textColor, String lineNumberTooltip, String textTooltip); /*MANUAL + auto lineNumberTooltip = obj_lineNumberTooltip == NULL ? NULL : (char*)env->GetStringUTFChars(obj_lineNumberTooltip, JNI_FALSE); + auto textTooltip = obj_textTooltip == NULL ? NULL : (char*)env->GetStringUTFChars(obj_textTooltip, JNI_FALSE); + THIS->AddMarker(line, lineNumberColor, textColor, lineNumberTooltip, textTooltip); + if (lineNumberTooltip != NULL) env->ReleaseStringUTFChars(obj_lineNumberTooltip, lineNumberTooltip); + if (textTooltip != NULL) env->ReleaseStringUTFChars(obj_textTooltip, textTooltip); + */ + + public void addMarker(final int line, final int lineNumberColor, final int textColor) { + addMarker(line, lineNumberColor, textColor, "", ""); + } + + public void addMarker(final int line, final int lineNumberColor, final int textColor, final String lineNumberTooltip) { + addMarker(line, lineNumberColor, textColor, lineNumberTooltip, ""); + } + + public void clearMarkers() { + nClearMarkers(); + } + + private native void nClearMarkers(); /* + THIS->ClearMarkers(); + */ + + public boolean hasMarkers() { + return nHasMarkers(); + } + + private native boolean nHasMarkers(); /* + return THIS->HasMarkers(); + */ + + public void indentLines() { + nIndentLines(); + } + + private native void nIndentLines(); /* + THIS->IndentLines(); + */ + + public void deindentLines() { + nDeindentLines(); + } + + private native void nDeindentLines(); /* + THIS->DeindentLines(); + */ + + public void moveUpLines() { + nMoveUpLines(); + } + + private native void nMoveUpLines(); /* + THIS->MoveUpLines(); + */ + + public void moveDownLines() { + nMoveDownLines(); + } + + private native void nMoveDownLines(); /* + THIS->MoveDownLines(); + */ + + public void toggleComments() { + nToggleComments(); + } + + private native void nToggleComments(); /* + THIS->ToggleComments(); + */ + + public void selectionToLowerCase() { + nSelectionToLowerCase(); + } + + private native void nSelectionToLowerCase(); /* + THIS->SelectionToLowerCase(); + */ + + public void selectionToUpperCase() { + nSelectionToUpperCase(); + } + + private native void nSelectionToUpperCase(); /* + THIS->SelectionToUpperCase(); + */ + + public void stripTrailingWhitespaces() { + nStripTrailingWhitespaces(); + } + + private native void nStripTrailingWhitespaces(); /* + THIS->StripTrailingWhitespaces(); + */ + + public void tabsToSpaces() { + nTabsToSpaces(); + } + + private native void nTabsToSpaces(); /* + THIS->TabsToSpaces(); + */ + + public void spacesToTabs() { + nSpacesToTabs(); + } + + private native void nSpacesToTabs(); /* + THIS->SpacesToTabs(); + */ + + public native int[] getPalette(); /* + return TextEditorPaletteToArray(env, THIS->GetPalette()); + */ + + public void setPalette(final int[] palette) { + nSetPalette(palette); + } + + private native void nSetPalette(int[] palette); /* + auto newPalette = THIS->GetPalette(); + TextEditorArrayToPalette(env, obj_palette, newPalette); + THIS->SetPalette(newPalette); + */ + + public static native int[] getDefaultPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetDefaultPalette()); + */ + + public static void setDefaultPalette(final int[] palette) { + nSetDefaultPalette(palette); + } + + private static native void nSetDefaultPalette(int[] palette); /* + auto newPalette = TextEditor::GetDefaultPalette(); + TextEditorArrayToPalette(env, obj_palette, newPalette); + TextEditor::SetDefaultPalette(newPalette); + */ + + public static native int[] getDarkPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetDarkPalette()); + */ + + public static native int[] getLightPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetLightPalette()); + */ + + public void setDarkPalette() { + setPalette(getDarkPalette()); + } + + public void setLightPalette() { + setPalette(getLightPalette()); + } + + public native int getPaletteColor(int colorIndex); /* + const auto& palette = THIS->GetPalette(); + const auto index = static_cast(colorIndex); + if (index >= palette.size()) { + jclass exClass = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); + env->ThrowNew(exClass, "Invalid TextEditor color index"); + return 0; + } + return static_cast(palette[index]); + */ + + public int getPaletteColor(final TextEditorColor color) { + return getPaletteColor(color.value); + } + + public native void setPaletteColor(int colorIndex, int value); /* + auto palette = THIS->GetPalette(); + const auto index = static_cast(colorIndex); + if (index >= palette.size()) { + jclass exClass = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); + env->ThrowNew(exClass, "Invalid TextEditor color index"); + return; + } + palette[index] = static_cast(value); + THIS->SetPalette(palette); + */ + + public void setPaletteColor(final TextEditorColor color, final int value) { + setPaletteColor(color.value, value); + } + + public TextEditorLanguage getLanguage() { + return new TextEditorLanguage(nGetLanguage()); + } + + private native long nGetLanguage(); /* + return (uintptr_t)THIS->GetLanguage(); + */ + + public boolean hasLanguage() { + return nHasLanguage(); + } + + private native boolean nHasLanguage(); /* + return THIS->HasLanguage(); + */ + + public String getLanguageName() { + return nGetLanguageName(); + } + + private native String nGetLanguageName(); /* + return env->NewStringUTF(THIS->GetLanguageName().c_str()); + */ + + public static void setImGuiContext(final ImGuiContext ctx) { + nSetImGuiContext(ctx.ptr); + } + + private static native void nSetImGuiContext(long ctx); /* + TextEditor::SetImGuiContext(reinterpret_cast(ctx)); + */ + + public void setUserData(final int line, final long data) { + nSetUserData(line, data); + } + + private native void nSetUserData(int line, long data); /* + THIS->SetUserData(line, reinterpret_cast(data)); + */ + + public long getUserData(final int line) { + return nGetUserData(line); + } + + private native long nGetUserData(int line); /* + return reinterpret_cast(THIS->GetUserData(line)); + */ + + /*JNI + #undef THIS + */ +} diff --git a/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorPosition.java b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorPosition.java new file mode 100644 index 00000000..acf01c46 --- /dev/null +++ b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorPosition.java @@ -0,0 +1,60 @@ +package imgui.extension.texteditor; + +import java.util.Objects; + +public final class TextEditorCursorPosition implements Cloneable { + public int line; + public int column; + + public TextEditorCursorPosition() { + } + + public TextEditorCursorPosition(final int line, final int column) { + set(line, column); + } + + public TextEditorCursorPosition(final TextEditorCursorPosition value) { + set(value.line, value.column); + } + + public TextEditorCursorPosition set(final int line, final int column) { + this.line = line; + this.column = column; + return this; + } + + public TextEditorCursorPosition set(final TextEditorCursorPosition value) { + return set(value.line, value.column); + } + + @Override + public String toString() { + return "TextEditorCursorPosition{" + + "line=" + line + + ", column=" + column + + '}'; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TextEditorCursorPosition that = (TextEditorCursorPosition) o; + return line == that.line && column == that.column; + } + + @Override + public int hashCode() { + return Objects.hash(line, column); + } + + @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") + public TextEditorCursorPosition clone() { + return new TextEditorCursorPosition(this); + } +} diff --git a/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorSelection.java b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorSelection.java new file mode 100644 index 00000000..cf9c7220 --- /dev/null +++ b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorCursorSelection.java @@ -0,0 +1,66 @@ +package imgui.extension.texteditor; + +import java.util.Objects; + +public final class TextEditorCursorSelection implements Cloneable { + public final TextEditorCursorPosition start = new TextEditorCursorPosition(); + public final TextEditorCursorPosition end = new TextEditorCursorPosition(); + + public TextEditorCursorSelection() { + } + + public TextEditorCursorSelection(final int startLine, final int startColumn, final int endLine, final int endColumn) { + set(startLine, startColumn, endLine, endColumn); + } + + public TextEditorCursorSelection(final TextEditorCursorSelection value) { + set(value); + } + + public TextEditorCursorSelection set(final int startLine, final int startColumn, final int endLine, final int endColumn) { + start.set(startLine, startColumn); + end.set(endLine, endColumn); + return this; + } + + public TextEditorCursorSelection set(final TextEditorCursorPosition start, final TextEditorCursorPosition end) { + this.start.set(start); + this.end.set(end); + return this; + } + + public TextEditorCursorSelection set(final TextEditorCursorSelection value) { + return set(value.start, value.end); + } + + @Override + public String toString() { + return "TextEditorCursorSelection{" + + "start=" + start + + ", end=" + end + + '}'; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TextEditorCursorSelection that = (TextEditorCursorSelection) o; + return Objects.equals(start, that.start) && Objects.equals(end, that.end); + } + + @Override + public int hashCode() { + return Objects.hash(start, end); + } + + @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") + public TextEditorCursorSelection clone() { + return new TextEditorCursorSelection(this); + } +} diff --git a/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorLanguage.java b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorLanguage.java new file mode 100644 index 00000000..401d75f1 --- /dev/null +++ b/imgui-binding/src/generated/java/imgui/extension/texteditor/TextEditorLanguage.java @@ -0,0 +1,223 @@ +package imgui.extension.texteditor; + +import imgui.binding.ImGuiStruct; + + + + + + +public final class TextEditorLanguage extends ImGuiStruct { + public TextEditorLanguage(final long ptr) { + super(ptr); + } + + /*JNI + #include "_texteditor.h" + #define THIS ((const TextEditor::Language*)STRUCT_PTR) + */ + + public String getName() { + return nGetName(); + } + + private native String nGetName(); /* + return env->NewStringUTF(THIS->name.c_str()); + */ + + public boolean getCaseSensitive() { + return nGetCaseSensitive(); + } + + private native boolean nGetCaseSensitive(); /* + return THIS->caseSensitive; + */ + + public int getPreprocess() { + return nGetPreprocess(); + } + + private native int nGetPreprocess(); /* + return THIS->preprocess; + */ + + public String getSingleLineComment() { + return nGetSingleLineComment(); + } + + private native String nGetSingleLineComment(); /* + return env->NewStringUTF(THIS->singleLineComment.c_str()); + */ + + public String getSingleLineCommentAlt() { + return nGetSingleLineCommentAlt(); + } + + private native String nGetSingleLineCommentAlt(); /* + return env->NewStringUTF(THIS->singleLineCommentAlt.c_str()); + */ + + public String getCommentStart() { + return nGetCommentStart(); + } + + private native String nGetCommentStart(); /* + return env->NewStringUTF(THIS->commentStart.c_str()); + */ + + public String getCommentEnd() { + return nGetCommentEnd(); + } + + private native String nGetCommentEnd(); /* + return env->NewStringUTF(THIS->commentEnd.c_str()); + */ + + public boolean getHasSingleQuotedStrings() { + return nGetHasSingleQuotedStrings(); + } + + private native boolean nGetHasSingleQuotedStrings(); /* + return THIS->hasSingleQuotedStrings; + */ + + public boolean getHasDoubleQuotedStrings() { + return nGetHasDoubleQuotedStrings(); + } + + private native boolean nGetHasDoubleQuotedStrings(); /* + return THIS->hasDoubleQuotedStrings; + */ + + public String getOtherStringStart() { + return nGetOtherStringStart(); + } + + private native String nGetOtherStringStart(); /* + return env->NewStringUTF(THIS->otherStringStart.c_str()); + */ + + public String getOtherStringEnd() { + return nGetOtherStringEnd(); + } + + private native String nGetOtherStringEnd(); /* + return env->NewStringUTF(THIS->otherStringEnd.c_str()); + */ + + public String getOtherStringAltStart() { + return nGetOtherStringAltStart(); + } + + private native String nGetOtherStringAltStart(); /* + return env->NewStringUTF(THIS->otherStringAltStart.c_str()); + */ + + public String getOtherStringAltEnd() { + return nGetOtherStringAltEnd(); + } + + private native String nGetOtherStringAltEnd(); /* + return env->NewStringUTF(THIS->otherStringAltEnd.c_str()); + */ + + public int getStringEscape() { + return nGetStringEscape(); + } + + private native int nGetStringEscape(); /* + return THIS->stringEscape; + */ + + public static TextEditorLanguage C() { + return new TextEditorLanguage(nC()); + } + + private static native long nC(); /* + return (uintptr_t)TextEditor::Language::C(); + */ + + public static TextEditorLanguage Cpp() { + return new TextEditorLanguage(nCpp()); + } + + private static native long nCpp(); /* + return (uintptr_t)TextEditor::Language::Cpp(); + */ + + public static TextEditorLanguage Cs() { + return new TextEditorLanguage(nCs()); + } + + private static native long nCs(); /* + return (uintptr_t)TextEditor::Language::Cs(); + */ + + public static TextEditorLanguage AngelScript() { + return new TextEditorLanguage(nAngelScript()); + } + + private static native long nAngelScript(); /* + return (uintptr_t)TextEditor::Language::AngelScript(); + */ + + public static TextEditorLanguage Lua() { + return new TextEditorLanguage(nLua()); + } + + private static native long nLua(); /* + return (uintptr_t)TextEditor::Language::Lua(); + */ + + public static TextEditorLanguage Python() { + return new TextEditorLanguage(nPython()); + } + + private static native long nPython(); /* + return (uintptr_t)TextEditor::Language::Python(); + */ + + public static TextEditorLanguage Glsl() { + return new TextEditorLanguage(nGlsl()); + } + + private static native long nGlsl(); /* + return (uintptr_t)TextEditor::Language::Glsl(); + */ + + public static TextEditorLanguage Hlsl() { + return new TextEditorLanguage(nHlsl()); + } + + private static native long nHlsl(); /* + return (uintptr_t)TextEditor::Language::Hlsl(); + */ + + public static TextEditorLanguage Json() { + return new TextEditorLanguage(nJson()); + } + + private static native long nJson(); /* + return (uintptr_t)TextEditor::Language::Json(); + */ + + public static TextEditorLanguage Markdown() { + return new TextEditorLanguage(nMarkdown()); + } + + private static native long nMarkdown(); /* + return (uintptr_t)TextEditor::Language::Markdown(); + */ + + public static TextEditorLanguage Sql() { + return new TextEditorLanguage(nSql()); + } + + private static native long nSql(); /* + return (uintptr_t)TextEditor::Language::Sql(); + */ + + /*JNI + #undef THIS + */ +} diff --git a/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorColor.java b/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorColor.java new file mode 100644 index 00000000..a496cdc1 --- /dev/null +++ b/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorColor.java @@ -0,0 +1,33 @@ +package imgui.extension.texteditor.flag; + +public enum TextEditorColor { + text(0), + keyword(1), + declaration(2), + number(3), + string(4), + punctuation(5), + preprocessor(6), + identifier(7), + knownIdentifier(8), + comment(9), + background(10), + cursor(11), + selection(12), + whitespace(13), + matchingBracketBackground(14), + matchingBracketActive(15), + matchingBracketLevel1(16), + matchingBracketLevel2(17), + matchingBracketLevel3(18), + matchingBracketError(19), + lineNumber(20), + currentLineNumber(21), + count(22); + + public final int value; + + TextEditorColor(final int value) { + this.value = value; + } +} diff --git a/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorScroll.java b/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorScroll.java new file mode 100644 index 00000000..48bc15f3 --- /dev/null +++ b/imgui-binding/src/generated/java/imgui/extension/texteditor/flag/TextEditorScroll.java @@ -0,0 +1,13 @@ +package imgui.extension.texteditor.flag; + +public enum TextEditorScroll { + alignTop(0), + alignMiddle(1), + alignBottom(2); + + public final int value; + + TextEditorScroll(final int value) { + this.value = value; + } +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditor.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditor.java index a897f79e..a3b9d448 100644 --- a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditor.java +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditor.java @@ -5,13 +5,12 @@ import imgui.binding.annotation.ArgValue; import imgui.binding.annotation.BindingMethod; import imgui.binding.annotation.BindingSource; -import imgui.binding.annotation.ExcludedSource; import imgui.binding.annotation.OptArg; import imgui.binding.annotation.ReturnValue; +import imgui.extension.texteditor.flag.TextEditorColor; +import imgui.extension.texteditor.flag.TextEditorScroll; +import imgui.internal.ImGuiContext; -import java.util.Map; - -@ExcludedSource @BindingSource public final class TextEditor extends ImGuiStructDestroyable { public TextEditor() { @@ -30,7 +29,28 @@ protected long create() { /*JNI #include "_texteditor.h" #define THIS ((TextEditor*)STRUCT_PTR) - #define TextEditorLanguageDefinition TextEditor::LanguageDefinition + + static jintArray TextEditorPaletteToArray(JNIEnv* env, const TextEditor::Palette& palette) { + const auto size = static_cast(palette.size()); + jintArray result = env->NewIntArray(size); + std::vector values(static_cast(size)); + for (size_t i = 0; i < palette.size(); ++i) { + values[i] = static_cast(palette[i]); + } + env->SetIntArrayRegion(result, 0, size, values.data()); + return result; + } + + static void TextEditorArrayToPalette(JNIEnv* env, jintArray source, TextEditor::Palette& destination) { + const auto maxCount = static_cast(destination.size()); + auto valueCount = env->GetArrayLength(source); + valueCount = valueCount < maxCount ? valueCount : maxCount; + std::vector values(static_cast(valueCount)); + env->GetIntArrayRegion(source, 0, valueCount, values.data()); + for (jsize i = 0; i < valueCount; ++i) { + destination[static_cast(i)] = static_cast(values[static_cast(i)]); + } + } */ private native long nCreate(); /* @@ -38,67 +58,105 @@ protected long create() { */ @BindingMethod - public native void SetLanguageDefinition(@ArgValue(callPrefix = "*") TextEditorLanguageDefinition aLanguageDef); + public native void SetTabSize(int value); - @BindingMethod - @ReturnValue(callPrefix = "&") - public native TextEditorLanguageDefinition GetLanguageDefinition(); + public void setLanguage(final TextEditorLanguage language) { + nSetLanguage(language == null ? 0 : language.ptr); + } - public native int[] getPalette(); /* - const auto& palette = THIS->GetPalette(); - jintArray res = env->NewIntArray(palette.size()); - jint arr[palette.size()]; - for (int i = 0; i < palette.size(); i++) { - arr[i] = palette[i]; - } - env->SetIntArrayRegion(res, 0, palette.size(), arr); - return res; + private native void nSetLanguage(long languagePtr); /* + THIS->SetLanguage(reinterpret_cast(languagePtr)); */ - public void setPalette(final int[] palette) { - nSetPalette(palette, palette.length); - } + @BindingMethod + public native int GetTabSize(); - public native void nSetPalette(int[] palette, int length); /* - std::array arr; - for (int i = 0; i < length; i++) { - arr[i] = palette[i]; - } - THIS->SetPalette(arr); - */ + @BindingMethod + public native void SetInsertSpacesOnTabs(boolean value); - public void setErrorMarkers(final Map errorMarkers) { - final int[] keys = errorMarkers.keySet().stream().mapToInt(i -> i).toArray(); - final String[] values = errorMarkers.values().toArray(new String[0]); - nSetErrorMarkers(keys, keys.length, values, values.length); - } + @BindingMethod + public native boolean IsInsertSpacesOnTabs(); - private native void nSetErrorMarkers(int[] keys, int keysLen, String[] values, int valuesLen); /* - std::map markers; - for (int i = 0; i < keysLen; i++) { - int key = keys[i]; - jstring string = (jstring)env->GetObjectArrayElement(values, i); - const char* value = env->GetStringUTFChars(string, JNI_FALSE); - markers.emplace(std::pair(key, std::string(value))); - env->ReleaseStringUTFChars(string, value); - } - THIS->SetErrorMarkers(markers); - */ + @BindingMethod + public native void SetLineSpacing(float value); - public void setBreakpoints(final int[] breakpoints) { - nSetBreakpoints(breakpoints, breakpoints.length); - } + @BindingMethod + public native float GetLineSpacing(); - private native void nSetBreakpoints(int[] breakpoints, int length); /* - std::unordered_set set; - for (int i = 0; i < length; i++) { - set.emplace(breakpoints[i]); - } - THIS->SetBreakpoints(set); - */ + @BindingMethod + public native void SetReadOnlyEnabled(boolean value); + + @BindingMethod + public native boolean IsReadOnlyEnabled(); + + @BindingMethod + public native void SetAutoIndentEnabled(boolean value); + + @BindingMethod + public native boolean IsAutoIndentEnabled(); + + @BindingMethod + public native void SetShowWhitespacesEnabled(boolean value); + + @BindingMethod + public native boolean IsShowWhitespacesEnabled(); + + @BindingMethod + public native void SetShowSpacesEnabled(boolean value); + + @BindingMethod + public native boolean IsShowSpacesEnabled(); + + @BindingMethod + public native void SetShowTabsEnabled(boolean value); + + @BindingMethod + public native boolean IsShowTabsEnabled(); + + @BindingMethod + public native void SetShowLineNumbersEnabled(boolean value); + + @BindingMethod + public native boolean IsShowLineNumbersEnabled(); + + @BindingMethod + public native void SetShowScrollbarMiniMapEnabled(boolean value); + + @BindingMethod + public native boolean IsShowScrollbarMiniMapEnabled(); + + @BindingMethod + public native void SetShowPanScrollIndicatorEnabled(boolean value); + + @BindingMethod + public native boolean IsShowPanScrollIndicatorEnabled(); + + @BindingMethod + public native void SetShowMatchingBrackets(boolean value); + + @BindingMethod + public native boolean IsShowingMatchingBrackets(); + + @BindingMethod + public native void SetCompletePairedGlyphs(boolean value); + + @BindingMethod + public native boolean IsCompletingPairedGlyphs(); + + @BindingMethod + public native void SetOverwriteEnabled(boolean value); + + @BindingMethod + public native boolean IsOverwriteEnabled(); + + @BindingMethod + public native void SetMiddleMousePanMode(); + + @BindingMethod + public native void SetMiddleMouseScrollMode(); @BindingMethod - public native void Render(String title, @OptArg(callValue = "ImVec2()") ImVec2 aSize, @OptArg boolean aBorder); + public native boolean IsMiddleMousePanMode(); @BindingMethod public native void SetText(String text); @@ -107,210 +165,339 @@ public void setBreakpoints(final int[] breakpoints) { @ReturnValue(callSuffix = ".c_str()") public native String GetText(); - public void setTextLines(final String[] lines) { - nSetTextLines(lines, lines.length); + @BindingMethod + @ReturnValue(callSuffix = ".c_str()") + public native String GetCursorText(long cursor); + + @BindingMethod + @ReturnValue(callSuffix = ".c_str()") + public native String GetLineText(int line); + + @BindingMethod + @ReturnValue(callSuffix = ".c_str()") + public native String GetSectionText(int startLine, int startColumn, int endLine, int endColumn); + + @BindingMethod + public native void ReplaceSectionText(int startLine, int startColumn, int endLine, int endColumn, String text); + + public void clearText() { + setText(""); } - private native void nSetTextLines(String[] lines, int length); /* - std::vector vec; - vec.reserve(length); - for (int i = 0; i < length; i++) { - jstring string = (jstring)env->GetObjectArrayElement(lines, i); - const char* raw = env->GetStringUTFChars(string, JNI_FALSE); - vec.emplace_back(std::string(raw)); - env->ReleaseStringUTFChars(string, raw); - } - THIS->SetTextLines(vec); - */ + @BindingMethod + public native boolean IsEmpty(); - public native String[] getTextLines(); /* - const auto lines = THIS->GetTextLines(); + @BindingMethod + public native int GetLineCount(); - jobjectArray arr = env->NewObjectArray( - lines.size(), - env->FindClass("java/lang/String"), - env->NewStringUTF("") - ); + @BindingMethod + public native void Render(String title, @OptArg ImVec2 size, @OptArg boolean border); - for (int i = 0; i < lines.size(); i++) { - const auto& str = lines[i]; - env->SetObjectArrayElement(arr, i, env->NewStringUTF(str.c_str())); - } - return arr; - */ + public void render(final String title, final boolean border) { + render(title, new ImVec2(), border); + } @BindingMethod - @ReturnValue(callSuffix = ".c_str()") - public native String GetSelectedText(); + public native void SetFocus(); @BindingMethod - @ReturnValue(callSuffix = ".c_str()") - public native String GetCurrentLineText(); + public native void Cut(); @BindingMethod - public native int GetTotalLines(); + public native void Copy(); @BindingMethod - public native boolean IsOverwrite(); + public native void Paste(); @BindingMethod - public native void SetReadOnly(boolean aValue); + public native void Undo(); @BindingMethod - public native boolean IsReadOnly(); + public native void Redo(); @BindingMethod - public native boolean IsTextChanged(); + public native boolean CanUndo(); @BindingMethod - public native boolean IsCursorPositionChanged(); + public native boolean CanRedo(); @BindingMethod - public native boolean IsColorizerEnabled(); + public native long GetUndoIndex(); @BindingMethod - public native void SetColorizerEnable(boolean aValue); + public native void SetCursor(int line, int column); @BindingMethod - public native TextEditorCoordinates GetCursorPosition(); + public native void SelectAll(); @BindingMethod - public native void SetCursorPosition(TextEditorCoordinates aPosition); + public native void SelectLine(int line); @BindingMethod - public native void SetHandleMouseInputs(boolean aValue); + public native void SelectLines(int start, int end); @BindingMethod - public native boolean IsHandleMouseInputsEnabled(); + public native void SelectRegion(int startLine, int startColumn, int endLine, int endColumn); @BindingMethod - public native void SetHandleKeyboardInputs(boolean aValue); + public native void SelectToBrackets(@OptArg boolean includeBrackets); @BindingMethod - public native boolean IsHandleKeyboardInputsEnabled(); + public native void GrowSelectionsToCurlyBrackets(); @BindingMethod - public native void SetImGuiChildIgnored(boolean aValue); + public native void ShrinkSelectionsToCurlyBrackets(); @BindingMethod - public native boolean IsImGuiChildIgnored(); + public native void AddNextOccurrence(); @BindingMethod - public native void SetShowWhitespaces(boolean aValue); + public native void SelectAllOccurrences(); @BindingMethod - public native boolean IsShowingWhitespaces(); + public native boolean AnyCursorHasSelection(); @BindingMethod - public native void SetTabSize(int aValue); + public native boolean AllCursorsHaveSelection(); @BindingMethod - public native int GetTabSize(); + public native boolean CurrentCursorHasSelection(); @BindingMethod - public native void InsertText(String aValue); + public native void ClearCursors(); @BindingMethod - public native void MoveUp(@OptArg int aAmount, @OptArg boolean aSelect); + public native long GetNumberOfCursors(); @BindingMethod - public native void MoveDown(@OptArg int aAmount, @OptArg boolean aSelect); + public native TextEditorCursorPosition GetMainCursorPosition(); @BindingMethod - public native void MoveLeft(@OptArg int aAmount, @OptArg boolean aSelect, @OptArg boolean aWordMode); + public native TextEditorCursorPosition GetCurrentCursorPosition(); @BindingMethod - public native void MoveRight(@OptArg int aAmount, @OptArg boolean aSelect, @OptArg boolean aWordMode); + public native TextEditorCursorPosition GetCursorPosition(long cursor); @BindingMethod - public native void MoveTop(@OptArg boolean aSelect); + public native TextEditorCursorSelection GetCursorSelection(long cursor); @BindingMethod - public native void MoveBottom(@OptArg boolean aSelect); + public native TextEditorCursorSelection GetMainCursorSelection(); @BindingMethod - public native void MoveHome(@OptArg boolean aSelect); + @ReturnValue(callSuffix = ".c_str()") + public native String GetWordAtScreenPos(ImVec2 screenPos); @BindingMethod - public native void MoveEnd(@OptArg boolean aSelect); + public native void ScrollToLine(int line, @ArgValue(staticCast = "TextEditor::Scroll") int alignment); + + public void scrollToLine(final int line, final TextEditorScroll alignment) { + scrollToLine(line, alignment.value); + } @BindingMethod - public native void SetSelectionStart(TextEditorCoordinates aPosition); + public native int GetFirstVisibleLine(); @BindingMethod - public native void SetSelectionEnd(TextEditorCoordinates aPosition); + public native int GetLastVisibleLine(); @BindingMethod - public native void SetSelection(TextEditorCoordinates aStart, TextEditorCoordinates aEnd, @OptArg @ArgValue(staticCast = "TextEditor::SelectionMode") int aMode); + public native int GetFirstVisibleColumn(); @BindingMethod - public native void SelectWordUnderCursor(); + public native int GetLastVisibleColumn(); @BindingMethod - public native void SelectAll(); + public native float GetLineHeight(); @BindingMethod - public native boolean HasSelection(); + public native float GetGlyphWidth(); @BindingMethod - public native void Copy(); + public native void SelectFirstOccurrenceOf(String text, @OptArg boolean caseSensitive, @OptArg boolean wholeWord); @BindingMethod - public native void Cut(); + public native void SelectNextOccurrenceOf(String text, @OptArg boolean caseSensitive, @OptArg boolean wholeWord); @BindingMethod - public native void Paste(); + public native void SelectAllOccurrencesOf(String text, @OptArg boolean caseSensitive, @OptArg boolean wholeWord); @BindingMethod - public native void Delete(); + public native void ReplaceTextInCurrentCursor(String text); @BindingMethod - public native boolean CanUndo(); + public native void ReplaceTextInAllCursors(String text); @BindingMethod - public native boolean CanRedo(); + public native void OpenFindReplaceWindow(); @BindingMethod - public native void Undo(@OptArg int aSteps); + public native void CloseFindReplaceWindow(); @BindingMethod - public native void Redo(@OptArg int aSteps); + public native void SetFindButtonLabel(String label); - public native int[] getDarkPalette(); /* - const auto& palette = THIS->GetDarkPalette(); - jintArray res = env->NewIntArray(palette.size()); - jint arr[palette.size()]; - for (int i = 0; i < palette.size(); i++) { - arr[i] = palette[i]; - } - env->SetIntArrayRegion(res, 0, palette.size(), arr); - return res; + @BindingMethod + public native void SetFindAllButtonLabel(String label); + + @BindingMethod + public native void SetReplaceButtonLabel(String label); + + @BindingMethod + public native void SetReplaceAllButtonLabel(String label); + + @BindingMethod + public native boolean HasFindString(); + + @BindingMethod + public native void FindNext(); + + @BindingMethod + public native void FindAll(); + + @BindingMethod + public native void AddMarker(int line, int lineNumberColor, int textColor, String lineNumberTooltip, String textTooltip); + + public void addMarker(final int line, final int lineNumberColor, final int textColor) { + addMarker(line, lineNumberColor, textColor, "", ""); + } + + public void addMarker(final int line, final int lineNumberColor, final int textColor, final String lineNumberTooltip) { + addMarker(line, lineNumberColor, textColor, lineNumberTooltip, ""); + } + + @BindingMethod + public native void ClearMarkers(); + + @BindingMethod + public native boolean HasMarkers(); + + @BindingMethod + public native void IndentLines(); + + @BindingMethod + public native void DeindentLines(); + + @BindingMethod + public native void MoveUpLines(); + + @BindingMethod + public native void MoveDownLines(); + + @BindingMethod + public native void ToggleComments(); + + @BindingMethod + public native void SelectionToLowerCase(); + + @BindingMethod + public native void SelectionToUpperCase(); + + @BindingMethod + public native void StripTrailingWhitespaces(); + + @BindingMethod + public native void TabsToSpaces(); + + @BindingMethod + public native void SpacesToTabs(); + + public native int[] getPalette(); /* + return TextEditorPaletteToArray(env, THIS->GetPalette()); + */ + + public void setPalette(final int[] palette) { + nSetPalette(palette); + } + + private native void nSetPalette(int[] palette); /* + auto newPalette = THIS->GetPalette(); + TextEditorArrayToPalette(env, obj_palette, newPalette); + THIS->SetPalette(newPalette); + */ + + public static native int[] getDefaultPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetDefaultPalette()); + */ + + public static void setDefaultPalette(final int[] palette) { + nSetDefaultPalette(palette); + } + + private static native void nSetDefaultPalette(int[] palette); /* + auto newPalette = TextEditor::GetDefaultPalette(); + TextEditorArrayToPalette(env, obj_palette, newPalette); + TextEditor::SetDefaultPalette(newPalette); */ - public native int[] getLightPalette(); /* - const auto& palette = THIS->GetLightPalette(); - jintArray res = env->NewIntArray(palette.size()); - jint arr[palette.size()]; - for (int i = 0; i < palette.size(); i++) { - arr[i] = palette[i]; + public static native int[] getDarkPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetDarkPalette()); + */ + + public static native int[] getLightPalette(); /* + return TextEditorPaletteToArray(env, TextEditor::GetLightPalette()); + */ + + public void setDarkPalette() { + setPalette(getDarkPalette()); + } + + public void setLightPalette() { + setPalette(getLightPalette()); + } + + public native int getPaletteColor(int colorIndex); /* + const auto& palette = THIS->GetPalette(); + const auto index = static_cast(colorIndex); + if (index >= palette.size()) { + jclass exClass = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); + env->ThrowNew(exClass, "Invalid TextEditor color index"); + return 0; } - env->SetIntArrayRegion(res, 0, palette.size(), arr); - return res; + return static_cast(palette[index]); */ - public native int[] getRetroBluePalette(); /* - const auto& palette = THIS->GetRetroBluePalette(); - jintArray res = env->NewIntArray(palette.size()); - jint arr[palette.size()]; - for (int i = 0; i < palette.size(); i++) { - arr[i] = palette[i]; + public int getPaletteColor(final TextEditorColor color) { + return getPaletteColor(color.value); + } + + public native void setPaletteColor(int colorIndex, int value); /* + auto palette = THIS->GetPalette(); + const auto index = static_cast(colorIndex); + if (index >= palette.size()) { + jclass exClass = env->FindClass("java/lang/ArrayIndexOutOfBoundsException"); + env->ThrowNew(exClass, "Invalid TextEditor color index"); + return; } - env->SetIntArrayRegion(res, 0, palette.size(), arr); - return res; + palette[index] = static_cast(value); + THIS->SetPalette(palette); */ + public void setPaletteColor(final TextEditorColor color, final int value) { + setPaletteColor(color.value, value); + } + + @BindingMethod + public native TextEditorLanguage GetLanguage(); + + @BindingMethod + public native boolean HasLanguage(); + + @BindingMethod + @ReturnValue(callSuffix = ".c_str()") + public native String GetLanguageName(); + + @BindingMethod + public static native void SetImGuiContext(ImGuiContext ctx); + + @BindingMethod + public native void SetUserData(int line, @ArgValue(reinterpretCast = "void*") long data); + + @BindingMethod + @ReturnValue(callPrefix = "reinterpret_cast(", callSuffix = ")") + public native long GetUserData(int line); + /*JNI - #undef TextEditorLanguageDefinition #undef THIS */ } diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCoordinates.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCoordinates.java deleted file mode 100644 index 5fe4bfeb..00000000 --- a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCoordinates.java +++ /dev/null @@ -1,93 +0,0 @@ -package imgui.extension.texteditor; - -import imgui.binding.annotation.ExcludedSource; - -import java.util.Objects; - -@ExcludedSource -public final class TextEditorCoordinates implements Cloneable { - public int mLine; - public int mColumn; - - public TextEditorCoordinates() { - } - - public TextEditorCoordinates(final int mLine, final int mColumn) { - set(mLine, mColumn); - } - - public TextEditorCoordinates(final TextEditorCoordinates value) { - set(value.mLine, value.mColumn); - } - - public TextEditorCoordinates set(final int mLine, final int mColumn) { - this.mLine = mLine; - this.mColumn = mColumn; - return this; - } - - public TextEditorCoordinates set(final TextEditorCoordinates value) { - return set(value.mLine, value.mColumn); - } - - public TextEditorCoordinates plus(final int mLine, final int mColumn) { - this.mLine += mLine; - this.mColumn += mColumn; - return this; - } - - public TextEditorCoordinates plus(final TextEditorCoordinates value) { - return plus(value.mLine, value.mColumn); - } - - public TextEditorCoordinates minus(final int mLine, final int mColumn) { - this.mLine -= mLine; - this.mColumn -= mColumn; - return this; - } - - public TextEditorCoordinates minus(final TextEditorCoordinates value) { - return minus(value.mLine, value.mColumn); - } - - public TextEditorCoordinates times(final int mLine, final int mColumn) { - this.mLine *= mLine; - this.mColumn *= mColumn; - return this; - } - - public TextEditorCoordinates times(final TextEditorCoordinates value) { - return times(value.mLine, value.mColumn); - } - - @Override - public String toString() { - return "TextEditorCoordinates{" - + "mLine=" + mLine - + ", mColumn=" + mColumn - + '}'; - } - - @Override - public boolean equals(final Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final TextEditorCoordinates textEditorCoordinates = (TextEditorCoordinates) o; - return textEditorCoordinates.mLine == mLine && textEditorCoordinates.mColumn == mColumn; - } - - @Override - public int hashCode() { - return Objects.hash(mLine, mColumn); - } - - @Override - @SuppressWarnings("MethodDoesntCallSuperMethod") - public TextEditorCoordinates clone() { - return new TextEditorCoordinates(this); - } -} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorPosition.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorPosition.java new file mode 100644 index 00000000..acf01c46 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorPosition.java @@ -0,0 +1,60 @@ +package imgui.extension.texteditor; + +import java.util.Objects; + +public final class TextEditorCursorPosition implements Cloneable { + public int line; + public int column; + + public TextEditorCursorPosition() { + } + + public TextEditorCursorPosition(final int line, final int column) { + set(line, column); + } + + public TextEditorCursorPosition(final TextEditorCursorPosition value) { + set(value.line, value.column); + } + + public TextEditorCursorPosition set(final int line, final int column) { + this.line = line; + this.column = column; + return this; + } + + public TextEditorCursorPosition set(final TextEditorCursorPosition value) { + return set(value.line, value.column); + } + + @Override + public String toString() { + return "TextEditorCursorPosition{" + + "line=" + line + + ", column=" + column + + '}'; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TextEditorCursorPosition that = (TextEditorCursorPosition) o; + return line == that.line && column == that.column; + } + + @Override + public int hashCode() { + return Objects.hash(line, column); + } + + @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") + public TextEditorCursorPosition clone() { + return new TextEditorCursorPosition(this); + } +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorSelection.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorSelection.java new file mode 100644 index 00000000..cf9c7220 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorCursorSelection.java @@ -0,0 +1,66 @@ +package imgui.extension.texteditor; + +import java.util.Objects; + +public final class TextEditorCursorSelection implements Cloneable { + public final TextEditorCursorPosition start = new TextEditorCursorPosition(); + public final TextEditorCursorPosition end = new TextEditorCursorPosition(); + + public TextEditorCursorSelection() { + } + + public TextEditorCursorSelection(final int startLine, final int startColumn, final int endLine, final int endColumn) { + set(startLine, startColumn, endLine, endColumn); + } + + public TextEditorCursorSelection(final TextEditorCursorSelection value) { + set(value); + } + + public TextEditorCursorSelection set(final int startLine, final int startColumn, final int endLine, final int endColumn) { + start.set(startLine, startColumn); + end.set(endLine, endColumn); + return this; + } + + public TextEditorCursorSelection set(final TextEditorCursorPosition start, final TextEditorCursorPosition end) { + this.start.set(start); + this.end.set(end); + return this; + } + + public TextEditorCursorSelection set(final TextEditorCursorSelection value) { + return set(value.start, value.end); + } + + @Override + public String toString() { + return "TextEditorCursorSelection{" + + "start=" + start + + ", end=" + end + + '}'; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final TextEditorCursorSelection that = (TextEditorCursorSelection) o; + return Objects.equals(start, that.start) && Objects.equals(end, that.end); + } + + @Override + public int hashCode() { + return Objects.hash(start, end); + } + + @Override + @SuppressWarnings("MethodDoesntCallSuperMethod") + public TextEditorCursorSelection clone() { + return new TextEditorCursorSelection(this); + } +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguage.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguage.java new file mode 100644 index 00000000..7714f15d --- /dev/null +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguage.java @@ -0,0 +1,171 @@ +package imgui.extension.texteditor; + +import imgui.binding.ImGuiStruct; +import imgui.binding.annotation.BindingField; +import imgui.binding.annotation.BindingSource; +import imgui.binding.annotation.ReturnValue; +import imgui.binding.annotation.TypeStdString; + +@BindingSource +public final class TextEditorLanguage extends ImGuiStruct { + public TextEditorLanguage(final long ptr) { + super(ptr); + } + + /*JNI + #include "_texteditor.h" + #define THIS ((const TextEditor::Language*)STRUCT_PTR) + */ + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "name") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String Name; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "caseSensitive") + public boolean CaseSensitive; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "preprocess") + public int Preprocess; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "singleLineComment") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String SingleLineComment; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "singleLineCommentAlt") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String SingleLineCommentAlt; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "commentStart") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String CommentStart; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "commentEnd") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String CommentEnd; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "hasSingleQuotedStrings") + public boolean HasSingleQuotedStrings; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "hasDoubleQuotedStrings") + public boolean HasDoubleQuotedStrings; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "otherStringStart") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String OtherStringStart; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "otherStringEnd") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String OtherStringEnd; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "otherStringAltStart") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String OtherStringAltStart; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "otherStringAltEnd") + @TypeStdString + @ReturnValue(callSuffix = ".c_str()") + public String OtherStringAltEnd; + + @BindingField(accessors = BindingField.Accessor.GETTER, callName = "stringEscape") + public int StringEscape; + + public static TextEditorLanguage C() { + return new TextEditorLanguage(nC()); + } + + private static native long nC(); /* + return (uintptr_t)TextEditor::Language::C(); + */ + + public static TextEditorLanguage Cpp() { + return new TextEditorLanguage(nCpp()); + } + + private static native long nCpp(); /* + return (uintptr_t)TextEditor::Language::Cpp(); + */ + + public static TextEditorLanguage Cs() { + return new TextEditorLanguage(nCs()); + } + + private static native long nCs(); /* + return (uintptr_t)TextEditor::Language::Cs(); + */ + + public static TextEditorLanguage AngelScript() { + return new TextEditorLanguage(nAngelScript()); + } + + private static native long nAngelScript(); /* + return (uintptr_t)TextEditor::Language::AngelScript(); + */ + + public static TextEditorLanguage Lua() { + return new TextEditorLanguage(nLua()); + } + + private static native long nLua(); /* + return (uintptr_t)TextEditor::Language::Lua(); + */ + + public static TextEditorLanguage Python() { + return new TextEditorLanguage(nPython()); + } + + private static native long nPython(); /* + return (uintptr_t)TextEditor::Language::Python(); + */ + + public static TextEditorLanguage Glsl() { + return new TextEditorLanguage(nGlsl()); + } + + private static native long nGlsl(); /* + return (uintptr_t)TextEditor::Language::Glsl(); + */ + + public static TextEditorLanguage Hlsl() { + return new TextEditorLanguage(nHlsl()); + } + + private static native long nHlsl(); /* + return (uintptr_t)TextEditor::Language::Hlsl(); + */ + + public static TextEditorLanguage Json() { + return new TextEditorLanguage(nJson()); + } + + private static native long nJson(); /* + return (uintptr_t)TextEditor::Language::Json(); + */ + + public static TextEditorLanguage Markdown() { + return new TextEditorLanguage(nMarkdown()); + } + + private static native long nMarkdown(); /* + return (uintptr_t)TextEditor::Language::Markdown(); + */ + + public static TextEditorLanguage Sql() { + return new TextEditorLanguage(nSql()); + } + + private static native long nSql(); /* + return (uintptr_t)TextEditor::Language::Sql(); + */ + + /*JNI + #undef THIS + */ +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguageDefinition.java b/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguageDefinition.java deleted file mode 100644 index d698c7a3..00000000 --- a/imgui-binding/src/main/java/imgui/extension/texteditor/TextEditorLanguageDefinition.java +++ /dev/null @@ -1,182 +0,0 @@ -package imgui.extension.texteditor; - -import imgui.binding.ImGuiStructDestroyable; -import imgui.binding.annotation.BindingField; -import imgui.binding.annotation.BindingMethod; -import imgui.binding.annotation.BindingSource; -import imgui.binding.annotation.ExcludedSource; -import imgui.binding.annotation.ReturnValue; -import imgui.binding.annotation.TypeStdString; - -import java.util.Map; - -@ExcludedSource -@BindingSource -public final class TextEditorLanguageDefinition extends ImGuiStructDestroyable { - public TextEditorLanguageDefinition() { - super(); - } - - public TextEditorLanguageDefinition(final long ptr) { - super(ptr); - } - - @Override - protected long create() { - return nCreate(); - } - - /*JNI - #include "_texteditor.h" - #define THIS ((TextEditor::LanguageDefinition*)STRUCT_PTR) - #define TextEditorLanguageDefinition TextEditor::LanguageDefinition - */ - - private native long nCreate(); /* - return (uintptr_t)(new TextEditor::LanguageDefinition()); - */ - - @BindingField(callName = "mName") - @TypeStdString - @ReturnValue(callSuffix = ".c_str()") - public String Name; - - public void setKeywords(final String[] keywords) { - nSetKeywords(keywords, keywords.length); - } - - private native void nSetKeywords(String[] keywords, int length); /* - std::unordered_set set; - for (int i = 0; i < length; i++) { - jstring string = (jstring)env->GetObjectArrayElement(keywords, i); - const char* raw = env->GetStringUTFChars(string, JNI_FALSE); - set.emplace(std::string(raw)); - env->ReleaseStringUTFChars(string, raw); - } - THIS->mKeywords = set; - */ - - public void setIdentifiers(final Map identifiers) { - final String[] keys = identifiers.keySet().toArray(new String[0]); - final String[] decl = identifiers.values().toArray(new String[0]); - nSetIdentifiers(keys, keys.length, decl, decl.length); - } - - private native void nSetIdentifiers(String[] keys, int keysLen, String[] decl, int declLen); /* - std::unordered_map identifiers; - for (int i = 0; i < keysLen; i++) { - jstring string1 = (jstring)env->GetObjectArrayElement(keys, i); - jstring string2 = (jstring)env->GetObjectArrayElement(decl, i); - const char* key = env->GetStringUTFChars(string1, JNI_FALSE); - const char* value = env->GetStringUTFChars(string2, JNI_FALSE); - TextEditor::Identifier id; - id.mDeclaration = std::string(value); - identifiers.insert(std::pair(std::string(key), id)); - env->ReleaseStringUTFChars(string1, key); - env->ReleaseStringUTFChars(string2, value); - } - THIS->mIdentifiers = identifiers; - */ - - public void setPreprocIdentifiers(final Map identifiers) { - final String[] keys = identifiers.keySet().toArray(new String[0]); - final String[] decl = identifiers.values().toArray(new String[0]); - nSetPreprocIdentifiers(keys, keys.length, decl, decl.length); - } - - private native void nSetPreprocIdentifiers(String[] keys, int keysLen, String[] decl, int declLen); /* - std::unordered_map preprocIdentifiers; - for (int i = 0; i < keysLen; i++) { - jstring string1 = (jstring)env->GetObjectArrayElement(keys, i); - jstring string2 = (jstring)env->GetObjectArrayElement(decl, i); - const char* key = env->GetStringUTFChars(string1, JNI_FALSE); - const char* value = env->GetStringUTFChars(string2, JNI_FALSE); - TextEditor::Identifier id; - id.mDeclaration = std::string(value); - preprocIdentifiers.insert(std::pair(std::string(key), id)); - env->ReleaseStringUTFChars(string1, key); - env->ReleaseStringUTFChars(string2, value); - } - THIS->mPreprocIdentifiers = preprocIdentifiers; - */ - - @BindingField(callName = "mCommentStart") - @TypeStdString - @ReturnValue(callSuffix = ".c_str()") - public String CommentStart; - - @BindingField(callName = "mCommentEnd") - @TypeStdString - @ReturnValue(callSuffix = ".c_str()") - public String CommentEnd; - - @BindingField(callName = "mSingleLineComment") - @TypeStdString - @ReturnValue(callSuffix = ".c_str()") - public String SingleLineComment; - - @BindingField(callName = "mPreprocChar") - public char PreprocChar; - - @BindingField(callName = "mAutoIndentation") - public boolean AutoIndentation; - - public void setTokenRegexStrings(final Map tokenRegexStrings) { - final String[] keys = tokenRegexStrings.keySet().toArray(new String[0]); - final int[] paletteIndexes = tokenRegexStrings.values().stream().mapToInt(i -> i).toArray(); - nSetTokenRegexStrings(keys, keys.length, paletteIndexes, paletteIndexes.length); - } - - private native void nSetTokenRegexStrings(String[] keys, int keysLen, int[] paletteIndexes, int paletteIndexesLen); /* - std::vector> tokenRegexStrings; - for (int i = 0; i < keysLen; i++) { - jstring string = (jstring)env->GetObjectArrayElement(keys, i); - const char* key = env->GetStringUTFChars(string, JNI_FALSE); - int value = paletteIndexes[i]; - tokenRegexStrings.emplace_back( - std::pair( - std::string(key), - static_cast(value) - ) - ); - env->ReleaseStringUTFChars(string, key); - } - THIS->mTokenRegexStrings = tokenRegexStrings; - */ - - @BindingField - public boolean mCaseSensitive; - - @BindingMethod(name = "CPlusPlus") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition CPlusPlus(); - - @BindingMethod(name = "HLSL") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition HLSL(); - - @BindingMethod(name = "GLSL") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition GLSL(); - - @BindingMethod(name = "C") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition C(); - - @BindingMethod(name = "SQL") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition SQL(); - - @BindingMethod(name = "AngelScript") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition AngelScript(); - - @BindingMethod(name = "Lua") - @ReturnValue(isStatic = true, callPrefix = "&") - public static native TextEditorLanguageDefinition Lua(); - - /*JNI - #undef TextEditorLanguageDefinition - #undef THIS - */ -} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorColor.java b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorColor.java new file mode 100644 index 00000000..a496cdc1 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorColor.java @@ -0,0 +1,33 @@ +package imgui.extension.texteditor.flag; + +public enum TextEditorColor { + text(0), + keyword(1), + declaration(2), + number(3), + string(4), + punctuation(5), + preprocessor(6), + identifier(7), + knownIdentifier(8), + comment(9), + background(10), + cursor(11), + selection(12), + whitespace(13), + matchingBracketBackground(14), + matchingBracketActive(15), + matchingBracketLevel1(16), + matchingBracketLevel2(17), + matchingBracketLevel3(18), + matchingBracketError(19), + lineNumber(20), + currentLineNumber(21), + count(22); + + public final int value; + + TextEditorColor(final int value) { + this.value = value; + } +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorPaletteIndex.java b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorPaletteIndex.java deleted file mode 100644 index 646cb22a..00000000 --- a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorPaletteIndex.java +++ /dev/null @@ -1,15 +0,0 @@ -package imgui.extension.texteditor.flag; - -import imgui.binding.annotation.BindingAstEnum; -import imgui.binding.annotation.BindingSource; -import imgui.binding.annotation.ExcludedSource; - -@ExcludedSource -@BindingSource -public final class TextEditorPaletteIndex { - private TextEditorPaletteIndex() { - } - - @BindingAstEnum(file = "ast-TextEditor.json", qualType = "TextEditor::PaletteIndex") - public Void __; -} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorScroll.java b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorScroll.java new file mode 100644 index 00000000..48bc15f3 --- /dev/null +++ b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorScroll.java @@ -0,0 +1,13 @@ +package imgui.extension.texteditor.flag; + +public enum TextEditorScroll { + alignTop(0), + alignMiddle(1), + alignBottom(2); + + public final int value; + + TextEditorScroll(final int value) { + this.value = value; + } +} diff --git a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorSelectionMode.java b/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorSelectionMode.java deleted file mode 100644 index fdfdc0c8..00000000 --- a/imgui-binding/src/main/java/imgui/extension/texteditor/flag/TextEditorSelectionMode.java +++ /dev/null @@ -1,15 +0,0 @@ -package imgui.extension.texteditor.flag; - -import imgui.binding.annotation.BindingAstEnum; -import imgui.binding.annotation.BindingSource; -import imgui.binding.annotation.ExcludedSource; - -@ExcludedSource -@BindingSource -public final class TextEditorSelectionMode { - private TextEditorSelectionMode() { - } - - @BindingAstEnum(file = "ast-TextEditor.json", qualType = "TextEditor::SelectionMode") - public Void __; -} diff --git a/imgui-binding/src/main/native/_texteditor.h b/imgui-binding/src/main/native/_texteditor.h index 970f4f44..5859f7a5 100644 --- a/imgui-binding/src/main/native/_texteditor.h +++ b/imgui-binding/src/main/native/_texteditor.h @@ -10,6 +10,6 @@ #include #include "_common.h" -//#include "TextEditor.h" +#include "TextEditor.h" #include "jni_texteditor.h" diff --git a/imgui-binding/src/main/native/jni_texteditor.cpp b/imgui-binding/src/main/native/jni_texteditor.cpp index bad09578..8ce27735 100644 --- a/imgui-binding/src/main/native/jni_texteditor.cpp +++ b/imgui-binding/src/main/native/jni_texteditor.cpp @@ -1,38 +1,45 @@ #include "jni_texteditor.h" -//static jfieldID coordinatesLineID; -//static jfieldID coordinatesColumnID; - -//static void initialize(JNIEnv* env) { -// static bool initialized = false; -// if (initialized) { -// return; -// } -// -// jclass coordinatesClass = env->FindClass("imgui/extension/texteditor/TextEditorCoordinates"); -// coordinatesLineID = env->GetFieldID(coordinatesClass, "mLine", "I"); -// coordinatesColumnID = env->GetFieldID(coordinatesClass, "mColumn", "I"); -// -// initialized = true; -//} +static jfieldID cursorPositionLineID; +static jfieldID cursorPositionColumnID; +static jfieldID cursorSelectionStartID; +static jfieldID cursorSelectionEndID; + +static void initialize(JNIEnv* env) { + static bool initialized = false; + if (initialized) { + return; + } + + jclass cursorPositionClass = env->FindClass("imgui/extension/texteditor/TextEditorCursorPosition"); + cursorPositionLineID = env->GetFieldID(cursorPositionClass, "line", "I"); + cursorPositionColumnID = env->GetFieldID(cursorPositionClass, "column", "I"); + + jclass cursorSelectionClass = env->FindClass("imgui/extension/texteditor/TextEditorCursorSelection"); + cursorSelectionStartID = env->GetFieldID(cursorSelectionClass, "start", "Limgui/extension/texteditor/TextEditorCursorPosition;"); + cursorSelectionEndID = env->GetFieldID(cursorSelectionClass, "end", "Limgui/extension/texteditor/TextEditorCursorPosition;"); + + initialized = true; +} namespace Jni { -// void TextEditorCoordinatesCpy(JNIEnv* env, TextEditor::Coordinates* src, jobject dst) { -// initialize(env); -// env->SetIntField(dst, coordinatesLineID, src->mLine); -// env->SetIntField(dst, coordinatesColumnID, src->mColumn); -// } -// -// void TextEditorCoordinatesCpy(JNIEnv* env, TextEditor::Coordinates src, jobject dst) { -// initialize(env); -// env->SetIntField(dst, coordinatesLineID, src.mLine); -// env->SetIntField(dst, coordinatesColumnID, src.mColumn); -// } -// -// void TextEditorCoordinatesCpy(JNIEnv* env, jobject src, TextEditor::Coordinates* dst) { -// initialize(env); -// dst->mLine = env->GetIntField(src, coordinatesLineID); -// dst->mColumn = env->GetIntField(src, coordinatesColumnID); -// } + void TextEditorCursorPositionCpy(JNIEnv* env, TextEditor::CursorPosition src, jobject dst) { + initialize(env); + env->SetIntField(dst, cursorPositionLineID, src.line); + env->SetIntField(dst, cursorPositionColumnID, src.column); + } + + void TextEditorCursorSelectionCpy(JNIEnv* env, TextEditor::CursorSelection src, jobject dst) { + initialize(env); + + jobject start = env->GetObjectField(dst, cursorSelectionStartID); + jobject end = env->GetObjectField(dst, cursorSelectionEndID); + + TextEditorCursorPositionCpy(env, src.start, start); + TextEditorCursorPositionCpy(env, src.end, end); + + env->DeleteLocalRef(start); + env->DeleteLocalRef(end); + } } diff --git a/imgui-binding/src/main/native/jni_texteditor.h b/imgui-binding/src/main/native/jni_texteditor.h index 83942ef8..dcb542c8 100644 --- a/imgui-binding/src/main/native/jni_texteditor.h +++ b/imgui-binding/src/main/native/jni_texteditor.h @@ -1,11 +1,10 @@ #pragma once #include "jni.h" -//#include "TextEditor.h" +#include "TextEditor.h" namespace Jni { -// void TextEditorCoordinatesCpy(JNIEnv* env, TextEditor::Coordinates* src, jobject dst); -// void TextEditorCoordinatesCpy(JNIEnv* env, TextEditor::Coordinates src, jobject dst); -// void TextEditorCoordinatesCpy(JNIEnv* env, jobject src, TextEditor::Coordinates* dst); + void TextEditorCursorPositionCpy(JNIEnv* env, TextEditor::CursorPosition src, jobject dst); + void TextEditorCursorSelectionCpy(JNIEnv* env, TextEditor::CursorSelection src, jobject dst); } diff --git a/include/ImGuiColorTextEdit b/include/ImGuiColorTextEdit index 0a88824f..e8c57994 160000 --- a/include/ImGuiColorTextEdit +++ b/include/ImGuiColorTextEdit @@ -1 +1 @@ -Subproject commit 0a88824f7de8d0bd11d8419066caa7d3469395c4 +Subproject commit e8c57994dddfb533391b3bcc02be1b7596404297