feat: 移除 Qt5 支持;引入 antlr4 提供语法支持;
This commit is contained in:
parent
e374f759e5
commit
a84a62657b
|
@ -10,5 +10,5 @@ jobs:
|
|||
uses: jidicula/clang-format-action@v4.14.0
|
||||
with:
|
||||
clang-format-version: '19'
|
||||
exclude-regex: '(qt-template|mkinstaller)'
|
||||
exclude-regex: '(qt-template|mkinstaller|grammar)'
|
||||
fallback-style: 'LLVM' # optional
|
||||
|
|
|
@ -78,3 +78,8 @@ CMakeLists.txt.user*
|
|||
|
||||
#VSCode
|
||||
.vscode/
|
||||
|
||||
# antlr 4 caches
|
||||
*.interp
|
||||
*.tokens
|
||||
.antlr/
|
||||
|
|
|
@ -17,3 +17,6 @@
|
|||
[submodule "WingPlugin"]
|
||||
path = WingPlugin
|
||||
url = git@github.com:Wing-summer/WingHexExplorer2-SDK.git
|
||||
[submodule "3rdparty/antlr4-cpp"]
|
||||
path = 3rdparty/antlr4-cpp
|
||||
url = git@github.com:Wing-summer/antlr4-cpp.git
|
||||
|
|
|
@ -62,7 +62,7 @@ qint64 QConsoleIODevice::writeData(const char *data, qint64 len) {
|
|||
|
||||
writtenSinceLastEmit_ += len;
|
||||
if (!signalsBlocked()) {
|
||||
emit bytesWritten(writtenSinceLastEmit_);
|
||||
Q_EMIT bytesWritten(writtenSinceLastEmit_);
|
||||
writtenSinceLastEmit_ = 0;
|
||||
}
|
||||
return len;
|
||||
|
@ -82,7 +82,7 @@ void QConsoleIODevice::consoleWidgetInput(const QString &in) {
|
|||
|
||||
readSinceLastEmit_ += sz;
|
||||
if (!signalsBlocked()) {
|
||||
emit readyRead();
|
||||
Q_EMIT readyRead();
|
||||
readyReadEmmited_ = true;
|
||||
readSinceLastEmit_ = 0;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ void QConsoleWidget::handleReturnKey() {
|
|||
if (iodevice_->isOpen())
|
||||
iodevice_->consoleWidgetInput(code);
|
||||
|
||||
emit consoleCommand(code);
|
||||
Q_EMIT consoleCommand(code);
|
||||
}
|
||||
|
||||
void QConsoleWidget::handleTabKey() {
|
||||
|
@ -167,7 +167,7 @@ void QConsoleWidget::keyPressEvent(QKeyEvent *e) {
|
|||
if (e->modifiers() & Qt::ControlModifier) {
|
||||
if (e->key() == Qt::Key_Q) // Ctrl-Q aborts
|
||||
{
|
||||
emit abortEvaluation();
|
||||
Q_EMIT abortEvaluation();
|
||||
e->accept();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ bool QHexCursor::hasInternalSelection() const { return !m_sels.isEmpty(); }
|
|||
void QHexCursor::clearPreviewSelection() {
|
||||
m_selection = m_position;
|
||||
m_preMode = SelectionNormal;
|
||||
emit selectionChanged();
|
||||
Q_EMIT selectionChanged();
|
||||
}
|
||||
|
||||
void QHexCursor::clearSelection() { m_sels.clear(); }
|
||||
|
@ -155,10 +155,10 @@ void QHexCursor::moveTo(qsizetype line, int column, int nibbleindex,
|
|||
}
|
||||
|
||||
if (clearSelection) {
|
||||
emit selectionChanged();
|
||||
Q_EMIT selectionChanged();
|
||||
}
|
||||
|
||||
emit positionChanged();
|
||||
Q_EMIT positionChanged();
|
||||
}
|
||||
|
||||
void QHexCursor::select(qsizetype line, int column, SelectionModes modes) {
|
||||
|
@ -197,7 +197,7 @@ void QHexCursor::select(qsizetype line, int column, SelectionModes modes) {
|
|||
}
|
||||
}
|
||||
|
||||
emit selectionChanged();
|
||||
Q_EMIT selectionChanged();
|
||||
}
|
||||
|
||||
void QHexCursor::moveTo(qsizetype offset, bool clearSelection) {
|
||||
|
@ -223,7 +223,7 @@ void QHexCursor::setInsertionMode(QHexCursor::InsertionMode mode) {
|
|||
m_insertionmode = mode;
|
||||
|
||||
if (differentmode)
|
||||
emit insertionModeChanged();
|
||||
Q_EMIT insertionModeChanged();
|
||||
}
|
||||
|
||||
void QHexCursor::setLineWidth(quint8 width) {
|
||||
|
@ -243,7 +243,7 @@ void QHexCursor::switchInsertionMode() {
|
|||
else
|
||||
m_insertionmode = QHexCursor::OverwriteMode;
|
||||
|
||||
emit insertionModeChanged();
|
||||
Q_EMIT insertionModeChanged();
|
||||
}
|
||||
|
||||
bool QHexCursor::hasPreviewSelection() const {
|
||||
|
@ -299,5 +299,5 @@ void QHexCursor::mergePreviewSelection() {
|
|||
}
|
||||
clearPreviewSelection();
|
||||
|
||||
emit selectionChanged();
|
||||
Q_EMIT selectionChanged();
|
||||
}
|
||||
|
|
|
@ -71,20 +71,20 @@ void QHexDocument::addUndoCommand(QUndoCommand *command) {
|
|||
|
||||
void QHexDocument::setMetabgVisible(bool b) {
|
||||
m_metabg = b;
|
||||
emit documentChanged();
|
||||
emit metabgVisibleChanged(b);
|
||||
Q_EMIT documentChanged();
|
||||
Q_EMIT metabgVisibleChanged(b);
|
||||
}
|
||||
|
||||
void QHexDocument::setMetafgVisible(bool b) {
|
||||
m_metafg = b;
|
||||
emit documentChanged();
|
||||
emit metafgVisibleChanged(b);
|
||||
Q_EMIT documentChanged();
|
||||
Q_EMIT metafgVisibleChanged(b);
|
||||
}
|
||||
|
||||
void QHexDocument::setMetaCommentVisible(bool b) {
|
||||
m_metacomment = b;
|
||||
emit documentChanged();
|
||||
emit metaCommentVisibleChanged(b);
|
||||
Q_EMIT documentChanged();
|
||||
Q_EMIT metaCommentVisibleChanged(b);
|
||||
}
|
||||
|
||||
bool QHexDocument::metabgVisible() { return m_metabg; }
|
||||
|
@ -227,7 +227,7 @@ void QHexDocument::setDocSaved(bool b) {
|
|||
if (b) {
|
||||
m_undostack->setClean();
|
||||
}
|
||||
emit documentSaved(b);
|
||||
Q_EMIT documentSaved(b);
|
||||
}
|
||||
|
||||
bool QHexDocument::isReadOnly() { return m_readonly; }
|
||||
|
@ -242,7 +242,7 @@ bool QHexDocument::setLockedFile(bool b) {
|
|||
if (m_readonly)
|
||||
return false;
|
||||
m_islocked = b;
|
||||
emit documentLockedFile(b);
|
||||
Q_EMIT documentLockedFile(b);
|
||||
return true;
|
||||
}
|
||||
bool QHexDocument::setKeepSize(bool b) {
|
||||
|
@ -250,7 +250,7 @@ bool QHexDocument::setKeepSize(bool b) {
|
|||
return false;
|
||||
|
||||
m_keepsize = b;
|
||||
emit documentKeepSize(b);
|
||||
Q_EMIT documentKeepSize(b);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -326,8 +326,8 @@ bool QHexDocument::addBookMark(qsizetype pos, QString comment) {
|
|||
if (!existBookMark(pos)) {
|
||||
_bookmarks.insert(pos, comment);
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
emit bookMarkChanged();
|
||||
Q_EMIT documentChanged();
|
||||
Q_EMIT bookMarkChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -365,7 +365,7 @@ bool QHexDocument::RemoveBookMarks(const QList<qsizetype> &pos) {
|
|||
m_undostack->push(new BookMarkRemoveCommand(this, p, bookMark(p)));
|
||||
}
|
||||
m_undostack->endMacro();
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -395,8 +395,8 @@ bool QHexDocument::clearBookMark() {
|
|||
if (m_keepsize) {
|
||||
_bookmarks.clear();
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
emit bookMarkChanged();
|
||||
Q_EMIT documentChanged();
|
||||
Q_EMIT bookMarkChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -411,7 +411,7 @@ qsizetype QHexDocument::bookMarksCount() const { return _bookmarks.count(); }
|
|||
void QHexDocument::applyBookMarks(const QMap<qsizetype, QString> &books) {
|
||||
_bookmarks = books;
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::findAllBytes(qsizetype begin, qsizetype end,
|
||||
|
@ -502,7 +502,7 @@ bool QHexDocument::_insert(qsizetype offset, uchar b) {
|
|||
bool QHexDocument::_insert(qsizetype offset, const QByteArray &data) {
|
||||
m_buffer->insert(offset, data);
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -513,14 +513,14 @@ bool QHexDocument::_replace(qsizetype offset, uchar b) {
|
|||
bool QHexDocument::_replace(qsizetype offset, const QByteArray &data) {
|
||||
m_buffer->replace(offset, data);
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QHexDocument::_remove(qsizetype offset, qsizetype len) {
|
||||
m_buffer->remove(offset, len);
|
||||
setDocSaved(false);
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -636,7 +636,7 @@ QHexDocument::QHexDocument(QHexBuffer *buffer, bool readonly)
|
|||
|
||||
connect(m_metadata, &QHexMetadata::metadataChanged, this, [this] {
|
||||
setDocSaved(false);
|
||||
emit metaDataChanged();
|
||||
Q_EMIT metaDataChanged();
|
||||
});
|
||||
|
||||
/*=======================*/
|
||||
|
@ -665,7 +665,7 @@ int QHexDocument::hexLineWidth() const { return m_hexlinewidth; }
|
|||
void QHexDocument::setHexLineWidth(quint8 value) {
|
||||
m_hexlinewidth = value;
|
||||
m_metadata->setLineWidth(value);
|
||||
emit hexLineWidthChanged();
|
||||
Q_EMIT hexLineWidthChanged();
|
||||
}
|
||||
|
||||
QHexMetadata *QHexDocument::metadata() const { return m_metadata; }
|
||||
|
@ -683,19 +683,19 @@ void QHexDocument::setBaseAddress(quint64 baseaddress) {
|
|||
return;
|
||||
|
||||
m_baseaddress = baseaddress;
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::sync() { emit documentChanged(); }
|
||||
void QHexDocument::sync() { Q_EMIT documentChanged(); }
|
||||
|
||||
void QHexDocument::undo() {
|
||||
m_undostack->undo();
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::redo() {
|
||||
m_undostack->redo();
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
}
|
||||
|
||||
void QHexDocument::beginMarco(const QString &text) {
|
||||
|
@ -727,7 +727,7 @@ bool QHexDocument::Insert(QHexCursor *cursor, qsizetype offset,
|
|||
return false;
|
||||
}
|
||||
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -743,7 +743,7 @@ void QHexDocument::Append(QHexCursor *cursor, const QByteArray &data,
|
|||
if (cmd) {
|
||||
m_undostack->push(cmd);
|
||||
}
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
}
|
||||
|
||||
bool QHexDocument::Replace(QHexCursor *cursor, qsizetype offset,
|
||||
|
@ -757,7 +757,7 @@ bool QHexDocument::Replace(QHexCursor *cursor, qsizetype offset,
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -769,7 +769,7 @@ bool QHexDocument::Remove(QHexCursor *cursor, qsizetype offset, qsizetype len,
|
|||
if (cmd) {
|
||||
m_undostack->push(cmd);
|
||||
}
|
||||
emit documentChanged();
|
||||
Q_EMIT documentChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ bool QHexMetadata::removeLineMetadata(const QHexMetadataItem &item) {
|
|||
&item) { return item.second.isEmpty(); });
|
||||
#endif
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ void QHexMetadata::removeMetadata(qsizetype offset) {
|
|||
m_metadata.removeIf(rmfn);
|
||||
#endif
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
QVector<QHexMetadataItem> QHexMetadata::getAllMetadata() const {
|
||||
|
@ -279,7 +279,7 @@ void QHexMetadata::applyMetas(const QVector<QHexMetadataItem> &metas) {
|
|||
for (auto &meta : m_metadata) {
|
||||
addMetaLines(meta);
|
||||
}
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
bool QHexMetadata::hasMetadata() { return m_metadata.count() > 0; }
|
||||
|
@ -320,7 +320,7 @@ void QHexMetadata::endMarco() { m_undo->endMacro(); }
|
|||
void QHexMetadata::clear() {
|
||||
m_linemeta.clear();
|
||||
m_metadata.clear();
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
bool QHexMetadata::metadata(qsizetype begin, qsizetype end,
|
||||
|
@ -329,7 +329,7 @@ bool QHexMetadata::metadata(qsizetype begin, qsizetype end,
|
|||
if (checkValidMetadata(begin, end, fgcolor, bgcolor, comment)) {
|
||||
QHexMetadataItem absi(begin, end, fgcolor, bgcolor, comment);
|
||||
addMetadata(absi);
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -344,7 +344,7 @@ void QHexMetadata::setLineWidth(quint8 width) {
|
|||
addMetadata(item);
|
||||
}
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ void QHexMetadata::insertAdjust(qsizetype offset, qsizetype length) {
|
|||
addMetaLines(meta);
|
||||
}
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
void QHexMetadata::insertAdjustRevert(qsizetype offset, qsizetype length) {
|
||||
|
@ -391,7 +391,7 @@ void QHexMetadata::insertAdjustRevert(qsizetype offset, qsizetype length) {
|
|||
addMetaLines(meta);
|
||||
}
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
QVector<QHexMetadataItem> QHexMetadata::removeAdjust(qsizetype offset,
|
||||
|
@ -435,7 +435,7 @@ QVector<QHexMetadataItem> QHexMetadata::removeAdjust(qsizetype offset,
|
|||
addMetaLines(meta);
|
||||
}
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
|
||||
QtConcurrent::blockingMap(
|
||||
rmmetas, [](QHexMetadataItem &meta) { meta.flag = false; });
|
||||
|
@ -473,7 +473,7 @@ void QHexMetadata::removeAdjustRevert(const QVector<QHexMetadataItem> &metas,
|
|||
addMetaLines(meta);
|
||||
}
|
||||
|
||||
emit metadataChanged();
|
||||
Q_EMIT metadataChanged();
|
||||
}
|
||||
|
||||
bool QHexMetadata::areColorsContrast(const QColor &color1,
|
||||
|
|
|
@ -44,21 +44,21 @@ bool QHexRenderer::stringVisible() { return m_asciiVisible; }
|
|||
|
||||
void QHexRenderer::setStringVisible(bool b) {
|
||||
m_asciiVisible = b;
|
||||
emit m_document->documentChanged();
|
||||
Q_EMIT m_document->documentChanged();
|
||||
}
|
||||
|
||||
bool QHexRenderer::headerVisible() { return m_headerVisible; }
|
||||
|
||||
void QHexRenderer::setHeaderVisible(bool b) {
|
||||
m_headerVisible = b;
|
||||
emit m_document->documentChanged();
|
||||
Q_EMIT m_document->documentChanged();
|
||||
}
|
||||
|
||||
bool QHexRenderer::addressVisible() { return m_addressVisible; }
|
||||
|
||||
void QHexRenderer::setAddressVisible(bool b) {
|
||||
m_addressVisible = b;
|
||||
emit m_document->documentChanged();
|
||||
Q_EMIT m_document->documentChanged();
|
||||
}
|
||||
|
||||
void QHexRenderer::switchDoc(QHexDocument *doc) {
|
||||
|
|
|
@ -116,15 +116,15 @@ QFont QHexView::getHexeditorFont() {
|
|||
}
|
||||
|
||||
void QHexView::getStatus() {
|
||||
emit canUndoChanged(m_document->canUndo());
|
||||
emit canRedoChanged(m_document->canRedo());
|
||||
emit cursorLocationChanged();
|
||||
emit documentSaved(m_document->isDocSaved());
|
||||
emit documentKeepSize(m_document->isKeepSize());
|
||||
emit documentLockedFile(m_document->isLocked());
|
||||
emit metafgVisibleChanged(m_document->metafgVisible());
|
||||
emit metabgVisibleChanged(m_document->metabgVisible());
|
||||
emit metaCommentVisibleChanged(m_document->metaCommentVisible());
|
||||
Q_EMIT canUndoChanged(m_document->canUndo());
|
||||
Q_EMIT canRedoChanged(m_document->canRedo());
|
||||
Q_EMIT cursorLocationChanged();
|
||||
Q_EMIT documentSaved(m_document->isDocSaved());
|
||||
Q_EMIT documentKeepSize(m_document->isKeepSize());
|
||||
Q_EMIT documentLockedFile(m_document->isLocked());
|
||||
Q_EMIT metafgVisibleChanged(m_document->metafgVisible());
|
||||
Q_EMIT metabgVisibleChanged(m_document->metabgVisible());
|
||||
Q_EMIT metaCommentVisibleChanged(m_document->metaCommentVisible());
|
||||
}
|
||||
|
||||
void QHexView::establishSignal(QHexDocument *doc) {
|
||||
|
@ -139,16 +139,16 @@ void QHexView::establishSignal(QHexDocument *doc) {
|
|||
&QHexView::canRedoChanged);
|
||||
connect(doc, &QHexDocument::documentSaved, this, &QHexView::documentSaved);
|
||||
connect(doc, &QHexDocument::metabgVisibleChanged, this, [=](bool b) {
|
||||
emit metabgVisibleChanged(b);
|
||||
emit metaStatusChanged();
|
||||
Q_EMIT metabgVisibleChanged(b);
|
||||
Q_EMIT metaStatusChanged();
|
||||
});
|
||||
connect(doc, &QHexDocument::metafgVisibleChanged, this, [=](bool b) {
|
||||
emit metafgVisibleChanged(b);
|
||||
emit metaStatusChanged();
|
||||
Q_EMIT metafgVisibleChanged(b);
|
||||
Q_EMIT metaStatusChanged();
|
||||
});
|
||||
connect(doc, &QHexDocument::metaCommentVisibleChanged, this, [=](bool b) {
|
||||
emit metaCommentVisibleChanged(b);
|
||||
emit metaStatusChanged();
|
||||
Q_EMIT metaCommentVisibleChanged(b);
|
||||
Q_EMIT metaStatusChanged();
|
||||
});
|
||||
connect(doc, &QHexDocument::metaDataChanged, this,
|
||||
[=] { this->viewport()->update(); });
|
||||
|
@ -234,12 +234,12 @@ void QHexView::setDocument(const QSharedPointer<QHexDocument> &document,
|
|||
&QHexView::moveToSelection);
|
||||
connect(m_cursor, &QHexCursor::selectionChanged, this, [this]() {
|
||||
this->viewport()->update();
|
||||
emit cursorSelectionChanged();
|
||||
Q_EMIT cursorSelectionChanged();
|
||||
});
|
||||
connect(m_cursor, &QHexCursor::insertionModeChanged, this,
|
||||
&QHexView::renderCurrentLine);
|
||||
|
||||
emit documentChanged(document.data());
|
||||
Q_EMIT documentChanged(document.data());
|
||||
|
||||
this->adjustScrollBars();
|
||||
this->viewport()->update();
|
||||
|
@ -462,7 +462,7 @@ bool QHexView::Cut(bool hex, int nibbleindex) {
|
|||
if (res) {
|
||||
return this->RemoveSelection(nibbleindex);
|
||||
} else {
|
||||
emit copyLimitRaised();
|
||||
Q_EMIT copyLimitRaised();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ bool QHexView::cut(bool hex) {
|
|||
if (res) {
|
||||
return this->removeSelection();
|
||||
} else {
|
||||
emit copyLimitRaised();
|
||||
Q_EMIT copyLimitRaised();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ bool QHexView::copy(bool hex) {
|
|||
|
||||
// 如果拷贝字节超过 ? MB 阻止
|
||||
if (len > 1024 * 1024 * m_copylimit) {
|
||||
emit copyLimitRaised();
|
||||
Q_EMIT copyLimitRaised();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ void QHexView::setScaleRate(qreal rate) {
|
|||
if (rate >= 0.2 && rate < 3.01) {
|
||||
m_scaleRate = rate;
|
||||
setFontSize(fontSize());
|
||||
emit scaleRateChanged();
|
||||
Q_EMIT scaleRateChanged();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ QColor QHexView::selBackgroundColor() const {
|
|||
|
||||
void QHexView::setSelBackgroundColor(const QColor &newSelBackgroundColor) {
|
||||
m_renderer->setSelBackgroundColor(newSelBackgroundColor);
|
||||
emit selBackgroundColorChanged();
|
||||
Q_EMIT selBackgroundColorChanged();
|
||||
}
|
||||
|
||||
void QHexView::setFontSize(qreal size) {
|
||||
|
@ -583,7 +583,7 @@ QColor QHexView::selectionColor() const { return m_renderer->selectionColor(); }
|
|||
|
||||
void QHexView::setSelectionColor(const QColor &newSelectionColor) {
|
||||
m_renderer->setSelectionColor(newSelectionColor);
|
||||
emit selectionColorChanged();
|
||||
Q_EMIT selectionColorChanged();
|
||||
}
|
||||
|
||||
QColor QHexView::bytesAlterBackground() const {
|
||||
|
@ -592,14 +592,14 @@ QColor QHexView::bytesAlterBackground() const {
|
|||
|
||||
void QHexView::setBytesAlterBackground(const QColor &newBytesAlterBackground) {
|
||||
m_renderer->setBytesAlterBackground(newBytesAlterBackground);
|
||||
emit bytesAlterBackgroundChanged();
|
||||
Q_EMIT bytesAlterBackgroundChanged();
|
||||
}
|
||||
|
||||
QColor QHexView::bytesColor() const { return m_renderer->bytesColor(); }
|
||||
|
||||
void QHexView::setBytesColor(const QColor &newBytesColor) {
|
||||
m_renderer->setBytesColor(newBytesColor);
|
||||
emit bytesColorChanged();
|
||||
Q_EMIT bytesColorChanged();
|
||||
}
|
||||
|
||||
QColor QHexView::bytesBackground() const {
|
||||
|
@ -608,21 +608,21 @@ QColor QHexView::bytesBackground() const {
|
|||
|
||||
void QHexView::setBytesBackground(const QColor &newBytesBackground) {
|
||||
m_renderer->setBytesBackground(newBytesBackground);
|
||||
emit bytesBackgroundChanged();
|
||||
Q_EMIT bytesBackgroundChanged();
|
||||
}
|
||||
|
||||
QColor QHexView::addressColor() const { return m_renderer->addressColor(); }
|
||||
|
||||
void QHexView::setAddressColor(const QColor &newAddressColor) {
|
||||
m_renderer->setAddressColor(newAddressColor);
|
||||
emit addressColorChanged();
|
||||
Q_EMIT addressColorChanged();
|
||||
}
|
||||
|
||||
QColor QHexView::headerColor() const { return m_renderer->headerColor(); }
|
||||
|
||||
void QHexView::setHeaderColor(const QColor &newHeaderColor) {
|
||||
m_renderer->setHeaderColor(newHeaderColor);
|
||||
emit headerColorChanged();
|
||||
Q_EMIT headerColorChanged();
|
||||
}
|
||||
|
||||
void QHexView::mousePressEvent(QMouseEvent *e) {
|
||||
|
@ -794,7 +794,7 @@ void QHexView::moveToSelection() {
|
|||
} else
|
||||
this->viewport()->update();
|
||||
|
||||
emit cursorLocationChanged(); // added by wingsummer
|
||||
Q_EMIT cursorLocationChanged(); // added by wingsummer
|
||||
}
|
||||
|
||||
void QHexView::blinkCursor() {
|
||||
|
|
|
@ -131,7 +131,7 @@ void Ribbon::dropEvent(QDropEvent *event) {
|
|||
pathList.append(urlList.at(i).toLocalFile());
|
||||
}
|
||||
|
||||
emit onDragDropFiles(pathList);
|
||||
Q_EMIT onDragDropFiles(pathList);
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ void RibbonButtonGroup::addButton(QToolButton *button) {
|
|||
ui->horizontalLayout->addWidget(button);
|
||||
|
||||
if (_buttons.size() == 1) {
|
||||
emit emptyStatusChanged(false);
|
||||
Q_EMIT emptyStatusChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ void RibbonButtonGroup::removeButton(QToolButton *button) {
|
|||
ui->horizontalLayout->removeWidget(button);
|
||||
_buttons.removeOne(button);
|
||||
if (_buttons.empty()) {
|
||||
emit emptyStatusChanged(true);
|
||||
Q_EMIT emptyStatusChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit b8fc7ca25fc0781ba444b02f2ab203042c0c3f0a
|
|
@ -168,5 +168,5 @@ void QtLocalPeer::receiveConnection() {
|
|||
socket->waitForBytesWritten(1000);
|
||||
socket->waitForDisconnected(1000); // make sure client reads ack
|
||||
delete socket;
|
||||
emit messageReceived(uMsg); // ### (might take a long time to return)
|
||||
Q_EMIT messageReceived(uMsg); // ### (might take a long time to return)
|
||||
}
|
||||
|
|
|
@ -46,16 +46,13 @@ if(WIN32)
|
|||
add_definitions(-DNOMINMAX)
|
||||
endif()
|
||||
|
||||
if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
if(Qt5Widgets_VERSION VERSION_LESS 5.14.0)
|
||||
message(FATAL_ERROR "Minimum supported Qt5 version is 5.14!")
|
||||
endif()
|
||||
elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
if(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
if(Qt6Widgets_VERSION VERSION_LESS 6.6.2)
|
||||
message(FATAL_ERROR "Minimum supported Qt6 version is 6.6.2!")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported Qt version!")
|
||||
message(
|
||||
FATAL_ERROR "Qt${QT_VERSION_MAJOR} has been dropped and not supported!")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
|
@ -81,6 +78,26 @@ add_subdirectory(3rdparty/WingCodeEdit)
|
|||
add_subdirectory(3rdparty/Qt-Advanced-Docking-System)
|
||||
add_subdirectory(3rdparty/AngelScript/sdk/angelscript/projects/cmake)
|
||||
|
||||
set(DISABLE_WARNINGS ON)
|
||||
set(ANTLR4_INSTALL OFF)
|
||||
set(ANTLR_BUILD_CPP_TESTS OFF)
|
||||
set(ANTLR_BUILD_SHARED OFF)
|
||||
set(ANTLR_BUILD_STATIC ON)
|
||||
set(WITH_STATIC_CRT OFF)
|
||||
add_subdirectory(3rdparty/antlr4-cpp)
|
||||
|
||||
set(NUMCAL_GRAMMAR
|
||||
src/grammar/NumCal/NumCalBaseVisitor.cpp
|
||||
src/grammar/NumCal/NumCalBaseVisitor.h
|
||||
src/grammar/NumCal/NumCalLexer.cpp
|
||||
src/grammar/NumCal/NumCalLexer.h
|
||||
src/grammar/NumCal/NumCalParser.cpp
|
||||
src/grammar/NumCal/NumCalParser.h
|
||||
src/grammar/NumCal/NumCalVisitor.cpp
|
||||
src/grammar/NumCal/NumCalVisitor.h)
|
||||
|
||||
set(ANTLR4_GRAMMAR ${NUMCAL_GRAMMAR})
|
||||
|
||||
set(ANGEL_SCRIPT_ADDON_ROOT
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/AngelScript/sdk/add_on")
|
||||
set(ANGEL_SCRIPT_ADDON
|
||||
|
@ -241,8 +258,6 @@ set(CLASS_SRC
|
|||
src/class/asdebugger.cpp
|
||||
src/class/angelobjstring.h
|
||||
src/class/angelobjstring.cpp
|
||||
src/class/scripteditortheme.h
|
||||
src/class/scripteditortheme.cpp
|
||||
src/class/appmanager.h
|
||||
src/class/appmanager.cpp
|
||||
src/class/angelscripthelper.h
|
||||
|
@ -380,15 +395,8 @@ set(TRANSLATION_PATH
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/QWingRibbon
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
if(${QT_VERSION_MAJOR} EQUAL 5)
|
||||
qt5_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES} OPTIONS
|
||||
-no-obsolete)
|
||||
elseif(${QT_VERSION_MAJOR} EQUAL 6)
|
||||
qt6_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES} OPTIONS
|
||||
-no-obsolete)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported QT version")
|
||||
endif()
|
||||
qt_create_translation(QM_FILES ${TRANSLATION_PATH} ${TS_FILES} OPTIONS
|
||||
-no-obsolete)
|
||||
|
||||
set(LANG_SRC "${CMAKE_CURRENT_SOURCE_DIR}/lang")
|
||||
set(LANG_DEST "${CMAKE_CURRENT_BINARY_DIR}/.tmp/lang")
|
||||
|
@ -453,6 +461,7 @@ set(PROJECT_SOURCES
|
|||
${SCRIPT_ADDON_SRC}
|
||||
${ANGEL_SCRIPT_ADDON}
|
||||
${QM_FILES}
|
||||
${ANTLR4_GRAMMAR}
|
||||
theme/breeze.qrc
|
||||
resources.qrc)
|
||||
|
||||
|
@ -472,19 +481,6 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||
qt_add_executable(WingHexExplorer2 MANUAL_FINALIZATION
|
||||
${PROJECT_SOURCES})
|
||||
endif()
|
||||
else()
|
||||
if(ANDROID)
|
||||
message(FATAL_ERROR "Android is not supported!")
|
||||
else()
|
||||
if(WIN32)
|
||||
set(app_icon_resource_windows
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/favicon.rc")
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${PROJECT_SOURCES}
|
||||
${app_icon_resource_windows})
|
||||
else()
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${PROJECT_SOURCES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_compile_options(
|
||||
|
@ -510,6 +506,7 @@ target_link_libraries(
|
|||
QHexView
|
||||
WingCodeEdit
|
||||
angelscript
|
||||
antlr4_static
|
||||
qtadvanceddocking-qt${QT_VERSION_MAJOR})
|
||||
|
||||
if(WINGHEX_USE_FRAMELESS)
|
||||
|
@ -521,6 +518,9 @@ if(WIN32)
|
|||
PRIVATE Qt${QT_VERSION_MAJOR}::AxContainer)
|
||||
endif()
|
||||
|
||||
# emit marco in Qt conflicts with antlr4-cpp
|
||||
target_compile_definitions(WingHexExplorer2 PRIVATE QT_NO_EMIT)
|
||||
|
||||
target_include_directories(
|
||||
${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
|
|
|
@ -789,57 +789,57 @@
|
|||
<context>
|
||||
<name>Logger</name>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="96"/>
|
||||
<location filename="../../src/class/logger.cpp" line="98"/>
|
||||
<source>[Trace]</source>
|
||||
<translation>【跟踪】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="103"/>
|
||||
<location filename="../../src/class/logger.cpp" line="105"/>
|
||||
<source>[Warn]</source>
|
||||
<translation>【警告】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="110"/>
|
||||
<location filename="../../src/class/logger.cpp" line="112"/>
|
||||
<source>[Info]</source>
|
||||
<translation>【信息】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="117"/>
|
||||
<location filename="../../src/class/logger.cpp" line="119"/>
|
||||
<source>[Debug]</source>
|
||||
<translation>【调试】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="124"/>
|
||||
<location filename="../../src/class/logger.cpp" line="126"/>
|
||||
<source>[Error]</source>
|
||||
<translation>【错误】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="149"/>
|
||||
<location filename="../../src/class/logger.cpp" line="151"/>
|
||||
<source>Critial</source>
|
||||
<translation>崩溃</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="151"/>
|
||||
<location filename="../../src/class/logger.cpp" line="153"/>
|
||||
<source>Error</source>
|
||||
<translation>错误</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="153"/>
|
||||
<location filename="../../src/class/logger.cpp" line="155"/>
|
||||
<source>Warning</source>
|
||||
<translation>警告</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="155"/>
|
||||
<location filename="../../src/class/logger.cpp" line="157"/>
|
||||
<source>Info</source>
|
||||
<translation>信息</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="157"/>
|
||||
<location filename="../../src/class/logger.cpp" line="159"/>
|
||||
<source>Debug</source>
|
||||
<translation>调试</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="159"/>
|
||||
<location filename="../../src/class/logger.cpp" line="161"/>
|
||||
<source>Trace</source>
|
||||
<translation>跟踪</translation>
|
||||
</message>
|
||||
|
|
|
@ -789,57 +789,57 @@
|
|||
<context>
|
||||
<name>Logger</name>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="96"/>
|
||||
<location filename="../../src/class/logger.cpp" line="98"/>
|
||||
<source>[Trace]</source>
|
||||
<translation>【跟蹤】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="103"/>
|
||||
<location filename="../../src/class/logger.cpp" line="105"/>
|
||||
<source>[Warn]</source>
|
||||
<translation>【警告】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="110"/>
|
||||
<location filename="../../src/class/logger.cpp" line="112"/>
|
||||
<source>[Info]</source>
|
||||
<translation>【資訊】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="117"/>
|
||||
<location filename="../../src/class/logger.cpp" line="119"/>
|
||||
<source>[Debug]</source>
|
||||
<translation>【調試】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="124"/>
|
||||
<location filename="../../src/class/logger.cpp" line="126"/>
|
||||
<source>[Error]</source>
|
||||
<translation>【錯誤】</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="149"/>
|
||||
<location filename="../../src/class/logger.cpp" line="151"/>
|
||||
<source>Critial</source>
|
||||
<translation>崩潰</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="151"/>
|
||||
<location filename="../../src/class/logger.cpp" line="153"/>
|
||||
<source>Error</source>
|
||||
<translation>錯誤</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="153"/>
|
||||
<location filename="../../src/class/logger.cpp" line="155"/>
|
||||
<source>Warning</source>
|
||||
<translation>警告</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="155"/>
|
||||
<location filename="../../src/class/logger.cpp" line="157"/>
|
||||
<source>Info</source>
|
||||
<translation>資訊</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="157"/>
|
||||
<location filename="../../src/class/logger.cpp" line="159"/>
|
||||
<source>Debug</source>
|
||||
<translation>調試</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/class/logger.cpp" line="159"/>
|
||||
<location filename="../../src/class/logger.cpp" line="161"/>
|
||||
<source>Trace</source>
|
||||
<translation>跟蹤</translation>
|
||||
</message>
|
||||
|
|
|
@ -20,13 +20,10 @@
|
|||
|
||||
#include "class/asdebugger.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtGlobal>
|
||||
|
||||
class AngelObjString : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
class AngelObjString {
|
||||
public:
|
||||
static QString stringToString(void *obj, asDebugger *dbg, asUINT tag);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ AsCompletion::AsCompletion(WingCodeEdit *p)
|
|||
auto v = index.data(Qt::SelfDataRole).value<CodeInfoTip>();
|
||||
if (v.type == CodeInfoTip::Type::Function ||
|
||||
v.type == CodeInfoTip::Type::ClsFunction) {
|
||||
emit onFunctionTip(v.getTooltip());
|
||||
Q_EMIT onFunctionTip(v.getTooltip());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -217,7 +217,7 @@ void AsCompletion::clearCompleteDBUnused() {
|
|||
[](const QPair<QString, CompleteDB> &c) { return c.second.time == 0; });
|
||||
}
|
||||
|
||||
void AsCompletion::clearFunctionTip() { emit onFunctionTip({}); }
|
||||
void AsCompletion::clearFunctionTip() { Q_EMIT onFunctionTip({}); }
|
||||
|
||||
QString AsCompletion::wordSeperators() const {
|
||||
static QString eow(QStringLiteral("~!@$%^&*()_+{}|\"<>?,/;'[]\\-="));
|
||||
|
|
|
@ -41,8 +41,8 @@ void asDebugger::registerToStringCallback(const asITypeInfo *ti,
|
|||
}
|
||||
|
||||
void asDebugger::takeCommands(asIScriptContext *ctx) {
|
||||
emit onPullVariables(globalVariables(ctx), localVariables(ctx));
|
||||
emit onPullCallStack(retriveCallstack(ctx));
|
||||
Q_EMIT onPullVariables(globalVariables(ctx), localVariables(ctx));
|
||||
Q_EMIT onPullCallStack(retriveCallstack(ctx));
|
||||
|
||||
while (m_action == DebugAction::PAUSE) {
|
||||
qApp->processEvents();
|
||||
|
@ -66,7 +66,7 @@ void asDebugger::takeCommands(asIScriptContext *ctx) {
|
|||
break;
|
||||
}
|
||||
|
||||
emit onDebugActionExec();
|
||||
Q_EMIT onDebugActionExec();
|
||||
}
|
||||
|
||||
void asDebugger::lineCallback(asIScriptContext *ctx) {
|
||||
|
@ -202,7 +202,7 @@ void asDebugger::lineCallback(asIScriptContext *ctx) {
|
|||
|
||||
rc(dbgContext, file, lineNbr, col, ctx->GetCallstackSize());
|
||||
|
||||
emit onRunCurrentLine(file, lineNbr);
|
||||
Q_EMIT onRunCurrentLine(file, lineNbr);
|
||||
|
||||
takeCommands(ctx);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ void asDebugger::lineCallback(asIScriptContext *ctx) {
|
|||
void asDebugger::addFileBreakPoint(const QString &file, int lineNbr) {
|
||||
BreakPoint bp(file, lineNbr, false);
|
||||
m_breakPoints.push_back(bp);
|
||||
emit breakPointChanged();
|
||||
Q_EMIT breakPointChanged();
|
||||
}
|
||||
|
||||
void asDebugger::removeFileBreakPoint(const QString &file, int lineNbr) {
|
||||
|
@ -222,7 +222,7 @@ void asDebugger::removeFileBreakPoint(const QString &file, int lineNbr) {
|
|||
return;
|
||||
}
|
||||
m_breakPoints.erase(r);
|
||||
emit breakPointChanged();
|
||||
Q_EMIT breakPointChanged();
|
||||
}
|
||||
|
||||
void asDebugger::addFuncBreakPoint(const QString &func) {
|
||||
|
@ -231,7 +231,7 @@ void asDebugger::addFuncBreakPoint(const QString &func) {
|
|||
|
||||
BreakPoint bp(actual, 0, true);
|
||||
m_breakPoints.push_back(bp);
|
||||
emit breakPointChanged();
|
||||
Q_EMIT breakPointChanged();
|
||||
}
|
||||
|
||||
void asDebugger::removeFuncBreakPoint(const QString &func) {
|
||||
|
@ -240,12 +240,12 @@ void asDebugger::removeFuncBreakPoint(const QString &func) {
|
|||
m_breakPoints.begin(), m_breakPoints.end(), [=](const BreakPoint &bp) {
|
||||
return bp.name == actual && bp.func == true;
|
||||
}));
|
||||
emit breakPointChanged();
|
||||
Q_EMIT breakPointChanged();
|
||||
}
|
||||
|
||||
void asDebugger::clearBreakPoint() {
|
||||
m_breakPoints.clear();
|
||||
emit breakPointChanged();
|
||||
Q_EMIT breakPointChanged();
|
||||
}
|
||||
|
||||
const QVector<asDebugger::BreakPoint> &asDebugger::breakPoints() {
|
||||
|
@ -374,7 +374,7 @@ bool asDebugger::checkBreakPoint(asIScriptContext *ctx) {
|
|||
auto old = m_breakPoints[n];
|
||||
// Move the breakpoint to the next line
|
||||
m_breakPoints[n].lineNbr = line;
|
||||
emit onAdjustBreakPointLine(old, line);
|
||||
Q_EMIT onAdjustBreakPointLine(old, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ signals:
|
|||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override {
|
||||
if (event->type() == m_event) {
|
||||
emit eventTriggered(obj, event);
|
||||
Q_EMIT eventTriggered(obj, event);
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ void InspectQtLogHelper::init() {
|
|||
|
||||
menu->addSeparator();
|
||||
auto a = new QAction(tr("Clear"), menu);
|
||||
connect(a, &QAction::triggered, this, [this]() { _ctx->clear(); });
|
||||
QObject::connect(a, &QAction::triggered, qApp, [this]() { _ctx->clear(); });
|
||||
menu->addAction(a);
|
||||
|
||||
auto af = ma.at(0);
|
||||
af = menu->insertSeparator(af);
|
||||
a = new QAction(tr("TopMost"), menu);
|
||||
a->setCheckable(true);
|
||||
connect(a, &QAction::toggled, this, [this](bool b) {
|
||||
QObject::connect(a, &QAction::toggled, qApp, [this](bool b) {
|
||||
_logger->setWindowFlag(Qt::WindowStaysOnTopHint, b);
|
||||
if (!_logger->isVisible()) {
|
||||
_logger->setVisible(true);
|
||||
|
@ -41,10 +41,10 @@ void InspectQtLogHelper::init() {
|
|||
});
|
||||
menu->insertAction(af, a);
|
||||
|
||||
connect(_ctx, &QTextBrowser::customContextMenuRequested, this,
|
||||
[menu, this](const QPoint &pos) {
|
||||
menu->popup(_ctx->mapToGlobal(pos));
|
||||
});
|
||||
QObject::connect(_ctx, &QTextBrowser::customContextMenuRequested, qApp,
|
||||
[menu, this](const QPoint &pos) {
|
||||
menu->popup(_ctx->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
_logger->buildUpContent(_ctx);
|
||||
_logger->setWindowTitle(tr("Inspect"));
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include "dialog/framelessdialogbase.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QCoreApplication>
|
||||
#include <QTextBrowser>
|
||||
|
||||
class InspectQtLogHelper : public QObject {
|
||||
Q_OBJECT
|
||||
class InspectQtLogHelper {
|
||||
Q_DECLARE_TR_FUNCTIONS(InspectQtLogHelper)
|
||||
|
||||
public:
|
||||
static InspectQtLogHelper &instance();
|
||||
|
|
|
@ -105,14 +105,14 @@ LanguageManager::LanguageManager() {
|
|||
QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||
#endif
|
||||
|
||||
auto qtTranslator = new QTranslator(this);
|
||||
auto qtTranslator = new QTranslator(qApp);
|
||||
if (qtTranslator->load(_defaultLocale, QStringLiteral("qtbase"),
|
||||
QStringLiteral("_"), qtPath)) {
|
||||
|
||||
qApp->installTranslator(qtTranslator);
|
||||
}
|
||||
|
||||
qtTranslator = new QTranslator(this);
|
||||
qtTranslator = new QTranslator(qApp);
|
||||
if (qtTranslator->load(_defaultLocale, QStringLiteral("qt"),
|
||||
QStringLiteral("_"), qtPath)) {
|
||||
|
||||
|
@ -122,7 +122,7 @@ LanguageManager::LanguageManager() {
|
|||
if (unpackTr(langPath + QStringLiteral("/") + _defaultLocale.name() +
|
||||
QStringLiteral("/") + QStringLiteral(LANG_PAK_NAME),
|
||||
_defaultLocale)) {
|
||||
auto translator = new QTranslator(this);
|
||||
auto translator = new QTranslator(qApp);
|
||||
if (translator->load(
|
||||
reinterpret_cast<const uchar *>(_data.trFiles.data()),
|
||||
_data.trFiles.size())) {
|
||||
|
@ -193,7 +193,7 @@ QTranslator *LanguageManager::try2LoadPluginLang(const QString &plgID) {
|
|||
if (!langDir.cd(plgID)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto translator = new QTranslator(this);
|
||||
auto translator = new QTranslator(qApp);
|
||||
if (translator->load(_defaultLocale, plgID, QStringLiteral("_"),
|
||||
langDir.absolutePath())) {
|
||||
if (qApp->installTranslator(translator)) {
|
||||
|
|
|
@ -24,9 +24,7 @@
|
|||
#include <QStringList>
|
||||
#include <QTranslator>
|
||||
|
||||
class LanguageManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
class LanguageManager {
|
||||
public:
|
||||
struct LanguageData {
|
||||
QByteArray trFiles;
|
||||
|
|
|
@ -86,42 +86,44 @@ Logger &Logger::instance() {
|
|||
|
||||
Logger::Level Logger::logLevel() const { return _level; }
|
||||
|
||||
void Logger::logPrint(const QString &message) { emit instance().log(message); }
|
||||
void Logger::logPrint(const QString &message) {
|
||||
Q_EMIT instance().log(message);
|
||||
}
|
||||
|
||||
void Logger::newLine() { logPrint({}); }
|
||||
|
||||
void Logger::trace(const QString &message) {
|
||||
if (instance()._level >= q5TRACE) {
|
||||
QString str = message;
|
||||
emit instance().log(packDebugStr(tr("[Trace]") + str));
|
||||
Q_EMIT instance().log(packDebugStr(tr("[Trace]") + str));
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::warning(const QString &message) {
|
||||
if (instance()._level >= q2WARN) {
|
||||
QString str = message;
|
||||
emit instance().log(packWarnStr(tr("[Warn]") + str));
|
||||
Q_EMIT instance().log(packWarnStr(tr("[Warn]") + str));
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::info(const QString &message) {
|
||||
if (instance()._level >= q3INFO) {
|
||||
QString str = message;
|
||||
emit instance().log(packInfoStr(tr("[Info]") + str));
|
||||
Q_EMIT instance().log(packInfoStr(tr("[Info]") + str));
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::debug(const QString &message) {
|
||||
if (instance()._level >= q4DEBUG) {
|
||||
QString str = message;
|
||||
emit instance().log(packDebugStr(tr("[Debug]") + str));
|
||||
Q_EMIT instance().log(packDebugStr(tr("[Debug]") + str));
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::critical(const QString &message) {
|
||||
if (instance()._level >= q0FATAL) {
|
||||
QString str = message;
|
||||
emit instance().log(packErrorStr(tr("[Error]") + str));
|
||||
Q_EMIT instance().log(packErrorStr(tr("[Error]") + str));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3308,7 +3308,7 @@ void PluginSystem::loadPlugin(IWingPlugin *p, PluginInfo &meta,
|
|||
|
||||
// dependencies had been checked
|
||||
|
||||
emit pluginLoading(p->pluginName());
|
||||
Q_EMIT pluginLoading(p->pluginName());
|
||||
|
||||
p_tr = LanguageManager::instance().try2LoadPluginLang(meta.id);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ void RecentFileManager::addRecentFile(const RecentInfo &info) {
|
|||
|
||||
hitems.move(idx, 0);
|
||||
}
|
||||
emit triggered(f);
|
||||
Q_EMIT triggered(f);
|
||||
} else {
|
||||
auto index = hitems.indexOf(send);
|
||||
if (index < 0) {
|
||||
|
|
|
@ -1,233 +0,0 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify it under
|
||||
** the terms of the GNU Affero General Public License as published by the Free
|
||||
** Software Foundation, version 3.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
** details.
|
||||
**
|
||||
** You should have received a copy of the GNU Affero General Public License
|
||||
** along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#include "scripteditortheme.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QMetaEnum>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
ScriptEditorTheme::ScriptEditorTheme(QObject *parent) : QObject(parent) {}
|
||||
|
||||
ScriptEditorTheme::ScriptEditorTheme(const QString &filename, QObject *parent)
|
||||
: QObject(parent) {
|
||||
if (!filename.isEmpty() && QFile::exists(filename)) {
|
||||
loadTheme(filename);
|
||||
}
|
||||
}
|
||||
|
||||
ScriptEditorTheme::ColorScheme
|
||||
ScriptEditorTheme::colorScheme(Styles style) const {
|
||||
return m_colors.value(style);
|
||||
}
|
||||
|
||||
void ScriptEditorTheme::setColorScheme(Styles style,
|
||||
const ColorScheme &scheme) {
|
||||
m_colors[style] = scheme;
|
||||
}
|
||||
|
||||
bool ScriptEditorTheme::loadTheme(const QString &filename) {
|
||||
QFile xmlFile(filename);
|
||||
if (!xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return false;
|
||||
}
|
||||
QXmlStreamReader xmlReader(&xmlFile);
|
||||
|
||||
QString name;
|
||||
QString version;
|
||||
QString author;
|
||||
QString comment;
|
||||
|
||||
auto e = QMetaEnum::fromType<Styles>();
|
||||
|
||||
while (!xmlReader.atEnd() && !xmlReader.hasError()) {
|
||||
QXmlStreamReader::TokenType token = xmlReader.readNext();
|
||||
|
||||
if (token == QXmlStreamReader::StartDocument) {
|
||||
if (xmlReader.name() != QStringLiteral("style-scheme")) {
|
||||
return false;
|
||||
}
|
||||
auto attr = xmlReader.attributes();
|
||||
if (readAttr(attr, QStringLiteral("name"), name)) {
|
||||
readAttr(attr, QStringLiteral("version"), version);
|
||||
readAttr(attr, QStringLiteral("author"), author);
|
||||
readAttr(attr, QStringLiteral("comment"), comment);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
ColorScheme scheme;
|
||||
QString styleAttr;
|
||||
if (token == QXmlStreamReader::StartElement) {
|
||||
if (xmlReader.name() == QStringLiteral("style")) {
|
||||
auto attr = xmlReader.attributes();
|
||||
if (readAttr(attr, QStringLiteral("name"), styleAttr)) {
|
||||
auto v = e.keyToValue(styleAttr.toUtf8());
|
||||
if (v < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("foreground"),
|
||||
styleAttr)) {
|
||||
QColor color(styleAttr);
|
||||
if (color.isValid()) {
|
||||
scheme.foreground = color;
|
||||
}
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("background"),
|
||||
styleAttr)) {
|
||||
QColor color(styleAttr);
|
||||
if (color.isValid()) {
|
||||
scheme.background = color;
|
||||
}
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("fontfamily"),
|
||||
styleAttr)) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
if (QFontDatabase::hasFamily(styleAttr)) {
|
||||
#else
|
||||
if (QFontDatabase().hasFamily(styleAttr)) {
|
||||
#endif
|
||||
scheme.fontFamily = styleAttr;
|
||||
}
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("underLine"),
|
||||
styleAttr)) {
|
||||
scheme.underLine =
|
||||
QTextCharFormat::UnderlineStyle(styleAttr.toInt());
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("bold"), styleAttr)) {
|
||||
bool ok;
|
||||
scheme.isBold = string2Bool(styleAttr, ok);
|
||||
if (!ok) {
|
||||
scheme.isBold = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (readAttr(attr, QStringLiteral("italic"), styleAttr)) {
|
||||
bool ok;
|
||||
scheme.isItalic = string2Bool(styleAttr, ok);
|
||||
if (!ok) {
|
||||
scheme.isItalic = false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_name = name;
|
||||
m_version = version;
|
||||
m_author = author;
|
||||
m_comment = comment;
|
||||
m_isValid = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptEditorTheme::saveTheme(const QString &filename) {
|
||||
QFile xmlFile(filename);
|
||||
if (!xmlFile.open(QFile::WriteOnly | QFile::Text)) {
|
||||
return false;
|
||||
}
|
||||
QXmlStreamWriter stream(&xmlFile);
|
||||
stream.setAutoFormatting(true);
|
||||
stream.writeStartDocument();
|
||||
|
||||
auto e = QMetaEnum::fromType<Styles>();
|
||||
for (auto p = m_colors.begin(); p != m_colors.end(); p++) {
|
||||
stream.writeStartElement("style");
|
||||
stream.writeAttribute(QStringLiteral("name"),
|
||||
e.valueToKey(int(p.key())));
|
||||
auto v = p.value();
|
||||
if (v.foreground.isValid()) {
|
||||
stream.writeAttribute(QStringLiteral("foreground"),
|
||||
v.foreground.name());
|
||||
}
|
||||
if (v.background.isValid()) {
|
||||
stream.writeAttribute(QStringLiteral("background"),
|
||||
v.background.name());
|
||||
}
|
||||
if (!v.fontFamily.isEmpty()) {
|
||||
stream.writeAttribute(QStringLiteral("fontfamily"), v.fontFamily);
|
||||
}
|
||||
if (v.underLine != QTextCharFormat::NoUnderline) {
|
||||
stream.writeAttribute(QStringLiteral("underLine"),
|
||||
QString::number(v.underLine));
|
||||
}
|
||||
if (v.isBold) {
|
||||
stream.writeAttribute(QStringLiteral("bold"),
|
||||
bool2String(v.isBold));
|
||||
}
|
||||
if (v.isItalic) {
|
||||
stream.writeAttribute(QStringLiteral("italic"),
|
||||
bool2String(v.isBold));
|
||||
}
|
||||
stream.writeEndElement();
|
||||
}
|
||||
|
||||
stream.writeEndDocument();
|
||||
|
||||
xmlFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ScriptEditorTheme::isValid() const { return m_isValid; }
|
||||
|
||||
bool ScriptEditorTheme::readAttr(const QXmlStreamAttributes &attrs,
|
||||
const QString &name, QString &output) {
|
||||
if (attrs.hasAttribute(name)) {
|
||||
output = attrs.value(name).toString();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ScriptEditorTheme::string2Bool(const QString &str, bool &ok) {
|
||||
if (str.compare(QStringLiteral("true"), Qt::CaseInsensitive) == 0) {
|
||||
ok = true;
|
||||
return true;
|
||||
} else if (str.compare(QStringLiteral("false"), Qt::CaseInsensitive) == 0) {
|
||||
ok = true;
|
||||
return false;
|
||||
} else {
|
||||
ok = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString ScriptEditorTheme::bool2String(bool b) {
|
||||
return b ? QStringLiteral("true") : QStringLiteral("false");
|
||||
}
|
||||
|
||||
QString ScriptEditorTheme::comment() const { return m_comment; }
|
||||
|
||||
QString ScriptEditorTheme::author() const { return m_author; }
|
||||
|
||||
QString ScriptEditorTheme::version() const { return m_version; }
|
||||
|
||||
QString ScriptEditorTheme::name() const { return m_name; }
|
|
@ -1,84 +0,0 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2024-2027 WingSummer
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify it under
|
||||
** the terms of the GNU Affero General Public License as published by the Free
|
||||
** Software Foundation, version 3.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
** details.
|
||||
**
|
||||
** You should have received a copy of the GNU Affero General Public License
|
||||
** along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
#ifndef SCRIPTEDITORTHEME_H
|
||||
#define SCRIPTEDITORTHEME_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QTextCharFormat>
|
||||
#include <QXmlStreamAttributes>
|
||||
|
||||
class ScriptEditorTheme : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum class Styles {
|
||||
|
||||
};
|
||||
Q_ENUM(Styles)
|
||||
|
||||
struct ColorScheme {
|
||||
QColor foreground;
|
||||
QColor background;
|
||||
QString fontFamily;
|
||||
QTextCharFormat::UnderlineStyle underLine =
|
||||
QTextCharFormat::NoUnderline;
|
||||
bool isBold = false;
|
||||
bool isItalic = false;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit ScriptEditorTheme(QObject *parent = nullptr);
|
||||
explicit ScriptEditorTheme(const QString &filename = QString(),
|
||||
QObject *parent = nullptr);
|
||||
|
||||
ColorScheme colorScheme(Styles style) const;
|
||||
|
||||
void setColorScheme(Styles style, const ColorScheme &scheme);
|
||||
|
||||
bool loadTheme(const QString &filename);
|
||||
|
||||
bool saveTheme(const QString &filename);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString name() const;
|
||||
|
||||
QString version() const;
|
||||
|
||||
QString author() const;
|
||||
|
||||
QString comment() const;
|
||||
|
||||
private:
|
||||
bool readAttr(const QXmlStreamAttributes &attr, const QString &name,
|
||||
QString &output);
|
||||
|
||||
bool string2Bool(const QString &str, bool &ok);
|
||||
|
||||
QString bool2String(bool b);
|
||||
|
||||
private:
|
||||
bool m_isValid = false;
|
||||
QString m_name;
|
||||
QString m_version;
|
||||
QString m_author;
|
||||
QString m_comment;
|
||||
QMap<Styles, ColorScheme> m_colors;
|
||||
};
|
||||
|
||||
#endif // SCRIPTEDITORTHEME_H
|
|
@ -670,7 +670,7 @@ bool ScriptMachine::executeScript(ConsoleMode mode, const QString &script,
|
|||
|
||||
if (isDbg) {
|
||||
_debugger->clearBreakPoint();
|
||||
emit onDebugFinished();
|
||||
Q_EMIT onDebugFinished();
|
||||
}
|
||||
|
||||
if (retCode) {
|
||||
|
|
|
@ -39,7 +39,7 @@ QString ScriptManager::userScriptPath() const { return m_usrScriptsPath; }
|
|||
|
||||
QString ScriptManager::systemScriptPath() const { return m_sysScriptsPath; }
|
||||
|
||||
ScriptManager::ScriptManager() : QObject() {
|
||||
ScriptManager::ScriptManager() {
|
||||
ASSERT_SINGLETON;
|
||||
|
||||
// init script directory
|
||||
|
|
|
@ -21,13 +21,12 @@
|
|||
#include <QDir>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
|
||||
#include "QWingRibbon/ribbonbuttongroup.h"
|
||||
#include "utilities.h"
|
||||
|
||||
class ScriptManager : public QObject {
|
||||
Q_OBJECT
|
||||
class ScriptManager {
|
||||
Q_DECLARE_TR_FUNCTIONS(ScriptManager)
|
||||
|
||||
public:
|
||||
struct ScriptDirMeta {
|
||||
|
@ -100,7 +99,7 @@ private:
|
|||
return a;
|
||||
}
|
||||
|
||||
public slots:
|
||||
public:
|
||||
void runScript(const QString &filename);
|
||||
|
||||
private:
|
||||
|
|
|
@ -184,7 +184,7 @@ void ScriptSettings::save(SETTINGS cat) {
|
|||
m_editorAutoCloseChar);
|
||||
WRITE_CONFIG_EDITOR_SET(CODEEDIT_AUTO_IDEN, SETTING_ITEM::AUTO_IDEN,
|
||||
m_editorAutoIden);
|
||||
emit editorSettingsUpdate();
|
||||
Q_EMIT editorSettingsUpdate();
|
||||
}
|
||||
|
||||
if (cat.testFlag(SETTING::CONSOLE)) {
|
||||
|
@ -207,7 +207,7 @@ void ScriptSettings::save(SETTINGS cat) {
|
|||
WRITE_CONFIG_CONSOLE_SET(CONSOLE_AUTO_CLOSE_CHAR,
|
||||
SETTING_ITEM::AUTO_CLOSE_CHAR,
|
||||
m_consoleAutoCloseChar);
|
||||
emit consoleSettingUpdate();
|
||||
Q_EMIT consoleSettingUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,9 +170,9 @@ void SettingManager::load() {
|
|||
}
|
||||
}
|
||||
|
||||
emit sigEditorfontSizeChanged(m_editorfontSize);
|
||||
emit sigCopylimitChanged(m_copylimit);
|
||||
emit sigDecodeStrlimitChanged(m_decodeStrlimit);
|
||||
Q_EMIT sigEditorfontSizeChanged(m_editorfontSize);
|
||||
Q_EMIT sigCopylimitChanged(m_copylimit);
|
||||
Q_EMIT sigDecodeStrlimitChanged(m_decodeStrlimit);
|
||||
}
|
||||
|
||||
QList<RecentFileManager::RecentInfo>
|
||||
|
@ -483,7 +483,7 @@ void SettingManager::setDecodeStrlimit(qsizetype newDecodeStrlimit) {
|
|||
if (m_decodeStrlimit != newDecodeStrlimit) {
|
||||
m_decodeStrlimit = newDecodeStrlimit;
|
||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_DECSTRLIMIT);
|
||||
emit sigDecodeStrlimitChanged(m_decodeStrlimit);
|
||||
Q_EMIT sigDecodeStrlimitChanged(m_decodeStrlimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ void SettingManager::setCopylimit(qsizetype newCopylimit) {
|
|||
if (m_copylimit != newCopylimit) {
|
||||
m_copylimit = newCopylimit;
|
||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_COPY_LIMIT);
|
||||
emit sigDecodeStrlimitChanged(m_copylimit);
|
||||
Q_EMIT sigDecodeStrlimitChanged(m_copylimit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ void SettingManager::setEditorfontSize(int newEditorfontSize) {
|
|||
if (m_editorfontSize != newEditorfontSize) {
|
||||
m_editorfontSize = newEditorfontSize;
|
||||
_setUnsaved.setFlag(SETTING_ITEM::EDITOR_FONTSIZE);
|
||||
emit sigEditorfontSizeChanged(newEditorfontSize);
|
||||
Q_EMIT sigEditorfontSizeChanged(newEditorfontSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <QScreen>
|
||||
#include <QStyleFactory>
|
||||
|
||||
SkinManager::SkinManager(QObject *parent) : QObject(parent) {
|
||||
SkinManager::SkinManager() {
|
||||
ASSERT_SINGLETON;
|
||||
|
||||
int theme = SettingManager::instance().themeID();
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
#ifndef SKINMANAGER_H
|
||||
#define SKINMANAGER_H
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QObject>
|
||||
|
||||
class SkinManager : public QObject {
|
||||
Q_OBJECT
|
||||
class SkinManager {
|
||||
Q_GADGET
|
||||
Q_DECLARE_TR_FUNCTIONS(SkinManager)
|
||||
|
||||
public:
|
||||
enum class Theme {
|
||||
Dark,
|
||||
|
@ -30,7 +33,7 @@ public:
|
|||
Q_ENUM(Theme)
|
||||
|
||||
public:
|
||||
virtual ~SkinManager() override;
|
||||
virtual ~SkinManager();
|
||||
|
||||
static SkinManager &instance();
|
||||
|
||||
|
@ -45,7 +48,7 @@ private:
|
|||
private:
|
||||
Theme m_theme;
|
||||
|
||||
explicit SkinManager(QObject *parent = nullptr);
|
||||
explicit SkinManager();
|
||||
|
||||
Q_DISABLE_COPY_MOVE(SkinManager)
|
||||
};
|
||||
|
|
|
@ -189,7 +189,7 @@ void CodeEdit::applyEditorSetStyle() {
|
|||
|
||||
SearchReplaceWidget *CodeEdit::searchWidget() const { return m_searchWidget; }
|
||||
|
||||
void CodeEdit::setContentModified(bool b) { emit contentModified(b); }
|
||||
void CodeEdit::setContentModified(bool b) { Q_EMIT contentModified(b); }
|
||||
|
||||
void CodeEdit::resizeEvent(QResizeEvent *event) {
|
||||
if (event)
|
||||
|
|
|
@ -45,7 +45,7 @@ GotoLineWidget::GotoLineWidget(QWidget *parent)
|
|||
tbGoto->setAutoRaise(true);
|
||||
tbGoto->setIcon(skin.themeIcon(QStringLiteral("right_arrow")));
|
||||
connect(tbGoto, &QToolButton::clicked, this, [this]() {
|
||||
emit onGotoLine(m_sbline->value());
|
||||
Q_EMIT onGotoLine(m_sbline->value());
|
||||
close();
|
||||
});
|
||||
|
||||
|
@ -70,6 +70,6 @@ void GotoLineWidget::setOriginLine(int line) {
|
|||
}
|
||||
|
||||
void GotoLineWidget::cancel() {
|
||||
emit onGotoLine(m_line);
|
||||
Q_EMIT onGotoLine(m_line);
|
||||
CodeEditControlWidget::cancel();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,433 @@
|
|||
#include "gotowidget.h"
|
||||
#include "ui_gotowidget.h"
|
||||
|
||||
#include "grammar/NumCal/NumCalBaseVisitor.h"
|
||||
#include "grammar/NumCal/NumCalLexer.h"
|
||||
#include "grammar/NumCal/NumCalParser.h"
|
||||
|
||||
#include <QShortcut>
|
||||
|
||||
class Calculator : public NumCalBaseVisitor {
|
||||
public:
|
||||
void eval(const QString &exp) {
|
||||
if (exp.isEmpty()) {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
antlr4::ANTLRInputStream input(exp.toStdString());
|
||||
|
||||
NumCalLexer lexer(&input);
|
||||
antlr4::CommonTokenStream tokens(&lexer);
|
||||
|
||||
NumCalParser parser(&tokens);
|
||||
parser.removeErrorListeners();
|
||||
parser.setErrorHandler(std::make_shared<antlr4::BailErrorStrategy>());
|
||||
|
||||
try {
|
||||
visit(parser.entryExpression());
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
virtual std::any
|
||||
visitEntryExpression(NumCalParser::EntryExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
if (ctx->prefixGoto() == nullptr) {
|
||||
lastPos = GotoWidget::SEEKPOS::Start;
|
||||
} else {
|
||||
auto prefix = ctx->prefixGoto();
|
||||
if (prefix->Plus()) {
|
||||
lastPos = GotoWidget::SEEKPOS::RelativeAdd;
|
||||
} else if (prefix->Minus()) {
|
||||
lastPos = GotoWidget::SEEKPOS::RelativeMin;
|
||||
} else if (prefix->LessThan()) {
|
||||
lastPos = GotoWidget::SEEKPOS::End;
|
||||
} else {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->IntegerConstant()) {
|
||||
auto r = parseIntegerConstant(ctx->IntegerConstant()->getText());
|
||||
if (std::holds_alternative<qint64>(r)) {
|
||||
lastAddr = std::get<qint64>(r);
|
||||
} else if (std::holds_alternative<quint64>(r)) {
|
||||
lastAddr = std::get<quint64>(r);
|
||||
} else {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
}
|
||||
} else {
|
||||
auto r = visitAssignmentExpression(ctx->assignmentExpression());
|
||||
if (r.type() == typeid(quint64)) {
|
||||
lastAddr = std::any_cast<quint64>(r);
|
||||
} else if (r.type() == typeid(qint64)) {
|
||||
auto addr = std::any_cast<qint64>(r);
|
||||
if (addr < 0) {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
}
|
||||
lastAddr = quint64(addr);
|
||||
} else {
|
||||
lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
lastAddr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
public:
|
||||
quint64 lastAddr = 0;
|
||||
GotoWidget::SEEKPOS lastPos = GotoWidget::SEEKPOS::Invaild;
|
||||
|
||||
public:
|
||||
std::any
|
||||
visitCastExpression(NumCalParser::CastExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
if (ctx->IntegerConstant()) {
|
||||
auto r = parseIntegerConstant(ctx->IntegerConstant()->getText());
|
||||
if (std::holds_alternative<qint64>(r)) {
|
||||
return std::get<qint64>(r);
|
||||
} else if (std::holds_alternative<quint64>(r)) {
|
||||
return std::get<quint64>(r);
|
||||
}
|
||||
} else if (ctx->unaryExpression()) {
|
||||
return visitUnaryExpression(ctx->unaryExpression());
|
||||
}
|
||||
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
std::any
|
||||
visitUnaryExpression(NumCalParser::UnaryExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
auto op = ctx->unaryOperator();
|
||||
auto r = visitCastExpression(ctx->castExpression());
|
||||
if (r.type() == typeid(quint64)) {
|
||||
auto v = std::any_cast<quint64>(r);
|
||||
if (op->Minus()) {
|
||||
return -v;
|
||||
} else if (op->Plus()) {
|
||||
return +v;
|
||||
} else if (op->Tilde()) {
|
||||
return ~v;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else if (r.type() == typeid(qint64)) {
|
||||
auto v = std::any_cast<qint64>(r);
|
||||
if (op->Minus()) {
|
||||
return -v;
|
||||
} else if (op->Plus()) {
|
||||
return +v;
|
||||
} else if (op->Tilde()) {
|
||||
return ~v;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
std::any visitInclusiveOrExpression(
|
||||
NumCalParser::InclusiveOrExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
qulonglong ret = 0;
|
||||
for (auto &v : ctx->exclusiveOrExpression()) {
|
||||
auto r = visitExclusiveOrExpression(v);
|
||||
if (r.type() == typeid(quint64)) {
|
||||
auto rr = std::any_cast<quint64>(r);
|
||||
ret |= rr;
|
||||
} else if (r.type() == typeid(qint64)) {
|
||||
auto rr = std::any_cast<qint64>(r);
|
||||
ret |= rr;
|
||||
} else {
|
||||
// error
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::any visitAssignmentExpression(
|
||||
NumCalParser::AssignmentExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
if (ctx->IntegerConstant()) {
|
||||
auto r = parseIntegerConstant(ctx->IntegerConstant()->getText());
|
||||
if (std::holds_alternative<qint64>(r)) {
|
||||
return std::get<qint64>(r);
|
||||
} else if (std::holds_alternative<quint64>(r)) {
|
||||
return std::get<quint64>(r);
|
||||
}
|
||||
} else if (ctx->inclusiveOrExpression()) {
|
||||
return visitInclusiveOrExpression(ctx->inclusiveOrExpression());
|
||||
}
|
||||
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
std::any visitExclusiveOrExpression(
|
||||
NumCalParser::ExclusiveOrExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
quint64 v = 0;
|
||||
for (auto &ex : ctx->andExpression()) {
|
||||
auto r = visitAndExpression(ex);
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
v ^= rv;
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
v ^= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
std::any
|
||||
visitAndExpression(NumCalParser::AndExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
quint64 v = std::numeric_limits<quint64>::max();
|
||||
for (auto &ex : ctx->shiftExpression()) {
|
||||
auto r = visitShiftExpression(ex);
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
v &= rv;
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
v &= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
std::any
|
||||
visitShiftExpression(NumCalParser::ShiftExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
auto data = ctx->additiveExpression();
|
||||
auto total = data.size();
|
||||
|
||||
quint64 ret = 0;
|
||||
auto retv = visitAdditiveExpression(data.front());
|
||||
if (retv.type() == typeid(qint64)) {
|
||||
ret = std::any_cast<qint64>(retv);
|
||||
} else if (retv.type() == typeid(quint64)) {
|
||||
ret = std::any_cast<quint64>(retv);
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < total; ++i) {
|
||||
auto op = ctx->children[2 * i - 1]->getText();
|
||||
auto r = visitAdditiveExpression(data.at(i));
|
||||
if (op == "<<") {
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
ret <<= rv;
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
ret <<= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else if (op == ">>") {
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
ret >>= rv;
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
ret >>= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::any visitAdditiveExpression(
|
||||
NumCalParser::AdditiveExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
auto data = ctx->multiplicativeExpression();
|
||||
auto total = data.size();
|
||||
|
||||
quint64 ret = 0;
|
||||
auto retv = visitMultiplicativeExpression(data.front());
|
||||
if (retv.type() == typeid(qint64)) {
|
||||
ret = std::any_cast<qint64>(retv);
|
||||
} else if (retv.type() == typeid(quint64)) {
|
||||
ret = std::any_cast<quint64>(retv);
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < total; i++) {
|
||||
auto r = visitMultiplicativeExpression(data.at(i));
|
||||
auto op = ctx->children[2 * i - 1]->getText();
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
if (op == "+") {
|
||||
ret += rv;
|
||||
} else if (op == "-") {
|
||||
ret -= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
if (op == "+") {
|
||||
ret += rv;
|
||||
} else if (op == "-") {
|
||||
ret -= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::any visitMultiplicativeExpression(
|
||||
NumCalParser::MultiplicativeExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
auto data = ctx->castExpression();
|
||||
auto total = data.size();
|
||||
|
||||
quint64 ret = 0;
|
||||
auto retv = visitCastExpression(data.front());
|
||||
if (retv.type() == typeid(qint64)) {
|
||||
ret = std::any_cast<qint64>(retv);
|
||||
} else if (retv.type() == typeid(quint64)) {
|
||||
ret = std::any_cast<quint64>(retv);
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < total; i++) {
|
||||
auto r = visitCastExpression(data.at(i));
|
||||
auto op = ctx->children[2 * i - 1]->getText();
|
||||
if (r.type() == typeid(qint64)) {
|
||||
auto rv = std::any_cast<qint64>(r);
|
||||
if (op == "*") {
|
||||
ret *= rv;
|
||||
} else if (op == "/") {
|
||||
ret /= rv;
|
||||
} else if (op == "%") {
|
||||
ret %= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else if (r.type() == typeid(quint64)) {
|
||||
auto rv = std::any_cast<quint64>(r);
|
||||
if (op == "*") {
|
||||
ret *= rv;
|
||||
} else if (op == "/") {
|
||||
ret /= rv;
|
||||
} else if (op == "%") {
|
||||
ret %= rv;
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
} else {
|
||||
return defaultResult();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::any visitPrimaryExpression(
|
||||
NumCalParser::PrimaryExpressionContext *ctx) override {
|
||||
if (ctx == nullptr) {
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
if (ctx->IntegerConstant()) {
|
||||
auto r = parseIntegerConstant(ctx->IntegerConstant()->getText());
|
||||
if (std::holds_alternative<qint64>(r)) {
|
||||
return std::get<qint64>(r);
|
||||
} else if (std::holds_alternative<quint64>(r)) {
|
||||
return std::get<quint64>(r);
|
||||
}
|
||||
} else if (ctx->assignmentExpression()) {
|
||||
return visitAssignmentExpression(ctx->assignmentExpression());
|
||||
}
|
||||
|
||||
return defaultResult();
|
||||
}
|
||||
|
||||
private:
|
||||
std::variant<std::monostate, qint64, quint64>
|
||||
parseIntegerConstant(const std::string &text) {
|
||||
Q_STATIC_ASSERT_X(
|
||||
QT_VERSION >= QT_VERSION_CHECK(6, 4, 0),
|
||||
"If you want to support Qt version lower than 6.4.0, You should "
|
||||
"implement '0b' prefix integer converstion on your own!");
|
||||
|
||||
bool b;
|
||||
auto ct = QString::fromStdString(text);
|
||||
auto num = ct.toLongLong(&b, 0);
|
||||
if (b) {
|
||||
return num;
|
||||
} else {
|
||||
auto num = ct.toULongLong(&b, 0);
|
||||
if (b) {
|
||||
return num;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GotoWidget::GotoWidget(QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::GotoWidget) {
|
||||
ui->setupUi(this);
|
||||
|
@ -54,15 +479,15 @@ void GotoWidget::handleLineChanged() {
|
|||
auto isline = ui->rbLine->isChecked();
|
||||
auto p = convert2Pos(content, ps, isline);
|
||||
if (ps != SEEKPOS::Invaild) {
|
||||
ui->lineEdit->setStyleSheet(QString());
|
||||
emit jumpToLine(p, isline);
|
||||
ui->lineEdit->setStyleSheet({});
|
||||
} else {
|
||||
ui->lineEdit->setStyleSheet(QStringLiteral("QLineEdit{color: red}"));
|
||||
}
|
||||
Q_EMIT jumpToLine(p, isline);
|
||||
}
|
||||
|
||||
void GotoWidget::jumpCancel() {
|
||||
emit jumpToLine(m_oldFileOffsetBeforeJump, false);
|
||||
Q_EMIT jumpToLine(m_oldFileOffsetBeforeJump, false);
|
||||
hide();
|
||||
}
|
||||
|
||||
|
@ -73,114 +498,86 @@ void GotoWidget::jumpConfirm() {
|
|||
|
||||
void GotoWidget::on_btnClose_clicked() { this->hide(); }
|
||||
|
||||
void GotoWidget::on_btnGoto_clicked() { /*emit onGoto(ui->spinBox->value()); */
|
||||
}
|
||||
qsizetype GotoWidget::convert2Pos(const QString &value, SEEKPOS &ps,
|
||||
bool isline) {
|
||||
Calculator cal;
|
||||
cal.eval(value);
|
||||
|
||||
qsizetype GotoWidget::convert2Pos(QString value, SEEKPOS &ps, bool isline) {
|
||||
qsizetype res = 0;
|
||||
if (value.length() > 0) {
|
||||
auto ch = value.at(0);
|
||||
if (ch == '+') {
|
||||
ps = SEEKPOS::Relative;
|
||||
value = value.remove(0, 1);
|
||||
// you should ensure return value is origin position if invalid
|
||||
|
||||
bool ok = false;
|
||||
res = value.toLongLong(&ok, 0);
|
||||
|
||||
if (!ok) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
} else {
|
||||
if (isline) {
|
||||
if (res + m_rowBeforeJump > m_maxFilelines) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res += m_rowBeforeJump;
|
||||
}
|
||||
} else {
|
||||
if (res + m_oldFileOffsetBeforeJump > m_maxFileBytes) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res += m_oldFileOffsetBeforeJump;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ch == '-') {
|
||||
ps = SEEKPOS::Relative;
|
||||
|
||||
value = value.remove(0, 1);
|
||||
|
||||
bool ok = false;
|
||||
res = value.toLongLong(&ok, 0);
|
||||
|
||||
if (!ok) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
} else {
|
||||
if (isline) {
|
||||
if (res - m_rowBeforeJump < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res -= m_rowBeforeJump;
|
||||
}
|
||||
} else {
|
||||
if (qlonglong(m_oldFileOffsetBeforeJump) - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res = qlonglong(m_oldFileOffsetBeforeJump) - res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ch == '<') {
|
||||
ps = SEEKPOS::End;
|
||||
value = value.remove(0, 1);
|
||||
|
||||
bool ok = false;
|
||||
res = value.toLongLong(&ok, 0);
|
||||
|
||||
if (!ok || res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
} else {
|
||||
if (isline) {
|
||||
if (m_maxFilelines - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res = m_maxFilelines - res;
|
||||
}
|
||||
} else {
|
||||
if (qlonglong(m_maxFileBytes) - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
} else {
|
||||
res = qlonglong(m_maxFileBytes) - res;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ps = SEEKPOS::Start;
|
||||
|
||||
bool ok = false;
|
||||
res = value.toInt(&ok, 0);
|
||||
|
||||
if (!ok) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
} else {
|
||||
if (res < 0 || quint64(res) > (isline ? quint64(m_maxFilelines)
|
||||
: m_maxFileBytes)) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ps = SEEKPOS::Relative;
|
||||
qsizetype res = cal.lastAddr;
|
||||
ps = cal.lastPos;
|
||||
switch (cal.lastPos) {
|
||||
case SEEKPOS::Invaild:
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
break;
|
||||
case SEEKPOS::Start:
|
||||
if (res < 0 || quint64(res) > (isline ? quint64(m_maxFilelines)
|
||||
: m_maxFileBytes)) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
}
|
||||
break;
|
||||
case SEEKPOS::End:
|
||||
if (isline) {
|
||||
if (m_maxFilelines - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res = m_maxFilelines - res;
|
||||
}
|
||||
} else {
|
||||
if (qlonglong(m_maxFileBytes) - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res = qlonglong(m_maxFileBytes) - res;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SEEKPOS::RelativeAdd:
|
||||
if (isline) {
|
||||
if (res + m_rowBeforeJump > m_maxFilelines) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res += m_rowBeforeJump;
|
||||
}
|
||||
} else {
|
||||
if (res + m_oldFileOffsetBeforeJump > m_maxFileBytes) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res += m_oldFileOffsetBeforeJump;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SEEKPOS::RelativeMin:
|
||||
if (isline) {
|
||||
if (res - m_rowBeforeJump < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res -= m_rowBeforeJump;
|
||||
}
|
||||
} else {
|
||||
if (qlonglong(m_oldFileOffsetBeforeJump) - res < 0) {
|
||||
ps = SEEKPOS::Invaild;
|
||||
res = isline ? qsizetype(m_rowBeforeJump)
|
||||
: qsizetype(m_oldFileOffsetBeforeJump);
|
||||
} else {
|
||||
res = qlonglong(m_oldFileOffsetBeforeJump) - res;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ class GotoWidget;
|
|||
class GotoWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
enum SEEKPOS { Invaild, Start, End, Relative };
|
||||
public:
|
||||
enum class SEEKPOS { Invaild, Start, End, RelativeAdd, RelativeMin };
|
||||
|
||||
public:
|
||||
explicit GotoWidget(QWidget *parent = nullptr);
|
||||
|
@ -50,10 +51,8 @@ signals:
|
|||
private slots:
|
||||
void on_btnClose_clicked();
|
||||
|
||||
void on_btnGoto_clicked();
|
||||
|
||||
private:
|
||||
qsizetype convert2Pos(QString value, SEEKPOS &ps, bool isline);
|
||||
qsizetype convert2Pos(const QString &value, SEEKPOS &ps, bool isline);
|
||||
|
||||
private:
|
||||
Ui::GotoWidget *ui;
|
||||
|
|
|
@ -38,7 +38,7 @@ HueColorPickerSlider::HueColorPickerSlider(Qt::Orientation orientation,
|
|||
connect(this, &HueColorPickerSlider::valueChanged, this, [this](int v) {
|
||||
_color.setHsv(v, _color.hsvSaturation(), _color.value());
|
||||
this->setToolTip(_color.name());
|
||||
emit colorChanged(_color);
|
||||
Q_EMIT colorChanged(_color);
|
||||
});
|
||||
|
||||
this->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
@ -72,7 +72,7 @@ void HueColorPickerSlider::setColor(const QColor &newColor) {
|
|||
{359.0 / 360.0, redColor(colorS, colorV)}});
|
||||
|
||||
this->setValue(_color.hsvHue());
|
||||
emit colorChanged(newColor);
|
||||
Q_EMIT colorChanged(newColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,5 +50,5 @@ void QListViewExt::setModel(QAbstractItemModel *model) {
|
|||
|
||||
QListView::setModel(model);
|
||||
|
||||
emit modelChanged();
|
||||
Q_EMIT modelChanged();
|
||||
}
|
||||
|
|
|
@ -50,5 +50,5 @@ void QTableViewExt::setModel(QAbstractItemModel *model) {
|
|||
|
||||
QTableView::setModel(model);
|
||||
|
||||
emit modelChanged();
|
||||
Q_EMIT modelChanged();
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ void ScriptingConsole::handleReturnKey() {
|
|||
iodevice_->consoleWidgetInput(code);
|
||||
|
||||
if (!_isWaitingRead) {
|
||||
emit consoleCommand(code);
|
||||
Q_EMIT consoleCommand(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ void TreeFilterEdit::resizeEvent(QResizeEvent *event) {
|
|||
|
||||
void TreeFilterEdit::keyPressEvent(QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_Down) {
|
||||
emit navigateDown();
|
||||
Q_EMIT navigateDown();
|
||||
return;
|
||||
}
|
||||
QLineEdit::keyPressEvent(event);
|
||||
|
@ -212,13 +212,15 @@ void SyntaxPopup::syntaxItemChosen(QTreeWidgetItem *current, int) {
|
|||
return;
|
||||
|
||||
if (current == m_plainTextItem) {
|
||||
emit syntaxSelected(WingCodeEdit::nullSyntax());
|
||||
Q_EMIT syntaxSelected(WingCodeEdit::nullSyntax());
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant itemData = current->data(0, Qt::UserRole);
|
||||
if (itemData.canConvert<KSyntaxHighlighting::Definition>())
|
||||
emit syntaxSelected(itemData.value<KSyntaxHighlighting::Definition>());
|
||||
if (itemData.canConvert<KSyntaxHighlighting::Definition>()) {
|
||||
Q_EMIT syntaxSelected(
|
||||
itemData.value<KSyntaxHighlighting::Definition>());
|
||||
}
|
||||
}
|
||||
|
||||
EncodingPopup::EncodingPopup(QWidget *parent) : FilteredTreePopup(parent) {
|
||||
|
@ -243,5 +245,5 @@ void EncodingPopup::encodingItemChosen(QTreeWidgetItem *current, int) {
|
|||
|
||||
QVariant codecName = current->data(0, Qt::UserRole);
|
||||
if (codecName.isValid())
|
||||
emit encodingSelected(codecName.toString());
|
||||
Q_EMIT encodingSelected(codecName.toString());
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ void ColorPickerDialog::updateColor(QColor color) {
|
|||
ui->leColor->setText(color.name());
|
||||
ui->wcolor->setStyleSheet(QStringLiteral("background-color: ") +
|
||||
color.name());
|
||||
emit colorChanged();
|
||||
Q_EMIT colorChanged();
|
||||
}
|
||||
|
||||
QColor ColorPickerDialog::color() const { return _color; }
|
||||
|
|
|
@ -77,7 +77,7 @@ FindDialog::FindDialog(const FindInfo &info, QWidget *parent)
|
|||
m_lineeditor->clear();
|
||||
} else {
|
||||
// force update
|
||||
emit m_lineeditor->textChanged();
|
||||
Q_EMIT m_lineeditor->textChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -908,7 +908,7 @@ MainWindow::buildUpHexBookMarkDock(ads::CDockManager *dock,
|
|||
|
||||
m_bookmarks->clearSelection();
|
||||
doc->RemoveBookMarks(pos);
|
||||
emit model->layoutChanged();
|
||||
Q_EMIT model->layoutChanged();
|
||||
});
|
||||
m_aDelBookMark->setEnabled(false);
|
||||
m_bookmarks->addAction(m_aDelBookMark);
|
||||
|
@ -982,7 +982,7 @@ MainWindow::buildUpHexMetaDataDock(ads::CDockManager *dock,
|
|||
|
||||
m_metadatas->clearSelection();
|
||||
hexeditor->document()->metadata()->RemoveMetadatas(pmetas);
|
||||
emit m_metadatas->model()->layoutChanged();
|
||||
Q_EMIT m_metadatas->model()->layoutChanged();
|
||||
});
|
||||
m_aDelMetaData->setEnabled(false);
|
||||
m_metadatas->addAction(m_aDelMetaData);
|
||||
|
@ -3979,7 +3979,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||
PluginSystem::instance().destory();
|
||||
|
||||
FramelessMainWindow::closeEvent(event);
|
||||
emit closed();
|
||||
Q_EMIT closed();
|
||||
}
|
||||
|
||||
bool MainWindow::eventFilter(QObject *watched, QEvent *event) {
|
||||
|
|
|
@ -135,7 +135,7 @@ QColor MetaDialog::backGroundColor() {
|
|||
void MetaDialog::setComment(QString comment) {
|
||||
if (comment.length() > 0) {
|
||||
ccomment->setChecked(true);
|
||||
emit ccomment->clicked(true);
|
||||
Q_EMIT ccomment->clicked(true);
|
||||
_comment = comment;
|
||||
m_comment->setText(comment);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ void MetaDialog::setComment(QString comment) {
|
|||
void MetaDialog::setBackGroundColor(QColor color) {
|
||||
if (color.isValid()) {
|
||||
cbackground->setChecked(true);
|
||||
emit cbackground->clicked(true);
|
||||
Q_EMIT cbackground->clicked(true);
|
||||
_background = color;
|
||||
ibackground->setColor(color);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ void MetaDialog::setBackGroundColor(QColor color) {
|
|||
void MetaDialog::setForeGroundColor(QColor color) {
|
||||
if (color.isValid()) {
|
||||
cforeground->setChecked(true);
|
||||
emit cforeground->clicked(true);
|
||||
Q_EMIT cforeground->clicked(true);
|
||||
_foreground = color;
|
||||
iforeground->setColor(color);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
/*==============================================================================
|
||||
** Copyright (C) 2025-2028 WingSummer
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify it under
|
||||
** the terms of the GNU Affero General Public License as published by the Free
|
||||
** Software Foundation, version 3.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
** details.
|
||||
**
|
||||
** You should have received a copy of the GNU Affero General Public License
|
||||
** along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
** =============================================================================
|
||||
*/
|
||||
|
||||
grammar NumCal;
|
||||
|
||||
primaryExpression
|
||||
: IntegerConstant
|
||||
| '(' assignmentExpression ')'
|
||||
;
|
||||
|
||||
unaryExpression
|
||||
: primaryExpression
|
||||
| unaryOperator castExpression
|
||||
;
|
||||
|
||||
unaryOperator
|
||||
: '+'
|
||||
| '-'
|
||||
| '~'
|
||||
;
|
||||
|
||||
castExpression
|
||||
: unaryExpression
|
||||
| IntegerConstant
|
||||
;
|
||||
|
||||
multiplicativeExpression
|
||||
: castExpression (('*' | '/' | '%') castExpression)*
|
||||
;
|
||||
|
||||
additiveExpression
|
||||
: multiplicativeExpression (('+' | '-') multiplicativeExpression)*
|
||||
;
|
||||
|
||||
shiftExpression
|
||||
: additiveExpression (('<<' | '>>') additiveExpression)*
|
||||
;
|
||||
|
||||
andExpression
|
||||
: shiftExpression ('&' shiftExpression)*
|
||||
;
|
||||
|
||||
exclusiveOrExpression
|
||||
: andExpression ('^' andExpression)*
|
||||
;
|
||||
|
||||
inclusiveOrExpression
|
||||
: exclusiveOrExpression ('|' exclusiveOrExpression)*
|
||||
;
|
||||
|
||||
assignmentExpression
|
||||
: IntegerConstant
|
||||
| inclusiveOrExpression
|
||||
;
|
||||
|
||||
entryExpression
|
||||
: prefixGoto? IntegerConstant EOF
|
||||
| (prefixGoto Colon)? assignmentExpression EOF
|
||||
| (prefixGoto LeftBracket)? assignmentExpression RightBracket EOF
|
||||
| (prefixGoto LeftParen)? assignmentExpression RightParen EOF
|
||||
;
|
||||
|
||||
prefixGoto
|
||||
: (Plus | Minus | LessThan)
|
||||
;
|
||||
|
||||
|
||||
LeftParen
|
||||
: '('
|
||||
;
|
||||
|
||||
RightParen
|
||||
: ')'
|
||||
;
|
||||
|
||||
LeftShift
|
||||
: '<<'
|
||||
;
|
||||
|
||||
RightShift
|
||||
: '>>'
|
||||
;
|
||||
|
||||
Plus
|
||||
: '+'
|
||||
;
|
||||
|
||||
Minus
|
||||
: '-'
|
||||
;
|
||||
|
||||
Star
|
||||
: '*'
|
||||
;
|
||||
|
||||
Div
|
||||
: '/'
|
||||
;
|
||||
|
||||
Mod
|
||||
: '%'
|
||||
;
|
||||
|
||||
And
|
||||
: '&'
|
||||
;
|
||||
|
||||
Or
|
||||
: '|'
|
||||
;
|
||||
|
||||
Caret
|
||||
: '^'
|
||||
;
|
||||
|
||||
Tilde
|
||||
: '~'
|
||||
;
|
||||
|
||||
LessThan
|
||||
: '<'
|
||||
;
|
||||
|
||||
Colon
|
||||
: ':'
|
||||
;
|
||||
|
||||
LeftBracket
|
||||
: '['
|
||||
;
|
||||
|
||||
RightBracket
|
||||
: ']'
|
||||
;
|
||||
|
||||
fragment Digit
|
||||
: [0-9]
|
||||
;
|
||||
|
||||
fragment HexQuad
|
||||
: HexadecimalDigit HexadecimalDigit HexadecimalDigit HexadecimalDigit
|
||||
;
|
||||
|
||||
IntegerConstant
|
||||
: DecimalConstant
|
||||
| OctalConstant
|
||||
| HexadecimalConstant
|
||||
| BinaryConstant
|
||||
;
|
||||
|
||||
fragment BinaryConstant
|
||||
: '0' [bB] [0-1]+
|
||||
;
|
||||
|
||||
fragment DecimalConstant
|
||||
: NonzeroDigit Digit*
|
||||
;
|
||||
|
||||
fragment OctalConstant
|
||||
: '0' OctalDigit*
|
||||
;
|
||||
|
||||
fragment HexadecimalConstant
|
||||
: HexadecimalPrefix HexadecimalDigit+
|
||||
;
|
||||
|
||||
fragment HexadecimalPrefix
|
||||
: '0' [xX]
|
||||
;
|
||||
|
||||
fragment NonzeroDigit
|
||||
: [1-9]
|
||||
;
|
||||
|
||||
fragment OctalDigit
|
||||
: [0-7]
|
||||
;
|
||||
|
||||
fragment HexadecimalDigit
|
||||
: [0-9a-fA-F]
|
||||
;
|
||||
|
||||
fragment FractionalConstant
|
||||
: DigitSequence? '.' DigitSequence
|
||||
| DigitSequence '.'
|
||||
;
|
||||
|
||||
fragment ExponentPart
|
||||
: [eE] Sign? DigitSequence
|
||||
;
|
||||
|
||||
fragment Sign
|
||||
: [+-]
|
||||
;
|
||||
|
||||
fragment DigitSequence
|
||||
: Digit+
|
||||
;
|
||||
|
||||
fragment BinaryExponentPart
|
||||
: [pP] Sign? DigitSequence
|
||||
;
|
||||
|
||||
fragment HexadecimalDigitSequence
|
||||
: HexadecimalDigit+
|
||||
;
|
||||
|
||||
Whitespace
|
||||
: [ \t]+ -> skip
|
||||
;
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
|
||||
#include "NumCalBaseVisitor.h"
|
||||
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "NumCalVisitor.h"
|
||||
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of NumCalVisitor, which can be
|
||||
* extended to create a visitor which only needs to handle a subset of the available methods.
|
||||
*/
|
||||
class NumCalBaseVisitor : public NumCalVisitor {
|
||||
public:
|
||||
|
||||
virtual std::any visitPrimaryExpression(NumCalParser::PrimaryExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitUnaryExpression(NumCalParser::UnaryExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitUnaryOperator(NumCalParser::UnaryOperatorContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitCastExpression(NumCalParser::CastExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitMultiplicativeExpression(NumCalParser::MultiplicativeExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitAdditiveExpression(NumCalParser::AdditiveExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitShiftExpression(NumCalParser::ShiftExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitAndExpression(NumCalParser::AndExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitExclusiveOrExpression(NumCalParser::ExclusiveOrExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitInclusiveOrExpression(NumCalParser::InclusiveOrExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitAssignmentExpression(NumCalParser::AssignmentExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitEntryExpression(NumCalParser::EntryExpressionContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
virtual std::any visitPrefixGoto(NumCalParser::PrefixGotoContext *ctx) override {
|
||||
return visitChildren(ctx);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
|
||||
#include "NumCalLexer.h"
|
||||
|
||||
|
||||
using namespace antlr4;
|
||||
|
||||
|
||||
|
||||
using namespace antlr4;
|
||||
|
||||
namespace {
|
||||
|
||||
struct NumCalLexerStaticData final {
|
||||
NumCalLexerStaticData(std::vector<std::string> ruleNames,
|
||||
std::vector<std::string> channelNames,
|
||||
std::vector<std::string> modeNames,
|
||||
std::vector<std::string> literalNames,
|
||||
std::vector<std::string> symbolicNames)
|
||||
: ruleNames(std::move(ruleNames)), channelNames(std::move(channelNames)),
|
||||
modeNames(std::move(modeNames)), literalNames(std::move(literalNames)),
|
||||
symbolicNames(std::move(symbolicNames)),
|
||||
vocabulary(this->literalNames, this->symbolicNames) {}
|
||||
|
||||
NumCalLexerStaticData(const NumCalLexerStaticData&) = delete;
|
||||
NumCalLexerStaticData(NumCalLexerStaticData&&) = delete;
|
||||
NumCalLexerStaticData& operator=(const NumCalLexerStaticData&) = delete;
|
||||
NumCalLexerStaticData& operator=(NumCalLexerStaticData&&) = delete;
|
||||
|
||||
std::vector<antlr4::dfa::DFA> decisionToDFA;
|
||||
antlr4::atn::PredictionContextCache sharedContextCache;
|
||||
const std::vector<std::string> ruleNames;
|
||||
const std::vector<std::string> channelNames;
|
||||
const std::vector<std::string> modeNames;
|
||||
const std::vector<std::string> literalNames;
|
||||
const std::vector<std::string> symbolicNames;
|
||||
const antlr4::dfa::Vocabulary vocabulary;
|
||||
antlr4::atn::SerializedATNView serializedATN;
|
||||
std::unique_ptr<antlr4::atn::ATN> atn;
|
||||
};
|
||||
|
||||
::antlr4::internal::OnceFlag numcallexerLexerOnceFlag;
|
||||
#if ANTLR4_USE_THREAD_LOCAL_CACHE
|
||||
static thread_local
|
||||
#endif
|
||||
std::unique_ptr<NumCalLexerStaticData> numcallexerLexerStaticData = nullptr;
|
||||
|
||||
void numcallexerLexerInitialize() {
|
||||
#if ANTLR4_USE_THREAD_LOCAL_CACHE
|
||||
if (numcallexerLexerStaticData != nullptr) {
|
||||
return;
|
||||
}
|
||||
#else
|
||||
assert(numcallexerLexerStaticData == nullptr);
|
||||
#endif
|
||||
auto staticData = std::make_unique<NumCalLexerStaticData>(
|
||||
std::vector<std::string>{
|
||||
"LeftParen", "RightParen", "LeftShift", "RightShift", "Plus", "Minus",
|
||||
"Star", "Div", "Mod", "And", "Or", "Caret", "Tilde", "LessThan", "Colon",
|
||||
"LeftBracket", "RightBracket", "Digit", "HexQuad", "IntegerConstant",
|
||||
"BinaryConstant", "DecimalConstant", "OctalConstant", "HexadecimalConstant",
|
||||
"HexadecimalPrefix", "NonzeroDigit", "OctalDigit", "HexadecimalDigit",
|
||||
"FractionalConstant", "ExponentPart", "Sign", "DigitSequence", "BinaryExponentPart",
|
||||
"HexadecimalDigitSequence", "Whitespace"
|
||||
},
|
||||
std::vector<std::string>{
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
},
|
||||
std::vector<std::string>{
|
||||
"DEFAULT_MODE"
|
||||
},
|
||||
std::vector<std::string>{
|
||||
"", "'('", "')'", "'<<'", "'>>'", "'+'", "'-'", "'*'", "'/'", "'%'",
|
||||
"'&'", "'|'", "'^'", "'~'", "'<'", "':'", "'['", "']'"
|
||||
},
|
||||
std::vector<std::string>{
|
||||
"", "LeftParen", "RightParen", "LeftShift", "RightShift", "Plus",
|
||||
"Minus", "Star", "Div", "Mod", "And", "Or", "Caret", "Tilde", "LessThan",
|
||||
"Colon", "LeftBracket", "RightBracket", "IntegerConstant", "Whitespace"
|
||||
}
|
||||
);
|
||||
static const int32_t serializedATNSegment[] = {
|
||||
4,0,19,197,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
|
||||
6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,
|
||||
7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,
|
||||
7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,
|
||||
7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,1,0,
|
||||
1,0,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,5,1,5,1,6,1,6,1,7,1,7,1,
|
||||
8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,1,15,
|
||||
1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,
|
||||
3,19,119,8,19,1,20,1,20,1,20,4,20,124,8,20,11,20,12,20,125,1,21,1,21,
|
||||
5,21,130,8,21,10,21,12,21,133,9,21,1,22,1,22,5,22,137,8,22,10,22,12,22,
|
||||
140,9,22,1,23,1,23,4,23,144,8,23,11,23,12,23,145,1,24,1,24,1,24,1,25,
|
||||
1,25,1,26,1,26,1,27,1,27,1,28,3,28,158,8,28,1,28,1,28,1,28,1,28,1,28,
|
||||
3,28,165,8,28,1,29,1,29,3,29,169,8,29,1,29,1,29,1,30,1,30,1,31,4,31,176,
|
||||
8,31,11,31,12,31,177,1,32,1,32,3,32,182,8,32,1,32,1,32,1,33,4,33,187,
|
||||
8,33,11,33,12,33,188,1,34,4,34,192,8,34,11,34,12,34,193,1,34,1,34,0,0,
|
||||
35,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,
|
||||
14,29,15,31,16,33,17,35,0,37,0,39,18,41,0,43,0,45,0,47,0,49,0,51,0,53,
|
||||
0,55,0,57,0,59,0,61,0,63,0,65,0,67,0,69,19,1,0,11,1,0,48,57,2,0,66,66,
|
||||
98,98,1,0,48,49,2,0,88,88,120,120,1,0,49,57,1,0,48,55,3,0,48,57,65,70,
|
||||
97,102,2,0,69,69,101,101,2,0,43,43,45,45,2,0,80,80,112,112,2,0,9,9,32,
|
||||
32,194,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,
|
||||
11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,
|
||||
0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,
|
||||
0,0,33,1,0,0,0,0,39,1,0,0,0,0,69,1,0,0,0,1,71,1,0,0,0,3,73,1,0,0,0,5,
|
||||
75,1,0,0,0,7,78,1,0,0,0,9,81,1,0,0,0,11,83,1,0,0,0,13,85,1,0,0,0,15,87,
|
||||
1,0,0,0,17,89,1,0,0,0,19,91,1,0,0,0,21,93,1,0,0,0,23,95,1,0,0,0,25,97,
|
||||
1,0,0,0,27,99,1,0,0,0,29,101,1,0,0,0,31,103,1,0,0,0,33,105,1,0,0,0,35,
|
||||
107,1,0,0,0,37,109,1,0,0,0,39,118,1,0,0,0,41,120,1,0,0,0,43,127,1,0,0,
|
||||
0,45,134,1,0,0,0,47,141,1,0,0,0,49,147,1,0,0,0,51,150,1,0,0,0,53,152,
|
||||
1,0,0,0,55,154,1,0,0,0,57,164,1,0,0,0,59,166,1,0,0,0,61,172,1,0,0,0,63,
|
||||
175,1,0,0,0,65,179,1,0,0,0,67,186,1,0,0,0,69,191,1,0,0,0,71,72,5,40,0,
|
||||
0,72,2,1,0,0,0,73,74,5,41,0,0,74,4,1,0,0,0,75,76,5,60,0,0,76,77,5,60,
|
||||
0,0,77,6,1,0,0,0,78,79,5,62,0,0,79,80,5,62,0,0,80,8,1,0,0,0,81,82,5,43,
|
||||
0,0,82,10,1,0,0,0,83,84,5,45,0,0,84,12,1,0,0,0,85,86,5,42,0,0,86,14,1,
|
||||
0,0,0,87,88,5,47,0,0,88,16,1,0,0,0,89,90,5,37,0,0,90,18,1,0,0,0,91,92,
|
||||
5,38,0,0,92,20,1,0,0,0,93,94,5,124,0,0,94,22,1,0,0,0,95,96,5,94,0,0,96,
|
||||
24,1,0,0,0,97,98,5,126,0,0,98,26,1,0,0,0,99,100,5,60,0,0,100,28,1,0,0,
|
||||
0,101,102,5,58,0,0,102,30,1,0,0,0,103,104,5,91,0,0,104,32,1,0,0,0,105,
|
||||
106,5,93,0,0,106,34,1,0,0,0,107,108,7,0,0,0,108,36,1,0,0,0,109,110,3,
|
||||
55,27,0,110,111,3,55,27,0,111,112,3,55,27,0,112,113,3,55,27,0,113,38,
|
||||
1,0,0,0,114,119,3,43,21,0,115,119,3,45,22,0,116,119,3,47,23,0,117,119,
|
||||
3,41,20,0,118,114,1,0,0,0,118,115,1,0,0,0,118,116,1,0,0,0,118,117,1,0,
|
||||
0,0,119,40,1,0,0,0,120,121,5,48,0,0,121,123,7,1,0,0,122,124,7,2,0,0,123,
|
||||
122,1,0,0,0,124,125,1,0,0,0,125,123,1,0,0,0,125,126,1,0,0,0,126,42,1,
|
||||
0,0,0,127,131,3,51,25,0,128,130,3,35,17,0,129,128,1,0,0,0,130,133,1,0,
|
||||
0,0,131,129,1,0,0,0,131,132,1,0,0,0,132,44,1,0,0,0,133,131,1,0,0,0,134,
|
||||
138,5,48,0,0,135,137,3,53,26,0,136,135,1,0,0,0,137,140,1,0,0,0,138,136,
|
||||
1,0,0,0,138,139,1,0,0,0,139,46,1,0,0,0,140,138,1,0,0,0,141,143,3,49,24,
|
||||
0,142,144,3,55,27,0,143,142,1,0,0,0,144,145,1,0,0,0,145,143,1,0,0,0,145,
|
||||
146,1,0,0,0,146,48,1,0,0,0,147,148,5,48,0,0,148,149,7,3,0,0,149,50,1,
|
||||
0,0,0,150,151,7,4,0,0,151,52,1,0,0,0,152,153,7,5,0,0,153,54,1,0,0,0,154,
|
||||
155,7,6,0,0,155,56,1,0,0,0,156,158,3,63,31,0,157,156,1,0,0,0,157,158,
|
||||
1,0,0,0,158,159,1,0,0,0,159,160,5,46,0,0,160,165,3,63,31,0,161,162,3,
|
||||
63,31,0,162,163,5,46,0,0,163,165,1,0,0,0,164,157,1,0,0,0,164,161,1,0,
|
||||
0,0,165,58,1,0,0,0,166,168,7,7,0,0,167,169,3,61,30,0,168,167,1,0,0,0,
|
||||
168,169,1,0,0,0,169,170,1,0,0,0,170,171,3,63,31,0,171,60,1,0,0,0,172,
|
||||
173,7,8,0,0,173,62,1,0,0,0,174,176,3,35,17,0,175,174,1,0,0,0,176,177,
|
||||
1,0,0,0,177,175,1,0,0,0,177,178,1,0,0,0,178,64,1,0,0,0,179,181,7,9,0,
|
||||
0,180,182,3,61,30,0,181,180,1,0,0,0,181,182,1,0,0,0,182,183,1,0,0,0,183,
|
||||
184,3,63,31,0,184,66,1,0,0,0,185,187,3,55,27,0,186,185,1,0,0,0,187,188,
|
||||
1,0,0,0,188,186,1,0,0,0,188,189,1,0,0,0,189,68,1,0,0,0,190,192,7,10,0,
|
||||
0,191,190,1,0,0,0,192,193,1,0,0,0,193,191,1,0,0,0,193,194,1,0,0,0,194,
|
||||
195,1,0,0,0,195,196,6,34,0,0,196,70,1,0,0,0,13,0,118,125,131,138,145,
|
||||
157,164,168,177,181,188,193,1,6,0,0
|
||||
};
|
||||
staticData->serializedATN = antlr4::atn::SerializedATNView(serializedATNSegment, sizeof(serializedATNSegment) / sizeof(serializedATNSegment[0]));
|
||||
|
||||
antlr4::atn::ATNDeserializer deserializer;
|
||||
staticData->atn = deserializer.deserialize(staticData->serializedATN);
|
||||
|
||||
const size_t count = staticData->atn->getNumberOfDecisions();
|
||||
staticData->decisionToDFA.reserve(count);
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i);
|
||||
}
|
||||
numcallexerLexerStaticData = std::move(staticData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NumCalLexer::NumCalLexer(CharStream *input) : Lexer(input) {
|
||||
NumCalLexer::initialize();
|
||||
_interpreter = new atn::LexerATNSimulator(this, *numcallexerLexerStaticData->atn, numcallexerLexerStaticData->decisionToDFA, numcallexerLexerStaticData->sharedContextCache);
|
||||
}
|
||||
|
||||
NumCalLexer::~NumCalLexer() {
|
||||
delete _interpreter;
|
||||
}
|
||||
|
||||
std::string NumCalLexer::getGrammarFileName() const {
|
||||
return "NumCal.g4";
|
||||
}
|
||||
|
||||
const std::vector<std::string>& NumCalLexer::getRuleNames() const {
|
||||
return numcallexerLexerStaticData->ruleNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& NumCalLexer::getChannelNames() const {
|
||||
return numcallexerLexerStaticData->channelNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string>& NumCalLexer::getModeNames() const {
|
||||
return numcallexerLexerStaticData->modeNames;
|
||||
}
|
||||
|
||||
const dfa::Vocabulary& NumCalLexer::getVocabulary() const {
|
||||
return numcallexerLexerStaticData->vocabulary;
|
||||
}
|
||||
|
||||
antlr4::atn::SerializedATNView NumCalLexer::getSerializedATN() const {
|
||||
return numcallexerLexerStaticData->serializedATN;
|
||||
}
|
||||
|
||||
const atn::ATN& NumCalLexer::getATN() const {
|
||||
return *numcallexerLexerStaticData->atn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void NumCalLexer::initialize() {
|
||||
#if ANTLR4_USE_THREAD_LOCAL_CACHE
|
||||
numcallexerLexerInitialize();
|
||||
#else
|
||||
::antlr4::internal::call_once(numcallexerLexerOnceFlag, numcallexerLexerInitialize);
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class NumCalLexer : public antlr4::Lexer {
|
||||
public:
|
||||
enum {
|
||||
LeftParen = 1, RightParen = 2, LeftShift = 3, RightShift = 4, Plus = 5,
|
||||
Minus = 6, Star = 7, Div = 8, Mod = 9, And = 10, Or = 11, Caret = 12,
|
||||
Tilde = 13, LessThan = 14, Colon = 15, LeftBracket = 16, RightBracket = 17,
|
||||
IntegerConstant = 18, Whitespace = 19
|
||||
};
|
||||
|
||||
explicit NumCalLexer(antlr4::CharStream *input);
|
||||
|
||||
~NumCalLexer() override;
|
||||
|
||||
|
||||
std::string getGrammarFileName() const override;
|
||||
|
||||
const std::vector<std::string>& getRuleNames() const override;
|
||||
|
||||
const std::vector<std::string>& getChannelNames() const override;
|
||||
|
||||
const std::vector<std::string>& getModeNames() const override;
|
||||
|
||||
const antlr4::dfa::Vocabulary& getVocabulary() const override;
|
||||
|
||||
antlr4::atn::SerializedATNView getSerializedATN() const override;
|
||||
|
||||
const antlr4::atn::ATN& getATN() const override;
|
||||
|
||||
// By default the static state used to implement the lexer is lazily initialized during the first
|
||||
// call to the constructor. You can call this function if you wish to initialize the static state
|
||||
// ahead of time.
|
||||
static void initialize();
|
||||
|
||||
private:
|
||||
|
||||
// Individual action functions triggered by action() above.
|
||||
|
||||
// Individual semantic predicate functions triggered by sempred() above.
|
||||
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,282 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class NumCalParser : public antlr4::Parser {
|
||||
public:
|
||||
enum {
|
||||
LeftParen = 1, RightParen = 2, LeftShift = 3, RightShift = 4, Plus = 5,
|
||||
Minus = 6, Star = 7, Div = 8, Mod = 9, And = 10, Or = 11, Caret = 12,
|
||||
Tilde = 13, LessThan = 14, Colon = 15, LeftBracket = 16, RightBracket = 17,
|
||||
IntegerConstant = 18, Whitespace = 19
|
||||
};
|
||||
|
||||
enum {
|
||||
RulePrimaryExpression = 0, RuleUnaryExpression = 1, RuleUnaryOperator = 2,
|
||||
RuleCastExpression = 3, RuleMultiplicativeExpression = 4, RuleAdditiveExpression = 5,
|
||||
RuleShiftExpression = 6, RuleAndExpression = 7, RuleExclusiveOrExpression = 8,
|
||||
RuleInclusiveOrExpression = 9, RuleAssignmentExpression = 10, RuleEntryExpression = 11,
|
||||
RulePrefixGoto = 12
|
||||
};
|
||||
|
||||
explicit NumCalParser(antlr4::TokenStream *input);
|
||||
|
||||
NumCalParser(antlr4::TokenStream *input, const antlr4::atn::ParserATNSimulatorOptions &options);
|
||||
|
||||
~NumCalParser() override;
|
||||
|
||||
std::string getGrammarFileName() const override;
|
||||
|
||||
const antlr4::atn::ATN& getATN() const override;
|
||||
|
||||
const std::vector<std::string>& getRuleNames() const override;
|
||||
|
||||
const antlr4::dfa::Vocabulary& getVocabulary() const override;
|
||||
|
||||
antlr4::atn::SerializedATNView getSerializedATN() const override;
|
||||
|
||||
|
||||
class PrimaryExpressionContext;
|
||||
class UnaryExpressionContext;
|
||||
class UnaryOperatorContext;
|
||||
class CastExpressionContext;
|
||||
class MultiplicativeExpressionContext;
|
||||
class AdditiveExpressionContext;
|
||||
class ShiftExpressionContext;
|
||||
class AndExpressionContext;
|
||||
class ExclusiveOrExpressionContext;
|
||||
class InclusiveOrExpressionContext;
|
||||
class AssignmentExpressionContext;
|
||||
class EntryExpressionContext;
|
||||
class PrefixGotoContext;
|
||||
|
||||
class PrimaryExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
PrimaryExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *IntegerConstant();
|
||||
antlr4::tree::TerminalNode *LeftParen();
|
||||
AssignmentExpressionContext *assignmentExpression();
|
||||
antlr4::tree::TerminalNode *RightParen();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
PrimaryExpressionContext* primaryExpression();
|
||||
|
||||
class UnaryExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
UnaryExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
PrimaryExpressionContext *primaryExpression();
|
||||
UnaryOperatorContext *unaryOperator();
|
||||
CastExpressionContext *castExpression();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
UnaryExpressionContext* unaryExpression();
|
||||
|
||||
class UnaryOperatorContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
UnaryOperatorContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *Plus();
|
||||
antlr4::tree::TerminalNode *Minus();
|
||||
antlr4::tree::TerminalNode *Tilde();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
UnaryOperatorContext* unaryOperator();
|
||||
|
||||
class CastExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
CastExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
UnaryExpressionContext *unaryExpression();
|
||||
antlr4::tree::TerminalNode *IntegerConstant();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
CastExpressionContext* castExpression();
|
||||
|
||||
class MultiplicativeExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
MultiplicativeExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<CastExpressionContext *> castExpression();
|
||||
CastExpressionContext* castExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Star();
|
||||
antlr4::tree::TerminalNode* Star(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Div();
|
||||
antlr4::tree::TerminalNode* Div(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Mod();
|
||||
antlr4::tree::TerminalNode* Mod(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
MultiplicativeExpressionContext* multiplicativeExpression();
|
||||
|
||||
class AdditiveExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
AdditiveExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<MultiplicativeExpressionContext *> multiplicativeExpression();
|
||||
MultiplicativeExpressionContext* multiplicativeExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Plus();
|
||||
antlr4::tree::TerminalNode* Plus(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Minus();
|
||||
antlr4::tree::TerminalNode* Minus(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
AdditiveExpressionContext* additiveExpression();
|
||||
|
||||
class ShiftExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ShiftExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<AdditiveExpressionContext *> additiveExpression();
|
||||
AdditiveExpressionContext* additiveExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> LeftShift();
|
||||
antlr4::tree::TerminalNode* LeftShift(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> RightShift();
|
||||
antlr4::tree::TerminalNode* RightShift(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
ShiftExpressionContext* shiftExpression();
|
||||
|
||||
class AndExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
AndExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<ShiftExpressionContext *> shiftExpression();
|
||||
ShiftExpressionContext* shiftExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> And();
|
||||
antlr4::tree::TerminalNode* And(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
AndExpressionContext* andExpression();
|
||||
|
||||
class ExclusiveOrExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ExclusiveOrExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<AndExpressionContext *> andExpression();
|
||||
AndExpressionContext* andExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Caret();
|
||||
antlr4::tree::TerminalNode* Caret(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
ExclusiveOrExpressionContext* exclusiveOrExpression();
|
||||
|
||||
class InclusiveOrExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
InclusiveOrExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
std::vector<ExclusiveOrExpressionContext *> exclusiveOrExpression();
|
||||
ExclusiveOrExpressionContext* exclusiveOrExpression(size_t i);
|
||||
std::vector<antlr4::tree::TerminalNode *> Or();
|
||||
antlr4::tree::TerminalNode* Or(size_t i);
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
InclusiveOrExpressionContext* inclusiveOrExpression();
|
||||
|
||||
class AssignmentExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
AssignmentExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *IntegerConstant();
|
||||
InclusiveOrExpressionContext *inclusiveOrExpression();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
AssignmentExpressionContext* assignmentExpression();
|
||||
|
||||
class EntryExpressionContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
EntryExpressionContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *IntegerConstant();
|
||||
antlr4::tree::TerminalNode *EOF();
|
||||
PrefixGotoContext *prefixGoto();
|
||||
AssignmentExpressionContext *assignmentExpression();
|
||||
antlr4::tree::TerminalNode *Colon();
|
||||
antlr4::tree::TerminalNode *RightBracket();
|
||||
antlr4::tree::TerminalNode *LeftBracket();
|
||||
antlr4::tree::TerminalNode *RightParen();
|
||||
antlr4::tree::TerminalNode *LeftParen();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
EntryExpressionContext* entryExpression();
|
||||
|
||||
class PrefixGotoContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
PrefixGotoContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *Plus();
|
||||
antlr4::tree::TerminalNode *Minus();
|
||||
antlr4::tree::TerminalNode *LessThan();
|
||||
|
||||
|
||||
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
PrefixGotoContext* prefixGoto();
|
||||
|
||||
|
||||
// By default the static state used to implement the parser is lazily initialized during the first
|
||||
// call to the constructor. You can call this function if you wish to initialize the static state
|
||||
// ahead of time.
|
||||
static void initialize();
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
|
||||
#include "NumCalVisitor.h"
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
|
||||
// Generated from NumCal.g4 by ANTLR 4.13.2
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "antlr4-runtime.h"
|
||||
#include "NumCalParser.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class defines an abstract visitor for a parse tree
|
||||
* produced by NumCalParser.
|
||||
*/
|
||||
class NumCalVisitor : public antlr4::tree::AbstractParseTreeVisitor {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Visit parse trees produced by NumCalParser.
|
||||
*/
|
||||
virtual std::any visitPrimaryExpression(NumCalParser::PrimaryExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitUnaryExpression(NumCalParser::UnaryExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitUnaryOperator(NumCalParser::UnaryOperatorContext *context) = 0;
|
||||
|
||||
virtual std::any visitCastExpression(NumCalParser::CastExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitMultiplicativeExpression(NumCalParser::MultiplicativeExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitAdditiveExpression(NumCalParser::AdditiveExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitShiftExpression(NumCalParser::ShiftExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitAndExpression(NumCalParser::AndExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitExclusiveOrExpression(NumCalParser::ExclusiveOrExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitInclusiveOrExpression(NumCalParser::InclusiveOrExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitAssignmentExpression(NumCalParser::AssignmentExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitEntryExpression(NumCalParser::EntryExpressionContext *context) = 0;
|
||||
|
||||
virtual std::any visitPrefixGoto(NumCalParser::PrefixGotoContext *context) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
antlr4 -Dlanguage=Cpp -visitor -no-listener NumCal.g4 -o .
|
|
@ -69,5 +69,5 @@ QVariant BookMarksModel::headerData(int section, Qt::Orientation orientation,
|
|||
void BookMarksModel::setDocument(QHexDocument *newDoc) {
|
||||
_doc = newDoc;
|
||||
connect(newDoc, &QHexDocument::bookMarkChanged, this,
|
||||
[=] { emit this->layoutChanged(); });
|
||||
[=] { Q_EMIT this->layoutChanged(); });
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void CheckSumModel::setCheckSumData(QCryptographicHash::Algorithm algorithm,
|
|||
_checkSumData[algorithm] = data;
|
||||
auto index = this->index(
|
||||
Utilities::supportedHashAlgorithms().indexOf(algorithm), 0);
|
||||
emit dataChanged(index, index);
|
||||
Q_EMIT dataChanged(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ void CheckSumModel::clearData() {
|
|||
for (auto p = _checkSumData.begin(); p != _checkSumData.end(); ++p) {
|
||||
p->clear();
|
||||
}
|
||||
emit dataChanged(
|
||||
Q_EMIT dataChanged(
|
||||
this->index(0, 0),
|
||||
this->index(Utilities::supportedHashAlgorithms().size() - 1, 0));
|
||||
}
|
||||
|
|
|
@ -81,5 +81,5 @@ QVariant DbgCallStackModel::headerData(int section, Qt::Orientation orientation,
|
|||
void DbgCallStackModel::updateData(
|
||||
const QList<asDebugger::CallStackItem> &callstack) {
|
||||
_stack = callstack;
|
||||
emit layoutChanged();
|
||||
Q_EMIT layoutChanged();
|
||||
}
|
||||
|
|
|
@ -65,5 +65,5 @@ QVariant DbgVarShowModel::headerData(int section, Qt::Orientation orientation,
|
|||
void DbgVarShowModel::updateData(
|
||||
const QVector<asDebugger::VariablesInfo> &varinfos) {
|
||||
_vars = varinfos;
|
||||
emit layoutChanged();
|
||||
Q_EMIT layoutChanged();
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ QString FindResultModel::encoding() const { return m_encoding; }
|
|||
void FindResultModel::setEncoding(const QString &newEncoding) {
|
||||
if (m_encoding != newEncoding) {
|
||||
m_encoding = newEncoding;
|
||||
emit dataChanged(index(0, 4), index(rowCount(QModelIndex()), 4));
|
||||
Q_EMIT dataChanged(index(0, 4), index(rowCount(QModelIndex()), 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ FindResultModel::FindResult FindResultModel::resultAt(qsizetype index) const {
|
|||
void FindResultModel::clear() {
|
||||
m_results.clear();
|
||||
m_findData.clear();
|
||||
emit layoutChanged();
|
||||
Q_EMIT layoutChanged();
|
||||
}
|
||||
|
||||
QList<FindResultModel::FindResult>::size_type FindResultModel::size() const {
|
||||
|
|
|
@ -119,5 +119,5 @@ QVariant MetaDataModel::headerData(int section, Qt::Orientation orientation,
|
|||
void MetaDataModel::setDocument(QHexDocument *newDoc) {
|
||||
_doc = newDoc;
|
||||
connect(newDoc, &QHexDocument::metaDataChanged, this,
|
||||
[=] { emit this->layoutChanged(); });
|
||||
[=] { Q_EMIT this->layoutChanged(); });
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ void NumShowModel::setNumData(NumTableIndex index, const QString &data) {
|
|||
} else {
|
||||
m_num[index] = data;
|
||||
}
|
||||
emit dataChanged(this->index(index, 0), this->index(index, 0));
|
||||
Q_EMIT dataChanged(this->index(index, 0), this->index(index, 0));
|
||||
}
|
||||
|
||||
QString NumShowModel::numData(NumTableIndex index) const {
|
||||
|
|
Loading…
Reference in New Issue