- fix: Custom editor colors shouldn't be tested for high contrast with the default background color
- fix: Custom color settings not correctly displayed in the options widget - enhancement: add hit counts in the search result view - fix: editor actions' state not correctly updated after close editors. - fix: When replace in the editor, "Yes to All" and "No" button doesn't work correctly. - fix: crash when editing non-c/c++ files - enhancement: set the alpha value of scheme colors - enhancement: can use symbols' own scheme color to draw selection - enhancement: can use different colors to highlight the current word and the selections
This commit is contained in:
parent
d297faf3af
commit
6ad87990c7
5
NEWS.md
5
NEWS.md
|
@ -8,6 +8,11 @@ Version 0.7.8
|
||||||
- fix: Custom color settings not correctly displayed in the options widget
|
- fix: Custom color settings not correctly displayed in the options widget
|
||||||
- enhancement: add hit counts in the search result view
|
- enhancement: add hit counts in the search result view
|
||||||
- fix: editor actions' state not correctly updated after close editors.
|
- fix: editor actions' state not correctly updated after close editors.
|
||||||
|
- fix: When replace in the editor, "Yes to All" and "No" button doesn't work correctly.
|
||||||
|
- fix: crash when editing non-c/c++ files
|
||||||
|
- enhancement: set the alpha value of scheme colors
|
||||||
|
- enhancement: can use symbols' own scheme color to draw selection
|
||||||
|
- enhancement: can use different colors to highlight the current word and the selections
|
||||||
|
|
||||||
Version 0.7.7
|
Version 0.7.7
|
||||||
- enhancement: Problem Set
|
- enhancement: Problem Set
|
||||||
|
|
|
@ -60,6 +60,14 @@ PColorScheme ColorScheme::load(const QString &filename)
|
||||||
return ColorScheme::fromJson(doc.object());
|
return ColorScheme::fromJson(doc.object());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorScheme::addItem(const QString& name)
|
||||||
|
{
|
||||||
|
if (mItems.contains(name))
|
||||||
|
return;
|
||||||
|
PColorSchemeItem item = std::make_shared<ColorSchemeItem>();
|
||||||
|
mItems[name]=item;
|
||||||
|
}
|
||||||
|
|
||||||
QMap<QString, PColorSchemeItem> ColorScheme::items()
|
QMap<QString, PColorSchemeItem> ColorScheme::items()
|
||||||
{
|
{
|
||||||
return mItems;
|
return mItems;
|
||||||
|
@ -220,12 +228,12 @@ PColorSchemeItem ColorSchemeItem::fromJson(const QJsonObject &json)
|
||||||
void ColorSchemeItem::toJson(QJsonObject &json)
|
void ColorSchemeItem::toJson(QJsonObject &json)
|
||||||
{
|
{
|
||||||
if (mForeground.isValid()) {
|
if (mForeground.isValid()) {
|
||||||
json["foreground"] = mForeground.name();
|
json["foreground"] = mForeground.name(QColor::HexArgb);
|
||||||
} else if (json.contains("foreground")){
|
} else if (json.contains("foreground")){
|
||||||
json.remove("foreground");
|
json.remove("foreground");
|
||||||
}
|
}
|
||||||
if (mBackground.isValid()) {
|
if (mBackground.isValid()) {
|
||||||
json["background"] = mBackground.name();
|
json["background"] = mBackground.name(QColor::HexArgb);
|
||||||
} else if (json.contains("background")){
|
} else if (json.contains("background")){
|
||||||
json.remove("background");
|
json.remove("background");
|
||||||
}
|
}
|
||||||
|
@ -503,6 +511,10 @@ void ColorManager::initItemDefines()
|
||||||
QObject::tr("Gutter"),
|
QObject::tr("Gutter"),
|
||||||
QObject::tr("Editor"),
|
QObject::tr("Editor"),
|
||||||
true,true,true);
|
true,true,true);
|
||||||
|
addDefine(COLOR_SCHEME_GUTTER_ACTIVE_LINE,
|
||||||
|
QObject::tr("Gutter Active Line"),
|
||||||
|
QObject::tr("Editor"),
|
||||||
|
true,false,false);
|
||||||
//Active Line
|
//Active Line
|
||||||
addDefine(COLOR_SCHEME_ACTIVE_LINE,
|
addDefine(COLOR_SCHEME_ACTIVE_LINE,
|
||||||
QObject::tr("Active Line"),
|
QObject::tr("Active Line"),
|
||||||
|
@ -528,6 +540,17 @@ void ColorManager::initItemDefines()
|
||||||
QObject::tr("Selection"),
|
QObject::tr("Selection"),
|
||||||
QObject::tr("Editor"),
|
QObject::tr("Editor"),
|
||||||
true,true,false);
|
true,true,false);
|
||||||
|
|
||||||
|
addDefine(COLOR_SCHEME_TEXT,
|
||||||
|
QObject::tr("Editor Text"),
|
||||||
|
QObject::tr("Editor"),
|
||||||
|
true,true,false);
|
||||||
|
|
||||||
|
addDefine(COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD,
|
||||||
|
QObject::tr("Current Highlighted Word"),
|
||||||
|
QObject::tr("Editor"),
|
||||||
|
true,true,false);
|
||||||
|
|
||||||
//Syntax Error
|
//Syntax Error
|
||||||
addDefine(COLOR_SCHEME_ERROR,
|
addDefine(COLOR_SCHEME_ERROR,
|
||||||
QObject::tr("Error"),
|
QObject::tr("Error"),
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
#define COLOR_SCHEME_ERROR "Error"
|
#define COLOR_SCHEME_ERROR "Error"
|
||||||
#define COLOR_SCHEME_ACTIVE_BREAKPOINT "Active Breakpoint"
|
#define COLOR_SCHEME_ACTIVE_BREAKPOINT "Active Breakpoint"
|
||||||
#define COLOR_SCHEME_GUTTER "Gutter"
|
#define COLOR_SCHEME_GUTTER "Gutter"
|
||||||
|
#define COLOR_SCHEME_GUTTER_ACTIVE_LINE "Gutter Active Line"
|
||||||
#define COLOR_SCHEME_SELECTION "Selected text"
|
#define COLOR_SCHEME_SELECTION "Selected text"
|
||||||
|
#define COLOR_SCHEME_TEXT "Editor Text"
|
||||||
|
#define COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD "Current Highlighted Word"
|
||||||
#define COLOR_SCHEME_FOLD_LINE "Fold Line"
|
#define COLOR_SCHEME_FOLD_LINE "Fold Line"
|
||||||
#define COLOR_SCHEME_ACTIVE_LINE "Active Line"
|
#define COLOR_SCHEME_ACTIVE_LINE "Active Line"
|
||||||
#define COLOR_SCHEME_WARNING "Warning"
|
#define COLOR_SCHEME_WARNING "Warning"
|
||||||
|
@ -69,6 +72,8 @@ public:
|
||||||
|
|
||||||
static PColorScheme load(const QString& filename);
|
static PColorScheme load(const QString& filename);
|
||||||
|
|
||||||
|
void addItem(const QString& name);
|
||||||
|
|
||||||
QMap<QString,PColorSchemeItem> items();
|
QMap<QString,PColorSchemeItem> items();
|
||||||
|
|
||||||
static PColorScheme fromJson(const QJsonObject& json);
|
static PColorScheme fromJson(const QJsonObject& json);
|
||||||
|
|
|
@ -113,7 +113,6 @@
|
||||||
},
|
},
|
||||||
"Space" : {
|
"Space" : {
|
||||||
"foreground" : "#505050",
|
"foreground" : "#505050",
|
||||||
"background" : "#1E1E1E",
|
|
||||||
"bold" : false,
|
"bold" : false,
|
||||||
"italic" : false,
|
"italic" : false,
|
||||||
"underlined" : false,
|
"underlined" : false,
|
||||||
|
@ -140,14 +139,23 @@
|
||||||
"underlined" : false,
|
"underlined" : false,
|
||||||
"strikeout" : false
|
"strikeout" : false
|
||||||
},
|
},
|
||||||
|
"Editor Text": {
|
||||||
|
"foreground" : "#ffffff",
|
||||||
|
"background" : "#1E1E1E"
|
||||||
|
},
|
||||||
|
"Current Highlighted Word": {
|
||||||
|
"background": "#50ffffff"
|
||||||
|
},
|
||||||
"Selected text" : {
|
"Selected text" : {
|
||||||
"foreground" : "#000000",
|
"background" : "#3c55aaff"
|
||||||
"background" : "#808080"
|
|
||||||
},
|
},
|
||||||
"Gutter" : {
|
"Gutter" : {
|
||||||
"foreground" : "#858585",
|
"foreground" : "#858585",
|
||||||
"background" : "#1E1E1E"
|
"background" : "#1E1E1E"
|
||||||
},
|
},
|
||||||
|
"Gutter Active Line" : {
|
||||||
|
"foreground" : "#C0C0C0"
|
||||||
|
},
|
||||||
"Breakpoint" : {
|
"Breakpoint" : {
|
||||||
},
|
},
|
||||||
"Error" : {
|
"Error" : {
|
||||||
|
|
|
@ -74,8 +74,8 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
mLastIdCharPressed(0),
|
mLastIdCharPressed(0),
|
||||||
mCurrentWord(),
|
mCurrentWord(),
|
||||||
mCurrentTipType(TipType::None),
|
mCurrentTipType(TipType::None),
|
||||||
mOldSelectionWord(),
|
mOldHighlightedWord(),
|
||||||
mSelectionWord(),
|
mCurrentHighlightedWord(),
|
||||||
mSaving(false)
|
mSaving(false)
|
||||||
{
|
{
|
||||||
mUseCppSyntax = pSettings->editor().defaultFileCpp();
|
mUseCppSyntax = pSettings->editor().defaultFileCpp();
|
||||||
|
@ -855,37 +855,6 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
{
|
{
|
||||||
if (token.isEmpty())
|
if (token.isEmpty())
|
||||||
return;
|
return;
|
||||||
//selection
|
|
||||||
if (selAvail() && highlighter()) {
|
|
||||||
if ((
|
|
||||||
(attr == highlighter()->identifierAttribute())
|
|
||||||
|| (attr == highlighter()->keywordAttribute())
|
|
||||||
|| (attr->name() == SYNS_AttrPreprocessor)
|
|
||||||
)
|
|
||||||
&& (token == mSelectionWord)) {
|
|
||||||
foreground = selectedForeground();
|
|
||||||
background = selectedBackground();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!selAvail() && attr->name() == SYNS_AttrSymbol) {
|
|
||||||
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
|
|
||||||
|
|
||||||
if ( (line == mHighlightCharPos1.Line)
|
|
||||||
&& (aChar == mHighlightCharPos1.Char)) {
|
|
||||||
foreground = selectedForeground();
|
|
||||||
background = selectedBackground();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((line == mHighlightCharPos2.Line)
|
|
||||||
&& (aChar == mHighlightCharPos2.Char)) {
|
|
||||||
foreground = selectedForeground();
|
|
||||||
background = selectedBackground();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// qDebug()<<token<<"-"<<attr->name()<<" - "<<line<<" : "<<aChar;
|
// qDebug()<<token<<"-"<<attr->name()<<" - "<<line<<" : "<<aChar;
|
||||||
if (mParser && (attr == highlighter()->identifierAttribute())) {
|
if (mParser && (attr == highlighter()->identifierAttribute())) {
|
||||||
|
@ -918,7 +887,43 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
} else {
|
} else {
|
||||||
foreground = highlighter()->identifierAttribute()->foreground();
|
foreground = highlighter()->identifierAttribute()->foreground();
|
||||||
}
|
}
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
//selection
|
||||||
|
if (highlighter()) {
|
||||||
|
if ((
|
||||||
|
(attr == highlighter()->identifierAttribute())
|
||||||
|
|| (attr == highlighter()->keywordAttribute())
|
||||||
|
|| (attr->name() == SYNS_AttrPreprocessor)
|
||||||
|
)
|
||||||
|
&& (token == mCurrentHighlightedWord)) {
|
||||||
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
|
foreground = mCurrentHighlighWordForeground;
|
||||||
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
|
background = mCurrentHighlighWordBackground;
|
||||||
|
}
|
||||||
|
} else if (token == mCurrentHighlightedWord) {
|
||||||
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
|
foreground = mCurrentHighlighWordForeground;
|
||||||
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
|
background = mCurrentHighlighWordBackground;
|
||||||
|
} else if (!selAvail() && attr->name() == SYNS_AttrSymbol) {
|
||||||
|
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
|
||||||
|
|
||||||
|
if ( (line == mHighlightCharPos1.Line)
|
||||||
|
&& (aChar == mHighlightCharPos1.Char)) {
|
||||||
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
|
foreground = mCurrentHighlighWordForeground;
|
||||||
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
|
background = mCurrentHighlighWordBackground;
|
||||||
|
}
|
||||||
|
if ((line == mHighlightCharPos2.Line)
|
||||||
|
&& (aChar == mHighlightCharPos2.Char)) {
|
||||||
|
if (mCurrentHighlighWordForeground.isValid())
|
||||||
|
foreground = mCurrentHighlighWordForeground;
|
||||||
|
if (mCurrentHighlighWordBackground.isValid())
|
||||||
|
background = mCurrentHighlighWordBackground;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,31 +1441,32 @@ void Editor::onStatusChanged(SynStatusChanges changes)
|
||||||
|
|
||||||
// scSelection includes anything caret related
|
// scSelection includes anything caret related
|
||||||
if (changes.testFlag(SynStatusChange::scSelection)) {
|
if (changes.testFlag(SynStatusChange::scSelection)) {
|
||||||
mSelectionWord="";
|
mCurrentHighlightedWord = wordAtCursor();
|
||||||
if (selAvail()) {
|
// mSelectionWord="";
|
||||||
BufferCoord wordBegin,wordEnd,bb,be;
|
// if (selAvail()) {
|
||||||
bb = blockBegin();
|
// BufferCoord wordBegin,wordEnd,bb,be;
|
||||||
be = blockEnd();
|
// bb = blockBegin();
|
||||||
wordBegin = wordStartEx(bb);
|
// be = blockEnd();
|
||||||
wordEnd = wordEndEx(be);
|
// wordBegin = wordStartEx(bb);
|
||||||
if (wordBegin.Line == bb.Line
|
// wordEnd = wordEndEx(be);
|
||||||
&& wordBegin.Char == bb.Char
|
// if (wordBegin.Line == bb.Line
|
||||||
&& wordEnd.Line == be.Line
|
// && wordBegin.Char == bb.Char
|
||||||
&& wordEnd.Char == be.Char) {
|
// && wordEnd.Line == be.Line
|
||||||
if (wordBegin.Line>=1 && wordBegin.Line<=lines()->count()) {
|
// && wordEnd.Char == be.Char) {
|
||||||
QString line = lines()->getString(wordBegin.Line-1);
|
// if (wordBegin.Line>=1 && wordBegin.Line<=lines()->count()) {
|
||||||
mSelectionWord = line.mid(wordBegin.Char-1,wordEnd.Char-wordBegin.Char);
|
// QString line = lines()->getString(wordBegin.Line-1);
|
||||||
}
|
// mSelectionWord = line.mid(wordBegin.Char-1,wordEnd.Char-wordBegin.Char);
|
||||||
}
|
// }
|
||||||
// qDebug()<<QString("(%1,%2)").arg(bb.Line).arg(bb.Char)
|
// }
|
||||||
// <<" - "<<QString("(%1,%2)").arg(be.Line).arg(be.Char)
|
//// qDebug()<<QString("(%1,%2)").arg(bb.Line).arg(bb.Char)
|
||||||
// <<" - "<<QString("(%1,%2)").arg(wordBegin.Line).arg(wordBegin.Char)
|
//// <<" - "<<QString("(%1,%2)").arg(be.Line).arg(be.Char)
|
||||||
// <<" - "<<QString("(%1,%2)").arg(wordEnd.Line).arg(wordEnd.Char)
|
//// <<" - "<<QString("(%1,%2)").arg(wordBegin.Line).arg(wordBegin.Char)
|
||||||
// <<" : "<<mSelectionWord;
|
//// <<" - "<<QString("(%1,%2)").arg(wordEnd.Line).arg(wordEnd.Char)
|
||||||
}
|
//// <<" : "<<mSelectionWord;
|
||||||
if (mOldSelectionWord != mSelectionWord) {
|
// }
|
||||||
|
if (mOldHighlightedWord != mCurrentHighlightedWord) {
|
||||||
invalidate();
|
invalidate();
|
||||||
mOldSelectionWord = mSelectionWord;
|
mOldHighlightedWord = mCurrentHighlightedWord;
|
||||||
}
|
}
|
||||||
pMainWindow->updateStatusbarForLineCol();
|
pMainWindow->updateStatusbarForLineCol();
|
||||||
|
|
||||||
|
@ -3742,6 +3748,10 @@ void Editor::applyColorScheme(const QString& schemeName)
|
||||||
gutter().setTextColor(item->foreground());
|
gutter().setTextColor(item->foreground());
|
||||||
gutter().setColor(item->background());
|
gutter().setColor(item->background());
|
||||||
}
|
}
|
||||||
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_GUTTER_ACTIVE_LINE);
|
||||||
|
if (item) {
|
||||||
|
gutter().setActiveLineTextColor(item->foreground());
|
||||||
|
}
|
||||||
item = pColorManager->getItem(schemeName,COLOR_SCHEME_FOLD_LINE);
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_FOLD_LINE);
|
||||||
if (item) {
|
if (item) {
|
||||||
codeFolding().folderBarLinesColor = item->foreground();
|
codeFolding().folderBarLinesColor = item->foreground();
|
||||||
|
@ -3762,6 +3772,9 @@ void Editor::applyColorScheme(const QString& schemeName)
|
||||||
if (item) {
|
if (item) {
|
||||||
setSelectedForeground(item->foreground());
|
setSelectedForeground(item->foreground());
|
||||||
setSelectedBackground(item->background());
|
setSelectedBackground(item->background());
|
||||||
|
} else {
|
||||||
|
this->setForegroundColor(palette().color(QPalette::HighlightedText));
|
||||||
|
this->setBackgroundColor(palette().color(QPalette::Highlight));
|
||||||
}
|
}
|
||||||
item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_BREAKPOINT);
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_BREAKPOINT);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
@ -3773,6 +3786,23 @@ void Editor::applyColorScheme(const QString& schemeName)
|
||||||
this->mBreakpointForegroundColor = item->foreground();
|
this->mBreakpointForegroundColor = item->foreground();
|
||||||
this->mBreakpointBackgroundColor = item->background();
|
this->mBreakpointBackgroundColor = item->background();
|
||||||
}
|
}
|
||||||
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_TEXT);
|
||||||
|
if (item) {
|
||||||
|
this->setForegroundColor(item->foreground());
|
||||||
|
this->setBackgroundColor(item->background());
|
||||||
|
} else {
|
||||||
|
this->setForegroundColor(palette().color(QPalette::Text));
|
||||||
|
this->setBackgroundColor(palette().color(QPalette::Base));
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD);
|
||||||
|
if (item) {
|
||||||
|
mCurrentHighlighWordForeground = item->foreground();
|
||||||
|
mCurrentHighlighWordBackground = item->background();
|
||||||
|
} else {
|
||||||
|
mCurrentHighlighWordForeground = selectedForeground();
|
||||||
|
mCurrentHighlighWordBackground = selectedBackground();
|
||||||
|
}
|
||||||
|
|
||||||
this->invalidate();
|
this->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,8 @@ private:
|
||||||
QColor mActiveBreakpointBackgroundColor;
|
QColor mActiveBreakpointBackgroundColor;
|
||||||
QColor mBreakpointForegroundColor;
|
QColor mBreakpointForegroundColor;
|
||||||
QColor mBreakpointBackgroundColor;
|
QColor mBreakpointBackgroundColor;
|
||||||
|
QColor mCurrentHighlighWordForeground;
|
||||||
|
QColor mCurrentHighlighWordBackground;
|
||||||
int mSyntaxErrorLine;
|
int mSyntaxErrorLine;
|
||||||
int mLineCount;
|
int mLineCount;
|
||||||
int mGutterClickedLine;
|
int mGutterClickedLine;
|
||||||
|
@ -257,8 +259,8 @@ private:
|
||||||
QString mCurrentWord;
|
QString mCurrentWord;
|
||||||
QString mCurrentDebugTipWord;
|
QString mCurrentDebugTipWord;
|
||||||
TipType mCurrentTipType;
|
TipType mCurrentTipType;
|
||||||
QString mOldSelectionWord;
|
QString mOldHighlightedWord;
|
||||||
QString mSelectionWord;
|
QString mCurrentHighlightedWord;
|
||||||
|
|
||||||
bool mSaving;
|
bool mSaving;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,16 @@ void SynGutter::setChanged()
|
||||||
emit changed();
|
emit changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor &SynGutter::activeLineTextColor() const
|
||||||
|
{
|
||||||
|
return mActiveLineTextColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SynGutter::setActiveLineTextColor(const QColor &newActiveLineTextColor)
|
||||||
|
{
|
||||||
|
mActiveLineTextColor = newActiveLineTextColor;
|
||||||
|
}
|
||||||
|
|
||||||
QColor SynGutter::textColor() const
|
QColor SynGutter::textColor() const
|
||||||
{
|
{
|
||||||
return mTextColor;
|
return mTextColor;
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
QColor textColor() const;
|
QColor textColor() const;
|
||||||
void setTextColor(const QColor &value);
|
void setTextColor(const QColor &value);
|
||||||
|
|
||||||
|
const QColor &activeLineTextColor() const;
|
||||||
|
void setActiveLineTextColor(const QColor &newActiveLineTextColor);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
private:
|
private:
|
||||||
|
@ -84,6 +87,7 @@ private:
|
||||||
bool mAutoSize;
|
bool mAutoSize;
|
||||||
QColor mBorderColor;
|
QColor mBorderColor;
|
||||||
QColor mTextColor;
|
QColor mTextColor;
|
||||||
|
QColor mActiveLineTextColor;
|
||||||
QColor mColor;
|
QColor mColor;
|
||||||
int mDigitCount;
|
int mDigitCount;
|
||||||
QFont mFont;
|
QFont mFont;
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ void SynEdit::processGutterClick(QMouseEvent *event)
|
||||||
rect.setLeft(mGutterWidth - mGutter.rightOffset());
|
rect.setLeft(mGutterWidth - mGutter.rightOffset());
|
||||||
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
|
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
|
||||||
rect.setTop((RowColumn.Row - mTopLine) * mTextHeight);
|
rect.setTop((RowColumn.Row - mTopLine) * mTextHeight);
|
||||||
rect.setBottom(rect.top() + mTextHeight);
|
rect.setBottom(rect.top() + mTextHeight - 1);
|
||||||
if (rect.contains(QPoint(X, Y))) {
|
if (rect.contains(QPoint(X, Y))) {
|
||||||
if (FoldRange->collapsed)
|
if (FoldRange->collapsed)
|
||||||
uncollapse(FoldRange);
|
uncollapse(FoldRange);
|
||||||
|
@ -3081,6 +3081,8 @@ int SynEdit::scanFrom(int Index, int canStopIndex)
|
||||||
|
|
||||||
void SynEdit::rescanRange(int line)
|
void SynEdit::rescanRange(int line)
|
||||||
{
|
{
|
||||||
|
if (!mHighlighter)
|
||||||
|
return;
|
||||||
line--;
|
line--;
|
||||||
line = std::max(0,line);
|
line = std::max(0,line);
|
||||||
if (line >= mLines->count())
|
if (line >= mLines->count())
|
||||||
|
@ -3507,7 +3509,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
|
||||||
ct =mOverwriteCaret;
|
ct =mOverwriteCaret;
|
||||||
}
|
}
|
||||||
if (mCaretUseTextColor) {
|
if (mCaretUseTextColor) {
|
||||||
painter.setPen(palette().color(QPalette::Text));
|
painter.setPen(mForegroundColor);
|
||||||
} else {
|
} else {
|
||||||
painter.setPen(mCaretColor);
|
painter.setPen(mCaretColor);
|
||||||
}
|
}
|
||||||
|
@ -3592,6 +3594,26 @@ void SynEdit::onScrolled(int)
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor &SynEdit::backgroundColor() const
|
||||||
|
{
|
||||||
|
return mBackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SynEdit::setBackgroundColor(const QColor &newBackgroundColor)
|
||||||
|
{
|
||||||
|
mBackgroundColor = newBackgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor &SynEdit::foregroundColor() const
|
||||||
|
{
|
||||||
|
return mForegroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SynEdit::setForegroundColor(const QColor &newForegroundColor)
|
||||||
|
{
|
||||||
|
mForegroundColor = newForegroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
int SynEdit::mouseWheelScrollSpeed() const
|
int SynEdit::mouseWheelScrollSpeed() const
|
||||||
{
|
{
|
||||||
return mMouseWheelScrollSpeed;
|
return mMouseWheelScrollSpeed;
|
||||||
|
@ -4698,6 +4720,8 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
|
||||||
doOnPaintTransient(SynTransientType::ttAfter);
|
doOnPaintTransient(SynTransientType::ttAfter);
|
||||||
});
|
});
|
||||||
int i;
|
int i;
|
||||||
|
// If it's a search only we can leave the procedure now.
|
||||||
|
SynSearchAction searchAction = SynSearchAction::Exit;
|
||||||
while ((ptCurrent.Line >= ptStart.Line) && (ptCurrent.Line <= ptEnd.Line)) {
|
while ((ptCurrent.Line >= ptStart.Line) && (ptCurrent.Line <= ptEnd.Line)) {
|
||||||
int nInLine = searchEngine->findAll(mLines->getString(ptCurrent.Line - 1));
|
int nInLine = searchEngine->findAll(mLines->getString(ptCurrent.Line - 1));
|
||||||
int iResultOffset = 0;
|
int iResultOffset = 0;
|
||||||
|
@ -4748,8 +4772,7 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
|
||||||
internalSetCaretXY(blockBegin());
|
internalSetCaretXY(blockBegin());
|
||||||
else
|
else
|
||||||
internalSetCaretXY(ptCurrent);
|
internalSetCaretXY(ptCurrent);
|
||||||
// If it's a search only we can leave the procedure now.
|
|
||||||
SynSearchAction searchAction = SynSearchAction::Exit;
|
|
||||||
QString replaceText = searchEngine->replace(selText(), sReplace);
|
QString replaceText = searchEngine->replace(selText(), sReplace);
|
||||||
if (matchedCallback && !dobatchReplace) {
|
if (matchedCallback && !dobatchReplace) {
|
||||||
searchAction = matchedCallback(sSearch,replaceText,ptCurrent.Line,
|
searchAction = matchedCallback(sSearch,replaceText,ptCurrent.Line,
|
||||||
|
|
|
@ -376,6 +376,12 @@ public:
|
||||||
int mouseWheelScrollSpeed() const;
|
int mouseWheelScrollSpeed() const;
|
||||||
void setMouseWheelScrollSpeed(int newMouseWheelScrollSpeed);
|
void setMouseWheelScrollSpeed(int newMouseWheelScrollSpeed);
|
||||||
|
|
||||||
|
const QColor &foregroundColor() const;
|
||||||
|
void setForegroundColor(const QColor &newForegroundColor);
|
||||||
|
|
||||||
|
const QColor &backgroundColor() const;
|
||||||
|
void setBackgroundColor(const QColor &newBackgroundColor);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linesDeleted(int FirstLine, int Count);
|
void linesDeleted(int FirstLine, int Count);
|
||||||
void linesInserted(int FirstLine, int Count);
|
void linesInserted(int FirstLine, int Count);
|
||||||
|
@ -610,6 +616,8 @@ private:
|
||||||
PSynHighlighter mHighlighter;
|
PSynHighlighter mHighlighter;
|
||||||
QColor mSelectedForeground;
|
QColor mSelectedForeground;
|
||||||
QColor mSelectedBackground;
|
QColor mSelectedBackground;
|
||||||
|
QColor mForegroundColor;
|
||||||
|
QColor mBackgroundColor;
|
||||||
QColor mCaretColor;
|
QColor mCaretColor;
|
||||||
PSynHighlighterAttribute mRainbowAttr0;
|
PSynHighlighterAttribute mRainbowAttr0;
|
||||||
PSynHighlighterAttribute mRainbowAttr1;
|
PSynHighlighterAttribute mRainbowAttr1;
|
||||||
|
|
|
@ -16,6 +16,7 @@ SynEditTextPainter::SynEditTextPainter(SynEdit *edit, QPainter *painter, int Fir
|
||||||
|
|
||||||
void SynEditTextPainter::paintTextLines(const QRect& clip)
|
void SynEditTextPainter::paintTextLines(const QRect& clip)
|
||||||
{
|
{
|
||||||
|
painter->fillRect(clip, edit->mBackgroundColor);
|
||||||
AClip = clip;
|
AClip = clip;
|
||||||
vFirstLine = edit->rowToLine(aFirstRow);
|
vFirstLine = edit->rowToLine(aFirstRow);
|
||||||
vLastLine = edit->rowToLine(aLastRow);
|
vLastLine = edit->rowToLine(aLastRow);
|
||||||
|
@ -81,14 +82,6 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
|
||||||
|
|
||||||
AClip = clip;
|
AClip = clip;
|
||||||
|
|
||||||
//todo: Does the following comment still apply?
|
|
||||||
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
|
|
||||||
// when absolutely necessary. Note: Never change brush / pen / font of the
|
|
||||||
// canvas inside of this block (only through methods of fTextDrawer)!
|
|
||||||
// If we have to draw the line numbers then we don't want to erase
|
|
||||||
// the background first. Do it line by line with TextRect instead
|
|
||||||
// and fill only the area after the last visible line.
|
|
||||||
//painter->setClipRect(AClip);
|
|
||||||
painter->fillRect(AClip,edit->mGutter.color());
|
painter->fillRect(AClip,edit->mGutter.color());
|
||||||
|
|
||||||
rcLine=AClip;
|
rcLine=AClip;
|
||||||
|
@ -108,16 +101,22 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
|
||||||
newFont.setUnderline(false);
|
newFont.setUnderline(false);
|
||||||
painter->setFont(newFont);
|
painter->setFont(newFont);
|
||||||
}
|
}
|
||||||
|
QColor textColor;
|
||||||
if (edit->mGutter.textColor().isValid()) {
|
if (edit->mGutter.textColor().isValid()) {
|
||||||
painter->setPen(edit->mGutter.textColor());
|
textColor = edit->mGutter.textColor();
|
||||||
} else {
|
} else {
|
||||||
painter->setPen(edit->palette().color(QPalette::Text));
|
textColor = edit->mForegroundColor;
|
||||||
}
|
}
|
||||||
// draw each line if it is not hidden by a fold
|
// draw each line if it is not hidden by a fold
|
||||||
for (int cRow = aFirstRow; cRow <= aLastRow; cRow++) {
|
for (int cRow = aFirstRow; cRow <= aLastRow; cRow++) {
|
||||||
vLine = edit->rowToLine(cRow);
|
vLine = edit->rowToLine(cRow);
|
||||||
if ((vLine > edit->mLines->count()) && (edit->mLines->count() > 0 ))
|
if ((vLine > edit->mLines->count()) && (edit->mLines->count() > 0 ))
|
||||||
break;
|
break;
|
||||||
|
if (edit->mCaretY==vLine && edit->mGutter.activeLineTextColor().isValid()) {
|
||||||
|
painter->setPen(edit->mGutter.activeLineTextColor());
|
||||||
|
} else {
|
||||||
|
painter->setPen(textColor);
|
||||||
|
}
|
||||||
vLineTop = (cRow - edit->mTopLine) * edit->mTextHeight;
|
vLineTop = (cRow - edit->mTopLine) * edit->mTextHeight;
|
||||||
|
|
||||||
// next line rect
|
// next line rect
|
||||||
|
@ -270,14 +269,8 @@ QColor SynEditTextPainter::colEditorBG()
|
||||||
if (edit->mActiveLineColor.isValid() && bCurrentLine) {
|
if (edit->mActiveLineColor.isValid() && bCurrentLine) {
|
||||||
return edit->mActiveLineColor;
|
return edit->mActiveLineColor;
|
||||||
} else {
|
} else {
|
||||||
if (edit->mHighlighter) {
|
return edit->mBackgroundColor;
|
||||||
PSynHighlighterAttribute attr = edit->mHighlighter->whitespaceAttribute();
|
|
||||||
if (attr && attr->background().isValid()) {
|
|
||||||
return attr->background();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return edit->palette().color(QPalette::Base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditTextPainter::ComputeSelectionInfo()
|
void SynEditTextPainter::ComputeSelectionInfo()
|
||||||
|
@ -351,13 +344,19 @@ void SynEditTextPainter::ComputeSelectionInfo()
|
||||||
void SynEditTextPainter::setDrawingColors(bool Selected)
|
void SynEditTextPainter::setDrawingColors(bool Selected)
|
||||||
{
|
{
|
||||||
if (Selected) {
|
if (Selected) {
|
||||||
|
if (colSelFG.isValid())
|
||||||
painter->setPen(colSelFG);
|
painter->setPen(colSelFG);
|
||||||
|
else
|
||||||
|
painter->setPen(colFG);
|
||||||
|
if (colSelBG.isValid())
|
||||||
painter->setBrush(colSelBG);
|
painter->setBrush(colSelBG);
|
||||||
painter->setBackground(colSelBG);
|
else
|
||||||
|
painter->setBrush(colBG);
|
||||||
|
painter->setBackground(edit->mBackgroundColor);
|
||||||
} else {
|
} else {
|
||||||
painter->setPen(colFG);
|
painter->setPen(colFG);
|
||||||
painter->setBrush(colBG);
|
painter->setBrush(colBG);
|
||||||
painter->setBackground(colBG);
|
painter->setBackground(edit->mBackgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +375,9 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
|
||||||
nX = ColumnToXValue(First);
|
nX = ColumnToXValue(First);
|
||||||
First -= ColumnsBefore;
|
First -= ColumnsBefore;
|
||||||
Last -= ColumnsBefore;
|
Last -= ColumnsBefore;
|
||||||
painter->fillRect(rcToken,painter->brush());
|
QRect rcTokenBack = rcToken;
|
||||||
|
rcTokenBack.setWidth(rcTokenBack.width()-1);
|
||||||
|
painter->fillRect(rcTokenBack,painter->brush());
|
||||||
if (First > TokenCols) {
|
if (First > TokenCols) {
|
||||||
} else {
|
} else {
|
||||||
int tokenColLen=0;
|
int tokenColLen=0;
|
||||||
|
@ -588,8 +589,6 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
|
||||||
SynFontStyles Style;
|
SynFontStyles Style;
|
||||||
bool bSpacesTest,bIsSpaces;
|
bool bSpacesTest,bIsSpaces;
|
||||||
|
|
||||||
// qDebug()<<"Add highlight token"<<Token<<ColumnsBefore<<TokenColumns<<cLine;
|
|
||||||
|
|
||||||
if (p_Attri) {
|
if (p_Attri) {
|
||||||
Foreground = p_Attri->foreground();
|
Foreground = p_Attri->foreground();
|
||||||
Background = p_Attri->background();
|
Background = p_Attri->background();
|
||||||
|
@ -604,7 +603,7 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
|
||||||
Background = colEditorBG();
|
Background = colEditorBG();
|
||||||
}
|
}
|
||||||
if (!Foreground.isValid()) {
|
if (!Foreground.isValid()) {
|
||||||
Foreground = edit->palette().color(QPalette::Text);
|
Foreground = edit->mForegroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
edit->onPreparePaintHighlightToken(cLine,edit->mHighlighter->getTokenPos()+1,
|
edit->onPreparePaintHighlightToken(cLine,edit->mHighlighter->getTokenPos()+1,
|
||||||
|
@ -618,7 +617,7 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
|
||||||
if (TokenAccu.Style == Style || ( (Style & SynFontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline)
|
if (TokenAccu.Style == Style || ( (Style & SynFontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline)
|
||||||
&& TokenIsSpaces(bSpacesTest,Token,bIsSpaces)) ) {
|
&& TokenIsSpaces(bSpacesTest,Token,bIsSpaces)) ) {
|
||||||
// either special colors or same colors
|
// either special colors or same colors
|
||||||
if ((bSpecialLine && !(edit->mOptions.testFlag(SynEditorOption::eoSpecialLineDefaultFg))) || bLineSelected ||
|
if ((bSpecialLine && !(edit->mOptions.testFlag(SynEditorOption::eoSpecialLineDefaultFg))) ||
|
||||||
// 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
|
||||||
|
@ -819,14 +818,8 @@ void SynEditTextPainter::PaintLines()
|
||||||
colBG = colEditorBG();
|
colBG = colEditorBG();
|
||||||
bSpecialLine = edit->onGetSpecialLineColors(vLine, colFG, colBG);
|
bSpecialLine = edit->onGetSpecialLineColors(vLine, colFG, colBG);
|
||||||
|
|
||||||
if (bSpecialLine) {
|
|
||||||
// The selection colors are just swapped, like seen in Delphi.
|
|
||||||
colSelFG = colBG;
|
|
||||||
colSelBG = colFG;
|
|
||||||
} else {
|
|
||||||
colSelFG = edit->mSelectedForeground;
|
colSelFG = edit->mSelectedForeground;
|
||||||
colSelBG = edit->mSelectedBackground;
|
colSelBG = edit->mSelectedBackground;
|
||||||
}
|
|
||||||
edit->onGetEditingAreas(vLine, areaList);
|
edit->onGetEditingAreas(vLine, areaList);
|
||||||
// Removed word wrap support
|
// Removed word wrap support
|
||||||
vFirstChar = FirstCol;
|
vFirstChar = FirstCol;
|
||||||
|
@ -867,8 +860,10 @@ void SynEditTextPainter::PaintLines()
|
||||||
} //endif bAnySelection
|
} //endif bAnySelection
|
||||||
|
|
||||||
// Update the rcLine rect to this line.
|
// Update the rcLine rect to this line.
|
||||||
rcLine.setTop(rcLine.bottom());
|
// rcLine.setTop(rcLine.bottom());
|
||||||
rcLine.setBottom(rcLine.bottom()+edit->mTextHeight);
|
// rcLine.setBottom(rcLine.bottom()+edit->mTextHeight);
|
||||||
|
rcLine.setTop((cRow - edit->mTopLine) * edit->mTextHeight);
|
||||||
|
rcLine.setHeight(edit->mTextHeight);
|
||||||
|
|
||||||
bLineSelected = (!bComplexLine) && (nLineSelStart > 0);
|
bLineSelected = (!bComplexLine) && (nLineSelStart > 0);
|
||||||
rcToken = rcLine;
|
rcToken = rcLine;
|
||||||
|
|
|
@ -189,18 +189,23 @@ void EditorColorSchemeWidget::onItemSelectionChanged()
|
||||||
ui->colorForeground->setEnabled(define->hasForeground());
|
ui->colorForeground->setEnabled(define->hasForeground());
|
||||||
ui->grpFontStyles->setEnabled(define->hasFontStyle());
|
ui->grpFontStyles->setEnabled(define->hasFontStyle());
|
||||||
PColorSchemeItem item = pColorManager->getItem(ui->cbScheme->currentText(), name);
|
PColorSchemeItem item = pColorManager->getItem(ui->cbScheme->currentText(), name);
|
||||||
if (item) {
|
if (!item) {
|
||||||
if (define->hasBackground()) {
|
PColorScheme scheme = pColorManager->get(ui->cbScheme->currentText());
|
||||||
|
if (scheme) {
|
||||||
|
scheme->addItem(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (define->hasBackground() && item) {
|
||||||
setColorProp(ui->colorBackground, ui->cbBackground,item->background());
|
setColorProp(ui->colorBackground, ui->cbBackground,item->background());
|
||||||
} else {
|
} else {
|
||||||
setColorProp(ui->colorBackground, ui->cbBackground,QColor());
|
setColorProp(ui->colorBackground, ui->cbBackground,QColor());
|
||||||
}
|
}
|
||||||
if (define->hasForeground()) {
|
if (define->hasForeground() && item) {
|
||||||
setColorProp(ui->colorForeground, ui->cbForeground,item->foreground());
|
setColorProp(ui->colorForeground, ui->cbForeground,item->foreground());
|
||||||
} else {
|
} else {
|
||||||
setColorProp(ui->colorForeground, ui->cbForeground,QColor());
|
setColorProp(ui->colorForeground, ui->cbForeground,QColor());
|
||||||
}
|
}
|
||||||
if (define->hasFontStyle()) {
|
if (define->hasFontStyle() && item) {
|
||||||
ui->cbBold->setChecked(item->bold());
|
ui->cbBold->setChecked(item->bold());
|
||||||
ui->cbItalic->setChecked(item->italic());
|
ui->cbItalic->setChecked(item->italic());
|
||||||
ui->cbUnderlined->setChecked(item->underlined());
|
ui->cbUnderlined->setChecked(item->underlined());
|
||||||
|
@ -213,7 +218,6 @@ void EditorColorSchemeWidget::onItemSelectionChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ui->widgetSchemeItem->setEnabled(found);
|
ui->widgetSchemeItem->setEnabled(found);
|
||||||
connectModificationSlots();
|
connectModificationSlots();
|
||||||
|
|
|
@ -73,7 +73,7 @@ void ColorEdit::paintEvent(QPaintEvent *)
|
||||||
painter.setBrush(palette().color(QPalette::Disabled,QPalette::Base));
|
painter.setBrush(palette().color(QPalette::Disabled,QPalette::Base));
|
||||||
}
|
}
|
||||||
painter.drawRect(rect);
|
painter.drawRect(rect);
|
||||||
painter.drawText(rect,Qt::AlignCenter, mColor.name());
|
painter.drawText(rect,Qt::AlignCenter, mColor.name(QColor::HexArgb));
|
||||||
} else {
|
} else {
|
||||||
//painter.fillRect(rect,palette().color(QPalette::Base));
|
//painter.fillRect(rect,palette().color(QPalette::Base));
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
|
@ -92,7 +92,8 @@ void ColorEdit::paintEvent(QPaintEvent *)
|
||||||
|
|
||||||
void ColorEdit::mouseReleaseEvent(QMouseEvent *)
|
void ColorEdit::mouseReleaseEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
QColor c = QColorDialog::getColor();
|
QColor c = QColorDialog::getColor(mColor,nullptr,tr("Color"),
|
||||||
|
QColorDialog::ShowAlphaChannel | QColorDialog::DontUseNativeDialog);
|
||||||
if (c.isValid()) {
|
if (c.isValid()) {
|
||||||
setColor(c);
|
setColor(c);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue