RynthCore as of 2026-10-04 (internal 843c801): RynthNav auto-travel and the navigation map, plugin API v75 (server and titles), launcher with Available plugins, download progress and the update on the front page, opt-in usage statistics, NPC names, radar colours, title-bar text size, FPS limiter, client action unlocks, release 2026.10.4.6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9b5e2765b7
commit
a24ed6df7c
322 changed files with 83009 additions and 7504 deletions
2
native/cimgui/.gitattributes
vendored
Normal file
2
native/cimgui/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Applied with git apply to an LF checkout: keep the bytes as committed.
|
||||
*.patch -text
|
||||
3
native/cimgui/.gitignore
vendored
Normal file
3
native/cimgui/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
_src/
|
||||
_build/
|
||||
_textedit/
|
||||
47
native/cimgui/CMakeLists.txt
Normal file
47
native/cimgui/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# RynthCore cimgui build: upstream cimgui 1.91.6dock (fetched into _src by
|
||||
# scripts/Build-Cimgui.ps1) plus rynth_imconfig.h and rynth_cimgui_ext.cpp,
|
||||
# and ImGuiColorTextEdit (fetched into _textedit, patched by
|
||||
# textedit-rynth.patch) with its C exports in rynth_textedit_ext.cpp.
|
||||
# Output: a 32-bit cimgui.dll whose structs match ImGui.NET 1.91.6.1.
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
project(rynth_cimgui CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
# Static CRT, like the stock ImGui.NET native build: no VC++ redistributable needed.
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
|
||||
set(SRC ${CMAKE_CURRENT_SOURCE_DIR}/_src)
|
||||
set(TEXTEDIT ${CMAKE_CURRENT_SOURCE_DIR}/_textedit)
|
||||
|
||||
add_library(cimgui SHARED
|
||||
${SRC}/cimgui.cpp
|
||||
${SRC}/imgui/imgui.cpp
|
||||
${SRC}/imgui/imgui_draw.cpp
|
||||
${SRC}/imgui/imgui_demo.cpp
|
||||
${SRC}/imgui/imgui_tables.cpp
|
||||
${SRC}/imgui/imgui_widgets.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rynth_cimgui_ext.cpp
|
||||
${TEXTEDIT}/TextEditor.cpp
|
||||
${TEXTEDIT}/LanguageDefinitions.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rynth_textedit_ext.cpp
|
||||
)
|
||||
|
||||
# Same defines as upstream cimgui's CMakeLists, except the user config.
|
||||
target_compile_definitions(cimgui PRIVATE
|
||||
IMGUI_USER_CONFIG=\"rynth_imconfig.h\"
|
||||
IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1
|
||||
"IMGUI_IMPL_API=extern \"C\" __declspec(dllexport)"
|
||||
)
|
||||
target_include_directories(cimgui PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${SRC}
|
||||
${SRC}/imgui
|
||||
${TEXTEDIT}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/textedit_shim
|
||||
)
|
||||
# ImGuiColorTextEdit uses std::string/printf-style code MSVC warns about.
|
||||
set_source_files_properties(${TEXTEDIT}/TextEditor.cpp ${TEXTEDIT}/LanguageDefinitions.cpp
|
||||
PROPERTIES COMPILE_OPTIONS "/wd4244;/wd4267;/wd4018;/wd4305")
|
||||
set_target_properties(cimgui PROPERTIES PREFIX "")
|
||||
target_link_libraries(cimgui imm32)
|
||||
118
native/cimgui/rynth_cimgui_ext.cpp
Normal file
118
native/cimgui/rynth_cimgui_ext.cpp
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
// ============================================================================
|
||||
// RynthCore cimgui build - extra exports compiled into cimgui.dll.
|
||||
//
|
||||
// RynthImGui_BuildTag identifies this build (the engine refuses others).
|
||||
// RynthImGui_GetLayout sizes/offsets/enum counts the engine compares
|
||||
// against ImGui.NET's structs before creating a
|
||||
// context (see ImGuiSelfTest.cs; same index order).
|
||||
// RynthImGui_ReportAssert IM_ASSERT target (rynth_imconfig.h); records into
|
||||
// a ring buffer the engine polls from AC's thread.
|
||||
// ============================================================================
|
||||
|
||||
#include "imgui.h"
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define RYNTH_EXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
// ---- Build tag -------------------------------------------------------------
|
||||
// Bump the trailing number whenever the layout table or config changes.
|
||||
RYNTH_EXPORT const char* RynthImGui_BuildTag(void)
|
||||
{
|
||||
return "rynth-cimgui 1.91.6dock ImTextureID=void* soft-assert layout-1 textedit-264bee4";
|
||||
}
|
||||
|
||||
// ---- Layout table ------------------------------------------------------------
|
||||
// Index order is a contract with ImGuiSelfTest.ExpectedLayout(); append only.
|
||||
RYNTH_EXPORT int RynthImGui_GetLayout(int* out, int capacity)
|
||||
{
|
||||
const int values[] =
|
||||
{
|
||||
1, // 0 table version
|
||||
(int)sizeof(ImTextureID), // 1
|
||||
(int)sizeof(ImWchar), // 2
|
||||
(int)sizeof(ImDrawIdx), // 3
|
||||
(int)sizeof(ImDrawVert), // 4
|
||||
(int)sizeof(ImDrawCmd), // 5
|
||||
(int)offsetof(ImDrawCmd, TextureId), // 6
|
||||
(int)offsetof(ImDrawCmd, VtxOffset), // 7
|
||||
(int)offsetof(ImDrawCmd, IdxOffset), // 8
|
||||
(int)offsetof(ImDrawCmd, ElemCount), // 9
|
||||
(int)offsetof(ImDrawCmd, UserCallback), // 10
|
||||
(int)sizeof(ImDrawList), // 11
|
||||
(int)offsetof(ImDrawList, VtxBuffer), // 12
|
||||
(int)sizeof(ImDrawData), // 13
|
||||
(int)offsetof(ImDrawData, CmdLists), // 14
|
||||
(int)offsetof(ImDrawData, DisplayPos), // 15
|
||||
(int)offsetof(ImDrawData, DisplaySize), // 16
|
||||
(int)sizeof(ImFontAtlas), // 17
|
||||
(int)offsetof(ImFontAtlas, TexID), // 18
|
||||
(int)sizeof(ImFont), // 19
|
||||
(int)sizeof(ImFontGlyph), // 20
|
||||
(int)sizeof(ImFontConfig), // 21
|
||||
(int)sizeof(ImGuiIO), // 22
|
||||
(int)offsetof(ImGuiIO, Fonts), // 23
|
||||
(int)offsetof(ImGuiIO, WantCaptureMouse), // 24
|
||||
(int)offsetof(ImGuiIO, WantTextInput), // 25
|
||||
(int)sizeof(ImGuiStyle), // 26
|
||||
(int)sizeof(ImGuiViewport), // 27
|
||||
(int)sizeof(ImGuiPlatformIO), // 28
|
||||
(int)sizeof(ImGuiInputTextCallbackData), // 29
|
||||
(int)sizeof(ImGuiListClipper), // 30
|
||||
(int)sizeof(ImGuiPayload), // 31
|
||||
(int)sizeof(ImGuiTableSortSpecs), // 32
|
||||
(int)sizeof(ImGuiTableColumnSortSpecs), // 33
|
||||
(int)sizeof(ImGuiStorage), // 34
|
||||
(int)sizeof(ImGuiWindowClass), // 35
|
||||
(int)sizeof(ImGuiSizeCallbackData), // 36
|
||||
(int)ImGuiCol_COUNT, // 37
|
||||
(int)ImGuiKey_NamedKey_END, // 38
|
||||
(int)ImGuiStyleVar_COUNT, // 39
|
||||
(int)ImGuiMouseCursor_COUNT, // 40
|
||||
};
|
||||
const int count = (int)(sizeof(values) / sizeof(values[0]));
|
||||
if (out != NULL)
|
||||
for (int i = 0; i < count && i < capacity; i++)
|
||||
out[i] = values[i];
|
||||
return count;
|
||||
}
|
||||
|
||||
// ---- Soft asserts ------------------------------------------------------------
|
||||
// ImGui runs on one thread (AC's render thread); the engine polls on the same
|
||||
// thread, so plain statics are enough. The ring keeps the last 16 failures.
|
||||
static const int kAssertSlots = 16;
|
||||
static const int kAssertTextLen = 256;
|
||||
static int g_assertCount;
|
||||
static char g_assertText[kAssertSlots][kAssertTextLen];
|
||||
|
||||
extern "C" void RynthImGui_ReportAssert(const char* expr, const char* file, int line)
|
||||
{
|
||||
const char* base = file;
|
||||
for (const char* p = file; *p; p++)
|
||||
if (*p == '\\' || *p == '/')
|
||||
base = p + 1;
|
||||
char* slot = g_assertText[g_assertCount % kAssertSlots];
|
||||
_snprintf_s(slot, kAssertTextLen, _TRUNCATE, "%s:%d: %s", base, line, expr);
|
||||
g_assertCount++;
|
||||
}
|
||||
|
||||
// Total failures since load (monotonic; wraps only after 2^31).
|
||||
RYNTH_EXPORT int RynthImGui_GetAssertCount(void)
|
||||
{
|
||||
return g_assertCount;
|
||||
}
|
||||
|
||||
// Copies failure number `index` (0-based, < count) into buf. Returns the
|
||||
// length copied, or -1 when that entry was already overwritten or not yet made.
|
||||
RYNTH_EXPORT int RynthImGui_GetAssertText(int index, char* buf, int capacity)
|
||||
{
|
||||
if (buf == NULL || capacity <= 0 || index < 0 || index >= g_assertCount || index < g_assertCount - kAssertSlots)
|
||||
return -1;
|
||||
const char* src = g_assertText[index % kAssertSlots];
|
||||
int len = (int)strnlen(src, kAssertTextLen);
|
||||
if (len >= capacity) len = capacity - 1;
|
||||
memcpy(buf, src, (size_t)len);
|
||||
buf[len] = '\0';
|
||||
return len;
|
||||
}
|
||||
26
native/cimgui/rynth_imconfig.h
Normal file
26
native/cimgui/rynth_imconfig.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// ============================================================================
|
||||
// RynthCore cimgui build - Dear ImGui user config (IMGUI_USER_CONFIG).
|
||||
// Replaces upstream cimgui's cimconfig.h (which only did #undef NDEBUG).
|
||||
// ============================================================================
|
||||
#pragma once
|
||||
|
||||
// ImGui.NET 1.91.6.1 declares ImTextureID as IntPtr (pointer-sized). Dear ImGui
|
||||
// 1.91.4+ defaults it to ImU64, which on x86 makes ImDrawCmd, ImDrawList and
|
||||
// ImFontAtlas wider than ImGui.NET's structs and shifts every by-value texture
|
||||
// argument (SetTexID, Image, AddImage, ...). This is why the stock NuGet x86
|
||||
// cimgui.dll does not match its own wrapper. A named typedef (not a bare
|
||||
// "void*" macro) keeps functional casts like ImTextureID() valid.
|
||||
typedef void* RynthImTextureID;
|
||||
#define ImTextureID RynthImTextureID
|
||||
|
||||
// Soft asserts. A failed IM_ASSERT is recorded in a small native ring buffer
|
||||
// (rynth_cimgui_ext.cpp) that the engine polls and logs; control flow then
|
||||
// continues exactly as in a release build with asserts compiled out. The
|
||||
// handler never calls into managed code (a managed exception inside a native
|
||||
// frame fail-fasts the process).
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
void RynthImGui_ReportAssert(const char* expr, const char* file, int line);
|
||||
|
||||
#define IM_ASSERT(_EXPR) do { if (!(_EXPR)) RynthImGui_ReportAssert(#_EXPR, __FILE__, __LINE__); } while (0)
|
||||
308
native/cimgui/rynth_textedit_ext.cpp
Normal file
308
native/cimgui/rynth_textedit_ext.cpp
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
// ============================================================================
|
||||
// RynthCore cimgui build - C exports for ImGuiColorTextEdit (santaclose fork,
|
||||
// fetched into _textedit and patched by textedit-rynth.patch).
|
||||
//
|
||||
// The engine P/Invokes these by hand (ImGui/TextEditorNative.cs). Every call
|
||||
// is made on AC's render thread inside an ImGui frame (Create reads the style,
|
||||
// so it needs a current context too). Strings are UTF-8; returned pointers
|
||||
// stay valid until the next call of the same export.
|
||||
//
|
||||
// Languages: 1 = Meta (.af source: coloured by the tokenizer below from the
|
||||
// vocabulary the engine passes in), 2 = Lua (the fork's own definition).
|
||||
// ============================================================================
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include "TextEditor.h"
|
||||
|
||||
#define RYNTH_EXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
struct RynthTextEditAccess
|
||||
{
|
||||
typedef TextEditor::PaletteIndex PI;
|
||||
|
||||
static std::unordered_set<std::string>& StructWords() { static std::unordered_set<std::string> s; return s; }
|
||||
static std::unordered_set<std::string>& ConditionWords() { static std::unordered_set<std::string> s; return s; }
|
||||
static std::unordered_set<std::string>& ActionWords() { static std::unordered_set<std::string> s; return s; }
|
||||
|
||||
static bool IsWordStart(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'; }
|
||||
static bool IsDigit(char c) { return c >= '0' && c <= '9'; }
|
||||
static bool IsWordChar(char c) { return IsWordStart(c) || IsDigit(c); }
|
||||
|
||||
// Mirrors MetaSourceEditor.MetaColorizer: "~~" comments to the end of the
|
||||
// line, braces, numbers (hex and signed too), STATE:/IF:/DO:/NAV: (the
|
||||
// colon included), condition keywords, action keywords.
|
||||
static bool TokenizeMeta(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PI& color)
|
||||
{
|
||||
while (in_begin < in_end && (*in_begin == ' ' || *in_begin == '\t'))
|
||||
in_begin++;
|
||||
if (in_begin == in_end)
|
||||
{
|
||||
out_begin = out_end = in_end;
|
||||
color = PI::Default;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* p = in_begin;
|
||||
out_begin = p;
|
||||
char c = *p;
|
||||
|
||||
if (c == '~' && p + 1 < in_end && p[1] == '~')
|
||||
{
|
||||
out_end = in_end;
|
||||
color = PI::Comment;
|
||||
return true;
|
||||
}
|
||||
if (c == '{' || c == '}')
|
||||
{
|
||||
out_end = p + 1;
|
||||
color = PI::Punctuation;
|
||||
return true;
|
||||
}
|
||||
if (IsDigit(c) || (c == '-' && p + 1 < in_end && IsDigit(p[1])))
|
||||
{
|
||||
p++;
|
||||
while (p < in_end && (IsWordChar(*p) || *p == '.'))
|
||||
p++;
|
||||
out_end = p;
|
||||
color = PI::Number;
|
||||
return true;
|
||||
}
|
||||
if (IsWordStart(c))
|
||||
{
|
||||
p++;
|
||||
while (p < in_end && IsWordChar(*p))
|
||||
p++;
|
||||
std::string word(in_begin, p);
|
||||
std::transform(word.begin(), word.end(), word.begin(), [](char ch) { return (char)::toupper((unsigned char)ch); });
|
||||
color = PI::Default;
|
||||
if (p < in_end && *p == ':' && StructWords().count(word) != 0)
|
||||
{
|
||||
p++;
|
||||
color = PI::Keyword;
|
||||
}
|
||||
else if (ConditionWords().count(word) != 0)
|
||||
color = PI::KnownIdentifier;
|
||||
else if (ActionWords().count(word) != 0)
|
||||
color = PI::PreprocIdentifier;
|
||||
out_end = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Anything else (punctuation, UTF-8 bytes): one byte, default colour.
|
||||
out_end = p + 1;
|
||||
color = PI::Default;
|
||||
return true;
|
||||
}
|
||||
|
||||
static const TextEditor::LanguageDefinition& MetaLanguage()
|
||||
{
|
||||
static TextEditor::LanguageDefinition def;
|
||||
static bool built = false;
|
||||
if (!built)
|
||||
{
|
||||
built = true;
|
||||
def.mName = "Meta";
|
||||
def.mTokenize = &TokenizeMeta;
|
||||
def.mSingleLineComment = "~~"; // Ctrl+/ toggles "~~"
|
||||
// An empty block-comment start matches everywhere in ColorizeInternal,
|
||||
// so give it one that never occurs in text.
|
||||
def.mCommentStart = "\x01\x02";
|
||||
def.mCommentEnd = "\x02\x01";
|
||||
def.mPreprocChar = '\x01';
|
||||
def.mCaseSensitive = false;
|
||||
def.mTokenizerOwnsComments = true; // TokenizeMeta colours "~~" itself
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
static void SetLanguage(TextEditor* ed, int language)
|
||||
{
|
||||
if (language == 1)
|
||||
{
|
||||
ed->SetLanguageDefinition(TextEditor::LanguageDefinitionId::None);
|
||||
ed->mLanguageDefinition = &MetaLanguage();
|
||||
ed->Colorize();
|
||||
}
|
||||
else if (language == 2)
|
||||
ed->SetLanguageDefinition(TextEditor::LanguageDefinitionId::Lua);
|
||||
else
|
||||
ed->SetLanguageDefinition(TextEditor::LanguageDefinitionId::None);
|
||||
}
|
||||
|
||||
static void SetPalette(TextEditor* ed, const ImU32* colors, int count)
|
||||
{
|
||||
int n = std::min(count, (int)PI::Max);
|
||||
for (int i = 0; i < n; i++)
|
||||
ed->mPalette[i] = colors[i];
|
||||
}
|
||||
|
||||
static void CursorScreenPos(TextEditor* ed, float* x, float* y)
|
||||
{
|
||||
TextEditor::Coordinates at = ed->GetSanitizedCursorCoordinates();
|
||||
*x = ed->mTextOrigin.x + ed->mTextStart + ed->TextDistanceToLineStart(at);
|
||||
*y = ed->mTextOrigin.y + (at.mLine + 1) * ed->mCharAdvance.y;
|
||||
}
|
||||
|
||||
static std::string LinePrefix(TextEditor* ed)
|
||||
{
|
||||
TextEditor::Coordinates at = ed->GetSanitizedCursorCoordinates();
|
||||
return ed->GetText(TextEditor::Coordinates(at.mLine, 0), at);
|
||||
}
|
||||
|
||||
// Completion: replace the `bytes` characters before the cursor with `text`,
|
||||
// as one undo step.
|
||||
static void ReplaceBeforeCursor(TextEditor* ed, int bytes, const char* text)
|
||||
{
|
||||
if (ed->mReadOnly)
|
||||
return;
|
||||
ed->ClearExtraCursors();
|
||||
ed->ClearSelections();
|
||||
TextEditor::Coordinates end = ed->GetSanitizedCursorCoordinates();
|
||||
int endIndex = ed->GetCharacterIndexR(end);
|
||||
int startIndex = std::max(0, endIndex - std::max(0, bytes));
|
||||
TextEditor::Coordinates start(end.mLine, ed->GetCharacterColumn(end.mLine, startIndex));
|
||||
|
||||
TextEditor::UndoRecord u;
|
||||
u.mBefore = ed->mState;
|
||||
if (start < end)
|
||||
{
|
||||
ed->SetSelection(start, end);
|
||||
u.mOperations.push_back({ ed->GetSelectedText(), start, end, TextEditor::UndoOperationType::Delete });
|
||||
ed->DeleteSelection();
|
||||
}
|
||||
TextEditor::Coordinates insertAt = ed->GetSanitizedCursorCoordinates();
|
||||
ed->InsertTextAtCursor(text);
|
||||
u.mOperations.push_back({ std::string(text), insertAt, ed->GetSanitizedCursorCoordinates(), TextEditor::UndoOperationType::Add });
|
||||
u.mAfter = ed->mState;
|
||||
ed->AddUndo(u);
|
||||
}
|
||||
};
|
||||
|
||||
static void FillWordSet(std::unordered_set<std::string>& set, const char* words)
|
||||
{
|
||||
set.clear();
|
||||
if (words == nullptr)
|
||||
return;
|
||||
std::string current;
|
||||
for (const char* p = words;; p++)
|
||||
{
|
||||
if (*p == '\n' || *p == '\0')
|
||||
{
|
||||
if (!current.empty())
|
||||
set.insert(current);
|
||||
current.clear();
|
||||
if (*p == '\0')
|
||||
break;
|
||||
}
|
||||
else
|
||||
current.push_back((char)::toupper((unsigned char)*p));
|
||||
}
|
||||
}
|
||||
|
||||
RYNTH_EXPORT TextEditor* RynthTE_Create(void)
|
||||
{
|
||||
TextEditor* ed = new TextEditor();
|
||||
ed->SetShowWhitespacesEnabled(false);
|
||||
return ed;
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_Destroy(TextEditor* ed)
|
||||
{
|
||||
delete ed;
|
||||
}
|
||||
|
||||
/// Newline-separated words, matched case-insensitively. Applies to every Meta editor.
|
||||
RYNTH_EXPORT void RynthTE_SetMetaVocabulary(const char* structWords, const char* conditionWords, const char* actionWords)
|
||||
{
|
||||
FillWordSet(RynthTextEditAccess::StructWords(), structWords);
|
||||
FillWordSet(RynthTextEditAccess::ConditionWords(), conditionWords);
|
||||
FillWordSet(RynthTextEditAccess::ActionWords(), actionWords);
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_SetLanguage(TextEditor* ed, int language)
|
||||
{
|
||||
RynthTextEditAccess::SetLanguage(ed, language);
|
||||
}
|
||||
|
||||
/// `count` ImU32 colours in TextEditor::PaletteIndex order.
|
||||
RYNTH_EXPORT void RynthTE_SetPalette(TextEditor* ed, const ImU32* colors, int count)
|
||||
{
|
||||
RynthTextEditAccess::SetPalette(ed, colors, count);
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_SetOptions(TextEditor* ed, int readOnly, int showWhitespaces, int showLineNumbers, int tabSize)
|
||||
{
|
||||
ed->SetReadOnlyEnabled(readOnly != 0);
|
||||
ed->SetShowWhitespacesEnabled(showWhitespaces != 0);
|
||||
ed->SetShowLineNumbersEnabled(showLineNumbers != 0);
|
||||
ed->SetTabSize(tabSize);
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_SetText(TextEditor* ed, const char* utf8)
|
||||
{
|
||||
ed->SetText(utf8 != nullptr ? std::string(utf8) : std::string());
|
||||
}
|
||||
|
||||
RYNTH_EXPORT const char* RynthTE_GetText(TextEditor* ed, int* length)
|
||||
{
|
||||
static std::string text;
|
||||
text = ed->GetText();
|
||||
if (length != nullptr)
|
||||
*length = (int)text.size();
|
||||
return text.c_str();
|
||||
}
|
||||
|
||||
RYNTH_EXPORT unsigned RynthTE_GetChangeCount(TextEditor* ed)
|
||||
{
|
||||
return ed->GetChangeCount();
|
||||
}
|
||||
|
||||
/// Draws the editor as a child window; returns whether it has keyboard focus.
|
||||
RYNTH_EXPORT int RynthTE_Render(TextEditor* ed, const char* id, float width, float height, int border)
|
||||
{
|
||||
return ed->Render(id, false, ImVec2(width, height), border != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_GetCursor(TextEditor* ed, int* line, int* column)
|
||||
{
|
||||
ed->GetCursorPosition(*line, *column);
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_SetCursor(TextEditor* ed, int line, int charIndex)
|
||||
{
|
||||
ed->SetCursorPosition(line, charIndex);
|
||||
}
|
||||
|
||||
/// Screen position of the bottom-left corner of the cursor's cell (valid after Render).
|
||||
RYNTH_EXPORT void RynthTE_GetCursorScreenPos(TextEditor* ed, float* x, float* y)
|
||||
{
|
||||
RynthTextEditAccess::CursorScreenPos(ed, x, y);
|
||||
}
|
||||
|
||||
/// The cursor's line up to the cursor.
|
||||
RYNTH_EXPORT const char* RynthTE_GetLinePrefix(TextEditor* ed, int* length)
|
||||
{
|
||||
static std::string prefix;
|
||||
prefix = RynthTextEditAccess::LinePrefix(ed);
|
||||
if (length != nullptr)
|
||||
*length = (int)prefix.size();
|
||||
return prefix.c_str();
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_ReplaceBeforeCursor(TextEditor* ed, int bytes, const char* utf8)
|
||||
{
|
||||
RynthTextEditAccess::ReplaceBeforeCursor(ed, bytes, utf8 != nullptr ? utf8 : "");
|
||||
}
|
||||
|
||||
/// While set, the editor ignores Up/Down/PageUp/PageDown/Enter/Tab/Escape (the host's completion list uses them).
|
||||
RYNTH_EXPORT void RynthTE_SetCompletionKeysHeld(TextEditor* ed, int held)
|
||||
{
|
||||
ed->SetCompletionKeysHeld(held != 0);
|
||||
}
|
||||
|
||||
RYNTH_EXPORT void RynthTE_RequestFocus(TextEditor* ed)
|
||||
{
|
||||
ed->RequestFocus();
|
||||
}
|
||||
129
native/cimgui/textedit-rynth.patch
Normal file
129
native/cimgui/textedit-rynth.patch
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
diff --git a/TextEditor.cpp b/TextEditor.cpp
|
||||
index 013111f..9cd55a1 100644
|
||||
--- a/TextEditor.cpp
|
||||
+++ b/TextEditor.cpp
|
||||
@@ -325,13 +325,19 @@ void TextEditor::Paste()
|
||||
void TextEditor::Undo(int aSteps)
|
||||
{
|
||||
while (CanUndo() && aSteps-- > 0)
|
||||
+ {
|
||||
mUndoBuffer[--mUndoIndex].Undo(this);
|
||||
+ ++mChangeCount;
|
||||
+ }
|
||||
}
|
||||
|
||||
void TextEditor::Redo(int aSteps)
|
||||
{
|
||||
while (CanRedo() && aSteps-- > 0)
|
||||
+ {
|
||||
mUndoBuffer[mUndoIndex++].Redo(this);
|
||||
+ ++mChangeCount;
|
||||
+ }
|
||||
}
|
||||
|
||||
void TextEditor::SetText(const std::string& aText)
|
||||
@@ -355,6 +361,7 @@ void TextEditor::SetText(const std::string& aText)
|
||||
|
||||
mUndoBuffer.clear();
|
||||
mUndoIndex = 0;
|
||||
+ ++mChangeCount;
|
||||
|
||||
Colorize();
|
||||
}
|
||||
@@ -392,6 +399,7 @@ void TextEditor::SetTextLines(const std::vector<std::string>& aLines)
|
||||
|
||||
mUndoBuffer.clear();
|
||||
mUndoIndex = 0;
|
||||
+ ++mChangeCount;
|
||||
|
||||
Colorize();
|
||||
}
|
||||
@@ -428,6 +436,11 @@ bool TextEditor::Render(const char* aTitle, bool aParentIsFocused, const ImVec2&
|
||||
|
||||
ImGui::BeginChild(aTitle, aSize, aBorder, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNavInputs);
|
||||
|
||||
+ if (mFocusRequested)
|
||||
+ {
|
||||
+ ImGui::SetWindowFocus();
|
||||
+ mFocusRequested = false;
|
||||
+ }
|
||||
bool isFocused = ImGui::IsWindowFocused();
|
||||
HandleKeyboardInputs(aParentIsFocused);
|
||||
HandleMouseInputs();
|
||||
@@ -1993,7 +2006,12 @@ void TextEditor::HandleKeyboardInputs(bool aParentIsFocused)
|
||||
io.WantCaptureKeyboard = true;
|
||||
io.WantTextInput = true;
|
||||
|
||||
- if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGuiKey_Z))
|
||||
+ if (mCompletionKeysHeld && (ImGui::IsKeyPressed(ImGuiKey_UpArrow) || ImGui::IsKeyPressed(ImGuiKey_DownArrow) ||
|
||||
+ ImGui::IsKeyPressed(ImGuiKey_PageUp) || ImGui::IsKeyPressed(ImGuiKey_PageDown) ||
|
||||
+ ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter) ||
|
||||
+ ImGui::IsKeyPressed(ImGuiKey_Tab) || ImGui::IsKeyPressed(ImGuiKey_Escape)))
|
||||
+ ; // the host's completion list owns these keys
|
||||
+ else if (!mReadOnly && isShortcut && ImGui::IsKeyPressed(ImGuiKey_Z))
|
||||
Undo();
|
||||
else if (!mReadOnly && isAltOnly && ImGui::IsKeyPressed(ImGuiKey_Backspace))
|
||||
Undo();
|
||||
@@ -2238,6 +2256,7 @@ void TextEditor::Render(bool aParentIsFocused)
|
||||
}
|
||||
|
||||
ImVec2 cursorScreenPos = ImGui::GetCursorScreenPos();
|
||||
+ mTextOrigin = cursorScreenPos;
|
||||
mScrollX = ImGui::GetScrollX();
|
||||
mScrollY = ImGui::GetScrollY();
|
||||
UpdateViewVariables(mScrollX, mScrollY);
|
||||
@@ -2549,6 +2568,7 @@ void TextEditor::AddUndo(UndoRecord& aValue)
|
||||
mUndoBuffer.resize((size_t)(mUndoIndex + 1));
|
||||
mUndoBuffer.back() = aValue;
|
||||
++mUndoIndex;
|
||||
+ ++mChangeCount;
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -2687,6 +2707,8 @@ void TextEditor::ColorizeInternal()
|
||||
if (mLines.empty() || mLanguageDefinition == nullptr)
|
||||
return;
|
||||
|
||||
+ if (mCheckComments && mLanguageDefinition->mTokenizerOwnsComments)
|
||||
+ mCheckComments = false;
|
||||
if (mCheckComments)
|
||||
{
|
||||
auto endLine = mLines.size();
|
||||
diff --git a/TextEditor.h b/TextEditor.h
|
||||
index 19ad61b..6883412 100644
|
||||
--- a/TextEditor.h
|
||||
+++ b/TextEditor.h
|
||||
@@ -97,6 +97,14 @@ public:
|
||||
void ImGuiDebugPanel(const std::string& panelName = "Debug");
|
||||
void UnitTests();
|
||||
|
||||
+ // RynthCore (native/cimgui/textedit-rynth.patch): a text change counter, a
|
||||
+ // hold-off on the keys the host's completion list uses, a focus request,
|
||||
+ // and access for the C exports in rynth_textedit_ext.cpp.
|
||||
+ inline unsigned GetChangeCount() const { return mChangeCount; }
|
||||
+ inline void SetCompletionKeysHeld(bool aValue) { mCompletionKeysHeld = aValue; }
|
||||
+ inline void RequestFocus() { mFocusRequested = true; }
|
||||
+ friend struct RynthTextEditAccess;
|
||||
+
|
||||
private:
|
||||
// ------------- Generic utils ------------- //
|
||||
|
||||
@@ -280,6 +288,7 @@ private:
|
||||
TokenizeCallback mTokenize = nullptr;
|
||||
std::vector<TokenRegexString> mTokenRegexStrings;
|
||||
bool mCaseSensitive = true;
|
||||
+ bool mTokenizerOwnsComments = false; // RynthCore: skip the whole-text comment scan
|
||||
|
||||
static const LanguageDefinition& Cpp();
|
||||
static const LanguageDefinition& Hlsl();
|
||||
@@ -452,6 +461,10 @@ private:
|
||||
Palette mPalette;
|
||||
LanguageDefinitionId mLanguageDefinitionId;
|
||||
const LanguageDefinition* mLanguageDefinition = nullptr;
|
||||
+ unsigned mChangeCount = 0;
|
||||
+ bool mCompletionKeysHeld = false;
|
||||
+ bool mFocusRequested = false;
|
||||
+ ImVec2 mTextOrigin;
|
||||
|
||||
inline bool IsHorizontalScrollbarVisible() const { return mCurrentSpaceWidth > mContentWidth; }
|
||||
inline bool IsVerticalScrollbarVisible() const { return mCurrentSpaceHeight > mContentHeight; }
|
||||
13
native/cimgui/textedit_shim/boost/regex.hpp
Normal file
13
native/cimgui/textedit_shim/boost/regex.hpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// RynthCore: ImGuiColorTextEdit (santaclose fork) includes <boost/regex.hpp>.
|
||||
// Its regex path only runs for languages without a hand-written tokenizer, and
|
||||
// the two we use (Meta, Lua) both have one, so std::regex stands in for Boost.
|
||||
#pragma once
|
||||
#include <regex>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
using std::regex;
|
||||
using std::cmatch;
|
||||
using std::regex_search;
|
||||
namespace regex_constants = std::regex_constants;
|
||||
}
|
||||
Loading…
Reference in a new issue