- enhancement: "Line Spacing" in options / editor / font

- enhancement: "Show whitespaces" in options / editor / font
This commit is contained in:
Roy Qu 2022-12-20 20:38:02 +08:00
parent ed89690f7a
commit 892b987894
13 changed files with 509 additions and 244 deletions

View File

@ -20,6 +20,8 @@ Red Panda C++ Version 2.7
- fix: Project's "static link" option is overwrited by global compiler set settings, when project options dialog is opened. - fix: Project's "static link" option is overwrited by global compiler set settings, when project options dialog is opened.
- fix: Icon size not correct under macOS high DPI / zoom factor settings. - fix: Icon size not correct under macOS high DPI / zoom factor settings.
- enhancement: "Icon zoom" in options / environment / appearance - enhancement: "Icon zoom" in options / environment / appearance
- enhancement: "Line Spacing" in options / editor / font
- enhancement: "Show whitespaces" in options / editor / font
Red Panda C++ Version 2.6 Red Panda C++ Version 2.6

View File

@ -4705,7 +4705,10 @@ 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, pSettings->editor().showSpecialChars()); options.setFlag(QSynedit::eoShowLeadingSpaces, pSettings->editor().showLeadingSpaces());
options.setFlag(QSynedit::eoShowTrailingSpaces, pSettings->editor().showTrailingSpaces());
options.setFlag(QSynedit::eoShowInnerSpaces, pSettings->editor().showInnerSpaces());
options.setFlag(QSynedit::eoShowLineBreaks, pSettings->editor().showLineBreaks());
//options //options
options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent()); options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent());
@ -4746,6 +4749,7 @@ void Editor::applySettings()
f2.setPixelSize(pointToPixel(pSettings->editor().fontSize())); f2.setPixelSize(pointToPixel(pSettings->editor().fontSize()));
f2.setStyleStrategy(QFont::PreferAntialias); f2.setStyleStrategy(QFont::PreferAntialias);
setFontForNonAscii(f2); setFontForNonAscii(f2);
setLineSpacingFactor(pSettings->editor().lineSpacing());
// Set gutter properties // Set gutter properties
gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset()); gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset());

View File

