remove all warnings

This commit is contained in:
Roy Qu 2022-07-04 11:39:06 +08:00
parent 2d7c2145e3
commit a6f334f837
38 changed files with 364 additions and 647 deletions

View File

@ -106,7 +106,7 @@ static QString fullParentName(PStatement statement) {
return "";
}
}
void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QString &word, const QString &newWord)
void CppRefacter::renameSymbol(Editor *editor, const BufferCoord &pos, const QString &newWord)
{
if (!editor->parser()->freeze())
return;

View File

@ -34,7 +34,7 @@ public:
bool findOccurence(Editor * editor, const BufferCoord& pos);
bool findOccurence(const QString& statementFullname, SearchFileScope scope);
void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& word, const QString& newWord);
void renameSymbol(Editor* editor, const BufferCoord& pos, const QString& newWord);
private:
void doFindOccurenceInEditor(PStatement statement, Editor* editor, const PCppParser& parser);
void doFindOccurenceInProject(PStatement statement, std::shared_ptr<Project> project, const PCppParser& parser);

View File

@ -835,6 +835,8 @@ void DebugReader::processResult(const QByteArray &result)
case GDBMIResultType::UpdateVarValue:
handleUpdateVarValue(multiValues["changelist"].array());
return;
default:
return;
}
}
@ -2511,16 +2513,28 @@ void MemoryModel::updateMemory(const QStringList &value)
QList<PMemoryLine> newModel;
for (int i=0;i<value.length();i++) {
QString line = value[i].trimmed();
#if QT_VERSION_CHECK(5, 15, 0)
QStringList dataLst = line.split(delimiter,Qt::SkipEmptyParts);
#else
QStringList dataLst = line.split(delimiter,QString::SkipEmptyParts);
#endif
PMemoryLine memoryLine = std::make_shared<MemoryLine>();
memoryLine->startAddress = -1;
if (dataLst.length()>0) {
memoryLine->startAddress = stringToHex(dataLst[0],0);
for (int j=1;j<dataLst.length();j++) {
qulonglong data = stringToHex(dataLst[j],-1);
if (data>=0)
memoryLine->datas.append((unsigned char)data);
bool isOk;
memoryLine->startAddress = stringToHex(dataLst[0],isOk);
if (isOk) {
for (int j=1;j<dataLst.length();j++) {
qulonglong data = stringToHex(dataLst[j],isOk);
if (isOk)
memoryLine->datas.append((unsigned char)data);
else
memoryLine->datas.append(0);
}
} else {
memoryLine->startAddress=0;
}
}
newModel.append(memoryLine);
}
@ -2551,12 +2565,12 @@ void MemoryModel::updateMemory(const QStringList &value)
}
}
int MemoryModel::rowCount(const QModelIndex &parent) const
int MemoryModel::rowCount(const QModelIndex &/*parent*/) const
{
return mLines.count();
}
int MemoryModel::columnCount(const QModelIndex &parent) const
int MemoryModel::columnCount(const QModelIndex &/*parent*/) const
{
return mDataPerLine;
}
@ -2600,7 +2614,7 @@ bool MemoryModel::setData(const QModelIndex &index, const QVariant &value, int r
if (role == Qt::EditRole && mStartAddress>0) {
bool ok;
unsigned char val = ("0x"+value.toString()).toUInt(&ok,16);
if (!ok || val>255)
if (!ok)
return false;
emit setMemoryData(mStartAddress+mDataPerLine*index.row()+col,val);
return true;
@ -2608,7 +2622,7 @@ bool MemoryModel::setData(const QModelIndex &index, const QVariant &value, int r
return false;
}
Qt::ItemFlags MemoryModel::flags(const QModelIndex &index) const
Qt::ItemFlags MemoryModel::flags(const QModelIndex &/*index*/) const
{
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
if (mStartAddress!=0)

View File

@ -562,10 +562,6 @@ void Editor::focusOutEvent(QFocusEvent *event)
pMainWindow->functionTip()->hide();
}
static bool isSpaceOrRightParenthesis(const QChar& ch) {
return ch.isSpace() || ch==')' || ch=="]" || ch=="}";
}
void Editor::keyPressEvent(QKeyEvent *event)
{
bool handled = false;
@ -3427,7 +3423,7 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/
if (statement->kind == StatementKind::skFunction
|| statement->kind == StatementKind::skConstructor
|| statement->kind == StatementKind::skDestructor) {
PStatement parentScope = statement->parentScope.lock();
//PStatement parentScope = statement->parentScope.lock();
// if (parentScope && parentScope->kind == StatementKind::skNamespace) {
// PStatementList namespaceStatementsList =
// mParser->findNamespace(parentScope->command);
@ -3449,8 +3445,7 @@ QString Editor::getParserHint(const QStringList& expression,const QString &/*s*/
// }
// }
// } else
result = getHintForFunction(statement, parentScope,
mFilename,line);
result = getHintForFunction(statement,mFilename,line);
} else if (statement->line>0) {
QFileInfo fileInfo(statement->fileName);
result = mParser->prettyPrintStatement(statement,mFilename, line) + " - "
@ -3494,7 +3489,7 @@ QString Editor::getErrorHint(const PSyntaxIssue& issue)
}
}
QString Editor::getHintForFunction(const PStatement &statement, const PStatement &scopeStatement, const QString& filename, int line)
QString Editor::getHintForFunction(const PStatement &statement, const QString& filename, int line)
{
QFileInfo fileInfo(statement->fileName);
QString result;

View File

@ -275,7 +275,7 @@ private:
QString getParserHint(const QStringList& expression,const QString& s, int line);
void showDebugHint(const QString& s,int line);
QString getErrorHint(const PSyntaxIssue& issue);
QString getHintForFunction(const PStatement& statement, const PStatement& scope,
QString getHintForFunction(const PStatement& statement,
const QString& filename, int line);
void updateFunctionTip(bool showTip);

View File

@ -835,7 +835,7 @@ void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus)
}
}
void MainWindow::updateDPI(int oldDPI, int newDPI)
void MainWindow::updateDPI(int oldDPI, int /*newDPI*/)
{
//applySettings();
if (oldDPI<1)
@ -6436,6 +6436,8 @@ void MainWindow::on_actionRename_Symbol_triggered()
Editor * editor = mEditorList->getEditor();
if (!editor)
return;
if (!editor->parser())
return;
editor->beginUpdate();
BufferCoord oldCaretXY = editor->caretXY();
// mClassBrowserModel.beginUpdate();
@ -6446,16 +6448,12 @@ void MainWindow::on_actionRename_Symbol_triggered()
// mClassBrowserModel.EndTreeUpdate;
editor->setCursor(oldCursor);
});
QString word = editor->wordAtCursor();
if (word.isEmpty())
return;
// if (!isIdentifier(word)) {
// return;
// }
if (isCppKeyword(word)) {
return;
QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
if (expression.isEmpty() && oldCaretXY.ch>1) {
BufferCoord coord=oldCaretXY;
coord.ch--;
expression = editor->getExpressionAtPosition(coord);
}
if (editor->inProject() && mProject) {
@ -6465,13 +6463,8 @@ void MainWindow::on_actionRename_Symbol_triggered()
mProject->cppParser()->parseFile(editor->filename(), editor->inProject(), false, false);
}
}
QStringList expression = editor->getExpressionAtPosition(oldCaretXY);
if (expression.isEmpty() && oldCaretXY.ch>1) {
BufferCoord coord=oldCaretXY;
coord.ch--;
expression = editor->getExpressionAtPosition(coord);
}
// Find it's definition
// Find it's definition
PStatement oldStatement = editor->parser()->findStatementOf(
editor->filename(),
expression,
@ -6496,6 +6489,19 @@ void MainWindow::on_actionRename_Symbol_triggered()
return;
}
}
//not in project
PStatement oldStatement = editor->parser()->findStatementOf(
editor->filename(),
expression,
oldCaretXY.line);
if (!oldStatement)
return;
QString word = oldStatement->command;
if (word.isEmpty())
return;
if (isCppKeyword(word)) {
return;
}
bool ok;
QString newWord = QInputDialog::getText(editor,
@ -6515,7 +6521,7 @@ void MainWindow::on_actionRename_Symbol_triggered()
}
CppRefacter refactor;
refactor.renameSymbol(editor,oldCaretXY,word,newWord);
refactor.renameSymbol(editor,oldCaretXY,newWord);
editor->reparse();
}

