diff --git a/.gitmodules b/.gitmodules index 37ec90d..ee0bca8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,7 @@ [submodule "3rdparty/AngelScript"] path = 3rdparty/AngelScript url = git@github.com:Wing-summer/AngelScript.git + branch=stable [submodule "3rdparty/json"] path = 3rdparty/json url = git@github.com:nlohmann/json.git diff --git a/3rdparty/AngelScript b/3rdparty/AngelScript index 387b486..d259eab 160000 --- a/3rdparty/AngelScript +++ b/3rdparty/AngelScript @@ -1 +1 @@ -Subproject commit 387b48653eb0840765bcbf24773de50ed632ad59 +Subproject commit d259eab41fd08fbde83cf1a7b01f4def6a09e895 diff --git a/3rdparty/json b/3rdparty/json index 663058e..60c4875 160000 --- a/3rdparty/json +++ b/3rdparty/json @@ -1 +1 @@ -Subproject commit 663058e7d18241338aec42846d4f77995275ccf6 +Subproject commit 60c48755e3f717eace7830d7bbc0d8f1a5e0cc8a diff --git a/3rdparty/qtsingleapplication/src/qtsingleapplication.cpp b/3rdparty/qtsingleapplication/src/qtsingleapplication.cpp index 26db1f0..63aa7b1 100644 --- a/3rdparty/qtsingleapplication/src/qtsingleapplication.cpp +++ b/3rdparty/qtsingleapplication/src/qtsingleapplication.cpp @@ -18,6 +18,9 @@ #define NOMINMAX 1 #endif #include +#ifdef PASCAL +#undef PASCAL +#endif #include #endif diff --git a/lang/zh_CN/winghex.ts b/lang/zh_CN/winghex.ts index d6a146c..f7d0a07 100644 --- a/lang/zh_CN/winghex.ts +++ b/lang/zh_CN/winghex.ts @@ -442,7 +442,7 @@ 编码 - + Untitled 未命名 @@ -851,18 +851,18 @@ MainWindow - + File 文件 - - + + View 视图 - + About 关于 @@ -883,341 +883,341 @@ 选长: - + Edit 编辑 - + Script 脚本 - - - + + + Plugin 插件 - + Setting 设置 - - + + Log 日志 - + ExportFindResult 导出搜索结果 - + ClearFindResult 清空记录 - + FindResult 搜索结果 - - - + + + Copy 复制 - - - - + + + + CopyToClipBoard 数据已拷贝到粘贴板 - + LittleEndian 小端 - + BigEndian 大端 - + Number 数值 - - + + CheckSum 校验和 - - + + DeleteBookMark 删除书签 - - + + ClearBookMark 清空书签 - - - - + + + + BookMark 书签 - + DecodeText 解码字符串 - + ScriptConsole 脚本控制台 - - + + DVList 可视化列表 - - + + DVTree 可视化树数据 - - + + DVTable 可视化表格 - - + + DVText 可视化文本 - - + + Basic 基础 - + New 新建 - + OpenF 打开文件 - + OpenFR 打开局部文件 - + OpenWorkSpace 打开工作区 - + OpenD 打开驱动器 - + RecentFiles 最近打开 - + Reload 重新加载 - - + + Save 保存 - + SaveAs 另存为 - + Export 导出 - + SaveSel 保存选区字节 - - - - + + + + General 基本 - + Undo 撤销 - + Redo 恢复 - + Cut 剪切 - + Paste 粘贴 - + Delete 删除 - + Clone 克隆 - + Lookup 查询 - + Find 查找 - + Goto 跳转 - + Encoding 编码 - + FileInfo 文件信息 - - + + Hex 十六进制 - + CutHex 剪切(十六进制) - + CopyHex 复制(十六进制) - + PasteHex 粘贴(十六进制) - - + + Fill 填充 - + FillZero 填充零 - - - - - + + + + + MetaData 标注 - + DeleteMetadata 删除标注 - + ClearMetadata 清空标注 - + MetaDataEdit 编辑标注 - + DeleteMetaData 删除标注 - + ClearMetaData 清空标注 - + Display 显示 - + ViewText 文本预览 - + Scale 缩放 @@ -1282,551 +1282,551 @@ 启动插件组件 - + SetupDockingLayout 恢复 Dock 布局 - + SetupWaiting 启动即将完成 - + SetupFinished 启动完毕 - + ResetScale 重置缩放 - + ShowMetafg 标注前景色 - + ShowMetabg 标注背景色 - + ShowMetaComment 批注 - + MetaShowAll 显示所有标注 - + MetaHideAll 隐藏所有标注 - + FileStatus 文件状态 - + InfoSave 是否保存 - + ReadOnly 可读写 - + SetLocked 启用/禁用锁定编辑 - + ErrUnLock 锁定编辑失败 - + SetOver 启用/禁用改变大小 - + ErrUnOver 锁定文件大小失败 - + InfoCanOverLimit 当前编辑处于受限模式! - + Window 窗体 - + Editor 编辑器 - + Tools 工具 - + HexEditorLayout 编辑器布局 - + SetBaseAddr 设置基址 - + addressBase 基址 - + inputAddressBase 请输入基址 - + WarnBigBaseAddress 基址过大,你得到的地址将会不正确! - + ErrBaseAddress 非法基址输入 - + SetColInfo 显示/隐藏地址栏 - + SetHeaderInfo 显示/隐藏表头 - + SetAsciiString 显示/隐藏解码字符串 - + Layout 布局 - + Fullscreen 全屏 - + Default 默认 - + RestoreLayout 恢复布局 - - + + SaveLayout 保存布局 - + ExportLog 导出日志 - + ClearLog 清空日志 - + ScriptEditor 脚本编辑器 - + Scripts 脚本仓库 - + PluginFunctions 插件功能 - + ScriptSetting 脚本设置 - + PluginSettings 插件设置 - + Info 信息 - + Software 软件 - + Sponsor 赞助 - + CheckUpdate 检查更新 - + Wiki 网页 Wiki - + AboutQT 关于 QT - + SetPageIDEmptyTryUseName 设置页 ID 为空,尝试使用名称作为 ID - + SetPageDupNameIgnored 设置页重复的 ID 名称,已忽略加载 - + Plugin %1 contains a duplicate ID (%2) that is already registered by plugin %3 插件 %1 包含重复 ID (%2),该 ID 已被插件 %3 注册 - - + + ChooseFile 选择文件 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + Error 错误 - - - - + + + + FileNotExist 文件不存在! - - - - - + + + + + FilePermission 因文件权限无法继续! - + ProjectFile (*.wingpro) 项目文件 (*.wingpro) - + Root Required! 需要管理员权限继续操作! - + ReloadSuccessfully 文件重新加载成功! - + ReloadUnSuccessfully 文件重新加载失败! - - - + + + ChooseSaveFile 请选择保存文件路径: - + NoMoreClone 克隆已到上限,无法继续操作! - + FindFininishBusy 查找任务繁忙,请勿重复查找! - + MayTooMuchFindResult 搜索数量已到达上限,结果可能不全,建议请按区段搜索。 - + SaveLayoutSuccess 保存布局成功 - + SaveLayoutError 保存布局失败 - + ConfirmSave 正在关闭未保存的文件或工作区,你确定保存吗? - + ConfirmAPPSave 你尝试关闭程序,但仍存在未保存的文件或工作区,你确定保存这些更改吗? - - + + SaveSuccessfully 保存成功! - - + + SaveWSError 保存工作区错误! - - - + + + Warn 警告 - + ScriptObjShow 脚本对象 - - - + + + SourceChanged 局部打开原始文件更改! - - + + SaveSourceFileError 由于原文件更改,保存文件失败! - + SaveUnSuccessfully 保存失败! - + ChooseExportFile 请选择导出文件路径: - + ExportSuccessfully 导出成功! - + ExportSourceFileError 由于原文件更改,导出文件失败! - + ExportUnSuccessfully 导出失败! - + SaveSelSuccess 保存选区字节成功! - + SaveSelError 保存选区字节失败,因文件不具有可写权限! - - + + CutToClipBoard 数据已剪切到粘贴板! - - + + UnCutToClipBoard 由于保持大小限制,数据剪切到粘贴板失败! - - + + UnCopyToClipBoard 由于保持大小限制,数据剪切到复制板失败! - + FindFininish 查找结果完毕! - + PleaseInputFill 请输入填充字节值 - + FillInputError 填充字节输入错误 - - + + InputComment 请输入批注: - - - + + + NoSelection 没有选区,无法继续的操作! - + NoMetaData 无可编辑标记 - + EmptyFindResult 没有可导出的搜索结果! - + SaveFindResult 导出搜索结果成功! - + SaveFindResultError 导出结果失败! - + TooManyBytesDecode 超出解码字节限制…… - + ExportLogError 导出日志失败! - + ExportLogSuccess 导出日志成功,路径: - + ClearLogSuccess 清空日志成功! - + BadNetwork 无法与远程服务器的更新检查建立连接,请检查网络。 - + NewestVersion 当前软件为最新版本 - - + + OlderVersion 你使用的软件为老版本,建议到 Github 和 Gitee 的仓库发行版下载更新。 - + CheckingUpdate 检查更新中…… - + Too much opened files 打开的文件过多,无法继续操作! - + CopyLimit 拷贝字节超出限制 - + ErrOpenFileBelow 打开文件出现错误(由于权限不足),如下为打开错误的文件: @@ -2009,27 +2009,27 @@ 插件: - + Plugin 插件 - + pluginName 插件名 - + pluginAuthor 插件作者 - + pluginVersion 插件版本 - + pluginComment 插件说明 @@ -2037,127 +2037,127 @@ PluginSystem - + LoadingPlugin 正在加载插件: - + RegisteredFnDup 注册重复函数对象 - + ErrLoadPluginSign 插件加载失败:非法插件签名! - + ErrLoadPluginSDKVersion 插件加载失败:非法插件 SDK 版本! - + ErrLoadPluginNoName 插件加载失败:非法插件名称! - + ErrLoadInvalidPUID 插件加载失败:非法插件唯一标志符! - + ErrLoadLoadedPlugin 插件加载失败:重复加载插件! - + ErrLoadInitPlugin 插件加载失败:初始化插件失败! - + PluginName : 插件名: - + PluginAuthor : 插件作者: - + PluginWidgetRegister 注册插件对象中…… - + EmptyNameDockWidget: 空的贴边组件名: - + InvalidNameDockWidget: 无效贴边组件名: - + InvalidNullDockWidget: 无效空贴边组件: - + [EvilCall] 【恶意调用】 - + Not allowed operation in non-UI thread 该操作在非 UI 线程非法 - + UnsafePluginDir 不安全的插件目录,请将插件目录设置为仅管理员账户可写 - + FoundPluginCount 总计发现插件数目: - + PluginLoadingFailedSummary 有依赖插件加载失败总结 - + - PluginName: - 插件名: - + - Dependencies: - 依赖: - + PUID: 插件唯一标志符: - + Version: 版本: - + MD5: MD5 校验和: - + PluginLoadingFinished 加载插件完毕! @@ -2635,23 +2635,23 @@ Do you wish to keep up to date by reloading the file? 关闭标签 - + Failed to open script file 打开脚本文件失败 - - + + Invalid file name for #include; it contains a line-break: #include 的文件名无效;它包含换行符: - + Invalid file name for #include; it contains a line-break or unpaired symbol #include 的文件名无效;它包含换行符或不成对的符号 - + Invalid #pragma directive #pragma 指令无效 diff --git a/qt-template/qt-template-installer.py b/qt-template/qt-template-installer.py index d5a9248..9c3363f 100644 --- a/qt-template/qt-template-installer.py +++ b/qt-template/qt-template-installer.py @@ -13,6 +13,7 @@ from colorama import Fore, Style def install(): installer_path = os.path.dirname(os.path.abspath(__file__)) install_path = os.path.join(getQtTemplateDir(), "winghexplugin") + shutil.rmtree(install_path, ignore_errors=True) # uninstall first shutil.copytree(os.path.join(installer_path, "winghexplugin"), install_path, dirs_exist_ok=True) print(Fore.GREEN + "WingHexExplorer2 plugin Template was installed under: " + install_path + Style.RESET_ALL) @@ -27,7 +28,7 @@ def getQtTemplateDir() -> pathlib.Path: # https://docs.huihoo.com/qt/qtcreator/4.2/creator-project-wizards.html#locating-wizards home = pathlib.Path.home() if sys.platform == "win32": - return home / "AppData/QtProject/qtcreator/templates/wizards" + return home / "AppData/Roaming/QtProject/qtcreator/templates/wizards" else: return home / ".config/QtProject/qtcreator/templates/wizards" diff --git a/qt-template/winghexplugin/CMakeLists.txt b/qt-template/winghexplugin/CMakeLists.txt index dc7a854..4e88978 100644 --- a/qt-template/winghexplugin/CMakeLists.txt +++ b/qt-template/winghexplugin/CMakeLists.txt @@ -18,7 +18,9 @@ endif() option(TEST_MODE TRUE) -set(WINGHEX_SDK "%{WingHexSDKPath}") +if(NOT EXISTS "${WINGHEX_SDK}") + message(FATAL_ERROR "Please config the SDK Path - WINGHEX_SDK") +endif() set(PLUGIN_INTERFACE_FOUND FALSE) set(PLUGIN_SETPAGE_FOUND FALSE) @@ -96,7 +98,11 @@ if(TEST_MODE) # this variable. Because this test plugin is a subproject of the main # project, use CMAKE_BINARY_DIR - set(WINGHEX_PATH "%{WingHexEXEPath}") + if(NOT EXISTS "${WINGHEX_PATH}") + message( + FATAL_ERROR "Please config the WingHexExplorer2 Path - WINGHEX_PATH" + ) + endif() set(WINGHEX_PLUGIN_PATH "${WINGHEX_PATH}/plugin") add_custom_command( diff --git a/qt-template/winghexplugin/wizard.json b/qt-template/winghexplugin/wizard.json index 2a2a3ad..097749a 100644 --- a/qt-template/winghexplugin/wizard.json +++ b/qt-template/winghexplugin/wizard.json @@ -12,8 +12,6 @@ "options": [ - { "key": "WingHexSDKPath", "value": "%{SDKPath}" }, - { "key": "WingHexEXEPath", "value": "%{WingHexPath}" }, { "key": "ProjectFile", "value": "%{JS: value('CMakeFile') }" }, { "key": "PluginNameLower", "value": "%{JS: value('PluginName').toLowerCase()}"}, { "key": "PluginJsonFile", "value": "%{JS: Util.fileName(value('PluginName'), 'json.in')}" }, @@ -123,28 +121,6 @@ { "text": "https://www.%{JS: encodeURIComponent(value('VendorName').toLowerCase())}.com" } - }, - { - "name": "SDKPath", - "persistenceKey": "SDKPath", - "trDisplayName": "SDK Path:", - "mandatory": true, - "type": "PathChooser", - "data": - { - "kind": "existingDirectory" - } - }, - { - "name": "WingHexPath", - "persistenceKey": "WingHexPath", - "type": "PathChooser", - "trDisplayName": "WingHexExplorer2 Installation:", - "mandatory": true, - "data": - { - "kind": "existingDirectory" - } } ] }, diff --git a/src/class/asbuilder.cpp b/src/class/asbuilder.cpp index b4d9f56..51f83c9 100644 --- a/src/class/asbuilder.cpp +++ b/src/class/asbuilder.cpp @@ -50,175 +50,6 @@ int asBuilder::Build() { if (r < 0) return r; - // After the script has been built, the metadata strings should be - // stored for later lookup by function id, type id, and variable index - for (int n = 0; n < (int)foundDeclarations.size(); n++) { - SMetadataDecl &decl = foundDeclarations[n]; - module->SetDefaultNamespace(decl.nameSpace.toUtf8()); - if (decl.type == MDT_TYPE) { - // Find the type id - int typeId = module->GetTypeIdByDecl(decl.declaration.toUtf8()); - Q_ASSERT(typeId >= 0); - if (typeId >= 0) - typeMetadataMap.insert(typeId, decl.metadata); - } else if (decl.type == MDT_FUNC) { - if (decl.parentClass.isEmpty()) { - // Find the function id - asIScriptFunction *func = - module->GetFunctionByDecl(decl.declaration.toUtf8()); - Q_ASSERT(func); - if (func) - funcMetadataMap.insert(func->GetId(), decl.metadata); - } else { - // Find the method id - int typeId = module->GetTypeIdByDecl(decl.parentClass.toUtf8()); - Q_ASSERT(typeId > 0); - - auto it = classMetadataMap.find(typeId); - if (it == classMetadataMap.end()) { - classMetadataMap.insert(typeId, - SClassMetadata(decl.parentClass)); - it = classMetadataMap.find(typeId); - } - - asITypeInfo *type = engine->GetTypeInfoById(typeId); - asIScriptFunction *func = - type->GetMethodByDecl(decl.declaration.toUtf8()); - Q_ASSERT(func); - if (func) - it.value().funcMetadataMap.insert(func->GetId(), - decl.metadata); - } - } else if (decl.type == MDT_VIRTPROP) { - if (decl.parentClass.isEmpty()) { - // Find the global virtual property accessors - asIScriptFunction *func = module->GetFunctionByName( - (QStringLiteral("get_") + decl.declaration).toUtf8()); - if (func) - funcMetadataMap.insert(func->GetId(), decl.metadata); - func = module->GetFunctionByName( - (QStringLiteral("set_") + decl.declaration).toUtf8()); - if (func) - funcMetadataMap.insert(func->GetId(), decl.metadata); - } else { - // Find the method virtual property accessors - int typeId = module->GetTypeIdByDecl(decl.parentClass.toUtf8()); - Q_ASSERT(typeId > 0); - auto it = classMetadataMap.find(typeId); - if (it == classMetadataMap.end()) { - classMetadataMap.insert(typeId, - SClassMetadata(decl.parentClass)); - it = classMetadataMap.find(typeId); - } - - asITypeInfo *type = engine->GetTypeInfoById(typeId); - asIScriptFunction *func = type->GetMethodByName( - (QStringLiteral("get_") + decl.declaration).toUtf8()); - if (func) - it.value().funcMetadataMap.insert(func->GetId(), - decl.metadata); - func = type->GetMethodByName( - (QStringLiteral("set_") + decl.declaration).toUtf8()); - if (func) - it.value().funcMetadataMap.insert(func->GetId(), - decl.metadata); - } - } else if (decl.type == MDT_VAR) { - if (decl.parentClass.isEmpty()) { - // Find the global variable index - int varIdx = - module->GetGlobalVarIndexByName(decl.declaration.toUtf8()); - Q_ASSERT(varIdx >= 0); - if (varIdx >= 0) - varMetadataMap.insert(varIdx, decl.metadata); - } else { - int typeId = module->GetTypeIdByDecl(decl.parentClass.toUtf8()); - Q_ASSERT(typeId > 0); - - // Add the classes if needed - auto it = classMetadataMap.find(typeId); - if (it == classMetadataMap.end()) { - classMetadataMap.insert(typeId, - SClassMetadata(decl.parentClass)); - it = classMetadataMap.find(typeId); - } - - // Add the variable to class - asITypeInfo *objectType = engine->GetTypeInfoById(typeId); - int idx = -1; - - // Search through all properties to get proper declaration - for (asUINT i = 0; i < (asUINT)objectType->GetPropertyCount(); - ++i) { - const char *name; - objectType->GetProperty(i, &name); - if (decl.declaration == name) { - idx = i; - break; - } - } - - // If found, add it - Q_ASSERT(idx >= 0); - if (idx >= 0) - it.value().varMetadataMap.insert(idx, decl.metadata); - } - } else if (decl.type == MDT_FUNC_OR_VAR) { - if (decl.parentClass.isEmpty()) { - // Find the global variable index - int varIdx = - module->GetGlobalVarIndexByName(decl.name.toUtf8()); - if (varIdx >= 0) - varMetadataMap.insert(varIdx, decl.metadata); - else { - asIScriptFunction *func = - module->GetFunctionByDecl(decl.declaration.toUtf8()); - Q_ASSERT(func); - if (func) - funcMetadataMap.insert(func->GetId(), decl.metadata); - } - } else { - int typeId = module->GetTypeIdByDecl(decl.parentClass.toUtf8()); - Q_ASSERT(typeId > 0); - - // Add the classes if needed - auto it = classMetadataMap.find(typeId); - if (it == classMetadataMap.end()) { - classMetadataMap.insert(typeId, - SClassMetadata(decl.parentClass)); - it = classMetadataMap.find(typeId); - } - - // Add the variable to class - asITypeInfo *objectType = engine->GetTypeInfoById(typeId); - int idx = -1; - - // Search through all properties to get proper declaration - for (asUINT i = 0; i < (asUINT)objectType->GetPropertyCount(); - ++i) { - const char *name; - objectType->GetProperty(i, &name); - if (decl.name == name) { - idx = i; - break; - } - } - - // If found, add it - if (idx >= 0) - it.value().varMetadataMap.insert(idx, decl.metadata); - else { - // Look for the matching method instead - asITypeInfo *type = engine->GetTypeInfoById(typeId); - asIScriptFunction *func = - type->GetMethodByDecl(decl.declaration.toUtf8()); - if (func) - it.value().funcMetadataMap.insert(func->GetId(), - decl.metadata); - } - } - } - } module->SetDefaultNamespace(""); return 0; diff --git a/src/class/aspreprocesser.cpp b/src/class/aspreprocesser.cpp index a4705e6..c846e8f 100644 --- a/src/class/aspreprocesser.cpp +++ b/src/class/aspreprocesser.cpp @@ -98,47 +98,11 @@ QString AsPreprocesser::GetSectionName(unsigned int idx) const { return includedScripts.at(idx); } -QVector AsPreprocesser::GetMetadataForType(int typeId) { - return typeMetadataMap.value(typeId); -} - -QVector AsPreprocesser::GetMetadataForFunc(asIScriptFunction *func) { - return funcMetadataMap.value(func->GetId()); -} - -QVector AsPreprocesser::GetMetadataForVar(int varIdx) { - return varMetadataMap.value(varIdx); -} - -QVector AsPreprocesser::GetMetadataForTypeProperty(int typeId, - int varIdx) { - if (classMetadataMap.contains(typeId)) { - return varMetadataMap.value(varIdx); - } - return {}; -} - -QVector -AsPreprocesser::GetMetadataForTypeMethod(int typeId, - asIScriptFunction *method) { - if (method) { - if (classMetadataMap.contains(typeId)) { - return funcMetadataMap.value(method->GetId()); - } - } - return {}; -} - void AsPreprocesser::ClearAll() { includedScripts.clear(); currentClass.clear(); currentNamespace.clear(); - - foundDeclarations.clear(); - typeMetadataMap.clear(); - funcMetadataMap.clear(); - varMetadataMap.clear(); } int AsPreprocesser::ProcessScriptSection(const QByteArray &script, int length, @@ -335,26 +299,8 @@ int AsPreprocesser::ProcessScriptSection(const QByteArray &script, int length, continue; } - // Is this the start of metadata? - if (token == "[") { - // Get the metadata string - pos = ExtractMetadata(modifiedScript, pos, metadata); - - // Determine what this metadata is for - int type; - ExtractDeclaration(modifiedScript, pos, name, declaration, type); - - // Store away the declaration in a map for lookup after the build - // has completed - if (type > 0) { - SMetadataDecl decl(metadata, name, declaration, type, - currentClass, currentNamespace); - foundDeclarations.push_back(decl); - } - } else - - // Is this a preprocessor directive? - if (token == "#" && (qsizetype(pos + 1) < modifiedScript.size())) { + // Is this a preprocessor directive? + if (token == "#" && (qsizetype(pos + 1) < modifiedScript.size())) { int start = pos++; t = engine->ParseToken(modifiedScript.data() + pos, @@ -679,175 +625,3 @@ void AsPreprocesser::AddScriptSection(const QString §ion, data.script = code; modifiedScripts.append(data); } - -int AsPreprocesser::ExtractMetadata(QByteArray &modifiedScript, int pos, - QVector &metadata) { - metadata.clear(); - - // Extract all metadata. They can be separated by whitespace and comments - for (;;) { - QString metadataString; - - // Overwrite the metadata with space characters to allow compilation - modifiedScript[pos] = ' '; - - // Skip opening brackets - pos += 1; - - int level = 1; - asUINT len = 0; - while (level > 0 && pos < (int)modifiedScript.size()) { - asETokenClass t = engine->ParseToken( - modifiedScript.data() + pos, modifiedScript.size() - pos, &len); - if (t == asTC_KEYWORD) { - if (modifiedScript[pos] == '[') - level++; - else if (modifiedScript[pos] == ']') - level--; - } - - // Copy the metadata to our buffer - if (level > 0) - metadataString.append(modifiedScript.mid(pos, len)); - - // Overwrite the metadata with space characters to allow compilation - if (t != asTC_WHITESPACE) - OverwriteCode(modifiedScript, pos, len); - - pos += len; - } - - metadata.push_back(metadataString); - - // Check for more metadata. Possibly separated by comments - asETokenClass t = engine->ParseToken(modifiedScript.data() + pos, - modifiedScript.size() - pos, &len); - while (t == asTC_COMMENT || t == asTC_WHITESPACE) { - pos += len; - t = engine->ParseToken(modifiedScript.data() + pos, - modifiedScript.size() - pos, &len); - } - - if (modifiedScript[pos] != '[') - break; - } - - return pos; -} - -int AsPreprocesser::ExtractDeclaration(QByteArray &modifiedScript, int pos, - QString &name, QString &declaration, - int &type) { - declaration.clear(); - type = 0; - - int start = pos; - - QString token; - asUINT len = 0; - asETokenClass t = asTC_WHITESPACE; - - // Skip white spaces, comments, and leading decorators - do { - pos += len; - t = engine->ParseToken(modifiedScript.data() + pos, - modifiedScript.size() - pos, &len); - token = modifiedScript.mid(pos, len); - } while (t == asTC_WHITESPACE || t == asTC_COMMENT || token == "private" || - token == "protected" || token == "shared" || token == "external" || - token == "final" || token == "abstract"); - - // We're expecting, either a class, interface, function, or variable - // declaration - if (t == asTC_KEYWORD || t == asTC_IDENTIFIER) { - token = modifiedScript.mid(pos, len); - if (token == "interface" || token == "class" || token == "enum") { - // Skip white spaces and comments - do { - pos += len; - t = engine->ParseToken(modifiedScript.data() + pos, - modifiedScript.size() - pos, &len); - } while (t == asTC_WHITESPACE || t == asTC_COMMENT); - - if (t == asTC_IDENTIFIER) { - type = MDT_TYPE; - declaration = modifiedScript.mid(pos, len); - pos += len; - return pos; - } - } else { - // For function declarations, store everything up to the start of - // the statement block, except for succeeding decorators (final, - // override, etc) - - // For variable declaration store just the name as there can only be - // one - - // We'll only know if the declaration is a variable or function - // declaration when we see the statement block, or absense of a - // statement block. - bool hasParenthesis = false; - int nestedParenthesis = 0; - declaration.append(modifiedScript.mid(pos, len)); - pos += len; - for (; pos < (int)modifiedScript.size();) { - t = engine->ParseToken(modifiedScript.data() + pos, - modifiedScript.size() - pos, &len); - token = modifiedScript.mid(pos, len); - if (t == asTC_KEYWORD) { - if (token == "{" && nestedParenthesis == 0) { - if (hasParenthesis) { - // We've found the end of a function signature - type = MDT_FUNC; - } else { - // We've found a virtual property. Just keep the - // name - declaration = name; - type = MDT_VIRTPROP; - } - return pos; - } - if ((token == "=" && !hasParenthesis) || token == ";") { - if (hasParenthesis) { - // The declaration is ambigous. It can be a variable - // with initialization, or a function prototype - type = MDT_FUNC_OR_VAR; - } else { - // Substitute the declaration with just the name - declaration = name; - type = MDT_VAR; - } - return pos; - } else if (token == "(") { - nestedParenthesis++; - - // This is the first parenthesis we encounter. If the - // parenthesis isn't followed by a statement block, then - // this is a variable declaration, in which case we - // should only store the type and name of the variable, - // not the initialization parameters. - hasParenthesis = true; - } else if (token == ")") { - nestedParenthesis--; - } - } else if (t == asTC_IDENTIFIER) { - // If a parenthesis is already found then the name is - // already known so it must not be overwritten - if (!hasParenthesis) - name = token; - } - - // Skip trailing decorators - if (!hasParenthesis || nestedParenthesis > 0 || - t != asTC_IDENTIFIER || - (token != "final" && token != "override" && - token != "delete" && token != "property")) - declaration += token; - - pos += len; - } - } - } - - return start; -} diff --git a/src/class/aspreprocesser.h b/src/class/aspreprocesser.h index 64fbd63..eeccc46 100644 --- a/src/class/aspreprocesser.h +++ b/src/class/aspreprocesser.h @@ -107,22 +107,6 @@ public: QString GetSectionName(unsigned int idx) const; - // Get metadata declared for classes, interfaces, and enums - QVector GetMetadataForType(int typeId); - - // Get metadata declared for functions - QVector GetMetadataForFunc(asIScriptFunction *func); - - // Get metadata declared for global variables - QVector GetMetadataForVar(int varIdx); - - // Get metadata declared for class variables - QVector GetMetadataForTypeProperty(int typeId, int varIdx); - - // Get metadata declared for class methods - QVector GetMetadataForTypeMethod(int typeId, - asIScriptFunction *method); - protected: void ClearAll(); int ProcessScriptSection(const QByteArray &script, int length, @@ -147,51 +131,9 @@ protected: PRAGMACALLBACK_t pragmaCallback; void *pragmaParam; - int ExtractMetadata(QByteArray &modifiedScript, int pos, - QVector &metadata); - int ExtractDeclaration(QByteArray &modifiedScript, int pos, QString &name, - QString &declaration, int &type); - - enum METADATATYPE { - MDT_TYPE = 1, - MDT_FUNC = 2, - MDT_VAR = 3, - MDT_VIRTPROP = 4, - MDT_FUNC_OR_VAR = 5 - }; - - // Temporary structure for storing metadata and declaration - struct SMetadataDecl { - SMetadataDecl(const QVector &m, const QString &n, - const QString &d, int t, const QString &c, - const QString &ns) - : metadata(m), name(n), declaration(d), type(t), parentClass(c), - nameSpace(ns) {} - QVector metadata; - QString name; - QString declaration; - int type; - QString parentClass; - QString nameSpace; - }; - QVector foundDeclarations; QString currentClass; QString currentNamespace; - // Storage of metadata for global declarations - QMap> typeMetadataMap; - QMap> funcMetadataMap; - QMap> varMetadataMap; - - // Storage of metadata for class member declarations - struct SClassMetadata { - SClassMetadata(const QString &aName) : className(aName) {} - QString className; - QMap> funcMetadataMap; - QMap> varMetadataMap; - }; - QMap classMetadataMap; - QVector includedScripts; QVector definedWords; diff --git a/src/control/editorview.cpp b/src/control/editorview.cpp index 654d60c..c030088 100644 --- a/src/control/editorview.cpp +++ b/src/control/editorview.cpp @@ -210,7 +210,6 @@ EditorView::FindError EditorView::find(const FindDialog::Result &result) { m_findResults->clear(); auto lineWidth = m_hex->renderer()->hexLineWidth(); - auto docLen = d->length(); for (auto &ritem : results) { FindResult r; r.offset = ritem; @@ -616,8 +615,8 @@ FindResultModel::FindInfo EditorView::readContextFinding(qsizetype offset, auto header = doc->read(offset, qMin(findSize, halfSize)); QByteArray tailer; if (header.size() < findSize) { - tailer = doc->read( - offset, qMin(findSize, qsizetype(maxDisplayBytes) - halfSize)); + auto len = qMin(findSize, qsizetype(maxDisplayBytes) - halfSize); + tailer = doc->read(offset + findSize - len, len); } auto left = qsizetype(maxDisplayBytes) - header.size() - tailer.size(); diff --git a/src/dialog/mainwindow.cpp b/src/dialog/mainwindow.cpp index 9c597ed..0a50b27 100644 --- a/src/dialog/mainwindow.cpp +++ b/src/dialog/mainwindow.cpp @@ -220,6 +220,8 @@ MainWindow::MainWindow(SplashDialog *splash) : FramelessMainWindow() { auto plgview = m_toolBtneditors.value(PLUGIN_VIEWS); plgview->setEnabled(!plgview->menu()->isEmpty()); + finishBuildDockSystem(); + // load saved docking layout if (splash) splash->setInfoText(tr("SetupDockingLayout")); @@ -443,7 +445,9 @@ void MainWindow::buildUpDockSystem(QWidget *container) { qApp->processEvents(); m_bottomViewArea = bottomRightArea; +} +void MainWindow::finishBuildDockSystem() { // set the first tab visible for (auto &item : m_dock->openedDockAreas()) { for (int i = 0; i < item->dockWidgetsCount(); ++i) { @@ -455,7 +459,6 @@ void MainWindow::buildUpDockSystem(QWidget *container) { item->setCurrentIndex(i); break; } - qApp->processEvents(); } } diff --git a/src/dialog/mainwindow.h b/src/dialog/mainwindow.h index baab303..bc4ddac 100644 --- a/src/dialog/mainwindow.h +++ b/src/dialog/mainwindow.h @@ -91,6 +91,8 @@ private: private: void buildUpRibbonBar(); void buildUpDockSystem(QWidget *container); + void finishBuildDockSystem(); + ads::CDockAreaWidget *buildUpLogDock(ads::CDockManager *dock, ads::DockWidgetArea area, ads::CDockAreaWidget *areaw = nullptr); diff --git a/src/plugin/iwingplugin.h b/src/plugin/iwingplugin.h index 09a6139..1351554 100644 --- a/src/plugin/iwingplugin.h +++ b/src/plugin/iwingplugin.h @@ -159,9 +159,6 @@ signals: const QString &encoding = QString()); Q_REQUIRED_RESULT QByteArray readBytes(qsizetype offset, qsizetype count); - // an extension for AngelScript - // void read(? &in); // this function can read bytes to input container - Q_REQUIRED_RESULT qsizetype searchForward(qsizetype begin, const QByteArray &ba); Q_REQUIRED_RESULT qsizetype searchBackward(qsizetype begin, @@ -515,6 +512,8 @@ struct SenderInfo { #define WINGAPI_ARG(type, data) QArgument(#type, data) #define WINGAPI_RETURN_ARG(type, data) QReturnArgument(#type, data) +enum class AppTheme { Dark, Light }; + class IWingPlugin : public QObject { Q_OBJECT public: @@ -577,6 +576,7 @@ public: virtual bool init(const std::unique_ptr &set) = 0; virtual void unload(std::unique_ptr &set) = 0; virtual const QString pluginName() const = 0; + virtual QIcon pluginIcon() const { return {}; } virtual const QString pluginAuthor() const = 0; virtual uint pluginVersion() const = 0; virtual const QString pluginComment() const = 0; @@ -616,10 +616,6 @@ public: return {}; } -signals: - // QHash< obj-names, decl-members > - bool registerScriptObj(const QString &obj, const QStringList &members); - public: virtual void eventSelectionChanged(const QByteArrayList &selections, bool isPreview) { @@ -649,6 +645,9 @@ signals: void error(const QString &message); void info(const QString &message); + // theme + WingHex::AppTheme currentAppTheme(); + // not available for AngelScript // only for plugin UI extenstion diff --git a/src/plugin/pluginsystem.cpp b/src/plugin/pluginsystem.cpp index 331ee66..ae61b2d 100644 --- a/src/plugin/pluginsystem.cpp +++ b/src/plugin/pluginsystem.cpp @@ -21,6 +21,7 @@ #include "class/languagemanager.h" #include "class/logger.h" #include "class/settingmanager.h" +#include "class/skinmanager.h" #include "class/wingfiledialog.h" #include "class/winginputdialog.h" #include "class/wingmessagebox.h" @@ -769,6 +770,17 @@ void PluginSystem::connectBaseInterface(IWingPlugin *plg) { Logger::critical( packLogMessage(plg->metaObject()->className(), message)); }); + connect(plg, &IWingPlugin::currentAppTheme, this, + []() -> WingHex::AppTheme { + auto theme = SkinManager::instance().currentTheme(); + switch (theme) { + case SkinManager::Theme::Dark: + return WingHex::AppTheme::Dark; + case SkinManager::Theme::Light: + return WingHex::AppTheme::Light; + } + return WingHex::AppTheme::Dark; // fallback to default theme + }); connect(plg, &IWingPlugin::createDialog, this, [=](QWidget *w) -> QDialog * { if (!checkThreadAff()) { diff --git a/src/settings/pluginsettingdialog.cpp b/src/settings/pluginsettingdialog.cpp index 5d3abab..d757d30 100644 --- a/src/settings/pluginsettingdialog.cpp +++ b/src/settings/pluginsettingdialog.cpp @@ -49,7 +49,9 @@ PluginSettingDialog::PluginSettingDialog(QWidget *parent) auto pico = ICONRES("plugin"); ui->plglist->clear(); for (auto &p : plgsys.plugins()) { - ui->plglist->addItem(new QListWidgetItem(pico, p->pluginName())); + auto pco = p->pluginIcon(); + ui->plglist->addItem( + new QListWidgetItem(pco.isNull() ? pico : pco, p->pluginName())); } ui->txtc->clear(); @@ -96,7 +98,7 @@ void PluginSettingDialog::on_plglist_itemSelectionChanged() { auto &plgsys = PluginSystem::instance(); auto plg = plgsys.plugin(ui->plglist->currentRow()); - + ui->txtc->clear(); ui->txtc->append(tr("pluginName") + " : " + plg->pluginName()); ui->txtc->append(tr("pluginAuthor") + " : " + plg->pluginAuthor()); ui->txtc->append(tr("pluginVersion") + " : " +