@ -735,14 +735,54 @@ void Settings::Editor::setRemoveTrailingSpacesWhenSaved(bool newRemoveTrailingSp
mRemoveTrailingSpacesWhenSaved = newRemoveTrailingSpacesWhenSaved; mRemoveTrailingSpacesWhenSaved = newRemoveTrailingSpacesWhenSaved;
} }
bool Settings::Editor::showSpecialChars() const double Settings::Editor::lineSpacing() const
{ {
return mShowSpecialChars; return mLineSpacing;
} }
void Settings::Editor::setShowSpecialChars(bool newShowSpecialChars) void Settings::Editor::setLineSpacing(double newLineSpacing)
{ {
mShowSpecialChars = newShowSpecialChars; mLineSpacing = newLineSpacing;
}
bool Settings::Editor::showLeadingSpaces() const
{
return mShowLeadingSpaces;
}
void Settings::Editor::setShowLeadingSpaces(bool newShowStartSpaces)
{
mShowLeadingSpaces = newShowStartSpaces;
}
bool Settings::Editor::showTrailingSpaces() const
{
return mShowTrailingSpaces;
}
void Settings::Editor::setShowTrailingSpaces(bool newShowEndSpaces)
{
mShowTrailingSpaces = newShowEndSpaces;
}
bool Settings::Editor::showInnerSpaces() const
{
return mShowInnerSpaces;
}
void Settings::Editor::setShowInnerSpaces(bool newShowMiddleSpaces)
{
mShowInnerSpaces = newShowMiddleSpaces;
}
bool Settings::Editor::showLineBreaks() const
{
return mShowLineBreaks;
}
void Settings::Editor::setShowLineBreaks(bool newShowLineBreaks)
{
mShowLineBreaks = newShowLineBreaks;
} }
bool Settings::Editor::highlightCurrentWord() const bool Settings::Editor::highlightCurrentWord() const
@ -1235,8 +1275,6 @@ void Settings::Editor::doSave()
saveValue("caret_use_text_color",mCaretUseTextColor); saveValue("caret_use_text_color",mCaretUseTextColor);
saveValue("caret_color",mCaretColor); saveValue("caret_color",mCaretColor);
saveValue("show_special_chars",mShowSpecialChars);
//highlight //highlight
saveValue("highlight_matching_braces",mHighlightMathingBraces); saveValue("highlight_matching_braces",mHighlightMathingBraces);
saveValue("highlight_current_word",mHighlightCurrentWord); saveValue("highlight_current_word",mHighlightCurrentWord);
@ -1261,8 +1299,14 @@ void Settings::Editor::doSave()
saveValue("non_ascii_font_name", mNonAsciiFontName); saveValue("non_ascii_font_name", mNonAsciiFontName);
saveValue("font_size", mFontSize); saveValue("font_size", mFontSize);
saveValue("font_only_monospaced", mFontOnlyMonospaced); saveValue("font_only_monospaced", mFontOnlyMonospaced);
saveValue("line_spacing",mLineSpacing);
saveValue("enable_ligatures_support", mEnableLigaturesSupport); saveValue("enable_ligatures_support", mEnableLigaturesSupport);
saveValue("show_leading_spaces", mShowLeadingSpaces);
saveValue("show_trailing_spaces", mShowTrailingSpaces);
saveValue("show_inner_spaces", mShowInnerSpaces);
saveValue("show_line_breaks", mShowLineBreaks);
//gutter //gutter
saveValue("gutter_visible", mGutterVisible); saveValue("gutter_visible", mGutterVisible);
saveValue("gutter_auto_size", mGutterAutoSize); saveValue("gutter_auto_size", mGutterAutoSize);
@ -1362,9 +1406,6 @@ void Settings::Editor::doLoad()
mCaretUseTextColor = boolValue("caret_use_text_color",true); mCaretUseTextColor = boolValue("caret_use_text_color",true);
mCaretColor = colorValue("caret_color",Qt::yellow); mCaretColor = colorValue("caret_color",Qt::yellow);
mShowSpecialChars = boolValue("show_special_chars",false);
//highlight //highlight
mHighlightMathingBraces = boolValue("highlight_matching_braces",true); mHighlightMathingBraces = boolValue("highlight_matching_braces",true);
mHighlightCurrentWord = boolValue("highlight_current_word",true); mHighlightCurrentWord = boolValue("highlight_current_word",true);
@ -1397,8 +1438,14 @@ void Settings::Editor::doLoad()
#endif #endif
mFontSize = intValue("font_size",12); mFontSize = intValue("font_size",12);
mFontOnlyMonospaced = boolValue("font_only_monospaced",true); mFontOnlyMonospaced = boolValue("font_only_monospaced",true);
mLineSpacing = doubleValue("line_spacing",1.0);
mEnableLigaturesSupport = boolValue("enable_ligatures_support", false); mEnableLigaturesSupport = boolValue("enable_ligatures_support", false);
mShowLeadingSpaces = boolValue("show_leading_spaces", false);
mShowTrailingSpaces = boolValue("show_trailing_spaces", false);
mShowInnerSpaces = boolValue("show_inner_spaces", false);
mShowLineBreaks = boolValue("show_line_breaks", false);
//gutter //gutter
mGutterVisible = boolValue("gutter_visible",true); mGutterVisible = boolValue("gutter_visible",true);
mGutterAutoSize = boolValue("gutter_auto_size",true); mGutterAutoSize = boolValue("gutter_auto_size",true);
@ -1716,27 +1763,27 @@ QString Settings::CompilerSet::getCompileOptionValue(const QString &key)
return mCompileOptions.value(key,QString()); return mCompileOptions.value(key,QString());
} }
static void checkDirs(const QStringList& dirlist, QString& gooddirs, QString& baddirs) { //static void checkDirs(const QStringList& dirlist, QString& gooddirs, QString& baddirs) {
gooddirs = ""; // gooddirs = "";
baddirs = ""; // baddirs = "";
for (int i=0; i<dirlist.count();i++) { // for (int i=0; i<dirlist.count();i++) {
QDir dir(dirlist[i]); // QDir dir(dirlist[i]);
if (!dir.exists()) { // if (!dir.exists()) {
if (baddirs.isEmpty()) { // if (baddirs.isEmpty()) {
baddirs = dirlist[i]; // baddirs = dirlist[i];
} else { // } else {
baddirs += ";" + dirlist[i]; // baddirs += ";" + dirlist[i];
} // }
} else { // } else {
if (gooddirs.isEmpty()) { // if (gooddirs.isEmpty()) {
gooddirs = dirlist[i]; // gooddirs = dirlist[i];
} else { // } else {
gooddirs += ";" + dirlist[i]; // gooddirs += ";" + dirlist[i];
} // }
} // }
} // }
} //}
//bool Settings::CompilerSet::dirsValid(QString &msg) //bool Settings::CompilerSet::dirsValid(QString &msg)

View File

@ -383,8 +383,20 @@ public:
bool removeTrailingSpacesWhenSaved() const; bool removeTrailingSpacesWhenSaved() const;
void setRemoveTrailingSpacesWhenSaved(bool newRemoveTrailingSpacesWhenSaved); void setRemoveTrailingSpacesWhenSaved(bool newRemoveTrailingSpacesWhenSaved);
bool showSpecialChars() const; double lineSpacing() const;
void setShowSpecialChars(bool newShowSpecialChars); void setLineSpacing(double newLineSpacing);
bool showLineBreaks() const;
void setShowLineBreaks(bool newShowLineBreaks);
bool showInnerSpaces() const;
void setShowInnerSpaces(bool newShowMiddleSpaces);
bool showTrailingSpaces() const;
void setShowTrailingSpaces(bool newShowEndSpaces);
bool showLeadingSpaces() const;
void setShowLeadingSpaces(bool newShowStartSpaces);
private: private:
//General //General
@ -403,8 +415,7 @@ public:
QSynedit::EditCaretType mCaretForOverwrite; QSynedit::EditCaretType mCaretForOverwrite;
bool mCaretUseTextColor; bool mCaretUseTextColor;
QColor mCaretColor; QColor mCaretColor;
//
bool mShowSpecialChars;
//highlights //highlights
bool mHighlightCurrentWord; bool mHighlightCurrentWord;
@ -431,6 +442,12 @@ public:
QString mNonAsciiFontName; QString mNonAsciiFontName;
int mFontSize; int mFontSize;
bool mFontOnlyMonospaced; bool mFontOnlyMonospaced;
double mLineSpacing;
bool mShowLeadingSpaces;
bool mShowTrailingSpaces;
bool mShowInnerSpaces;
bool mShowLineBreaks;
//gutter //gutter
bool mGutterVisible; bool mGutterVisible;

View File

