- 功能增强:输入'('时,如果下一个非空白字符是'('或者标识符/数字,则不自动补全

- 功能增强:如果项目文件和项目的编码相同,则不保存它的编码信息
 - 修正:在保存文件时,会错误的使用缺省编码而不是文件原有的编码进行保存
This commit is contained in:
Roy Qu 2022-04-13 16:42:23 +08:00
parent d3c780a3a5
commit ca0ad3249f
5 changed files with 33 additions and 7 deletions

View File

@ -3,6 +3,9 @@ Red Panda C++ Version 1.0.4
- enhancement: add help link for regular expression in search dialog
- enhancement: remember current problem set's filename
- enhancement: F1 shorcut opens offcial website
- enhancement: don't auto complete '(', if the next non-space char is neither '(' nor ident char
- enhancement: if a project's unit encoding is the same with project's encoding, don't save its encoding
- fix: files will be saved to default encoding inspite of its original encoding
Red Panda C++ Version 1.0.3
- fix: when oj problem grabbed by competitive companion received,

View File

@ -228,7 +228,10 @@ void Editor::loadFile(QString filename) {
void Editor::saveFile(QString filename) {
QFile file(filename);
this->lines()->saveToFile(file,mEncodingOption,
QByteArray encoding = mFileEncoding;
if (mFileEncoding==ENCODING_ASCII)
encoding = mEncodingOption;
this->lines()->saveToFile(file,encoding,
pSettings->editor().defaultEncoding(),
mFileEncoding);
emit fileSaved(filename, mInProject);
@ -797,13 +800,14 @@ void Editor::keyPressEvent(QKeyEvent *event)
case '*':
handled = handleSymbolCompletion(ch);
return;
case '(':
if (caretX()-1>=lineText().length()
|| caretX()<=0
|| isSpaceOrRightParenthesis(lineText().at(caretX()-1))) {
case '(': {
QChar nextCh = nextNotspaceChar(caretY()-1,caretX()-1);
qDebug()<<nextCh;
if (!isIdentChar(nextCh) && nextCh!='(' ){
handled = handleSymbolCompletion(ch);
}
return;
}
case '>':
if ((caretX() <= 1) || lineText().isEmpty()
|| lineText()[caretX() - 2] != '-') {

View File

@ -608,7 +608,8 @@ bool Project::saveUnits()
ini.SetLongValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd());
ini.SetValue(groupName,"BuildCmd", toByteArray(unit->buildCmd()));
ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT);
ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding()));
if (unit->encoding() != options().encoding)
ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding()));
}
ini.SetLongValue("Project","UnitCount",count);
ini.SaveFile(mFilename.toLocal8Bit());
@ -927,7 +928,7 @@ PProjectUnit Project::addUnit(const QString &inFileName, PProjectModelNode paren
newUnit->setEncoding(e->fileEncoding());
e->setInProject(true);
} else {
newUnit->setEncoding(pSettings->editor().defaultEncoding());
newUnit->setEncoding(options().encoding.toUtf8());
}
newUnit->setFolder(getFolderPath(parentNode));
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode));

View File

@ -1100,6 +1100,23 @@ QChar SynEdit::charAt(const BufferCoord &pos)
return QChar(0);
}
QChar SynEdit::nextNotspaceChar(int line, int ch)
{
if (ch<0)
return QChar();
QString s = mLines->getString(line);
if (s.isEmpty())
return QChar();
int x=ch;
while (x<s.length()) {
QChar ch = s[x];
if (!ch.isSpace())
return ch;
x++;
}
return QChar();
}
void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord &ptBefore, const BufferCoord &ptAfter)
{
SynSelectionMode vOldMode = mActiveSelectionMode;

View File

@ -214,6 +214,7 @@ public:
QString wordAtRowCol(const BufferCoord& XY);
QChar charAt(const BufferCoord& pos);
QChar nextNotspaceChar(int line, int ch);
int charColumns(QChar ch) const;
bool isPointInSelection(const BufferCoord& Value) const;