* work save

* qsynedit can correctly load and display file without highlighter and chinese characters
This commit is contained in:
royqh1979@gmail.com 2021-05-24 22:09:14 +08:00
parent bd95fccfa8
commit 8fda9b7a4a
4 changed files with 16 additions and 23 deletions

View File

@ -89,19 +89,12 @@ SynKeyError::SynKeyError(const QString &reason):BaseError(reason)
PSynEditKeyStroke SynEditKeyStrokes::add(SynEditorCommand command, int key, Qt::KeyboardModifiers modifiers)
{
// qDebug()<<"add : 1" ;
// qDebug() << (int)command;
//// PSynEditKeyStroke keyStroke = std::make_shared<SynEditKeyStroke>();
//// qDebug()<<"add : 2";
//// keyStroke->setKey(key);
//// qDebug()<<"add : 3";
//// keyStroke->setKeyModifiers(modifiers);
//// qDebug()<<"add : 4";
//// keyStroke->setCommand(command);
// qDebug()<<"add : 5";
// //mList.append(keyStroke);
// qDebug()<<"add : 6";
PSynEditKeyStroke keyStroke = std::make_shared<SynEditKeyStroke>();
keyStroke->setKey(key);
keyStroke->setKeyModifiers(modifiers);
keyStroke->setCommand(command);
mList.append(keyStroke);
return keyStroke;
}
PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command)
@ -166,7 +159,6 @@ void SynEditKeyStrokes::clear()
void SynEditKeyStrokes::resetDefaults()
{
return;
qDebug()<<"SynEditKeyStrokes: resetDefaults ";
qDebug()<<"SynEditKeyStrokes: resetDefaults: clear ";
clear();

View File

@ -52,7 +52,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
mOrigRedoList = mRedoList;
qDebug()<<"init SynEdit: 4";
//DoubleBuffered = false;
mCaretColor = QColorConstants::Red;
mActiveLineColor = QColorConstants::Svg::lightblue;
mSelectedBackground = QColorConstants::Svg::lightgray;

View File

@ -491,8 +491,11 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
}
addItem(removeLineEnds(newLine));
}
if (file.atEnd()){
break;
}
line = file.readLine();
} while (!file.atEnd());
} while (true);
if (!needReread) {
if (allAscii)
realEncoding = ENCODING_ASCII;

View File

@ -356,17 +356,15 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
nX = ColumnToXValue(First);
First -= ColumnsBefore;
Last -= ColumnsBefore;
QPen oldPen = painter->pen();
QPen newPen(painter->brush().color());
painter->setPen(newPen);
painter->drawRect(rcToken);
painter->setPen(oldPen);
if (First > TokenCols) {
} else {
qDebug()<<"token clip rect:"<<rcToken << Token << First << Last;
// painter->setClipRect(rcToken);
int tokenColLen=0;
startPaint = false;
QPen oldPen = painter->pen();
QPen newPen(painter->brush().color());
painter->setPen(newPen);
painter->drawRect(rcToken);
painter->setPen(oldPen);
for (int i=0;i<Token.length();i++) {
int charCols;
if (Token[i] == SynTabChar) {
@ -936,6 +934,7 @@ void SynEditTextPainter::PaintLines()
// the flicker. Should not cost very much anyway, compared to the many
// calls to ExtTextOut.
if (bDoRightEdge) {
painter->setPen(edit->mRightEdgeColor);
painter->drawLine(nRightEdge, rcLine.top(),nRightEdge,rcLine.bottom()+1);
}
bCurrentLine = false;