View File

@ -208,7 +208,11 @@ void CppPreprocessor::dumpDefinesTo(const QString &fileName) const
stream<<QString("%1 %2 %3 %4 %5\n")
.arg(define->name,define->args,define->value)
.arg(define->hardCoded).arg(define->formatValue)
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}
}
@ -219,28 +223,83 @@ void CppPreprocessor::dumpIncludesListTo(const QString &fileName) const
if (file.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
QTextStream stream(&file);
for (const PFileIncludes& fileIncludes:mIncludesList) {
stream<<fileIncludes->baseFile<<" : "<<endl;
stream<<"\t**includes:**"<<endl;
stream<<fileIncludes->baseFile<<" : "
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
stream<<"\t**includes:**"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
foreach (const QString& s,fileIncludes->includeFiles.keys()) {
stream<<"\t--"+s<<endl;
stream<<"\t--"+s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
stream<<"\t**depends on:**"<<endl;
stream<<"\t**depends on:**"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
foreach (const QString& s,fileIncludes->dependingFiles) {
stream<<"\t^^"+s<<endl;
stream<<"\t^^"+s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
stream<<"\t**depended by:**"<<endl;
stream<<"\t**depended by:**"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
foreach (const QString& s,fileIncludes->dependedFiles) {
stream<<"\t&&"+s<<endl;
stream<<"\t&&"+s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
stream<<"\t**using:**"<<endl;
stream<<"\t**using:**"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
foreach (const QString& s,fileIncludes->usings) {
stream<<"\t++"+s<<endl;
stream<<"\t++"+s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
stream<<"\t**statements:**"<<endl;
stream<<"\t**statements:**"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
foreach (const PStatement& statement,fileIncludes->statements) {
if (statement) {
stream<<QString("\t**%1 , %2")
.arg(statement->command,statement->fullName)<<endl;
.arg(statement->command,statement->fullName)
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}
}

View File

@ -67,7 +67,12 @@ void CppTokenizer::dumpTokens(const QString &fileName)
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QTextStream stream(&file);
foreach (const PToken& token,mTokenList) {
stream<<QString("%1,%2").arg(token->line).arg(token->text)<<endl;
stream<<QString("%1,%2").arg(token->line).arg(token->text)
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}
}

View File

@ -146,11 +146,27 @@ void StatementModel::dumpStatementMap(StatementMap &map, QTextStream &out, int l
.arg(statement->line)
.arg(statement->definitionFileName)
.arg(statement->definitionLine);
out<<endl;
out
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
if (statement->children.isEmpty())
continue;
out<<indent<<statement->command<<" {"<<endl;
out<<indent<<statement->command<<" {"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
dumpStatementMap(statement->children,out,level+1);
out<<indent<<"}"<<endl;
out<<indent<<"}"
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}

View File

@ -634,7 +634,7 @@ bool Project::saveUnits()
return true;
}
void Project::saveAsTemplate(const QString &filename,
void Project::saveAsTemplate(const QString &/*filename*/,
const QString &name,
const QString &description,
const QString &category)
@ -1289,7 +1289,13 @@ void Project::checkProjectFileForUpdate(SimpleIni &ini)
if (!oldRes.isEmpty()) {
QFile::copy(mFilename,mFilename+".bak");
QStringList sl;
sl = oldRes.split(';',QString::SkipEmptyParts);
sl = oldRes.split(';',
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
for (int i=0;i<sl.count();i++){
const QString& s = sl[i];
QByteArray groupName = toByteArray(QString("Unit%1").arg(uCount+i));
@ -1524,7 +1530,13 @@ void Project::loadLayout()
int topLeft = layIni.GetLongValue("Editors","Focused",1);
//TopRight := layIni.ReadInteger('Editors', 'FocusedRight', -1);
QString temp =layIni.GetValue("Editors","Order", "");
QStringList sl = temp.split(",",QString::SkipEmptyParts);
QStringList sl = temp.split(",",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
foreach (const QString& s,sl) {
bool ok;
@ -1565,13 +1577,49 @@ void Project::loadOptions(SimpleIni& ini)
mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "Compiler", ""));
mOptions.cppCompilerCmd = fromByteArray(ini.GetValue("Project", "CppCompiler", ""));
mOptions.linkerCmd = fromByteArray(ini.GetValue("Project", "Linker", ""));
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
mOptions.binDirs = fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",QString::SkipEmptyParts);
mOptions.libDirs = fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.binDirs = fromByteArray(ini.GetValue("Project", "Bins", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.libDirs = fromByteArray(ini.GetValue("Project", "Libs", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "Includes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
mOptions.makeIncludes = fromByteArray(ini.GetValue("Project", "MakeIncludes", "")).split(";",QString::SkipEmptyParts);
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.makeIncludes = fromByteArray(ini.GetValue("Project", "MakeIncludes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.isCpp = ini.GetBoolValue("Project", "IsCpp", false);
mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", ""));
mOptions.objectOutput = fromByteArray(ini.GetValue("Project", "ObjectOutput", ""));
@ -1585,13 +1633,19 @@ void Project::loadOptions(SimpleIni& ini)
mOptions.usePrecompiledHeader = ini.GetBoolValue("Project", "UsePrecompiledHeader", false);
mOptions.precompiledHeader = fromByteArray(ini.GetValue("Project", "PrecompiledHeader", ""));
mOptions.cmdLineArgs = fromByteArray(ini.GetValue("Project", "CommandLine", ""));
mFolders = fromByteArray(ini.GetValue("Project", "Folders", "")).split(";",QString::SkipEmptyParts);
mFolders = fromByteArray(ini.GetValue("Project", "Folders", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.includeVersionInfo = ini.GetBoolValue("Project", "IncludeVersionInfo", false);
mOptions.supportXPThemes = ini.GetBoolValue("Project", "SupportXPThemes", false);
mOptions.compilerSet = ini.GetLongValue("Project", "CompilerSet", pSettings->compilerSets().defaultIndex());
mOptions.modelType = (ProjectModelType)ini.GetLongValue("Project", "ModelType", (int)ProjectModelType::Custom);
if (mOptions.compilerSet >= pSettings->compilerSets().size()
if (mOptions.compilerSet >= (int)pSettings->compilerSets().size()
|| mOptions.compilerSet < 0) { // TODO: change from indices to names
QMessageBox::critical(
nullptr,
@ -1685,9 +1739,27 @@ void Project::loadOptions(SimpleIni& ini)
mOptions.type = ProjectType::GUI;
mOptions.privateResource = fromByteArray(ini.GetValue("Project", "PrivateResource", ""));
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",QString::SkipEmptyParts);
mOptions.resourceIncludes = fromByteArray(ini.GetValue("Project", "ResourceIncludes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.objFiles = fromByteArray(ini.GetValue("Project", "ObjFiles", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.includeDirs = fromByteArray(ini.GetValue("Project", "IncludeDirs", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.compilerCmd = fromByteArray(ini.GetValue("Project", "CompilerOptions", ""));
mOptions.isCpp = ini.GetBoolValue("Project", "Use_GPP", false);
mOptions.exeOutput = fromByteArray(ini.GetValue("Project", "ExeOutput", ""));
@ -2480,7 +2552,6 @@ bool ProjectModelSortFilterProxy::lessThan(const QModelIndex &source_left, const
{
if (!sourceModel())
return false;
ProjectModel* projectModel = dynamic_cast<ProjectModel*>(sourceModel());
ProjectModelNode* pLeft=nullptr;
if (source_left.isValid())
pLeft = static_cast<ProjectModelNode*>(source_left.internalPointer());

View File

@ -129,11 +129,43 @@ void ProjectTemplate::readTemplateFile(const QString &fileName)
mOptions.icon = mIni->GetValue("Project", "Icon", "");
mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
mOptions.includeDirs = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
mOptions.binDirs = fromByteArray(mIni->GetValue("Project", "Bins", "")).split(";",QString::SkipEmptyParts);
mOptions.libDirs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.includeDirs = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.binDirs = fromByteArray(mIni->GetValue("Project", "Bins", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.libDirs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",
#if QT_VERSION_CHECK(5,15,0)
Qt::SkipEmptyParts
#else
QString::SkipEmptyParts
#endif
);
mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", ""));
mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", ""));
mOptions.linkerCmd = fromByteArray(mIni->GetValue("Project", "Linker",""));

View File

@ -39,8 +39,8 @@ PSynEditFoldRegion SynEditFoldRegions::get(int index)
}
SynEditCodeFolding::SynEditCodeFolding():
fillIndents(false),
indentGuides(true),
fillIndents(false),
showCollapsedLine(true),
collapsedLineColor(QColor("black")),
folderBarLinesColor(QColor("black")),

View File

@ -26,42 +26,6 @@ int minMax(int x, int mi, int ma)
return std::max( x, mi );
}
void swapInt(int &l, int &r)
{
int tmp = r;
r = l;
l = tmp;
}
QPoint maxPoint(const QPoint &P1, const QPoint &P2)
{
if ( (P2.y() > P1.y()) || ( (P2.y() == P1.y()) && (P2.x() > P1.x())) ) {
return P2;
} else {
return P1;
}
}
QPoint minPoint(const QPoint &P1, const QPoint &P2)
{
if ( (P2.y() < P1.y()) || ( (P2.y() == P1.y()) && (P2.x() < P1.x())) ) {
return P2;
} else {
return P1;
}
}
PIntArray getIntArray(size_t Count, int InitialValue)
{
return std::make_shared<IntArray>(Count,InitialValue);
}
void internalFillRect(QPainter *painter, const QRect &rcPaint, const QColor& color)
{
painter->fillRect(rcPaint,color);
}
bool IsPowerOfTwo(int TabWidth) {
if (TabWidth<2)
return false;
@ -74,176 +38,6 @@ bool IsPowerOfTwo(int TabWidth) {
return (nW == TabWidth);
}
QString ConvertTabs1Ex(const QString &Line, int TabWidth, bool &HasTabs) {
QString Result = Line; // increment reference count only
int nBeforeTab;
if (GetHasTabs(Line, nBeforeTab)) {
QChar* pDest;
HasTabs = true;
pDest = Result.data()+nBeforeTab+1;
// this will make a copy of Line
// We have at least one tab in the string, and the tab width is 1.
// pDest points to the first tab char. We overwrite all tabs with spaces.
while (*pDest!=0) {
if (*pDest == '\t') {
*pDest = ' ';
};
pDest++;
}
} else
HasTabs = false;
return Result;
}
QString ConvertTabs1(const QString &Line, int TabWidth) {
bool HasTabs;
return ConvertTabs1Ex(Line, TabWidth, HasTabs);
}
QString ConvertTabs2nEx(const QString &Line, int TabWidth, bool &HasTabs) {
QString Result = Line; // increment reference count only
int DestLen;
if (GetHasTabs(Line, DestLen)) {
HasTabs = true;
int pSrc = 1 + DestLen;
// We have at least one tab in the string, and the tab width equals 2^n.
// pSrc points to the first tab char in Line. We get the number of tabs
// and the length of the expanded string now.
int TabCount = 0;
int TabMask = (TabWidth - 1) ^ 0x7FFFFFFF;
do {
if (Line[pSrc] == '\t') {
DestLen = (DestLen + TabWidth) & TabMask;
TabCount++;
} else
DestLen ++ ;
} while (pSrc < Line.length());
// Set the length of the expanded string.
Result.resize(DestLen);
DestLen = 0;
pSrc = 0;
QChar * pDest = Result.data();
// We use another TabMask here to get the difference to 2^n.
TabMask = TabWidth - 1;
do {
if (Line[pSrc] == '\t') {
int i = TabWidth - (DestLen & TabMask);
DestLen += i;
//This is used for both drawing and other stuff and is meant to be #9 and not #32
do {
*pDest = '\t';
pDest ++ ;
i--;
} while (i > 0);
TabCount -- ;
if (TabCount == 0) {
do {
pSrc++ ;
*pDest = Line[pSrc];
pDest++;
} while (pSrc < Line.length());
return Result;
}
} else {
*pDest = Line[pSrc];
pDest ++ ;
DestLen ++;
}
pSrc++;
} while (pSrc < Line.length());
} else
HasTabs = false;
return Result;
}
QString ConvertTabs2n(const QString &Line, int TabWidth) {
bool HasTabs;
return ConvertTabs2nEx(Line, TabWidth, HasTabs);
}
ConvertTabsProc GetBestConvertTabsProc(int TabWidth)
{
if (TabWidth < 2)
return &ConvertTabs1;
else if (IsPowerOfTwo(TabWidth))
return &ConvertTabs2n;
else
return &ConvertTabs;
}
QString ConvertTabs(const QString &Line, int TabWidth)
{
bool HasTabs;
return ConvertTabsEx(Line, TabWidth, HasTabs);
}
ConvertTabsProcEx GetBestConvertTabsProcEx(int TabWidth)
{
if (TabWidth < 2)
return &ConvertTabs1Ex;
else if (IsPowerOfTwo(TabWidth))
return &ConvertTabs2nEx;
else
return &ConvertTabsEx;
}
QString ConvertTabsEx(const QString &Line, int TabWidth, bool &HasTabs)
{
QString Result = Line; // increment reference count only
int DestLen;
int pSrc;
QChar* pDest;
if (GetHasTabs(Line, DestLen)) {
HasTabs = true;
pSrc = (DestLen+1);
// We have at least one tab in the string, and the tab width is greater
// than 1. pSrc points to the first tab char in Line. We get the number
// of tabs and the length of the expanded string now.
int TabCount = 0;
do {
if (Line[pSrc] == '\t') {
DestLen = DestLen + TabWidth - DestLen % TabWidth;
TabCount++;
} else {
DestLen ++;
}
pSrc++;
} while (pSrc<Line.length());
// Set the length of the expanded string.
Result.resize(DestLen);
DestLen = 0;
pSrc = 0;
pDest = Result.data();
do {
if (Line[pSrc] == '\t') {
int i = TabWidth - (DestLen % TabWidth);
DestLen+=i;
do {
*pDest = '\t';
pDest++;
i--;
} while (i != 0);
TabCount--;
if (TabCount == 0) {
do {
pSrc++;
*pDest = Line[pSrc];
pDest++;
} while (pSrc<Line.length());
return Result;
}
} else {
*pDest = Line[pSrc];
pDest++;
DestLen++;
}
pSrc++;
} while (pSrc<Line.length());
} else
HasTabs = false;
return Result;
}
bool GetHasTabs(const QString &line, int &CharsBefore)
{
@ -261,118 +55,7 @@ bool GetHasTabs(const QString &line, int &CharsBefore)
return result;
}
int GetExpandedLength(const QString &aStr, int aTabWidth)
{
int Result = 0;
for (const QChar& ch : aStr) {
if (ch == '\t') {
Result += aTabWidth - (Result % aTabWidth);
} else {
Result ++;
}
}
return Result;
}
int CharIndex2CaretPos(int Index, int TabWidth, const QString &Line)
{
int Result;
int iChar;
if (Index > 1) {
if ((TabWidth <= 1) || !GetHasTabs(Line, iChar) ) {
Result = Index;
} else {
if (iChar + 1 >= Index) {
Result = Index;
} else {
// iChar is number of chars before first Tab
Result = iChar;
// Index is *not* zero-based
iChar++;
Index -= iChar;
int pNext = iChar;
while (Index > 0) {
if (pNext>=Line.length()) {
Result += Index;
break;
}
if (Line[pNext] == '\t') {
Result += TabWidth;
Result -= Result % TabWidth;
} else
Result++;
Index--;
pNext++;
}
// done with zero-based computation
Result++;
}
}
} else
Result = 1;
return Result;
}
int CaretPos2CharIndex(int Position, int TabWidth, const QString &Line, bool &InsideTabChar)
{
int Result;
int iPos;
InsideTabChar = false;
if (Position > 1) {
if ( (TabWidth <= 1) || !GetHasTabs(Line, iPos) ) {
Result = Position;
} else {
if (iPos + 1 >= Position) {
Result = Position;
} else {
// iPos is number of chars before first #9
Result = iPos + 1;
int pNext = Result;
// for easier computation go zero-based (mod-operation)
Position -=1;
while (iPos < Position) {
if (pNext>=Line.length())
break;
if (Line[pNext] == '\t') {
iPos+=TabWidth;
iPos-=iPos % TabWidth;
if (iPos > Position) {
InsideTabChar = true;
break;
}
} else
iPos++;
Result++;
pNext++;
}
}
}
} else
Result = Position;
return Result;
}
int StrScanForCharInSet(const QString &Line, int Start, const QSet<QChar>& AChars)
{
for (int i=Start;i<Line.length();i++) {
if (AChars.contains(Line[i])) {
return i;
}
}
return -1;
}
int StrRScanForCharInSet(const QString &Line, int Start, const QSet<QChar> &AChars)
{
for (int i=Line.size()-1;i>=Start;i--) {
if (AChars.contains(Line[i])) {
return i;
}
}
return -1;
}
int GetEOL(const QString &Line, int start)
int getEOL(const QString &Line, int start)
{
if (start<0 || start>=Line.size()) {
return start;
@ -385,57 +68,6 @@ int GetEOL(const QString &Line, int start)
return Line.size();
}
QString EncodeString(const QString &s)
{
QString Result;
Result.resize(s.length()*2); // worst case
int j=0;
for (const QChar& ch: s) {
if (ch == '\\' ) {
Result[j] = '\\';
Result[j+1] = '\\';
j+=2;
} else if (ch == '/') {
Result[j] = '\\';
Result[j+1] = '.';
j+=2;
} else {
Result[j]=ch;
j+=1;
}
}
Result.resize(j);
return Result;
}
QString DecodeString(const QString &s)
{
QString Result;
Result.resize(s.length()); // worst case
int j = 0;
int i = 0;
while (i < s.length()) {
if (i<s.length()-1 && s[i] == '\\' ) {
if (s[i+1] == '\\') {
Result[j]= '\\';
i+=2;
j+=1;
continue;
} else if (s[i+1] == '.') {
Result[j]= '/';
i+=2;
j+=1;
continue;
}
}
Result[j] = Result[i];
i+=1;
j+=1;
}
Result.resize(j);
return Result;
}
bool InternalEnumHighlighterAttris(PSynHighlighter Highlighter,
bool SkipDuplicates,
HighlighterAttriProc highlighterAttriProc,
@ -464,7 +96,7 @@ bool InternalEnumHighlighterAttris(PSynHighlighter Highlighter,
return Result;
}
bool EnumHighlighterAttris(PSynHighlighter Highlighter, bool SkipDuplicates,
bool enumHighlighterAttributes(PSynHighlighter Highlighter, bool SkipDuplicates,
HighlighterAttriProc highlighterAttriProc,
std::initializer_list<void *> Params)
{
@ -477,71 +109,6 @@ bool EnumHighlighterAttris(PSynHighlighter Highlighter, bool SkipDuplicates,
highlighterAttriProc, Params, HighlighterList);
}
uint16_t fcstab[] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};
uint16_t CalcFCS(unsigned char *ABuf, int ABufSize)
{
uint16_t CurFCS = 0xffff;
unsigned char* P = ABuf;
while (ABufSize>0) {
CurFCS = (CurFCS >> 8) ^ fcstab[(CurFCS ^ *P) & 0xff];
ABufSize -- ;
P ++ ;
}
return CurFCS;
}
void SynDrawGradient(QPaintDevice *ACanvas, const QColor &AStartColor, const QColor &AEndColor, int , const QRect &ARect, bool AHorizontal)
{
QPainter painter(ACanvas);
if (AHorizontal) {
int Size = ARect.right() - ARect.left();
QLinearGradient gradient(0,0,Size,0);
gradient.setColorAt(0,AStartColor);
gradient.setColorAt(1,AEndColor);
painter.fillRect(ARect,gradient);
} else {
int Size = ARect.bottom() - ARect.top();
QLinearGradient gradient(0,0,0,Size);
gradient.setColorAt(0,AStartColor);
gradient.setColorAt(1,AEndColor);
painter.fillRect(ARect,gradient);
}
}
int mulDiv(int a, int b, int c)
{
//todo: handle overflow?
@ -562,7 +129,7 @@ bool isWordChar(const QChar& ch) {
return (ch == '_') || ch.isLetterOrNumber();
}
int StrScanForWordChar(const QString &s, int startPos)
int findWordChar(const QString &s, int startPos)
{
for (int i=startPos-1;i<s.length();i++) {
if (isWordChar(s[i])) {
@ -572,7 +139,7 @@ int StrScanForWordChar(const QString &s, int startPos)
return 0;
}
int StrScanForNonWordChar(const QString &s, int startPos)
int findNonWordChar(const QString &s, int startPos)
{
for (int i=startPos-1;i<s.length();i++) {
if (!isWordChar(s[i])) {
@ -582,7 +149,7 @@ int StrScanForNonWordChar(const QString &s, int startPos)
return 0;
}
int StrRScanForWordChar(const QString &s, int startPos)
int findLastWordChar(const QString &s, int startPos)
{
int i = startPos-1;
while (i>=0) {
@ -593,7 +160,7 @@ int StrRScanForWordChar(const QString &s, int startPos)
return 0;
}
int StrRScanForNonWordChar(const QString &s, int startPos)
int findLastNonWordChar(const QString &s, int startPos)
{
int i = startPos-1;
while (i>=0) {
@ -604,21 +171,6 @@ int StrRScanForNonWordChar(const QString &s, int startPos)
return 0;
}
int CountLines(const QString &Line, int start)
{
int Result = 0;
int i=start;
while (i<Line.length()) {
if (Line[i]=='\r')
i++;
if (Line[i]=='\n')
i++;
Result ++ ;
i = GetEOL(Line,i);
}
return Result;
}
void ensureNotAfter(BufferCoord &cord1, BufferCoord &cord2)
{
if((cord1.line > cord2.line) || (

View File

@ -33,65 +33,17 @@ class QPainter;
class QRect;
class QColor;
using IntArray = QVector<int>;
using PIntArray = std::shared_ptr<IntArray>;
int minMax(int x, int mi, int ma);
int mulDiv(int a, int b, int c);
void swapInt(int& l, int &r);
BufferCoord maxBufferCoord(const BufferCoord& P1, const BufferCoord& P2);
BufferCoord minBufferCoord(const BufferCoord& P1, const BufferCoord& P2);
QPoint maxPoint(const QPoint& P1, const QPoint& P2);
QPoint minPoint(const QPoint& P1, const QPoint& P2);
PIntArray getIntArray(size_t Count, int InitialValue);
void internalFillRect(QPainter* painter, const QRect& rcPaint, const QColor& color);
// Converting tabs to spaces: To use the function several times it's better
// to use a function pointer that is set to the fastest conversion function.
using ConvertTabsProc = std::function<QString(const QString&, int)>;
ConvertTabsProc GetBestConvertTabsProc(int TabWidth);
// This is the slowest conversion function which can handle TabWidth <> 2^n.
QString ConvertTabs(const QString& Line, int TabWidth);
using ConvertTabsProcEx = std::function<QString(const QString&, int, bool& )>;
ConvertTabsProcEx GetBestConvertTabsProcEx(int TabWidth);
// This is the slowest conversion function which can handle TabWidth <> 2^n.
QString ConvertTabsEx(const QString& Line, int TabWidth, bool& HasTabs);
bool GetHasTabs(const QString& line, int& CharsBefore);
int GetExpandedLength(const QString& aStr, int aTabWidth);
int CharIndex2CaretPos(int Index, int TabWidth,
const QString& Line);
int CaretPos2CharIndex(int Position, int TabWidth, const QString& Line,
bool& InsideTabChar);
// search for the first char of set AChars in Line, starting at index Start
int StrScanForCharInSet(const QString& Line, int Start, const QSet<QChar>& AChars);
// the same, but searching backwards
int StrRScanForCharInSet(const QString& Line, int Start, const QSet<QChar>& AChars);
int GetEOL(const QString& Line, int start);
int CountLines(const QString& Line, int start);
int getEOL(const QString& Line, int start);
QStringList splitStrings(const QString& text);
int calSpanLines(const BufferCoord& startPos, const BufferCoord& endPos);
// Remove all '/' characters from string by changing them into '\.'.
// Change all '\' characters into '\\' to allow for unique decoding.
QString EncodeString(const QString & s);
// Decodes string, encoded with EncodeString.
QString DecodeString(const QString& s);
using HighlighterAttriProc = std::function<bool(PSynHighlighter Highlighter,
PSynHighlighterAttribute Attri, const QString& UniqueAttriName,
QList<void *> Params)>;
@ -99,17 +51,10 @@ using HighlighterAttriProc = std::function<bool(PSynHighlighter Highlighter,
// Enums all child highlighters and their attributes of a TSynMultiSyn through a
// callback function.
// This function also handles nested TSynMultiSyns including their MarkerAttri.
bool EnumHighlighterAttris(PSynHighlighter Highlighter,
bool enumHighlighterAttributes(PSynHighlighter Highlighter,
bool SkipDuplicates, HighlighterAttriProc highlighterAttriProc,
std::initializer_list<void *> Params);
// Calculates Frame Check Sequence (FCS) 16-bit Checksum (as defined in RFC 1171)
uint16_t CalcFCS(unsigned char* ABuf, int ABufSize);
void SynDrawGradient(QPaintDevice* ACanvas, const QColor& AStartColor, const QColor& AEndColor,
int ASteps, const QRect& ARect, bool AHorizontal);
SynFontStyles getFontStyles(const QFont& font);
/**
@ -117,28 +62,28 @@ SynFontStyles getFontStyles(const QFont& font);
* Note: the index of first char in s in 1
* @return index of the char founded , 0 if not found
*/
int StrScanForWordChar(const QString& s, int startPos);
int findWordChar(const QString& s, int startPos);
/**
* Find the first occurency of non word char in s, starting from startPos
* Note: the index of first char in s in 1
* @return index of the char founded , 0 if not found
*/
int StrScanForNonWordChar(const QString& s, int startPos);
int findNonWordChar(const QString& s, int startPos);
/**
* Find the first occurency of word char in s right to left, starting from startPos
* Note: the index of first char in s in 1
* @return index of the char founded , 0 if not found
*/
int StrRScanForWordChar(const QString& s, int startPos);
int findLastWordChar(const QString& s, int startPos);
/**
* Find the first occurency of non word char in s right to left, starting from startPos
* Note: the index of first char in s in 1
* @return index of the char founded , 0 if not found
*/
int StrRScanForNonWordChar(const QString& s, int startPos);
int findLastNonWordChar(const QString& s, int startPos);
void ensureNotAfter(BufferCoord& cord1, BufferCoord& cord2);

View File

@ -1083,7 +1083,7 @@ bool SynEdit::colSelAvail() const
return false;
if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line)
return false;
if (mBlockBegin.line == mBlockEnd.line && mBlockBegin.ch!=mBlockBegin.ch)
if (mBlockBegin.line == mBlockEnd.line && mBlockBegin.ch!=mBlockEnd.ch)
return true;
DisplayCoord coordBegin = bufferToDisplayPos(mBlockBegin);
DisplayCoord coordEnd = bufferToDisplayPos(mBlockEnd);
@ -1398,23 +1398,23 @@ BufferCoord SynEdit::nextWordPosEx(const BufferCoord &XY)
if (CY < mDocument->count()) {
Line = mDocument->getString(CY);
CY++;
CX=StrScanForWordChar(Line,1);
CX=findWordChar(Line,1);
if (CX==0)
CX=1;
}
} else {
// find next "whitespace" if current char is an IdentChar
if (!Line[CX-1].isSpace())
CX = StrScanForNonWordChar(Line,CX);
CX = findNonWordChar(Line,CX);
// if "whitespace" found, find the next IdentChar
if (CX > 0)
CX = StrScanForWordChar(Line, CX);
CX = findWordChar(Line, CX);
// if one of those failed position at the begin of next line
if (CX == 0) {
if (CY < mDocument->count()) {
Line = mDocument->getString(CY);
CY++;
CX=StrScanForWordChar(Line,1);
CX=findWordChar(Line,1);
if (CX==0)
CX=1;
} else {
@ -1441,7 +1441,7 @@ BufferCoord SynEdit::wordStartEx(const BufferCoord &XY)
CX = std::min(CX, Line.length()+1);
if (CX > 1) {
if (isWordChar(Line[CX - 2]))
CX = StrRScanForNonWordChar(Line, CX - 1) + 1;
CX = findLastNonWordChar(Line, CX - 1) + 1;
}
}
return BufferCoord{CX,CY};
@ -1461,7 +1461,7 @@ BufferCoord SynEdit::wordEndEx(const BufferCoord &XY)
QString Line = mDocument->getString(CY - 1);
if (CX <= Line.length() && CX-1>=0) {
if (isWordChar(Line[CX - 1]))
CX = StrScanForNonWordChar(Line, CX);
CX = findNonWordChar(Line, CX);
if (CX == 0)
CX = Line.length() + 1;
}
@ -1487,20 +1487,20 @@ BufferCoord SynEdit::prevWordPosEx(const BufferCoord &XY)
if (CY > 1) {
CY -- ;
Line = mDocument->getString(CY - 1);
CX = StrRScanForWordChar(Line, Line.length())+1;
CX = findLastWordChar(Line, Line.length())+1;
}
} else {
// if previous char is a "whitespace" search for the last IdentChar
if (!isWordChar(Line[CX - 2]))
CX = StrRScanForWordChar(Line, CX - 1);
CX = findLastWordChar(Line, CX - 1);
if (CX > 0) // search for the first IdentChar of this "word"
CX = StrRScanForNonWordChar(Line, CX - 1)+1;
CX = findLastNonWordChar(Line, CX - 1)+1;
if (CX == 0) {
// find last IdentChar in the previous line
if (CY > 1) {
CY -- ;
Line = mDocument->getString(CY - 1);
CX = StrRScanForWordChar(Line, Line.length())+1;
CX = findLastWordChar(Line, Line.length())+1;
} else {
CX = 1;
}
@ -2539,15 +2539,12 @@ void SynEdit::doTabKey()
setSelectedTextEmpty();
}
QString Spaces;
int NewCaretX = 0;
if (mOptions.testFlag(eoTabsToSpaces)) {
int cols = charToColumn(mCaretY,mCaretX);
i = tabWidth() - (cols) % tabWidth();
Spaces = QString(i,' ');
NewCaretX = mCaretX + i;
} else {
Spaces = '\t';
NewCaretX = mCaretX + 1;
}
setSelTextPrimitive(QStringList(Spaces));
}
@ -2701,7 +2698,6 @@ void SynEdit::computeCaret()
int X=iMousePos.x();
int Y=iMousePos.y();
BufferCoord oldCaret = caretXY();
DisplayCoord vCaretNearestPos = pixelsToNearestRowColumn(X, Y);
vCaretNearestPos.Row = minMax(vCaretNearestPos.Row, 1, displayLineCount());
setInternalDisplayXY(vCaretNearestPos);
@ -2806,7 +2802,7 @@ void SynEdit::doBlockIndent()
insertionPos.ch = std::min(BB.ch, BE.ch);
else
insertionPos.ch = 1;
insertBlock(insertionPos, insertionPos, strToInsert);
insertBlock(insertionPos, strToInsert);
//adjust caret and selection
oldCaretPos.ch = x;
if (BB.ch > 1)
@ -3247,7 +3243,7 @@ void SynEdit::doOnStatusChange(SynStatusChanges)
mStatusChanges = SynStatusChange::scNone;
}
void SynEdit::insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText)
void SynEdit::insertBlock(const BufferCoord& startPos, const QStringList& blockText)
{
setCaretAndSelection(startPos, startPos, startPos);
setSelTextPrimitiveEx(SynSelectionMode::Column, blockText);

View File

@ -506,7 +506,7 @@ private:
void internalSetCaretY(int Value);
void setStatusChanged(SynStatusChanges changes);
void doOnStatusChange(SynStatusChanges changes);
void insertBlock(const BufferCoord& startPos, const BufferCoord& endPos, const QStringList& blockText);
void insertBlock(const BufferCoord& startPos, const QStringList& blockText);
void updateScrollbars();
void updateCaret();
void recalcCharExtent();

View File

@ -29,8 +29,8 @@
SynDocument::SynDocument(const QFont& font, QObject *parent):
QObject(parent),
mTabWidth(4),
mFontMetrics(font),
mTabWidth(4),
mMutex(QMutex::Recursive)
{
@ -157,7 +157,7 @@ SynRangeState SynDocument::ranges(int Index)
} else {
ListIndexOutOfBounds(Index);
}
return {0};
return SynRangeState();
}
void SynDocument::insertItem(int Index, const QString &s)
@ -827,7 +827,7 @@ void SynDocument::invalidAllLineColumns()
SynDocumentLine::SynDocumentLine():
fString(),
fObject(nullptr),
fRange{0,0,0,0,0},
fRange(),
fColumns(-1)
{
}

View File

@ -693,7 +693,6 @@ void SynEditTextPainter::PaintFoldAttributes()
int indentLevel = braceLevel ;
if (edit->tabWidth()>0)
indentLevel = LineIndent / edit->tabWidth();
int levelDiff = std::max(0,braceLevel - indentLevel);
// Step horizontal coord
//TabSteps = edit->mTabWidth;
TabSteps = 0;

View File

@ -79,7 +79,7 @@ QString SynHTMLExporter::ColorToHTML(const QColor &AColor)
QString SynHTMLExporter::GetStyleName(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri)
{
QString result;
EnumHighlighterAttris(Highlighter,false,
enumHighlighterAttributes(Highlighter,false,
std::bind(
&SynHTMLExporter::StyleNameCallback,this,
std::placeholders::_1, std::placeholders::_2,
@ -161,7 +161,7 @@ QString SynHTMLExporter::GetHeader()
{
using namespace std::placeholders;
QString Styles;
EnumHighlighterAttris(mHighlighter, true,
enumHighlighterAttributes(mHighlighter, true,
std::bind(&SynHTMLExporter::AttriToCSSCallback,
this, _1, _2, _3, _4),
{&Styles});

View File

@ -377,19 +377,19 @@ bool SynEditASMHighlighter::getTokenFinished() const
return true;
}
bool SynEditASMHighlighter::isLastLineCommentNotFinished(int state) const
bool SynEditASMHighlighter::isLastLineCommentNotFinished(int /*state*/) const
{
return true;
}
bool SynEditASMHighlighter::isLastLineStringNotFinished(int state) const
bool SynEditASMHighlighter::isLastLineStringNotFinished(int /*state*/) const
{
return true;
}
SynRangeState SynEditASMHighlighter::getRangeState() const
{
return {0,0,0,0,0};
return SynRangeState();
}
void SynEditASMHighlighter::setState(const SynRangeState&)

View File

@ -249,3 +249,14 @@ int SynRangeState::getLastIndent()
return -1;
return indents.back();
}
SynRangeState::SynRangeState():
state(0),
braceLevel(0),
bracketLevel(0),
parenthesisLevel(0),
leftBraces(0),
rightBraces(0),
firstIndentThisLine(0)
{
}

View File

@ -48,6 +48,7 @@ struct SynRangeState {
(need by auto indent) */
bool operator==(const SynRangeState& s2);
int getLastIndent();
SynRangeState();
};
typedef int SynTokenKind;

View File

@ -1487,6 +1487,7 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder):
}
Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
mFullLoaded(set.mFullLoaded),
mCCompiler(set.mCCompiler),
mCppCompiler(set.mCppCompiler),
mMake(set.mMake),
@ -1509,8 +1510,7 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
mCustomCompileParams(set.mCustomCompileParams),
mCustomLinkParams(set.mCustomLinkParams),
mAutoAddCharsetParams(set.mAutoAddCharsetParams),
mCompileOptions(set.mCompileOptions),
mFullLoaded(set.mFullLoaded)
mCompileOptions(set.mCompileOptions)
{
}
@ -2493,7 +2493,7 @@ void Settings::CompilerSets::saveSets()
for (size_t i=0;i<mList.size();i++) {
saveSet(i);
}
if (mDefaultIndex>=mList.size()) {
if (mDefaultIndex>=(int)mList.size()) {
mDefaultIndex = mList.size()-1;
}
mSettings->mSettings.beginGroup(SETTING_COMPILTER_SETS);
@ -2538,7 +2538,7 @@ void Settings::CompilerSets::loadSets()
return;
}
findSets();
if ( mList.size() <= mDefaultIndex)
if ( (int)mList.size() <= mDefaultIndex)
mDefaultIndex = mList.size()-1;
pCurrentSet = defaultSet();
if (!pCurrentSet) {
@ -2601,7 +2601,7 @@ void Settings::CompilerSets::deleteSet(int index)
mSettings->mSettings.endGroup();
}
mList.erase(std::begin(mList)+index);
if (mDefaultIndex>=mList.size()) {
if (mDefaultIndex>=(int)mList.size()) {
mDefaultIndex = mList.size()-1;
}
saveSets();
@ -2629,7 +2629,7 @@ Settings::PCompilerSet Settings::CompilerSets::defaultSet()
Settings::PCompilerSet Settings::CompilerSets::getSet(int index)
{
if (index>=0 && index<mList.size()) {
if (index>=0 && index<(int)mList.size()) {
return mList[index];
}
return PCompilerSet();

View File

@ -78,7 +78,7 @@ void CompilerSetDirectoriesWidget::on_btnAdd_pressed()
}
}
void CompilerSetDirectoriesWidget::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void CompilerSetDirectoriesWidget::selectionChanged(const QItemSelection &selected, const QItemSelection &/*deselected*/)
{
ui->btnDelete->setEnabled(!selected.isEmpty());
}

View File

@ -132,7 +132,7 @@ void CompilerSetOptionWidget::doLoad()
ui->btnRemoveCompilerSet->setEnabled(true);
}
int index=pSettings->compilerSets().defaultIndex();
for (int i=0;i<pSettings->compilerSets().size();i++) {
for (size_t i=0;i<pSettings->compilerSets().size();i++) {
ui->cbCompilerSet->addItem(pSettings->compilerSets().getSet(i)->name());
}
if (index < 0 || index>=ui->cbCompilerSet->count()) {
@ -289,7 +289,7 @@ void CompilerSetOptionWidget::updateIcons()
pIconsManager->setIcon(ui->btnChooseResourceCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
}
void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &arg1)
void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/)
{
QString userData = ui->cbEncoding->currentData().toString();
if (userData == ENCODING_AUTO_DETECT
@ -308,7 +308,7 @@ void CompilerSetOptionWidget::on_cbEncoding_currentTextChanged(const QString &ar
}
void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QString &arg1)
void CompilerSetOptionWidget::on_cbEncodingDetails_currentTextChanged(const QString &/*arg1*/)
{
}

View File

@ -68,7 +68,7 @@ void ExecutorGeneralWidget::on_btnBrowse_clicked()
}
}
void ExecutorGeneralWidget::updateIcons(const QSize &size)
void ExecutorGeneralWidget::updateIcons(const QSize &/*size*/)
{
pIconsManager->setIcon(ui->btnBrowse,IconsManager::ACTION_FILE_OPEN_FOLDER);
}

View File

@ -120,7 +120,7 @@ void ProjectCompilerWidget::on_cbCompilerSet_currentIndexChanged(int)
refreshOptions();
}
void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &arg1)
void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &/*arg1*/)
{
QString userData = ui->cbEncoding->currentData().toString();
if (userData == ENCODING_AUTO_DETECT
@ -139,7 +139,7 @@ void ProjectCompilerWidget::on_cbEncoding_currentTextChanged(const QString &arg1
}
void ProjectCompilerWidget::on_cbEncodingDetails_currentTextChanged(const QString &arg1)
void ProjectCompilerWidget::on_cbEncodingDetails_currentTextChanged(const QString &/*arg1*/)
{
}

View File

@ -105,7 +105,11 @@ void ProjectGeneralWidget::doSave()
project->options().isCpp = ui->cbDefaultCpp->isChecked();
project->options().supportXPThemes = ui->cbSupportXPTheme->isChecked();
if (mIconPath.isEmpty()
#if QT_VERSION_CHECK(5,15,0)
|| !ui->lbIcon->pixmap(Qt::ReturnByValue).isNull()) {
#else
|| !ui->lbIcon->pixmap() || ui->lbIcon->pixmap()->isNull()) {
#endif
project->options().icon = "";
} else {
QString iconPath = QFileInfo(project->filename()).absoluteDir().absoluteFilePath("app.ico");
@ -120,7 +124,11 @@ void ProjectGeneralWidget::doSave()
}
}
if (!mIconPath.endsWith(".ico",PATH_SENSITIVITY) && QImageWriter::supportedImageFormats().contains("ico")) {
#if QT_VERSION_CHECK(5,15,0)
ui->lbIcon->pixmap(Qt::ReturnByValue).save(iconPath,"ico");
#else
ui->lbIcon->pixmap()->save(iconPath,"ico");
#endif
} else
QFile::copy(mIconPath, iconPath);
project->options().icon = iconPath;

View File

@ -34,8 +34,8 @@
SettingsWidget::SettingsWidget(const QString &name, const QString &group, QWidget *parent):
QWidget(parent),
mSettingsChanged(false),
mName(name),
mGroup(group)
mGroup(group),
mName(name)
{
}

View File

@ -33,7 +33,7 @@ void ToolsGitWidget::doSave()
pMainWindow->applySettings();
}
void ToolsGitWidget::updateIcons(const QSize &size)
void ToolsGitWidget::updateIcons(const QSize &/*size*/)
{
pIconsManager->setIcon(ui->btnBrowseGit,IconsManager::ACTION_FILE_OPEN_FOLDER);
}

View File

@ -596,7 +596,12 @@ void stringsToFile(const QStringList &list, const QString &fileName)
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QTextStream stream(&file);
for (QString s:list) {
stream<<s<<endl;
stream<<s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}
}
@ -703,7 +708,12 @@ void logToFile(const QString &s, const QString &filename, bool append)
}
if (file.open(mode)) {
QTextStream ts(&file);
ts<<s<<endl;
ts<<s
#if QT_VERSION_CHECK(5,15,0)
<<Qt::endl;
#else
<<endl;
#endif
}
}
@ -1101,13 +1111,10 @@ int screenDPI()
return defaultScreenDPI;
}
qulonglong stringToHex(const QString &str, qulonglong defaultValue)
qulonglong stringToHex(const QString &str, bool &isOk)
{
bool isOk;
qulonglong value = str.toULongLong(&isOk,16);
if (isOk)
return value;
return defaultValue;
return value;
}
void setScreenDPI(int dpi)

View File

@ -197,7 +197,7 @@ bool stringIsBlank(const QString& s);
int compareFileModifiedTime(const QString& filename1, const QString& filename2);
QByteArray getHTTPBody(const QByteArray& content);
bool haveGoodContrast(const QColor& c1, const QColor &c2);
qulonglong stringToHex(const QString& str, qulonglong defaultValue = 0);
qulonglong stringToHex(const QString& str, bool &isOk);
//void changeTheme(const QString& themeName);

View File

@ -40,12 +40,12 @@ GitLogModel::~GitLogModel()
GitLogModel_CacheManager.remove(this);
}
int GitLogModel::rowCount(const QModelIndex &parent) const
int GitLogModel::rowCount(const QModelIndex &/*parent*/) const
{
return mCount;
}
int GitLogModel::columnCount(const QModelIndex &parent) const
int GitLogModel::columnCount(const QModelIndex &/*parent*/) const
{
return 3;
}

View File

@ -53,7 +53,7 @@ void CodeCompletionListView::focusInEvent(QFocusEvent *)
}
}
void CodeCompletionListView::mouseDoubleClickEvent(QMouseEvent *event)
void CodeCompletionListView::mouseDoubleClickEvent(QMouseEvent */*event*/)
{
QKeyEvent keyEvent(QKeyEvent::Type::KeyPress,Qt::Key_Tab,Qt::KeyboardModifier::NoModifier,
"\t");

View File

@ -38,7 +38,7 @@ MacroInfoModel::MacroInfoModel(QObject *parent) : QAbstractListModel(parent)
addMacroInfo("<PROJECTPATH>", tr("Path to the current project's folder"));
}
int MacroInfoModel::rowCount(const QModelIndex &parent) const
int MacroInfoModel::rowCount(const QModelIndex &/*parent*/) const
{
return mMacroInfos.count();
}

View File

@ -72,7 +72,7 @@ void NewClassDialog::on_btnCancel_clicked()
this->reject();
}
void NewClassDialog::closeEvent(QCloseEvent *event)
void NewClassDialog::closeEvent(QCloseEvent */*event*/)
{
this->reject();
}

View File

@ -444,7 +444,7 @@ Qt::ItemFlags OJProblemModel::flags(const QModelIndex &idx) const
return flags;
}
int OJProblemModel::columnCount(const QModelIndex &parent) const
int OJProblemModel::columnCount(const QModelIndex &/*parent*/) const
{
return 2;
}

View File

@ -126,7 +126,7 @@
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<widget class="QWidget" name="widget_31" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>