work save
This commit is contained in:
parent
16db14e761
commit
ff336ad5c3
|
@ -4705,7 +4705,7 @@ void Editor::applySettings()
|
||||||
QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo
|
QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo
|
||||||
| QSynedit::eoSelectWordByDblClick;
|
| QSynedit::eoSelectWordByDblClick;
|
||||||
|
|
||||||
options.setFlag(QSynedit::eoShowSpecialChars);
|
options.setFlag(QSynedit::eoShowSpecialChars, false);
|
||||||
|
|
||||||
//options
|
//options
|
||||||
options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent());
|
options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent());
|
||||||
|
|
|
@ -21,7 +21,7 @@ const QSet<QChar> WordBreakChars{'.', ',', ';', ':',
|
||||||
'"', '\'', '!', '?', '[', ']', '(', ')', '{', '}', '^', '-', '=', '+',
|
'"', '\'', '!', '?', '[', ']', '(', ')', '{', '}', '^', '-', '=', '+',
|
||||||
'-', '*', '/', '\\', '|'};
|
'-', '*', '/', '\\', '|'};
|
||||||
const QChar TabGlyph(0x2192);
|
const QChar TabGlyph(0x2192);
|
||||||
const QChar SpaceGlyph(0x2027);
|
const QChar SpaceGlyph('.');
|
||||||
const QChar LineBreakGlyph(0x2193);
|
const QChar LineBreakGlyph(0x2193);
|
||||||
const QChar SoftBreakGlyph(0x2193);
|
const QChar SoftBreakGlyph(0x2193);
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,7 @@ int SynEditTextPainter::columnToXValue(int col)
|
||||||
|
|
||||||
void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int columnsBefore,
|
void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int columnsBefore,
|
||||||
int first, int last, bool /*isSelection*/, const QFont& font,
|
int first, int last, bool /*isSelection*/, const QFont& font,
|
||||||
const QFont& fontForNonAscii)
|
const QFont& fontForNonAscii, bool showGlyphs)
|
||||||
{
|
{
|
||||||
bool startPaint;
|
bool startPaint;
|
||||||
int nX;
|
int nX;
|
||||||
|
@ -392,7 +392,7 @@ void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int col
|
||||||
if (token[i].unicode()<=0xFF) {
|
if (token[i].unicode()<=0xFF) {
|
||||||
QChar ch;
|
QChar ch;
|
||||||
int padding=0;
|
int padding=0;
|
||||||
if (edit->mOptions.testFlag(eoShowSpecialChars)) {
|
if (showGlyphs) {
|
||||||
switch(token[i].unicode()) {
|
switch(token[i].unicode()) {
|
||||||
case '\t':
|
case '\t':
|
||||||
ch=TabGlyph;
|
ch=TabGlyph;
|
||||||
|
@ -530,24 +530,25 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
|
||||||
if (bU1) {
|
if (bU1) {
|
||||||
setDrawingColors(false);
|
setDrawingColors(false);
|
||||||
rcToken.setRight(columnToXValue(nLineSelStart));
|
rcToken.setRight(columnToXValue(nLineSelStart));
|
||||||
paintToken(TokenAccu.s,TokenAccu.Columns,TokenAccu.ColumnsBefore,nC1,nLineSelStart,false,font,nonAsciiFont);
|
paintToken(
|
||||||
|
TokenAccu.s,TokenAccu.Columns,TokenAccu.ColumnsBefore,nC1,nLineSelStart,false,font,nonAsciiFont, TokenAccu.showSpecialGlyphs);
|
||||||
}
|
}
|
||||||
// selected part of the token
|
// selected part of the token
|
||||||
setDrawingColors(true);
|
setDrawingColors(true);
|
||||||
nC1Sel = std::max(nLineSelStart, nC1);
|
nC1Sel = std::max(nLineSelStart, nC1);
|
||||||
nC2Sel = std::min(nLineSelEnd, nC2);
|
nC2Sel = std::min(nLineSelEnd, nC2);
|
||||||
rcToken.setRight(columnToXValue(nC2Sel));
|
rcToken.setRight(columnToXValue(nC2Sel));
|
||||||
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore, nC1Sel, nC2Sel,true,font,nonAsciiFont);
|
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore, nC1Sel, nC2Sel,true,font,nonAsciiFont, TokenAccu.showSpecialGlyphs);
|
||||||
// second unselected part of the token
|
// second unselected part of the token
|
||||||
if (bU2) {
|
if (bU2) {
|
||||||
setDrawingColors(false);
|
setDrawingColors(false);
|
||||||
rcToken.setRight(columnToXValue(nC2));
|
rcToken.setRight(columnToXValue(nC2));
|
||||||
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore,nLineSelEnd, nC2,false,font,nonAsciiFont);
|
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore,nLineSelEnd, nC2,false,font,nonAsciiFont, TokenAccu.showSpecialGlyphs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setDrawingColors(bSel);
|
setDrawingColors(bSel);
|
||||||
rcToken.setRight(columnToXValue(nC2));
|
rcToken.setRight(columnToXValue(nC2));
|
||||||
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore, nC1, nC2,bSel,font,nonAsciiFont);
|
paintToken(TokenAccu.s, TokenAccu.Columns, TokenAccu.ColumnsBefore, nC1, nC2,bSel,font,nonAsciiFont, TokenAccu.showSpecialGlyphs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,22 +590,6 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SynEditTextPainter::tokenIsSpaces(bool &bSpacesTest, const QString& token, bool& bIsSpaces)
|
|
||||||
{
|
|
||||||
if (!bSpacesTest) {
|
|
||||||
bSpacesTest = true;
|
|
||||||
for (QChar ch:token) {
|
|
||||||
//todo: should include tabs?
|
|
||||||
if (ch!= ' ') {
|
|
||||||
bIsSpaces = false;
|
|
||||||
return bIsSpaces;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bIsSpaces = true;
|
|
||||||
}
|
|
||||||
return bIsSpaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the token chars with the attributes in the TokenAccu
|
// Store the token chars with the attributes in the TokenAccu
|
||||||
// record. This will paint any chars already stored if there is
|
// record. This will paint any chars already stored if there is
|
||||||
// a (visible) change in the attributes.
|
// a (visible) change in the attributes.
|
||||||
|
@ -614,12 +599,15 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo
|
||||||
bool bCanAppend;
|
bool bCanAppend;
|
||||||
QColor foreground, background;
|
QColor foreground, background;
|
||||||
FontStyles style;
|
FontStyles style;
|
||||||
bool bSpacesTest,bIsSpaces;
|
bool isSpaces=false;
|
||||||
|
bool showGlyphs=false;
|
||||||
|
|
||||||
if (p_Attri) {
|
if (p_Attri) {
|
||||||
foreground = p_Attri->foreground();
|
foreground = p_Attri->foreground();
|
||||||
background = p_Attri->background();
|
background = p_Attri->background();
|
||||||
style = p_Attri->styles();
|
style = p_Attri->styles();
|
||||||
|
isSpaces = p_Attri->tokenType() == TokenType::Space;
|
||||||
|
showGlyphs = isSpaces && edit->mOptions.testFlag(eoShowSpecialChars);
|
||||||
} else {
|
} else {
|
||||||
foreground = colFG;
|
foreground = colFG;
|
||||||
background = colBG;
|
background = colBG;
|
||||||
|
@ -641,17 +629,18 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo
|
||||||
|
|
||||||
// Do we have to paint the old chars first, or can we just append?
|
// Do we have to paint the old chars first, or can we just append?
|
||||||
bCanAppend = false;
|
bCanAppend = false;
|
||||||
bSpacesTest = false;
|
if (TokenAccu.Columns > 0 ) {
|
||||||
if (TokenAccu.Columns > 0) {
|
if (showGlyphs == TokenAccu.showSpecialGlyphs) {
|
||||||
// font style must be the same or token is only spaces
|
// font style must be the same or token is only spaces
|
||||||
if (TokenAccu.Style == style || ( (style & FontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline)
|
if (TokenAccu.Style == style || ( (style & FontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline)
|
||||||
&& tokenIsSpaces(bSpacesTest,Token,bIsSpaces)) ) {
|
&& isSpaces)) {
|
||||||
if (
|
if (
|
||||||
// background color must be the same and
|
// background color must be the same and
|
||||||
((TokenAccu.BG == background) &&
|
(TokenAccu.BG == background) &&
|
||||||
// foreground color must be the same or token is only spaces
|
// foreground color must be the same or token is only spaces
|
||||||
((TokenAccu.FG == foreground) || (tokenIsSpaces(bSpacesTest,Token,bIsSpaces) && !edit->mOptions.testFlag(eoShowSpecialChars))))) {
|
((TokenAccu.FG == foreground) || isSpaces)) {
|
||||||
bCanAppend = true;
|
bCanAppend = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If we can't append it, then we have to paint the old token chars first.
|
// If we can't append it, then we have to paint the old token chars first.
|
||||||
|
@ -669,6 +658,7 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo
|
||||||
TokenAccu.FG = foreground;
|
TokenAccu.FG = foreground;
|
||||||
TokenAccu.BG = background;
|
TokenAccu.BG = background;
|
||||||
TokenAccu.Style = style;
|
TokenAccu.Style = style;
|
||||||
|
TokenAccu.showSpecialGlyphs = showGlyphs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,17 +916,17 @@ void SynEditTextPainter::paintLines()
|
||||||
setDrawingColors(true);
|
setDrawingColors(true);
|
||||||
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(nLineSelStart)));
|
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(nLineSelStart)));
|
||||||
rcToken.setRight(std::min(rcLine.right(), columnToXValue(nLineSelEnd)));
|
rcToken.setRight(std::min(rcLine.right(), columnToXValue(nLineSelEnd)));
|
||||||
paintToken(sToken, nTokenColumnLen, 0, nLineSelStart, nLineSelEnd,false,edit->font(),edit->fontForNonAscii());
|
paintToken(sToken, nTokenColumnLen, 0, nLineSelStart, nLineSelEnd,false,edit->font(),edit->fontForNonAscii(),false);
|
||||||
setDrawingColors(false);
|
setDrawingColors(false);
|
||||||
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(FirstCol)));
|
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(FirstCol)));
|
||||||
rcToken.setRight(std::min(rcLine.right(), columnToXValue(nLineSelStart)));
|
rcToken.setRight(std::min(rcLine.right(), columnToXValue(nLineSelStart)));
|
||||||
paintToken(sToken, nTokenColumnLen, 0, FirstCol, nLineSelStart,false,edit->font(),edit->fontForNonAscii());
|
paintToken(sToken, nTokenColumnLen, 0, FirstCol, nLineSelStart,false,edit->font(),edit->fontForNonAscii(),false);
|
||||||
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(nLineSelEnd)));
|
rcToken.setLeft(std::max(rcLine.left(), columnToXValue(nLineSelEnd)));
|
||||||
rcToken.setRight(std::min(rcLine.right(), columnToXValue(LastCol)));
|
rcToken.setRight(std::min(rcLine.right(), columnToXValue(LastCol)));
|
||||||
paintToken(sToken, nTokenColumnLen, 0, nLineSelEnd, LastCol,true,edit->font(),edit->fontForNonAscii());
|
paintToken(sToken, nTokenColumnLen, 0, nLineSelEnd, LastCol,true,edit->font(),edit->fontForNonAscii(),false);
|
||||||
} else {
|
} else {
|
||||||
setDrawingColors(bLineSelected);
|
setDrawingColors(bLineSelected);
|
||||||
paintToken(sToken, nTokenColumnLen, 0, FirstCol, LastCol,bLineSelected,edit->font(),edit->fontForNonAscii());
|
paintToken(sToken, nTokenColumnLen, 0, FirstCol, LastCol,bLineSelected,edit->font(),edit->fontForNonAscii(),false);
|
||||||
}
|
}
|
||||||
//Paint editingAreaBorders
|
//Paint editingAreaBorders
|
||||||
if (bCurrentLine && edit->mInputPreeditString.length()>0) {
|
if (bCurrentLine && edit->mInputPreeditString.length()>0) {
|
||||||
|
@ -1047,8 +1037,10 @@ void SynEditTextPainter::paintLines()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Draw LineBreak glyph.
|
// Draw LineBreak glyph.
|
||||||
if (edit->mOptions.testFlag(eoShowSpecialChars) && (!bLineSelected) &&
|
if (edit->mOptions.testFlag(eoShowSpecialChars)
|
||||||
(!bSpecialLine) && (edit->mDocument->lineColumns(vLine-1) < vLastChar)) {
|
// && (!bLineSelected)
|
||||||
|
// && (!bSpecialLine)
|
||||||
|
&& (edit->mDocument->lineColumns(vLine-1) < vLastChar)) {
|
||||||
addHighlightToken(LineBreakGlyph,
|
addHighlightToken(LineBreakGlyph,
|
||||||
edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol),
|
edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol),
|
||||||
edit->charColumns(LineBreakGlyph),vLine, edit->mSyntaxer->whitespaceAttribute());
|
edit->charColumns(LineBreakGlyph),vLine, edit->mSyntaxer->whitespaceAttribute());
|
||||||
|
|
|
@ -35,6 +35,7 @@ class SynEditTextPainter
|
||||||
QColor FG;
|
QColor FG;
|
||||||
QColor BG;
|
QColor BG;
|
||||||
FontStyles Style;
|
FontStyles Style;
|
||||||
|
bool showSpecialGlyphs;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -50,10 +51,9 @@ private:
|
||||||
int columnToXValue(int col);
|
int columnToXValue(int col);
|
||||||
void paintToken(const QString& token, int tokenLen, int columnsBefore,
|
void paintToken(const QString& token, int tokenLen, int columnsBefore,
|
||||||
int first, int last, bool isSelection, const QFont& font,
|
int first, int last, bool isSelection, const QFont& font,
|
||||||
const QFont& fontForNonAscii);
|
const QFont& fontForNonAscii, bool showGlyphs);
|
||||||
void paintEditAreas(const EditingAreaList& areaList);
|
void paintEditAreas(const EditingAreaList& areaList);
|
||||||
void paintHighlightToken(bool bFillToEOL);
|
void paintHighlightToken(bool bFillToEOL);
|
||||||
bool tokenIsSpaces(bool& bSpacesTest, const QString& token, bool& bIsSpaces);
|
|
||||||
void addHighlightToken(const QString& token, int columnsBefore, int tokenColumns,
|
void addHighlightToken(const QString& token, int columnsBefore, int tokenColumns,
|
||||||
int cLine, PTokenAttribute p_Attri);
|
int cLine, PTokenAttribute p_Attri);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue