- enhancement: Add "Generate Assembly" in "Run" Menu

- enhancement: Improve highlighter for asm
This commit is contained in:
Roy Qu 2022-12-01 22:10:44 +08:00
parent 164d766c75
commit f9fb966c38
23 changed files with 821 additions and 664 deletions

View File

@ -15,6 +15,8 @@ Red Panda C++ Version 2.5
- fix: Can't correctly show completion suggest for type with template parameters - fix: Can't correctly show completion suggest for type with template parameters
- enhancement: Show compltion suggest for std::pair::first and std::pair second - enhancement: Show compltion suggest for std::pair::first and std::pair second
- enhancement: Disable "run" and "debug" actions when current project is static or dynamic library - enhancement: Disable "run" and "debug" actions when current project is static or dynamic library
- enhancement: Add "Generate Assembly" in "Run" Menu
- enhancement: Improve highlighter for asm
Red Panda C++ Version 2.4 Red Panda C++ Version 2.4

View File

@ -19,6 +19,13 @@
#include <QString> #include <QString>
#include <memory> #include <memory>
#include <QMetaType> #include <QMetaType>
enum class CppCompileType {
Normal,
PreprocessOnly,
GenerateAssemblyOnly
};
enum class CompileIssueType { enum class CompileIssueType {
Other, Other,
Warning, Warning,

View File

@ -71,7 +71,7 @@ bool CompilerManager::running()
return (mRunner!=nullptr && !mRunner->pausing()); return (mRunner!=nullptr && !mRunner->pausing());
} }
void CompilerManager::compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent, bool onlyCheckSyntax) void CompilerManager::compile(const QString& filename, const QByteArray& encoding, bool rebuild, CppCompileType compileType)
{ {
if (!pSettings->compilerSets().defaultSet()) { if (!pSettings->compilerSets().defaultSet()) {
QMessageBox::critical(pMainWindow, QMessageBox::critical(pMainWindow,
@ -87,7 +87,7 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
mCompileErrorCount = 0; mCompileErrorCount = 0;
mCompileIssueCount = 0; mCompileIssueCount = 0;
//deleted when thread finished //deleted when thread finished
mCompiler = new FileCompiler(filename,encoding,silent,onlyCheckSyntax); mCompiler = new FileCompiler(filename,encoding,compileType,false,false);
mCompiler->setRebuild(rebuild); mCompiler->setRebuild(rebuild);
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);
@ -102,7 +102,7 @@ void CompilerManager::compile(const QString& filename, const QByteArray& encodin
} }
} }
void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebuild, bool silent,bool onlyCheckSyntax) void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebuild)
{ {
if (!pSettings->compilerSets().defaultSet()) { if (!pSettings->compilerSets().defaultSet()) {
QMessageBox::critical(pMainWindow, QMessageBox::critical(pMainWindow,
@ -118,7 +118,7 @@ void CompilerManager::compileProject(std::shared_ptr<Project> project, bool rebu
mCompileErrorCount = 0; mCompileErrorCount = 0;
mCompileIssueCount = 0; mCompileIssueCount = 0;
//deleted when thread finished //deleted when thread finished
mCompiler = new ProjectCompiler(project,silent,onlyCheckSyntax); mCompiler = new ProjectCompiler(project,false,false);
mCompiler->setRebuild(rebuild); mCompiler->setRebuild(rebuild);
connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater);
connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished);

View File

@ -23,8 +23,8 @@
#include "../common.h" #include "../common.h"
class Runner; class Runner;
class Compiler;
class Project; class Project;
class Compiler;
struct OJProblemCase; struct OJProblemCase;
using POJProblemCase = std::shared_ptr<OJProblemCase>; using POJProblemCase = std::shared_ptr<OJProblemCase>;
class CompilerManager : public QObject class CompilerManager : public QObject
@ -37,8 +37,8 @@ public:
bool backgroundSyntaxChecking(); bool backgroundSyntaxChecking();
bool running(); bool running();
void compile(const QString& filename, const QByteArray& encoding, bool rebuild, bool silent=false,bool onlyCheckSyntax=false); void compile(const QString& filename, const QByteArray& encoding, bool rebuild, CppCompileType compileType);
void compileProject(std::shared_ptr<Project> project, bool rebuild, bool silent=false,bool onlyCheckSyntax=false); void compileProject(std::shared_ptr<Project> project, bool rebuild);
void cleanProject(std::shared_ptr<Project> project); void cleanProject(std::shared_ptr<Project> project);
void buildProjectMakefile(std::shared_ptr<Project> project); void buildProjectMakefile(std::shared_ptr<Project> project);
void checkSyntax(const QString&filename, const QByteArray& encoding, const QString& content, std::shared_ptr<Project> project); void checkSyntax(const QString&filename, const QByteArray& encoding, const QString& content, std::shared_ptr<Project> project);

View File

@ -24,15 +24,33 @@
#include <QMessageBox> #include <QMessageBox>
FileCompiler::FileCompiler(const QString &filename, const QByteArray &encoding,bool silent,bool onlyCheckSyntax): FileCompiler::FileCompiler(const QString &filename, const QByteArray &encoding,
CppCompileType compileType,bool silent,bool onlyCheckSyntax):
Compiler(filename, silent,onlyCheckSyntax), Compiler(filename, silent,onlyCheckSyntax),
mEncoding(encoding) mEncoding(encoding),
mCompileType(compileType)
{ {
} }
bool FileCompiler::prepareForCompile() bool FileCompiler::prepareForCompile()
{ {
Settings::CompilerSet::CompilationStage oldStage = compilerSet()->compilationStage();
auto action = finally([this,oldStage]{
compilerSet()->setCompilationStage(oldStage);
});
Settings::CompilerSet::CompilationStage stage = oldStage;
switch(mCompileType) {
case CppCompileType::PreprocessOnly:
stage = Settings::CompilerSet::CompilationStage::PreprocessingOnly;
break;
case CppCompileType::GenerateAssemblyOnly:
stage = Settings::CompilerSet::CompilationStage::CompilationProperOnly;
break;
default:
stage = oldStage;
}
compilerSet()->setCompilationStage(stage);
log(tr("Compiling single file...")); log(tr("Compiling single file..."));
log("------------------"); log("------------------");
log(tr("- Filename: %1").arg(mFilename)); log(tr("- Filename: %1").arg(mFilename));

View File

@ -23,15 +23,17 @@ class FileCompiler : public Compiler
{ {
Q_OBJECT Q_OBJECT
public: public:
FileCompiler(const QString& filename, const QByteArray& encoding,bool silent,bool onlyCheckSyntax); FileCompiler(const QString& filename, const QByteArray& encoding,
CppCompileType compileType,
bool silent,bool onlyCheckSyntax);
// Compiler interface
protected: protected:
bool prepareForCompile() override; bool prepareForCompile() override;
private: private:
QByteArray mEncoding; QByteArray mEncoding;
CppCompileType mCompileType;
// Compiler interface // Compiler interface
protected: protected:
bool prepareForRebuild() override; bool prepareForRebuild() override;

View File

@ -4729,7 +4729,9 @@ void Editor::applySettings()
options.setFlag(QSynedit::eoScrollByOneLess,pSettings->editor().scrollByOneLess()); options.setFlag(QSynedit::eoScrollByOneLess,pSettings->editor().scrollByOneLess());
options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll()); options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll());
options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll()); options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll());
options.setFlag(QSynedit::eoShowRainbowColor, pSettings->editor().rainbowParenthesis()); options.setFlag(QSynedit::eoShowRainbowColor,
pSettings->editor().rainbowParenthesis()
&& highlighter() && highlighter()->supportBraceLevel());
setOptions(options); setOptions(options);
setTabWidth(pSettings->editor().tabWidth()); setTabWidth(pSettings->editor().tabWidth());
@ -4818,7 +4820,9 @@ static QSynedit::PHighlighterAttribute createRainbowAttribute(const QString& att
void Editor::applyColorScheme(const QString& schemeName) void Editor::applyColorScheme(const QString& schemeName)
{ {
QSynedit::EditorOptions options = getOptions(); QSynedit::EditorOptions options = getOptions();
options.setFlag(QSynedit::EditorOption::eoShowRainbowColor, pSettings->editor().rainbowParenthesis()); options.setFlag(QSynedit::EditorOption::eoShowRainbowColor,
pSettings->editor().rainbowParenthesis()
&& highlighter() && highlighter()->supportBraceLevel());
setOptions(options); setOptions(options);
highlighterManager.applyColorScheme(highlighter(),schemeName); highlighterManager.applyColorScheme(highlighter(),schemeName);
if (pSettings->editor().rainbowParenthesis()) { if (pSettings->editor().rainbowParenthesis()) {

View File

@ -674,6 +674,7 @@ void MainWindow::updateCompileActions()
ui->actionCompile_Run->setEnabled(false); ui->actionCompile_Run->setEnabled(false);
ui->actionRun->setEnabled(false); ui->actionRun->setEnabled(false);
ui->actionRebuild->setEnabled(false); ui->actionRebuild->setEnabled(false);
ui->actionGenerate_Assembly->setEnabled(false);
ui->actionDebug->setEnabled(false); ui->actionDebug->setEnabled(false);
ui->btnRunAllProblemCases->setEnabled(false); ui->btnRunAllProblemCases->setEnabled(false);
} else { } else {
@ -681,6 +682,7 @@ void MainWindow::updateCompileActions()
ui->actionCompile_Run->setEnabled(canRun); ui->actionCompile_Run->setEnabled(canRun);
ui->actionRun->setEnabled(canRun); ui->actionRun->setEnabled(canRun);
ui->actionRebuild->setEnabled(true); ui->actionRebuild->setEnabled(true);
ui->actionGenerate_Assembly->setEnabled(!forProject);
ui->actionDebug->setEnabled(canRun); ui->actionDebug->setEnabled(canRun);
ui->btnRunAllProblemCases->setEnabled(canRun); ui->btnRunAllProblemCases->setEnabled(canRun);
} }
@ -1801,7 +1803,7 @@ void MainWindow::checkSyntaxInBack(Editor *e)
} }
} }
bool MainWindow::compile(bool rebuild) bool MainWindow::compile(bool rebuild, CppCompileType compileType)
{ {
mCompilerManager->stopPausing(); mCompilerManager->stopPausing();
CompileTarget target =getCompileTarget(); CompileTarget target =getCompileTarget();
@ -1837,16 +1839,33 @@ bool MainWindow::compile(bool rebuild)
if (mCompileSuccessionTask) { if (mCompileSuccessionTask) {
Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet(); Settings::PCompilerSet compilerSet =pSettings->compilerSets().defaultSet();
if (compilerSet) { if (compilerSet) {
mCompileSuccessionTask->execName = compilerSet->getOutputFilename(editor->filename()); Settings::CompilerSet::CompilationStage stage;
mCompileSuccessionTask->isExecutable = compilerSet->isOutputExecutable(); switch(compileType) {
case CppCompileType::GenerateAssemblyOnly:
stage = Settings::CompilerSet::CompilationStage::CompilationProperOnly;
break;
case CppCompileType::PreprocessOnly:
stage = Settings::CompilerSet::CompilationStage::PreprocessingOnly;
break;
default:
stage = compilerSet->compilationStage();
break;
}
mCompileSuccessionTask->execName = compilerSet->getOutputFilename(editor->filename(),stage);
mCompileSuccessionTask->isExecutable = compilerSet->isOutputExecutable(stage);
} else { } else {
mCompileSuccessionTask->execName = changeFileExt(editor->filename(),DEFAULT_EXECUTABLE_SUFFIX); mCompileSuccessionTask->execName = changeFileExt(editor->filename(),DEFAULT_EXECUTABLE_SUFFIX);
mCompileSuccessionTask->isExecutable = true; mCompileSuccessionTask->isExecutable = true;
} }
if (!mCompileSuccessionTask->isExecutable) {
Editor *editor = mEditorList->getOpenedEditorByFilename(mCompileSuccessionTask->execName);
if (editor)
mEditorList->closeEditor(editor,false,true);
}
} }
stretchMessagesPanel(true); stretchMessagesPanel(true);
ui->tabMessages->setCurrentWidget(ui->tabToolsOutput); ui->tabMessages->setCurrentWidget(ui->tabToolsOutput);
mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild); mCompilerManager->compile(editor->filename(),editor->fileEncoding(),rebuild,compileType);
updateCompileActions(); updateCompileActions();
updateAppTitle(); updateAppTitle();
return true; return true;
@ -1963,7 +1982,7 @@ void MainWindow::runExecutable(RunType runType)
bool isExecutable; bool isExecutable;
if (compilerSet) { if (compilerSet) {
exeName = compilerSet->getOutputFilename(editor->filename()); exeName = compilerSet->getOutputFilename(editor->filename());
isExecutable = compilerSet->compilationStage()==Settings::CompilerSet::CompilationStage::GenerateExecutable; isExecutable = compilerSet->isOutputExecutable();
} else { } else {
exeName = changeFileExt(editor->filename(), DEFAULT_EXECUTABLE_SUFFIX); exeName = changeFileExt(editor->filename(), DEFAULT_EXECUTABLE_SUFFIX);
isExecutable = true; isExecutable = true;
@ -2140,7 +2159,7 @@ void MainWindow::debug()
bool isExecutable; bool isExecutable;
if (compilerSet) { if (compilerSet) {
filePath = compilerSet->getOutputFilename(e->filename()); filePath = compilerSet->getOutputFilename(e->filename());
isExecutable = compilerSet->compilationStage()==Settings::CompilerSet::CompilationStage::GenerateExecutable; isExecutable = compilerSet->isOutputExecutable();
} else { } else {
filePath = changeFileExt(e->filename(), DEFAULT_EXECUTABLE_SUFFIX); filePath = changeFileExt(e->filename(), DEFAULT_EXECUTABLE_SUFFIX);
isExecutable = true; isExecutable = true;
@ -7322,6 +7341,20 @@ void MainWindow::doCompileRun(RunType runType)
compile(); compile();
} }
void MainWindow::doGenerateAssembly()
{
CompileTarget target =getCompileTarget();
QStringList binDirs;
QString execName;
if (target == CompileTarget::File) {
binDirs = getDefaultCompilerSetBinDirs();
}
mCompileSuccessionTask = std::make_shared<CompileSuccessionTask>();
mCompileSuccessionTask->binDirs=binDirs;
mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal;
compile(false,CppCompileType::GenerateAssemblyOnly);
}
void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase) void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
{ {
if (problemCase->testState == ProblemCaseTestState::Failed) { if (problemCase->testState == ProblemCaseTestState::Failed) {
@ -8855,3 +8888,9 @@ SearchDialog *MainWindow::searchDialog() const
return mSearchDialog; return mSearchDialog;
} }
void MainWindow::on_actionGenerate_Assembly_triggered()
{
doGenerateAssembly();
}

View File

@ -129,7 +129,7 @@ public:
void updateDebuggerSettings(); void updateDebuggerSettings();
void updateActionIcons(); void updateActionIcons();
void checkSyntaxInBack(Editor* e); void checkSyntaxInBack(Editor* e);
bool compile(bool rebuild=false); bool compile(bool rebuild=false, CppCompileType compileType=CppCompileType::Normal);
void runExecutable( void runExecutable(
const QString& exeName, const QString& exeName,
const QString& filename, const QString& filename,
@ -281,6 +281,7 @@ private:
void showSearchReplacePanel(bool show); void showSearchReplacePanel(bool show);
void clearIssues(); void clearIssues();
void doCompileRun(RunType runType); void doCompileRun(RunType runType);
void doGenerateAssembly();
void updateProblemCaseOutput(POJProblemCase problemCase); void updateProblemCaseOutput(POJProblemCase problemCase);
void applyCurrentProblemCaseChanges(); void applyCurrentProblemCaseChanges();
void showHideInfosTab(QWidget *widget, bool show); void showHideInfosTab(QWidget *widget, bool show);
@ -745,6 +746,8 @@ private slots:
void on_actionSwitchHeaderSource_triggered(); void on_actionSwitchHeaderSource_triggered();
void on_actionGenerate_Assembly_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
EditorList *mEditorList; EditorList *mEditorList;

View File

@ -156,6 +156,7 @@
<addaction name="actionRun"/> <addaction name="actionRun"/>
<addaction name="actionCompile_Run"/> <addaction name="actionCompile_Run"/>
<addaction name="actionRebuild"/> <addaction name="actionRebuild"/>
<addaction name="actionGenerate_Assembly"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionRun_Parameters"/> <addaction name="actionRun_Parameters"/>
<addaction name="actionCompiler_Options"/> <addaction name="actionCompiler_Options"/>
@ -3263,6 +3264,11 @@
<string>Switch Header/Source</string> <string>Switch Header/Source</string>
</property> </property>
</action> </action>
<action name="actionGenerate_Assembly">
<property name="text">
<string>Generate Assembly</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -2464,7 +2464,12 @@ void Settings::CompilerSet::setCompilationStage(CompilationStage newCompilationS
QString Settings::CompilerSet::getOutputFilename(const QString &sourceFilename) QString Settings::CompilerSet::getOutputFilename(const QString &sourceFilename)
{ {
switch(compilationStage()) { return getOutputFilename(sourceFilename, compilationStage());
}
QString Settings::CompilerSet::getOutputFilename(const QString &sourceFilename, CompilationStage stage)
{
switch(stage) {
case Settings::CompilerSet::CompilationStage::PreprocessingOnly: case Settings::CompilerSet::CompilationStage::PreprocessingOnly:
return changeFileExt(sourceFilename, preprocessingSuffix()); return changeFileExt(sourceFilename, preprocessingSuffix());
case Settings::CompilerSet::CompilationStage::CompilationProperOnly: case Settings::CompilerSet::CompilationStage::CompilationProperOnly:
@ -2479,7 +2484,12 @@ QString Settings::CompilerSet::getOutputFilename(const QString &sourceFilename)
bool Settings::CompilerSet::isOutputExecutable() bool Settings::CompilerSet::isOutputExecutable()
{ {
return mCompilationStage == CompilationStage::GenerateExecutable; return isOutputExecutable(mCompilationStage);
}
bool Settings::CompilerSet::isOutputExecutable(CompilationStage stage)
{
return stage == CompilationStage::GenerateExecutable;
} }
const QString &Settings::CompilerSet::assemblingSuffix() const const QString &Settings::CompilerSet::assemblingSuffix() const

View File

@ -1331,8 +1331,9 @@ public:
void setCompilationStage(CompilationStage newCompilationStage); void setCompilationStage(CompilationStage newCompilationStage);
QString getOutputFilename(const QString& sourceFilename); QString getOutputFilename(const QString& sourceFilename);
QString getOutputFilename(const QString& sourceFilename,Settings::CompilerSet::CompilationStage stage);
bool isOutputExecutable(); bool isOutputExecutable();
bool isOutputExecutable(Settings::CompilerSet::CompilationStage stage);
private: private:
void setDirectories(const QString& binDir, CompilerType mCompilerType); void setDirectories(const QString& binDir, CompilerType mCompilerType);
//load hard defines //load hard defines

View File

@ -4728,6 +4728,10 @@
<source>Switch Header/Source</source> <source>Switch Header/Source</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Generate Assembly</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>NewClassDialog</name> <name>NewClassDialog</name>

File diff suppressed because it is too large Load Diff

View File

@ -4569,6 +4569,10 @@
<source>Switch Header/Source</source> <source>Switch Header/Source</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Generate Assembly</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>NewClassDialog</name> <name>NewClassDialog</name>

View File

@ -16,10 +16,34 @@
*/ */
#include "asm.h" #include "asm.h"
#include "../Constants.h" #include "../Constants.h"
#include <QDebug>
namespace QSynedit { namespace QSynedit {
const QSet<QString> ASMHighlighter::Keywords { const QSet<QString> ASMHighlighter::Keywords {
"movb","movw","movl","movq",
"leab","leaw","leal","leaq",
"incb","incw","incl","incq",
"decb","decw","decl","decq",
"addb","addw","addl","addq",
"subb","subw","subl","subq",
"imulb","imulw","imull","imulq",
"divb","divw","divl","divq",
"xorb","xorw","xorl","xorq",
"orb","orw","orl","orq",
"andb","andw","andl","andq",
"salb","salw","sall","salq",
"shlb","shlw","shll","shlq",
"sarb","sarw","sarl","sarq",
"shrb","shrw","shrl","shrq",
"cmpb","cmpw","cmpl","cmpq",
"testb","testw","testl","testq",
"pushq","popq",
"cmove", "cmovz", "cmovne", "cmovnz",
"cmovs", "cmovns", "cmovg", "cmovge",
"cmovl", "cmovle", "cmova", "cmovae",
"cmovb", "cmovbe", "cmovnbe","cmovnb",
"cmovnae","cmovna",
"aaa","aad","aam","adc","add","and","arpl","bound","bsf","bsr","bswap","bt","btc","btr","bts", "aaa","aad","aam","adc","add","and","arpl","bound","bsf","bsr","bswap","bt","btc","btr","bts",
"call","cbw","cdq","clc","cld","cli","clts","cmc","cmp","cmps","cmpsb","cmpsd","cmpsw", "call","cbw","cdq","clc","cld","cli","clts","cmc","cmp","cmps","cmpsb","cmpsd","cmpsw",
"cmpxchg","cwd","cwde","daa","das","dec","div","emms","enter","f2xm1","fabs","fadd","faddp","fbld", "cmpxchg","cwd","cwde","daa","das","dec","div","emms","enter","f2xm1","fabs","fadd","faddp","fbld",
@ -98,7 +122,7 @@ void ASMHighlighter::IdentProc()
} }
QString s = mLineString.mid(start,mRun-start); QString s = mLineString.mid(start,mRun-start);
if (Keywords.contains(s)) { if (Keywords.contains(s)) {
mTokenID = TokenId::Key; mTokenID = TokenId::rainbow;
} else { } else {
mTokenID = TokenId::Identifier; mTokenID = TokenId::Identifier;
} }
@ -130,7 +154,8 @@ void ASMHighlighter::NumberProc()
while (true) { while (true) {
QChar ch = mLine[mRun]; QChar ch = mLine[mRun];
if (!((ch>='0' && ch<='9') || (ch=='.') || (ch >= 'a' && ch<='f') if (!((ch>='0' && ch<='9') || (ch=='.') || (ch >= 'a' && ch<='f')
|| (ch=='h') || (ch >= 'A' && ch<='F') || (ch == 'H'))) || (ch=='h') || (ch >= 'A' && ch<='F') || (ch == 'H')
|| (ch == 'x')))
break; break;
mRun++; mRun++;
} }
@ -181,6 +206,7 @@ void ASMHighlighter::StringProc()
mTokenID = TokenId::String; mTokenID = TokenId::String;
if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\"') && (mLine[mRun + 2] == '\"')) if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\"') && (mLine[mRun + 2] == '\"'))
mRun += 2; mRun += 2;
mRun+=1;
while (true) { while (true) {
if (mLine[mRun] == 0 || mLine[mRun] == '\r' || mLine[mRun] == '\n') if (mLine[mRun] == 0 || mLine[mRun] == '\r' || mLine[mRun] == '\n')
break; break;
@ -231,7 +257,7 @@ PHighlighterAttribute ASMHighlighter::getTokenAttribute() const
return mCommentAttribute; return mCommentAttribute;
case TokenId::Identifier: case TokenId::Identifier:
return mIdentifierAttribute; return mIdentifierAttribute;
case TokenId::Key: case TokenId::rainbow:
return mKeywordAttribute; return mKeywordAttribute;
case TokenId::Number: case TokenId::Number:
return mNumberAttribute; return mNumberAttribute;

View File

@ -26,7 +26,7 @@ class ASMHighlighter : public Highlighter
enum class TokenId { enum class TokenId {
Comment, Comment,
Identifier, Identifier,
Key, rainbow, // add mov etc
Null, Null,
Number, Number,
Space, Space,
@ -91,6 +91,8 @@ public:
// SynHighlighter interface // SynHighlighter interface
public: public:
QSet<QString> keywords() const override; QSet<QString> keywords() const override;
const PHighlighterAttribute &directiveAttribute() const;
const PHighlighterAttribute &labelAttribute() const;
}; };
} }

View File

@ -103,6 +103,11 @@ QString Highlighter::foldString()
return " ... }"; return " ... }";
} }
bool Highlighter::supportBraceLevel()
{
return false;
}
bool Highlighter::isSpaceChar(const QChar &ch) bool Highlighter::isSpaceChar(const QChar &ch)
{ {
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'; return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';

View File

@ -154,6 +154,7 @@ public:
virtual QString foldString(); virtual QString foldString();
virtual bool supportBraceLevel();
virtual bool isSpaceChar(const QChar& ch); virtual bool isSpaceChar(const QChar& ch);
virtual bool isWordBreakChar(const QChar& ch); virtual bool isWordBreakChar(const QChar& ch);
bool enabled() const; bool enabled() const;

View File

@ -1399,6 +1399,11 @@ void CppHighlighter::setCustomTypeKeywords(const QSet<QString> &newCustomTypeKey
mCustomTypeKeywords = newCustomTypeKeywords; mCustomTypeKeywords = newCustomTypeKeywords;
} }
bool CppHighlighter::supportBraceLevel()
{
return true;
}
bool CppHighlighter::getTokenFinished() const bool CppHighlighter::getTokenFinished() const
{ {
if (mTokenId == TokenId::Comment if (mTokenId == TokenId::Comment

View File

@ -202,6 +202,10 @@ public:
QString foldString() override; QString foldString() override;
const QSet<QString> &customTypeKeywords() const; const QSet<QString> &customTypeKeywords() const;
void setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords); void setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords);
// Highlighter interface
public:
bool supportBraceLevel() override;
}; };
} }

View File

@ -1471,4 +1471,9 @@ QSet<QString> GLSLHighlighter::keywords() const
{ {
return Keywords; return Keywords;
} }
bool GLSLHighlighter::supportBraceLevel()
{
return true;
}
} }

View File

@ -192,6 +192,10 @@ public:
// SynHighlighter interface // SynHighlighter interface
public: public:
QSet<QString> keywords() const override; QSet<QString> keywords() const override;
// Highlighter interface
public:
bool supportBraceLevel() override;
}; };
} }