@ -58,8 +58,12 @@ void EditorFontWidget::doLoad()
ui->cbFont->setCurrentFont(QFont(pSettings->editor().fontName())); ui->cbFont->setCurrentFont(QFont(pSettings->editor().fontName()));
ui->cbNonAsciiFont->setCurrentFont(QFont(pSettings->editor().nonAsciiFontName())); ui->cbNonAsciiFont->setCurrentFont(QFont(pSettings->editor().nonAsciiFontName()));
ui->spinFontSize->setValue(pSettings->editor().fontSize()); ui->spinFontSize->setValue(pSettings->editor().fontSize());
ui->spinLineSpacing->setValue(pSettings->editor().lineSpacing());
ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport()); ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport());
ui->chkShowSpecialChars->setChecked(pSettings->editor().showSpecialChars()); ui->chkLeadingSpaces->setChecked(pSettings->editor().showLeadingSpaces());
ui->chkInnerSpaces->setChecked(pSettings->editor().showInnerSpaces());
ui->chkTrailingSpaces->setChecked(pSettings->editor().showTrailingSpaces());
ui->chkLineBreaks->setChecked(pSettings->editor().showLineBreaks());
//gutter //gutter
ui->chkGutterVisible->setChecked(pSettings->editor().gutterVisible()); ui->chkGutterVisible->setChecked(pSettings->editor().gutterVisible());
ui->chkAutoSizeGutter->setChecked(pSettings->editor().gutterAutoSize()); ui->chkAutoSizeGutter->setChecked(pSettings->editor().gutterAutoSize());
@ -82,8 +86,13 @@ void EditorFontWidget::doSave()
pSettings->editor().setFontName(ui->cbFont->currentFont().family()); pSettings->editor().setFontName(ui->cbFont->currentFont().family());
pSettings->editor().setNonAsciiFontName(ui->cbNonAsciiFont->currentFont().family()); pSettings->editor().setNonAsciiFontName(ui->cbNonAsciiFont->currentFont().family());
pSettings->editor().setFontSize(ui->spinFontSize->value()); pSettings->editor().setFontSize(ui->spinFontSize->value());
pSettings->editor().setLineSpacing(ui->spinLineSpacing->value());
pSettings->editor().setEnableLigaturesSupport(ui->chkLigature->isChecked()); pSettings->editor().setEnableLigaturesSupport(ui->chkLigature->isChecked());
pSettings->editor().setShowSpecialChars(ui->chkShowSpecialChars->isChecked()); pSettings->editor().setShowLeadingSpaces(ui->chkLeadingSpaces->isChecked());
pSettings->editor().setShowInnerSpaces(ui->chkInnerSpaces->isChecked());
pSettings->editor().setShowTrailingSpaces(ui->chkTrailingSpaces->isChecked());
pSettings->editor().setShowLineBreaks(ui->chkLineBreaks->isChecked());
//gutter //gutter
pSettings->editor().setGutterVisible(ui->chkGutterVisible->isChecked()); pSettings->editor().setGutterVisible(ui->chkGutterVisible->isChecked());
pSettings->editor().setGutterAutoSize(ui->chkAutoSizeGutter->isChecked()); pSettings->editor().setGutterAutoSize(ui->chkAutoSizeGutter->isChecked());

View File

@ -23,13 +23,146 @@
<property name="rightMargin"> <property name="rightMargin">
<number>11</number> <number>11</number>
</property> </property>
<item row="0" column="0"> <item row="1" column="1">
<widget class="QLabel" name="label"> <widget class="QWidget" name="widget_9" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFontComboBox" name="cbNonAsciiFont"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="widget_10" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spinLineSpacing">
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>3.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>563</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Font:</string> <string>Size:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="chkLigature">
<property name="text">
<string>Enable ligatures support</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Line Spacing:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSpinBox" name="spinFontSize">
<property name="minimum">
<number>2</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QWidget" name="widget_2" native="true"> <widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
@ -81,51 +214,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSpinBox" name="spinFontSize">
<property name="minimum">
<number>2</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
@ -133,51 +221,47 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="0">
<widget class="QWidget" name="widget_9" native="true"> <widget class="QLabel" name="label">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFontComboBox" name="cbNonAsciiFont"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="chkShowSpecialChars">
<property name="text"> <property name="text">
<string>Show special chars</string> <string>Font:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> </layout>
<widget class="QCheckBox" name="chkLigature"> </widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Show whitespaces</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QCheckBox" name="chkLeadingSpaces">
<property name="text"> <property name="text">
<string>Enable ligatures support</string> <string>Leading</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkInnerSpaces">
<property name="text">
<string>Inner</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkTrailingSpaces">
<property name="text">
<string>Trailing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkLineBreaks">
<property name="text">
<string>Line break</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1402,11 +1402,31 @@
<translation>Usar fonte personalizada</translation> <translation>Usar fonte personalizada</translation>
</message> </message>
<message> <message>
<source>Show special chars</source> <source>Enable ligatures support</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Enable ligatures support</source> <source>Line Spacing:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show whitespaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Leading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inner</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Trailing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line break</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>

View File

