This commit is contained in:
寂静的羽夏 2022-07-05 13:22:05 +08:00
parent 658e60825e
commit 2370619d19
4 changed files with 21 additions and 2 deletions

View File

@ -1127,7 +1127,8 @@ void MainWindow::connectBase(IWingPlugin *plugin) {
PCHECKRETURN(hexfiles[_pcurfile].render->documentLines(), quint64(0));
});
ConnectBaseLamba2(WingPlugin::Reader::documentBytes, [=] {
PCHECKRETURN(quint64(hexfiles[_pcurfile].doc->length()), quint64(0));
PCHECKRETURN(quint64(hexfiles[_pcurfile].doc->length()),
quint64(hexeditor->documentBytes()));
});
ConnectBaseLamba2(WingPlugin::Reader::currentPos, [=] {
HexPosition pos;
@ -1478,6 +1479,11 @@ void MainWindow::connectControl(IWingPlugin *plugin) {
PCHECK(hexfiles[_pcurfile].doc->cursor()->select(length), );
});
ConnectControlLamba2(WingPlugin::Controller::enabledCursor, [=](bool b) {
plgsys->resetTimeout(qobject_cast<IWingPlugin *>(sender()));
PCHECK(hexfiles[_pcurfile].render->enableCursor(b), )
});
ConnectControlLamba2(WingPlugin::Controller::selectOffset, [=](qint64 offset,
int length) {
plgsys->resetTimeout(qobject_cast<IWingPlugin *>(sender()));
@ -1964,6 +1970,7 @@ ErrFile MainWindow::openFile(QString filename, bool readonly, int *openedindex,
tabs->setCurrentIndex(index);
tabs->setTabToolTip(index, filename);
setEditModeEnabled(true);
_currentfile = index;
if (_enableplugin) {
params << ErrFile::Success;

View File

@ -138,6 +138,7 @@ enum HookIndex {
Q_DECLARE_METATYPE(WingPluginMessage)
Q_DECLARE_METATYPE(ResponseMsg)
Q_DECLARE_METATYPE(HookIndex)
Q_DECLARE_METATYPE(ErrFile)
namespace WingPlugin {
class Reader : public QObject {
@ -241,6 +242,7 @@ signals:
void selectOffset(qint64 offset, int length);
void setInsertionMode(bool isinsert);
void setLineWidth(quint8 width);
void enabledCursor(bool b);
// metadata
bool metadata(qint64 begin, qint64 end, const QColor &fgcolor,
@ -370,6 +372,12 @@ public:
#define PluginMenuInitEnd() }
#define USINGCONTROL(Segment) \
if (this->requestControl()) { \
Segment; \
this->requestRelease(); \
}
class PluginUtils {
public:
static QString GetPUID(IWingPlugin *plugin) {

View File

@ -40,7 +40,7 @@ QList<IWingPlugin *> PluginSystem::plugins() { return loadedplgs; }
void PluginSystem::raiseDispatch(HookIndex hookindex, QList<QVariant> params) {
auto dispatch = dispatcher[hookindex];
params << hookindex;
params.push_front(hookindex);
for (auto item : dispatch) {
item->plugin2MessagePipe(WingPluginMessage::HookMessage, params);
}
@ -118,6 +118,7 @@ void PluginSystem::loadPlugin(QFileInfo fileinfo) {
INSERTSUBSCRIBE(HookIndex::CloseFileEnd);
INSERTSUBSCRIBE(HookIndex::NewFileBegin);
INSERTSUBSCRIBE(HookIndex::NewFileEnd);
INSERTSUBSCRIBE(HookIndex::DocumentSwitched);
emit p->plugin2MessagePipe(WingPluginMessage::PluginLoaded, emptyparam);
@ -177,6 +178,7 @@ bool PluginSystem::requestRelease(IWingPlugin *plugin) {
plugintimer[plugin]->stop();
plugintimeout[plugin] = false;
curpluginctl = nullptr;
mutex.unlock();
return true;
}
return false;

View File

@ -80,3 +80,5 @@ v1.4.0 ( Wiki 公测版 ):
1. 修复保存状态异常问题
2. 添加遗漏的插件订阅消息处理
3. 增加更多的插件接口和消息订阅
4. 修复插件释放控制权但互斥锁未释放导致之后的插件无法再次获取控制的 Bug
5. 修改有关文档的未获取控制的默认值为编辑器默认