diff --git a/lang/zh_CN/winghex_zh_CN.ts b/lang/zh_CN/winghex_zh_CN.ts
index 83bd658..1be7688 100644
--- a/lang/zh_CN/winghex_zh_CN.ts
+++ b/lang/zh_CN/winghex_zh_CN.ts
@@ -2374,7 +2374,7 @@
【恶意调用】
-
+
Not allowed operation in non-UI thread
该操作在非 UI 线程非法
@@ -4760,32 +4760,32 @@ Do you wish to keep up to date by reloading the file?
ScriptingConsole
-
+
Scripting console for WingHexExplorer
羽云十六进制编辑器脚本控制台
-
+
>>>> Powered by AngelScript <<<<
>>>> 由 AngelScript 引擎提供支持 <<<<
-
+
[Info]
【信息】
-
+
[Warn]
【警告】
-
+
[Error]
【错误】
-
+
[Console]
【控制台】
@@ -4798,421 +4798,421 @@ Do you wish to keep up to date by reloading the file?
脚本编辑器
-
+
ScriptPermissionDenied
因权限无法打开脚本
-
+
File
文件
-
+
Edit
编辑
-
+
Debugger
调试器
-
+
Setting
设置
-
+
About
关于
-
+
InvalidSourceFile
非法代码文件
-
+
Basic
基础
-
+
New
新建
-
+
OpenF
打开文件
-
+
RecentFiles
最近打开
-
+
Reload
重新加载
-
-
+
+
Save
保存
-
+
SaveAs
另存为
-
+
General
基本
-
+
Undo
撤销
-
+
Redo
恢复
-
+
Cut
剪切
-
+
Copy
复制
-
+
Paste
粘贴
-
+
Delete
删除
-
+
Lookup
查询
-
+
Find
查找
-
+
Replace
替换
-
+
Goto
跳转
-
-
+
+
Format
代码样式
-
+
CodeFormat
代码格式化
-
+
Display
显示
-
+
Scale
缩放
-
+
ResetScale
重置缩放
-
+
Window
窗体
-
-
+
+
Editor
编辑器
-
+
Tools
工具
-
+
Layout
布局
-
+
Fullscreen
全屏
-
+
RestoreLayout
恢复默认布局
-
+
BreakPoint
断点
-
+
ToggleBreakPoint
切换断点
-
+
AddBreakPoint
添加断点
-
+
Settings
设置
-
+
ClangFormat
Clang Format
-
+
Local
本地
-
+
Global
全局
-
+
Variables
变量
-
+
ConsoleOutput
输出
-
+
StackTrace
栈跟踪
-
+
Symbol
符号
-
-
-
-
-
-
+
+
+
+
+
+
Error
错误
-
+
Too much opened files
打开的文件过多,无法继续操作!
-
+
ConfirmSave
正在关闭未保存的脚本文件,你确定保存吗?
-
+
ScriptSaveFailedClose
脚本保存失败,你仍确认关闭吗?
-
+
Debuging...
调试中...
-
+
Running...
运行中...
-
-
+
+
ChooseFile
选择文件
-
-
-
+
+
+
FilePermission
因文件权限无法继续!
-
+
ReloadSuccessfully
文件重新加载成功!
-
+
ReloadUnSuccessfully
文件重新加载失败!
-
+
ChooseSaveFile
请选择保存文件路径:
-
-
+
+
SaveSuccessfully
保存成功!
-
+
SaveUnSuccessfully
保存失败!
-
+
FormatCodeFailed
代码格式化失败
-
-
+
+
CannotSave2RunScript
无法保存,故无法继续运行脚本。
-
-
+
+
ScriptStillRunning
脚本仍在运行,你确定要退出吗?
-
+
ConfirmScriptSave
你尝试关闭程序,但仍存在未保存的脚本文件,你确定保存这些更改吗?
-
+
View
视图
-
+
Debug
调试
-
+
Run
运行
-
+
RunWithDbg
调试运行
-
+
Pause
暂停
-
+
Continue
继续
-
+
Stop
停止
-
+
Restart
重启
-
+
StepInto
单步步入
-
+
StepOver
单步步过
-
+
StepOut
单步跳出
-
+
RemoveBreakPoint
删除断点
-
+
Info
信息
-
+
Software
软件
-
+
Sponsor
赞助
-
+
Wiki
网页 Wiki
-
+
AboutQT
关于 QT
@@ -5389,39 +5389,39 @@ Do you wish to keep up to date by reloading the file?
提供基础的文件结构分析支持
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
InvalidParamsCount
非法参数个数
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
InvalidParam
非法参数
diff --git a/lang/zh_TW/winghex_zh_TW.ts b/lang/zh_TW/winghex_zh_TW.ts
index f5f584e..035368f 100644
--- a/lang/zh_TW/winghex_zh_TW.ts
+++ b/lang/zh_TW/winghex_zh_TW.ts
@@ -2374,7 +2374,7 @@
【惡意調用】
-
+
Not allowed operation in non-UI thread
該操作在非 UI 線程非法
@@ -4760,32 +4760,32 @@ Do you wish to keep up to date by reloading the file?
ScriptingConsole
-
+
Scripting console for WingHexExplorer
羽雲十六進制編輯器腳本控制臺
-
+
>>>> Powered by AngelScript <<<<
>>>> 由 AngelScript 引擎提供支持 <<<<
-
+
[Info]
【資訊】
-
+
[Warn]
【警告】
-
+
[Error]
【錯誤】
-
+
[Console]
【控制臺】
@@ -4798,421 +4798,421 @@ Do you wish to keep up to date by reloading the file?
腳本編輯器
-
+
ScriptPermissionDenied
因許可權無法打開腳本
-
+
File
檔
-
+
Edit
編輯
-
+
Debugger
調試器
-
+
Setting
設置
-
+
About
關於
-
+
InvalidSourceFile
非法代碼檔
-
+
Basic
基礎
-
+
New
新建
-
+
OpenF
打開檔
-
+
RecentFiles
最近打開
-
+
Reload
重新加載
-
-
+
+
Save
保存
-
+
SaveAs
另存為
-
+
General
基本
-
+
Undo
撤銷
-
+
Redo
恢復
-
+
Cut
剪切
-
+
Copy
複製
-
+
Paste
粘貼
-
+
Delete
刪除
-
+
Lookup
查詢
-
+
Find
查找
-
+
Replace
替換
-
+
Goto
跳轉
-
-
+
+
Format
代碼樣式
-
+
CodeFormat
代碼格式化
-
+
Display
顯示
-
+
Scale
縮放
-
+
ResetScale
重置縮放
-
+
Window
窗體
-
-
+
+
Editor
編輯器
-
+
Tools
工具
-
+
Layout
佈局
-
+
Fullscreen
全屏
-
+
RestoreLayout
恢復默認佈局
-
+
BreakPoint
中斷點
-
+
ToggleBreakPoint
切換中斷點
-
+
AddBreakPoint
添加中斷點
-
+
Settings
設置
-
+
ClangFormat
Clang Format
-
+
Local
本地
-
+
Global
全局
-
+
Variables
變數
-
+
ConsoleOutput
輸出
-
+
StackTrace
棧跟蹤
-
+
Symbol
符號
-
-
-
-
-
-
+
+
+
+
+
+
Error
錯誤
-
+
Too much opened files
打開的檔過多,無法繼續操作!
-
+
ConfirmSave
正在關閉未保存的腳本檔,你確定保存嗎?
-
+
ScriptSaveFailedClose
腳本保存失敗,你仍確認關閉嗎?
-
+
Debuging...
調試中...
-
+
Running...
運行中...
-
-
+
+
ChooseFile
選擇檔
-
-
-
+
+
+
FilePermission
因檔許可權無法繼續!
-
+
ReloadSuccessfully
檔重新加載成功!
-
+
ReloadUnSuccessfully
檔重新加載失敗!
-
+
ChooseSaveFile
請選擇保存檔路徑:
-
-
+
+
SaveSuccessfully
保存成功!
-
+
SaveUnSuccessfully
保存失敗!
-
+
FormatCodeFailed
代碼格式化失敗
-
-
+
+
CannotSave2RunScript
無法保存,故無法繼續運行腳本。
-
-
+
+
ScriptStillRunning
腳本仍在運行,你確定要退出嗎?
-
+
ConfirmScriptSave
你嘗試關閉程式,但仍存在未保存的腳本檔,你確定保存這些更改嗎?
-
+
View
視圖
-
+
Debug
調試
-
+
Run
運行
-
+
RunWithDbg
調試運行
-
+
Pause
暫停
-
+
Continue
繼續
-
+
Stop
停止
-
+
Restart
重啟
-
+
StepInto
單步步入
-
+
StepOver
單步步過
-
+
StepOut
單步跳出
-
+
RemoveBreakPoint
刪除中斷點
-
+
Info
資訊
-
+
Software
軟體
-
+
Sponsor
贊助
-
+
Wiki
網頁 Wiki
-
+
AboutQT
關於 QT
@@ -5389,39 +5389,39 @@ Do you wish to keep up to date by reloading the file?
提供基礎的檔結構分析支持
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
InvalidParamsCount
非法參數個數
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
InvalidParam
非法參數
diff --git a/src/class/ctypeparser.cpp b/src/class/ctypeparser.cpp
index 1311a2c..7149257 100644
--- a/src/class/ctypeparser.cpp
+++ b/src/class/ctypeparser.cpp
@@ -53,17 +53,15 @@ void CTypeParser::initialize() {
#define ADD_TYPE_S(T, MT, S) type_maps_.insert(#T, qMakePair(MT, S))
// qualifiers to ignore in parsing
- qualifiers_ =
- QStringList{"static", "const", "far", "extern", "volatile",
- "auto", "register", "inline", "__attribute__"};
+ qualifiers_ = QStringList{"static", "const", "far", "extern",
+ "signed", "unsigned", "volatile", "auto",
+ "register", "inline", "__attribute__"};
// keywords that we care
keywords_["struct"] = kStructKeyword;
keywords_["union"] = kUnionKeyword;
keywords_["enum"] = kEnumKeyword;
keywords_["typedef"] = kTypedefKeyword;
- keywords_["signed"] = kSignedKeyword;
- keywords_["unsigned"] = KUnsignedKeyword;
using byte = unsigned char;
using char8_t = unsigned char;
@@ -157,6 +155,10 @@ void CTypeParser::initialize() {
ADD_TYPE_U(DWORD, QMetaType::UInt);
ADD_TYPE_U(QWORD, QMetaType::ULongLong);
ADD_TYPE_U(DWORDLONG, QMetaType::ULongLong);
+ ADD_TYPE(FLOAT, QMetaType::Float);
+ ADD_TYPE(DOUBLE, QMetaType::Double);
+ ADD_TYPE_U(DWORD32, QMetaType::UInt);
+ ADD_TYPE_U(DWORD64, QMetaType::UInt);
using INT8 = qint8;
using INT16 = qint16;
@@ -284,7 +286,6 @@ bool CTypeParser::parseSource(const QString &src) {
case kBlockStart:
case kBlockEnd:
case kSemicolon:
- decl.force_unsigned = false;
break;
default:
@@ -336,11 +337,6 @@ bool CTypeParser::parseSource(const QString &src) {
}
break;
- case kSignedKeyword: // ignore
- break;
- case KUnsignedKeyword:
- decl.force_unsigned = true;
- break;
default:
break;
}
diff --git a/src/class/ctypeparser.h b/src/class/ctypeparser.h
index e0762d1..30b7584 100644
--- a/src/class/ctypeparser.h
+++ b/src/class/ctypeparser.h
@@ -42,10 +42,8 @@
/// with this awareness
///
typedef struct {
- QString data_type; ///< name of a data type, either basic type or
- ///< user-defined type
-
- bool force_unsigned;
+ QString data_type; ///< name of a data type, either basic type or
+ ///< user-defined type
QString var_name; ///< variable name
qsizetype offset; ///< member offset in struct: 0 for non-struct
qsizetype array_size; ///< array size: 0 for non-array
@@ -62,8 +60,6 @@ enum TokenTypes {
kUnionKeyword,
kEnumKeyword,
kTypedefKeyword,
- kSignedKeyword,
- KUnsignedKeyword,
kBasicDataType,
kAbstractType,
diff --git a/src/class/scriptmachine.cpp b/src/class/scriptmachine.cpp
index 5f78d69..47be6b8 100644
--- a/src/class/scriptmachine.cpp
+++ b/src/class/scriptmachine.cpp
@@ -291,7 +291,7 @@ bool ScriptMachine::executeScript(const QString &script, bool isInDebug) {
return false;
}
- asIScriptModule *mod = _engine->GetModule("script", asGM_ONLY_IF_EXISTS);
+ asIScriptModule *mod = builder.GetModule();
if (!mod) {
return false;
}
diff --git a/src/class/wingcstruct.cpp b/src/class/wingcstruct.cpp
index 1260bf7..799baa4 100644
--- a/src/class/wingcstruct.cpp
+++ b/src/class/wingcstruct.cpp
@@ -491,39 +491,6 @@ QString WingCStruct::getqsizeTypeAsString() const {
: QStringLiteral("int32");
}
-QMetaType::Type WingCStruct::correctTypeSign(QMetaType::Type type,
- bool forceUnsigned) {
- if (forceUnsigned) {
- switch (type) {
- case QMetaType::Int:
- return QMetaType::UInt;
- case QMetaType::UInt:
- return QMetaType::Int;
- case QMetaType::LongLong:
- return QMetaType::ULongLong;
- case QMetaType::ULongLong:
- return QMetaType::LongLong;
- case QMetaType::Long:
- return QMetaType::ULong;
- case QMetaType::Short:
- return QMetaType::UShort;
- case QMetaType::Char:
- return QMetaType::UChar;
- case QMetaType::ULong:
- return QMetaType::Long;
- case QMetaType::UShort:
- return QMetaType::Short;
- case QMetaType::UChar:
- return QMetaType::SChar;
- case QMetaType::SChar:
- return QMetaType::Char;
- default:
- break;
- }
- }
- return type;
-}
-
QVariant WingCStruct::getData(const char *ptr, const char *end,
QMetaType::Type type, qsizetype size) {
if (ptr + size > end) {
@@ -594,9 +561,7 @@ QVariantHash WingCStruct::readStruct(const char *&ptr, const char *end,
if (m.array_size) {
QVariantList l;
for (qsizetype i = 0; i < m.array_size; ++i) {
- auto data = getData(
- ptr, end, correctTypeSign(t.first, m.force_unsigned),
- t.second);
+ auto data = getData(ptr, end, t.first, t.second);
if (data.isNull()) {
return content;
}
@@ -605,9 +570,7 @@ QVariantHash WingCStruct::readStruct(const char *&ptr, const char *end,
}
content.insert(m.var_name, l);
} else {
- auto data = getData(ptr, end,
- correctTypeSign(t.first, m.force_unsigned),
- t.second);
+ auto data = getData(ptr, end, t.first, t.second);
if (data.isNull()) {
return content;
}
diff --git a/src/class/wingcstruct.h b/src/class/wingcstruct.h
index 5afabd6..77cebae 100644
--- a/src/class/wingcstruct.h
+++ b/src/class/wingcstruct.h
@@ -94,8 +94,6 @@ private:
QString getqsizeTypeAsString() const;
- QMetaType::Type correctTypeSign(QMetaType::Type type, bool forceUnsigned);
-
QVariant getData(const char *ptr, const char *end, QMetaType::Type type,
qsizetype size);
diff --git a/src/control/scriptingconsole.cpp b/src/control/scriptingconsole.cpp
index 8ed1880..81b6510 100644
--- a/src/control/scriptingconsole.cpp
+++ b/src/control/scriptingconsole.cpp
@@ -18,6 +18,7 @@
#include "scriptingconsole.h"
#include "class/logger.h"
#include "class/scriptconsolemachine.h"
+#include "qdocumentline.h"
#include "qregularexpression.h"
#include
@@ -52,18 +53,29 @@ void ScriptingConsole::init() {
connect(_sp, &ScriptConsoleMachine::onOutput, this,
[=](ScriptConsoleMachine::MessageType type,
const ScriptConsoleMachine::MessageInfo &message) {
+ auto doc = this->document();
+ auto lastLine = doc->line(doc->lineCount() - 1);
switch (type) {
case ScriptMachine::MessageType::Info:
+ if (lastLine.length()) {
+ _s << Qt::endl;
+ }
stdOut(tr("[Info]") + message.message);
_s << Qt::flush;
newLine();
break;
case ScriptMachine::MessageType::Warn:
+ if (lastLine.length()) {
+ _s << Qt::endl;
+ }
stdWarn(tr("[Warn]") + message.message);
_s << Qt::flush;
newLine();
break;
case ScriptMachine::MessageType::Error:
+ if (lastLine.length()) {
+ _s << Qt::endl;
+ }
stdErr(tr("[Error]") + message.message);
_s << Qt::flush;
newLine();
diff --git a/src/dialog/scriptingdialog.cpp b/src/dialog/scriptingdialog.cpp
index 164db8d..8c9a237 100644
--- a/src/dialog/scriptingdialog.cpp
+++ b/src/dialog/scriptingdialog.cpp
@@ -128,29 +128,26 @@ void ScriptingDialog::initConsole() {
m_gvarshow->updateData({});
// clean up
- if (_lastCurLine.first.isEmpty() || _lastCurLine.second < 0) {
- // no need
- return;
- }
+ if (!(_lastCurLine.first.isEmpty() || _lastCurLine.second < 0)) {
+ auto bpMark = m_symID.value(Symbols::BreakPoint);
+ auto curMark = m_symID.value(Symbols::DbgRunCurrentLine);
+ auto curHitMark = m_symID.value(Symbols::DbgRunHitBreakPoint);
- auto bpMark = m_symID.value(Symbols::BreakPoint);
- auto curMark = m_symID.value(Symbols::DbgRunCurrentLine);
- auto curHitMark = m_symID.value(Symbols::DbgRunHitBreakPoint);
-
- // remove the last mark
- if (!_lastCurLine.first.isEmpty() && _lastCurLine.second >= 0) {
- auto lastCur = QCodeEdit::managed(_lastCurLine.first);
- auto doc = lastCur->document();
- auto line = doc->line(_lastCurLine.second - 1);
- if (line.hasMark(curMark)) {
- line.removeMark(curMark);
- } else if (line.hasMark(curHitMark)) {
- line.removeMark(curHitMark);
- line.addMark(bpMark);
+ // remove the last mark
+ if (!_lastCurLine.first.isEmpty() && _lastCurLine.second >= 0) {
+ auto lastCur = QCodeEdit::managed(_lastCurLine.first);
+ auto doc = lastCur->document();
+ auto line = doc->line(_lastCurLine.second - 1);
+ if (line.hasMark(curMark)) {
+ line.removeMark(curMark);
+ } else if (line.hasMark(curHitMark)) {
+ line.removeMark(curHitMark);
+ line.addMark(bpMark);
+ }
}
+ _lastCurLine.first.clear();
+ _lastCurLine.second = -1;
}
- _lastCurLine.first.clear();
- _lastCurLine.second = -1;
if (_needRestart) {
_needRestart = false;
diff --git a/src/plugin/pluginsystem.cpp b/src/plugin/pluginsystem.cpp
index cfef446..158ab9a 100644
--- a/src/plugin/pluginsystem.cpp
+++ b/src/plugin/pluginsystem.cpp
@@ -2098,10 +2098,13 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
return false;
}
- auto &info = m_plgviewMap[plg];
- auto &e = info[fid];
- if (e.cmd) {
- return true;
+ auto r = pluginContextByIdIt(plg, fid);
+ if (r) {
+ auto v = *r;
+ if (v->cmd) {
+ (*r)->cmd = nullptr;
+ return true;
+ }
}
return false;
});
@@ -2405,7 +2408,8 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto uc = pluginCurrentUndoCmd(plg);
auto cmd = doc->metadata()->MakeMetadata(
- uc, begin, begin + length, fgcolor, bgcolor, comment);
+ uc, begin, begin + length - 1, fgcolor, bgcolor,
+ comment);
if (uc == nullptr && cmd) {
doc->pushMakeUndo(cmd);
return true;
@@ -2457,7 +2461,7 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto doc = e->hexEditor()->document();
auto uc = pluginCurrentUndoCmd(plg);
auto cmd = doc->metadata()->MakeComment(
- uc, begin, begin + length, comment);
+ uc, begin, begin + length - 1, comment);
if (uc == nullptr && cmd) {
doc->pushMakeUndo(cmd);
return true;
@@ -2476,7 +2480,7 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto doc = e->hexEditor()->document();
auto uc = pluginCurrentUndoCmd(plg);
auto cmd = doc->metadata()->MakeForeground(
- uc, begin, begin + length, fgcolor);
+ uc, begin, begin + length - 1, fgcolor);
if (uc == nullptr && cmd) {
doc->pushMakeUndo(cmd);
return true;
@@ -2495,7 +2499,7 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
auto doc = e->hexEditor()->document();
auto uc = pluginCurrentUndoCmd(plg);
auto cmd = doc->metadata()->MakeBackground(
- uc, begin, begin + length, bgcolor);
+ uc, begin, begin + length - 1, bgcolor);
if (uc == nullptr && cmd) {
doc->pushMakeUndo(cmd);
return true;
@@ -2699,7 +2703,6 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
return ErrFile::AlreadyOpened;
}
auto id = assginHandleForPluginView(plg, view);
- m_plgCurrentfid[plg] = id;
auto handle = getUIDHandle(id);
PluginSystem::instance().dispatchEvent(
IWingPlugin::RegisteredEvent::PluginFileOpened,
@@ -2820,9 +2823,8 @@ void PluginSystem::connectControllerInterface(IWingPlugin *plg) {
}
auto id = assginHandleForPluginView(plg, view);
- m_plgCurrentfid[plg] = id;
-
- return ErrFile(int(*id));
+ auto handle = getUIDHandle(id);
+ return ErrFile(handle);
}
return ErrFile::Error;
});
diff --git a/src/scriptaddon/scriptqstring.cpp b/src/scriptaddon/scriptqstring.cpp
index 93600d4..f2af82e 100644
--- a/src/scriptaddon/scriptqstring.cpp
+++ b/src/scriptaddon/scriptqstring.cpp
@@ -43,7 +43,7 @@ public:
// threads, so it is necessary to use a mutex.
asAcquireExclusiveLock();
- QString str = QString::fromUtf8(data, length);
+ QString str = QString::fromUtf8(QByteArray(data, length));
Map_t::iterator it = stringCache.find(str);
if (it != stringCache.end())
@@ -68,9 +68,11 @@ public:
auto strv = *reinterpret_cast(str);
Map_t::iterator it = stringCache.find(strv);
- if (it == stringCache.end())
- ret = asERROR;
- else {
+ if (it == stringCache.end()) {
+ // ret = asERROR;
+ // TODO: I don't know why invalid string pointer passed to it
+ // just ignore it.
+ } else {
it->second--;
if (it->second == 0)
stringCache.erase(it);