@ -1458,7 +1458,7 @@ Are you really want to continue?</oldsource>
<translation>:</translation> <translation>:</translation>
</message> </message>
<message> <message>
<location filename="../editor.cpp" line="4913"/> <location filename="../editor.cpp" line="4917"/>
<source>Readonly</source> <source>Readonly</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1568,7 +1568,7 @@ Are you really want to continue?</oldsource>
<message> <message>
<location filename="../settingsdialog/editorclipboardwidget.ui" line="107"/> <location filename="../settingsdialog/editorclipboardwidget.ui" line="107"/>
<source>Copy with format as</source> <source>Copy with format as</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorclipboardwidget.ui" line="133"/> <location filename="../settingsdialog/editorclipboardwidget.ui" line="133"/>
@ -1859,20 +1859,20 @@ Are you really want to continue?</oldsource>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="125"/> <location filename="../settingsdialog/editorfontwidget.ui" line="110"/>
<location filename="../settingsdialog/editorfontwidget.ui" line="410"/> <location filename="../settingsdialog/editorfontwidget.ui" line="494"/>
<source>Size:</source> <source>Size:</source>
<translation>:</translation> <translation>:</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="29"/> <location filename="../settingsdialog/editorfontwidget.ui" line="227"/>
<location filename="../settingsdialog/editorfontwidget.ui" line="403"/> <location filename="../settingsdialog/editorfontwidget.ui" line="487"/>
<source>Font:</source> <source>Font:</source>
<translation>:</translation> <translation>:</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="64"/> <location filename="../settingsdialog/editorfontwidget.ui" line="197"/>
<location filename="../settingsdialog/editorfontwidget.ui" line="498"/> <location filename="../settingsdialog/editorfontwidget.ui" line="582"/>
<source>Show only monospaced fonts</source> <source>Show only monospaced fonts</source>
<translation></translation> <translation></translation>
</message> </message>
@ -1881,67 +1881,96 @@ Are you really want to continue?</oldsource>
<translation type="vanished">Fira Code等字体</translation> <translation type="vanished">Fira Code等字体</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="132"/> <location filename="../settingsdialog/editorfontwidget.ui" line="220"/>
<source>Font for non-ascii Text:</source> <source>Font for non-ascii Text:</source>
<translation>:</translation> <translation>:</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="173"/>
<source>Show special chars</source> <source>Show special chars</source>
<translation></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="180"/> <location filename="../settingsdialog/editorfontwidget.ui" line="117"/>
<source>Enable ligatures support</source> <source>Enable ligatures support</source>
<translation>(ligratures)</translation> <translation>(ligratures)</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="190"/> <location filename="../settingsdialog/editorfontwidget.ui" line="124"/>
<source>Line Spacing:</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="237"/>
<source>Show whitespaces</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="243"/>
<source>Leading</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="250"/>
<source>Inner</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="257"/>
<source>Trailing</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="264"/>
<source>Line break</source>
<translation></translation>
</message>
<message>
<location filename="../settingsdialog/editorfontwidget.ui" line="274"/>
<source>Gutter</source> <source>Gutter</source>
<translation>线</translation> <translation>线</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="211"/> <location filename="../settingsdialog/editorfontwidget.ui" line="295"/>
<source>Gutter is visible</source> <source>Gutter is visible</source>
<translation>线</translation> <translation>线</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="233"/> <location filename="../settingsdialog/editorfontwidget.ui" line="317"/>
<source>Left Offset</source> <source>Left Offset</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="250"/> <location filename="../settingsdialog/editorfontwidget.ui" line="334"/>
<source>Right Offset</source> <source>Right Offset</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="283"/> <location filename="../settingsdialog/editorfontwidget.ui" line="367"/>
<source>Show Line Numbers</source> <source>Show Line Numbers</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="307"/> <location filename="../settingsdialog/editorfontwidget.ui" line="391"/>
<source>Add leading zeros to line numbers</source> <source>Add leading zeros to line numbers</source>
<translation>0</translation> <translation>0</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="314"/> <location filename="../settingsdialog/editorfontwidget.ui" line="398"/>
<source>Line numbers starts at zero</source> <source>Line numbers starts at zero</source>
<translation>0</translation> <translation>0</translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="321"/> <location filename="../settingsdialog/editorfontwidget.ui" line="405"/>
<source>Auto calculate the digit count of line number</source> <source>Auto calculate the digit count of line number</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="343"/> <location filename="../settingsdialog/editorfontwidget.ui" line="427"/>
<source>Digit count</source> <source>Digit count</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settingsdialog/editorfontwidget.ui" line="379"/> <location filename="../settingsdialog/editorfontwidget.ui" line="463"/>
<source>Use Custom Font</source> <source>Use Custom Font</source>
<translation>使</translation> <translation>使</translation>
</message> </message>
@ -8030,7 +8059,7 @@ Are you really want to continue?</oldsource>
<translation>(-g3)</translation> <translation>(-g3)</translation>
</message> </message>
<message> <message>
<location filename="../settings.cpp" line="2909"/> <location filename="../settings.cpp" line="2956"/>
<source>Would you like Red Panda C++ to search for compilers in PATH?</source> <source>Would you like Red Panda C++ to search for compilers in PATH?</source>
<translation>C++PATH路径中寻找gcc编译器吗</translation> <translation>C++PATH路径中寻找gcc编译器吗</translation>
</message> </message>
@ -8143,7 +8172,7 @@ Are you really want to continue?</oldsource>
<translation type="vanished">(-S)</translation> <translation type="vanished">(-S)</translation>
</message> </message>
<message> <message>
<location filename="../settings.cpp" line="2911"/> <location filename="../settings.cpp" line="2958"/>
<source>Confirm</source> <source>Confirm</source>
<translation></translation> <translation></translation>
</message> </message>
@ -8164,13 +8193,13 @@ Are you really want to continue?</oldsource>
<translation type="vanished">&lt;br /&gt;&lt;br /&gt;</translation> <translation type="vanished">&lt;br /&gt;&lt;br /&gt;</translation>
</message> </message>
<message> <message>
<location filename="../settings.cpp" line="2901"/> <location filename="../settings.cpp" line="2948"/>
<location filename="../settings.cpp" line="2907"/> <location filename="../settings.cpp" line="2954"/>
<source>Compiler set not configuared.</source> <source>Compiler set not configuared.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../settings.cpp" line="2903"/> <location filename="../settings.cpp" line="2950"/>
<source>Would you like Red Panda C++ to search for compilers in the following locations: &lt;BR /&gt;&apos;%1&apos;&lt;BR /&gt;&apos;%2&apos;? </source> <source>Would you like Red Panda C++ to search for compilers in the following locations: &lt;BR /&gt;&apos;%1&apos;&lt;BR /&gt;&apos;%2&apos;? </source>
<translation>C++&lt;br /&gt;%1&lt;br /&gt;%2</translation> <translation>C++&lt;br /&gt;%1&lt;br /&gt;%2</translation>
</message> </message>

View File

@ -1287,11 +1287,31 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Show special chars</source> <source>Enable ligatures support</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Enable ligatures support</source> <source>Line Spacing:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show whitespaces</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Leading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Inner</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Trailing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Line break</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>

View File

@ -105,7 +105,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent),
this->setCursor(Qt::CursorShape::IBeamCursor); this->setCursor(Qt::CursorShape::IBeamCursor);
//TabStop := True; //TabStop := True;
mInserting = true; mInserting = true;
mExtraLineSpacing = 0; mLineSpacingFactor = 1.0;
this->setFrameShape(QFrame::Panel); this->setFrameShape(QFrame::Panel);
this->setFrameShadow(QFrame::Sunken); this->setFrameShadow(QFrame::Sunken);
@ -3405,7 +3405,7 @@ void SynEdit::recalcCharExtent()
if (fm.horizontalAdvance("M")>mCharWidth) if (fm.horizontalAdvance("M")>mCharWidth)
mCharWidth = fm.horizontalAdvance("M"); mCharWidth = fm.horizontalAdvance("M");
} }
mTextHeight += mExtraLineSpacing; mTextHeight *= mLineSpacingFactor;
} }
QString SynEdit::expandAtWideGlyphs(const QString &S) QString SynEdit::expandAtWideGlyphs(const QString &S)
@ -3968,6 +3968,19 @@ void SynEdit::onScrolled(int)
invalidate(); invalidate();
} }
double SynEdit::lineSpacingFactor() const
{
return mLineSpacingFactor;
}
void SynEdit::setLineSpacingFactor(double newLineSpacingFactor)
{
if (newLineSpacingFactor<1.0)
newLineSpacingFactor = 1.0;
mLineSpacingFactor = newLineSpacingFactor;
recalcCharExtent();
}
ScrollStyle SynEdit::scrollBars() const ScrollStyle SynEdit::scrollBars() const
{ {
return mScrollBars; return mScrollBars;
@ -4185,6 +4198,10 @@ EditorOptions SynEdit::getOptions() const
return mOptions; return mOptions;
} }
static bool sameEditorOption(const EditorOptions& value1, const EditorOptions& value2, EditorOption flag) {
return value1.testFlag(flag)==value2.testFlag(flag);
}
void SynEdit::setOptions(const EditorOptions &Value) void SynEdit::setOptions(const EditorOptions &Value)
{ {
if (Value != mOptions) { if (Value != mOptions) {
@ -4195,8 +4212,11 @@ void SynEdit::setOptions(const EditorOptions &Value)
setTopLine(mTopLine); setTopLine(mTopLine);
bool bUpdateAll = bool bUpdateAll =
(Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars)) !sameEditorOption(Value,mOptions,eoShowLeadingSpaces)
|| (Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor)); || !sameEditorOption(Value,mOptions,eoShowInnerSpaces)
|| !sameEditorOption(Value,mOptions,eoShowTrailingSpaces)
|| !sameEditorOption(Value,mOptions,eoShowLineBreaks)
|| !sameEditorOption(Value,mOptions,eoShowRainbowColor);
//bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions); //bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions);
bool bUpdateScroll = true; bool bUpdateScroll = true;
mOptions = Value; mOptions = Value;

View File

@ -89,12 +89,16 @@ enum EditorOption {
eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less
eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker
eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line
eoShowSpecialChars = 0x00008000, //Shows the special Characters // eoShowSpecialChars = 0x00008000, //Shows the special Characters
// eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event // eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event
eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters
eoShowRainbowColor = 0x00080000, eoShowRainbowColor = 0x00080000,
eoSelectWordByDblClick= 0x00100000, eoSelectWordByDblClick= 0x00100000,
eoShowLeadingSpaces = 0x00200000,
eoShowTrailingSpaces = 0x00400000,
eoShowInnerSpaces= 0x00800000,
eoShowLineBreaks = 0x01000000,
}; };
Q_DECLARE_FLAGS(EditorOptions, EditorOption) Q_DECLARE_FLAGS(EditorOptions, EditorOption)
@ -682,7 +686,7 @@ private:
EditKeyStrokes mKeyStrokes; EditKeyStrokes mKeyStrokes;
bool mModified; bool mModified;
QDateTime mLastModifyTime; QDateTime mLastModifyTime;
int mExtraLineSpacing; double mLineSpacingFactor;
SelectionMode mSelectionMode; SelectionMode mSelectionMode;
SelectionMode mActiveSelectionMode; //mode of the active selection SelectionMode mActiveSelectionMode; //mode of the active selection
bool mWantReturns; bool mWantReturns;
@ -776,6 +780,9 @@ protected:
ScrollStyle scrollBars() const; ScrollStyle scrollBars() const;
void setScrollBars(ScrollStyle newScrollBars); void setScrollBars(ScrollStyle newScrollBars);
double lineSpacingFactor() const;
void setLineSpacingFactor(double newLineSpacingFactor);
protected: protected:
void dragEnterEvent(QDragEnterEvent *event) override; void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override; void dropEvent(QDropEvent *event) override;

View File

@ -485,8 +485,8 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
bool bU1, bSel, bU2; bool bU1, bSel, bU2;
int nX1, nX2; int nX1, nX2;
// Compute some helper variables. // Compute some helper variables.
nC1 = std::max(FirstCol, TokenAccu.ColumnsBefore + 1); nC1 = std::max(FirstCol, mTokenAccu.columnsBefore + 1);
nC2 = std::min(LastCol, TokenAccu.ColumnsBefore + TokenAccu.Columns + 1); nC2 = std::min(LastCol, mTokenAccu.columnsBefore + mTokenAccu.columns + 1);
if (bComplexLine) { if (bComplexLine) {
bU1 = (nC1 < nLineSelStart); bU1 = (nC1 < nLineSelStart);
bSel = (nC1 < nLineSelEnd) && (nC2 >= nLineSelStart); bSel = (nC1 < nLineSelEnd) && (nC2 >= nLineSelStart);
@ -499,10 +499,10 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
bU2 = false; // to shut up compiler warning. bU2 = false; // to shut up compiler warning.
} }
// Any token chars accumulated? // Any token chars accumulated?
if (TokenAccu.Columns > 0) { if (mTokenAccu.columns > 0) {
// Initialize the colors and the font style. // Initialize the colors and the font style.
colBG = TokenAccu.BG; colBG = mTokenAccu.background;
colFG = TokenAccu.FG; colFG = mTokenAccu.foreground;
if (bSpecialLine) { if (bSpecialLine) {
if (colSpFG.isValid()) if (colSpFG.isValid())
colFG = colSpFG; colFG = colSpFG;
@ -513,16 +513,16 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
// if (bSpecialLine && edit->mOptions.testFlag(eoSpecialLineDefaultFg)) // if (bSpecialLine && edit->mOptions.testFlag(eoSpecialLineDefaultFg))
// colFG = TokenAccu.FG; // colFG = TokenAccu.FG;
QFont font = edit->font(); QFont font = edit->font();
font.setBold(TokenAccu.Style & FontStyle::fsBold); font.setBold(mTokenAccu.style & FontStyle::fsBold);
font.setItalic(TokenAccu.Style & FontStyle::fsItalic); font.setItalic(mTokenAccu.style & FontStyle::fsItalic);
font.setStrikeOut(TokenAccu.Style & FontStyle::fsStrikeOut); font.setStrikeOut(mTokenAccu.style & FontStyle::fsStrikeOut);
font.setUnderline(TokenAccu.Style & FontStyle::fsUnderline); font.setUnderline(mTokenAccu.style & FontStyle::fsUnderline);
painter->setFont(font); painter->setFont(font);
QFont nonAsciiFont = edit->fontForNonAscii(); QFont nonAsciiFont = edit->fontForNonAscii();
nonAsciiFont.setBold(TokenAccu.Style & FontStyle::fsBold); nonAsciiFont.setBold(mTokenAccu.style & FontStyle::fsBold);
nonAsciiFont.setItalic(TokenAccu.Style & FontStyle::fsItalic); nonAsciiFont.setItalic(mTokenAccu.style & FontStyle::fsItalic);
nonAsciiFont.setStrikeOut(TokenAccu.Style & FontStyle::fsStrikeOut); nonAsciiFont.setStrikeOut(mTokenAccu.style & FontStyle::fsStrikeOut);
nonAsciiFont.setUnderline(TokenAccu.Style & FontStyle::fsUnderline); nonAsciiFont.setUnderline(mTokenAccu.style & FontStyle::fsUnderline);
// Paint the chars // Paint the chars
if (bComplexToken) { if (bComplexToken) {
@ -531,24 +531,24 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
setDrawingColors(false); setDrawingColors(false);
rcToken.setRight(columnToXValue(nLineSelStart)); rcToken.setRight(columnToXValue(nLineSelStart));
paintToken( paintToken(
TokenAccu.s,TokenAccu.Columns,TokenAccu.ColumnsBefore,nC1,nLineSelStart,false,font,nonAsciiFont, TokenAccu.showSpecialGlyphs); mTokenAccu.s,mTokenAccu.columns,mTokenAccu.columnsBefore,nC1,nLineSelStart,false,font,nonAsciiFont, mTokenAccu.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, TokenAccu.showSpecialGlyphs); paintToken(mTokenAccu.s, mTokenAccu.columns, mTokenAccu.columnsBefore, nC1Sel, nC2Sel,true,font,nonAsciiFont, mTokenAccu.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, TokenAccu.showSpecialGlyphs); paintToken(mTokenAccu.s, mTokenAccu.columns, mTokenAccu.columnsBefore,nLineSelEnd, nC2,false,font,nonAsciiFont, mTokenAccu.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, TokenAccu.showSpecialGlyphs); paintToken(mTokenAccu.s, mTokenAccu.columns, mTokenAccu.columnsBefore, nC1, nC2,bSel,font,nonAsciiFont, mTokenAccu.showSpecialGlyphs);
} }
} }
@ -593,21 +593,17 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL)
// 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.
void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefore, void SynEditTextPainter::addHighlightToken(const QString &token, int columnsBefore,
int tokenColumns, int cLine, PTokenAttribute p_Attri) int tokenColumns, int cLine, PTokenAttribute attri, bool showGlyphs)
{ {
bool bCanAppend; bool bCanAppend;
QColor foreground, background; QColor foreground, background;
FontStyles style; FontStyles style;
bool isSpaces=false;
bool showGlyphs=false;
if (p_Attri) { if (attri) {
foreground = p_Attri->foreground(); foreground = attri->foreground();
background = p_Attri->background(); background = attri->background();
style = p_Attri->styles(); style = attri->styles();
isSpaces = p_Attri->tokenType() == TokenType::Space;
showGlyphs = isSpaces && edit->mOptions.testFlag(eoShowSpecialChars);
} else { } else {
foreground = colFG; foreground = colFG;
background = colBG; background = colBG;
@ -625,21 +621,20 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo
} }
edit->onPreparePaintHighlightToken(cLine,edit->mSyntaxer->getTokenPos()+1, edit->onPreparePaintHighlightToken(cLine,edit->mSyntaxer->getTokenPos()+1,
Token,p_Attri,style,foreground,background); token,attri,style,foreground,background);
// 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;
if (TokenAccu.Columns > 0 ) { if (mTokenAccu.columns > 0 ) {
if (showGlyphs == TokenAccu.showSpecialGlyphs) { if (showGlyphs == mTokenAccu.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 (mTokenAccu.style == style) {
&& isSpaces)) {
if ( if (
// background color must be the same and // background color must be the same and
(TokenAccu.BG == background) && (mTokenAccu.background == 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) || isSpaces)) { (mTokenAccu.foreground == foreground)) {
bCanAppend = true; bCanAppend = true;
} }
} }
} }
@ -649,16 +644,16 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo
} }
// Don't use AppendStr because it's more expensive. // Don't use AppendStr because it's more expensive.
if (bCanAppend) { if (bCanAppend) {
TokenAccu.s.append(Token); mTokenAccu.s.append(token);
TokenAccu.Columns+=tokenColumns; mTokenAccu.columns+=tokenColumns;
} else { } else {
TokenAccu.Columns = tokenColumns; mTokenAccu.columns = tokenColumns;
TokenAccu.s = Token; mTokenAccu.s = token;
TokenAccu.ColumnsBefore = columnsBefore; mTokenAccu.columnsBefore = columnsBefore;
TokenAccu.FG = foreground; mTokenAccu.foreground = foreground;
TokenAccu.BG = background; mTokenAccu.background = background;
TokenAccu.Style = style; mTokenAccu.style = style;
TokenAccu.showSpecialGlyphs = showGlyphs; mTokenAccu.showSpecialGlyphs = showGlyphs;
} }
} }
@ -814,8 +809,8 @@ void SynEditTextPainter::paintLines()
// inside the loop. Get only the starting point for this. // inside the loop. Get only the starting point for this.
rcLine = AClip; rcLine = AClip;
rcLine.setBottom((aFirstRow - edit->mTopLine) * edit->mTextHeight); rcLine.setBottom((aFirstRow - edit->mTopLine) * edit->mTextHeight);
TokenAccu.Columns = 0; mTokenAccu.columns = 0;
TokenAccu.ColumnsBefore = 0; mTokenAccu.columnsBefore = 0;
// Now loop through all the lines. The indices are valid for Lines. // Now loop through all the lines. The indices are valid for Lines.
BufferCoord selectionBegin = edit->blockBegin(); BufferCoord selectionBegin = edit->blockBegin();
BufferCoord selectionEnd= edit->blockEnd(); BufferCoord selectionEnd= edit->blockEnd();
@ -908,7 +903,7 @@ void SynEditTextPainter::paintLines()
} else { } else {
nTokenColumnLen = edit->mDocument->lineColumns(vLine-1); nTokenColumnLen = edit->mDocument->lineColumns(vLine-1);
} }
if (edit->mOptions.testFlag(eoShowSpecialChars) && (!bLineSelected) && (!bSpecialLine) && (nTokenColumnLen < vLastChar)) { if (edit->mOptions.testFlag(eoShowLineBreaks) && (!bLineSelected) && (!bSpecialLine) && (nTokenColumnLen < vLastChar)) {
sToken = sToken + LineBreakGlyph; sToken = sToken + LineBreakGlyph;
nTokenColumnLen += edit->charColumns(LineBreakGlyph); nTokenColumnLen += edit->charColumns(LineBreakGlyph);
} }
@ -955,7 +950,7 @@ void SynEditTextPainter::paintLines()
// of ExtTextOut calls necessary. This depends on the selection state // of ExtTextOut calls necessary. This depends on the selection state
// or the line having special colors. For spaces the foreground color // or the line having special colors. For spaces the foreground color
// is ignored as well. // is ignored as well.
TokenAccu.Columns = 0; mTokenAccu.columns = 0;
nTokenColumnsBefore = 0; nTokenColumnsBefore = 0;
// Test first whether anything of this token is visible. // Test first whether anything of this token is visible.
while (!edit->mSyntaxer->eol()) { while (!edit->mSyntaxer->eol()) {
@ -1014,38 +1009,40 @@ void SynEditTextPainter::paintLines()
} }
} }
} }
bool showGlyph=false;
if (attr && attr->tokenType() == TokenType::Space) {
int pos = edit->mSyntaxer->getTokenPos();
if (pos==0) {
showGlyph = edit->mOptions.testFlag(eoShowLeadingSpaces);
} else if (pos+sToken.length()==sLine.length()) {
showGlyph = edit->mOptions.testFlag(eoShowTrailingSpaces);
} else {
showGlyph = edit->mOptions.testFlag(eoShowInnerSpaces);
}
}
addHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol), addHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol),
nTokenColumnLen, vLine,attr); nTokenColumnLen, vLine,attr, showGlyph);
} }
nTokenColumnsBefore+=nTokenColumnLen; nTokenColumnsBefore+=nTokenColumnLen;
// Let the highlighter scan the next token. // Let the highlighter scan the next token.
edit->mSyntaxer->next(); edit->mSyntaxer->next();
} }
// Don't assume HL.GetTokenPos is valid after HL.GetEOL == True. // // Don't assume HL.GetTokenPos is valid after HL.GetEOL == True.
//nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore); // //nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore);
if (edit->mSyntaxer->eol() && (nTokenColumnsBefore < vLastChar)) { // if (edit->mSyntaxer->eol() && (nTokenColumnsBefore < vLastChar)) {
int lineColumns = edit->mDocument->lineColumns(vLine-1); // int lineColumns = edit->mDocument->lineColumns(vLine-1);
// Draw text that couldn't be parsed by the highlighter, if any. // // Draw text that couldn't be parsed by the highlighter, if any.
if (nTokenColumnsBefore < lineColumns) { // if (nTokenColumnsBefore < lineColumns) {
if (nTokenColumnsBefore + 1 < vFirstChar) // if (nTokenColumnsBefore + 1 < vFirstChar)
nTokenColumnsBefore = vFirstChar - 1; // nTokenColumnsBefore = vFirstChar - 1;
nTokenColumnLen = std::min(lineColumns, vLastChar) - (nTokenColumnsBefore + 1); // nTokenColumnLen = std::min(lineColumns, vLastChar) - (nTokenColumnsBefore + 1);
if (nTokenColumnLen > 0) { // if (nTokenColumnLen > 0) {
sToken = edit->substringByColumns(sLine,nTokenColumnsBefore+1,nTokenColumnLen); // sToken = edit->substringByColumns(sLine,nTokenColumnsBefore+1,nTokenColumnLen);
addHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol), // addHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol),
nTokenColumnLen, vLine, PTokenAttribute()); // nTokenColumnLen, vLine, PTokenAttribute(),false);
} // }
} // }
// Draw LineBreak glyph. // }
if (edit->mOptions.testFlag(eoShowSpecialChars)
// && (!bLineSelected)
// && (!bSpecialLine)
&& (edit->mDocument->lineColumns(vLine-1) < vLastChar)) {
addHighlightToken(LineBreakGlyph,
edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol),
edit->charColumns(LineBreakGlyph),vLine, edit->mSyntaxer->whitespaceAttribute());
}
}
// Paint folding // Paint folding
foldRange = edit->foldStartAtLine(vLine); foldRange = edit->foldStartAtLine(vLine);
@ -1055,9 +1052,18 @@ void SynEditTextPainter::paintLines()
attr = edit->mSyntaxer->symbolAttribute(); attr = edit->mSyntaxer->symbolAttribute();
getBraceColorAttr(edit->mSyntaxer->getState().braceLevel,attr); getBraceColorAttr(edit->mSyntaxer->getState().braceLevel,attr);
addHighlightToken(sFold,edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol) addHighlightToken(sFold,edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol)
, nFold, vLine, attr); , nFold, vLine, attr,false);
} else {
// Draw LineBreak glyph.
if (edit->mOptions.testFlag(eoShowLineBreaks)
&& (!bLineSelected)
&& (!bSpecialLine)
&& (edit->mDocument->lineColumns(vLine-1) < vLastChar)) {
addHighlightToken(LineBreakGlyph,
edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol),
edit->charColumns(LineBreakGlyph),vLine, edit->mSyntaxer->whitespaceAttribute(),false);
}
} }
// Draw anything that's left in the TokenAccu record. Fill to the end // Draw anything that's left in the TokenAccu record. Fill to the end
// of the invalid area with the correct colors. // of the invalid area with the correct colors.
paintHighlightToken(true); paintHighlightToken(true);

View File

@ -29,12 +29,12 @@ class SynEdit;
class SynEditTextPainter class SynEditTextPainter
{ {
struct SynTokenAccu { struct SynTokenAccu {
int Columns; int columns;
int ColumnsBefore; int columnsBefore;
QString s; QString s;
QColor FG; QColor foreground;
QColor BG; QColor background;
FontStyles Style; FontStyles style;
bool showSpecialGlyphs; bool showSpecialGlyphs;
}; };
@ -55,7 +55,7 @@ private:
void paintEditAreas(const EditingAreaList& areaList); void paintEditAreas(const EditingAreaList& areaList);
void paintHighlightToken(bool bFillToEOL); void paintHighlightToken(bool bFillToEOL);
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, bool showGlyphs);
void paintFoldAttributes(); void paintFoldAttributes();
void getBraceColorAttr(int level, PTokenAttribute &attr); void getBraceColorAttr(int level, PTokenAttribute &attr);
@ -84,7 +84,7 @@ private:
QRect AClip; QRect AClip;
int aFirstRow, aLastRow, FirstCol, LastCol; int aFirstRow, aLastRow, FirstCol, LastCol;
SynTokenAccu TokenAccu; SynTokenAccu mTokenAccu;
}; };
} }