support highlighting trailing space

This commit is contained in:
Le Tan 2017-05-25 19:52:10 +08:00
parent c8ec95eb3d
commit 73530355fd
9 changed files with 232 additions and 49 deletions

View File

@ -5,6 +5,8 @@ editor
# QTextEdit just choose the first available font, so specify the Chinese fonts first # QTextEdit just choose the first available font, so specify the Chinese fonts first
# Do not use "" to quote the name # Do not use "" to quote the name
font-family: Hiragino Sans GB, 冬青黑体, Microsoft YaHei, 微软雅黑, Microsoft YaHei UI, WenQuanYi Micro Hei, 文泉驿雅黑, Dengxian, 等线体, STXihei, 华文细黑, Liberation Sans, Droid Sans, NSimSun, 新宋体, SimSun, 宋体, Helvetica, sans-serif, Tahoma, Arial, Verdana, Geneva, Georgia, Times New Roman font-family: Hiragino Sans GB, 冬青黑体, Microsoft YaHei, 微软雅黑, Microsoft YaHei UI, WenQuanYi Micro Hei, 文泉驿雅黑, Dengxian, 等线体, STXihei, 华文细黑, Liberation Sans, Droid Sans, NSimSun, 新宋体, SimSun, 宋体, Helvetica, sans-serif, Tahoma, Arial, Verdana, Geneva, Georgia, Times New Roman
# Style for trailing space
trailing-space: ffebee
editor-selection editor-selection
foreground: eeeeee foreground: eeeeee

View File

@ -42,6 +42,9 @@ enable_image_caption=false
; Image folder name for the notes ; Image folder name for the notes
image_folder=_v_images image_folder=_v_images
; Enable trailing space highlight
enable_trailing_space_highlight=true
[session] [session]
tools_dock_checked=true tools_dock_checked=true

View File

@ -143,6 +143,9 @@ void VConfigManager::initialize()
m_imageFolder = getConfigFromSettings("global", m_imageFolder = getConfigFromSettings("global",
"image_folder").toString(); "image_folder").toString();
m_enableTrailingSpaceHighlight = getConfigFromSettings("global",
"enable_trailing_space_highlight").toBool();
} }
void VConfigManager::readPredefinedColorsFromSettings() void VConfigManager::readPredefinedColorsFromSettings()
@ -325,6 +328,7 @@ void VConfigManager::updateMarkdownEditStyle()
{ {
static const QString defaultCurrentLineBackground = "#C5CAE9"; static const QString defaultCurrentLineBackground = "#C5CAE9";
static const QString defaultCurrentLineVimBackground = "#A5D6A7"; static const QString defaultCurrentLineVimBackground = "#A5D6A7";
static const QString defaultTrailingSpaceBackground = "#FFEBEE";
// Read style file .mdhl // Read style file .mdhl
QString file(getEditorStyleUrl()); QString file(getEditorStyleUrl());
@ -349,6 +353,7 @@ void VConfigManager::updateMarkdownEditStyle()
if (editorCurrentLineIt != styles.end()) { if (editorCurrentLineIt != styles.end()) {
auto backgroundIt = editorCurrentLineIt->find("background"); auto backgroundIt = editorCurrentLineIt->find("background");
if (backgroundIt != editorCurrentLineIt->end()) { if (backgroundIt != editorCurrentLineIt->end()) {
// Do not need to add "#" here, since this is a built-in attribute.
m_editorCurrentLineBackground = *backgroundIt; m_editorCurrentLineBackground = *backgroundIt;
} }
@ -357,6 +362,19 @@ void VConfigManager::updateMarkdownEditStyle()
m_editorCurrentLineVimBackground = "#" + *vimBackgroundIt; m_editorCurrentLineVimBackground = "#" + *vimBackgroundIt;
} }
} }
m_editorTrailingSpaceBackground = defaultTrailingSpaceBackground;
auto editorIt = styles.find("editor");
if (editorIt != styles.end()) {
auto trailingIt = editorIt->find("trailing-space");
if (trailingIt != editorIt->end()) {
m_editorTrailingSpaceBackground = "#" + *trailingIt;
}
}
qDebug() << "editor-current-line" << m_editorCurrentLineBackground;
qDebug() << "editor-current-line-vim" << m_editorCurrentLineVimBackground;
qDebug() << "editor-trailing-space" << m_editorTrailingSpaceBackground;
} }
void VConfigManager::updateEditStyle() void VConfigManager::updateEditStyle()

View File

@ -157,6 +157,7 @@ public:
inline QString getEditorCurrentLineBackground() const; inline QString getEditorCurrentLineBackground() const;
inline QString getEditorCurrentLineVimBackground() const; inline QString getEditorCurrentLineVimBackground() const;
inline QString getEditorTrailingSpaceBackground() const;
inline bool getEnableCodeBlockHighlight() const; inline bool getEnableCodeBlockHighlight() const;
inline void setEnableCodeBlockHighlight(bool p_enabled); inline void setEnableCodeBlockHighlight(bool p_enabled);
@ -174,12 +175,13 @@ public:
inline void setEnableImageCaption(bool p_enabled); inline void setEnableImageCaption(bool p_enabled);
inline const QString &getImageFolder() const; inline const QString &getImageFolder() const;
// Empty string to reset the default folder. // Empty string to reset the default folder.
inline void setImageFolder(const QString &p_folder); inline void setImageFolder(const QString &p_folder);
inline bool isCustomImageFolder() const; inline bool isCustomImageFolder() const;
inline bool getEnableTrailingSpaceHighlight() const;
inline void setEnableTrailingSapceHighlight(bool p_enabled);
// Get the folder the ini file exists. // Get the folder the ini file exists.
QString getConfigFolder() const; QString getConfigFolder() const;
@ -290,9 +292,13 @@ private:
// Current line background color in editor. // Current line background color in editor.
QString m_editorCurrentLineBackground; QString m_editorCurrentLineBackground;
// Current line background color in editor in Vim mode. // Current line background color in editor in Vim mode.
QString m_editorCurrentLineVimBackground; QString m_editorCurrentLineVimBackground;
// Trailing space background color in editor.
QString m_editorTrailingSpaceBackground;
// Enable colde block syntax highlight. // Enable colde block syntax highlight.
bool m_enableCodeBlockHighlight; bool m_enableCodeBlockHighlight;
@ -312,6 +318,9 @@ private:
// Each notebook can specify its custom folder. // Each notebook can specify its custom folder.
QString m_imageFolder; QString m_imageFolder;
// Enable trailing-space highlight.
bool m_enableTrailingSpaceHighlight;
// The name of the config file in each directory, obsolete. // The name of the config file in each directory, obsolete.
// Use c_dirConfigFile instead. // Use c_dirConfigFile instead.
static const QString c_obsoleteDirConfigFile; static const QString c_obsoleteDirConfigFile;
@ -722,6 +731,11 @@ inline QString VConfigManager::getEditorCurrentLineVimBackground() const
return m_editorCurrentLineVimBackground; return m_editorCurrentLineVimBackground;
} }
inline QString VConfigManager::getEditorTrailingSpaceBackground() const
{
return m_editorTrailingSpaceBackground;
}
inline bool VConfigManager::getEnableCodeBlockHighlight() const inline bool VConfigManager::getEnableCodeBlockHighlight() const
{ {
return m_enableCodeBlockHighlight; return m_enableCodeBlockHighlight;
@ -826,4 +840,20 @@ inline bool VConfigManager::isCustomImageFolder() const
return m_imageFolder != getDefaultConfig("global", "image_folder").toString(); return m_imageFolder != getDefaultConfig("global", "image_folder").toString();
} }
inline bool VConfigManager::getEnableTrailingSpaceHighlight() const
{
return m_enableTrailingSpaceHighlight;
}
inline void VConfigManager::setEnableTrailingSapceHighlight(bool p_enabled)
{
if (m_enableTrailingSpaceHighlight == p_enabled) {
return;
}
m_enableTrailingSpaceHighlight = p_enabled;
setConfigToSettings("global", "enable_trailing_space_highlight",
m_enableTrailingSpaceHighlight);
}
#endif // VCONFIGMANAGER_H #endif // VCONFIGMANAGER_H

View File

@ -17,12 +17,13 @@ VEdit::VEdit(VFile *p_file, QWidget *p_parent)
: QTextEdit(p_parent), m_file(p_file), m_editOps(NULL) : QTextEdit(p_parent), m_file(p_file), m_editOps(NULL)
{ {
const int labelTimerInterval = 500; const int labelTimerInterval = 500;
const int selectedWordTimerInterval = 500; const int extraSelectionHighlightTimer = 500;
const int labelSize = 64; const int labelSize = 64;
m_cursorLineColor = QColor(g_vnote->getColorFromPalette("Indigo1")); m_cursorLineColor = QColor(g_vnote->getColorFromPalette("Indigo1"));
m_selectedWordColor = QColor("Yellow"); m_selectedWordColor = QColor("Yellow");
m_searchedWordColor = QColor(g_vnote->getColorFromPalette("Green4")); m_searchedWordColor = QColor(g_vnote->getColorFromPalette("Green4"));
m_trailingSpaceColor = QColor(vconfig.getEditorTrailingSpaceBackground());
QPixmap wrapPixmap(":/resources/icons/search_wrap.svg"); QPixmap wrapPixmap(":/resources/icons/search_wrap.svg");
m_wrapLabel = new QLabel(this); m_wrapLabel = new QLabel(this);
@ -34,11 +35,11 @@ VEdit::VEdit(VFile *p_file, QWidget *p_parent)
connect(m_labelTimer, &QTimer::timeout, connect(m_labelTimer, &QTimer::timeout,
this, &VEdit::labelTimerTimeout); this, &VEdit::labelTimerTimeout);
m_selectedWordTimer = new QTimer(this); m_highlightTimer = new QTimer(this);
m_selectedWordTimer->setSingleShot(true); m_highlightTimer->setSingleShot(true);
m_selectedWordTimer->setInterval(selectedWordTimerInterval); m_highlightTimer->setInterval(extraSelectionHighlightTimer);
connect(m_selectedWordTimer, &QTimer::timeout, connect(m_highlightTimer, &QTimer::timeout,
this, &VEdit::highlightSelectedWord); this, &VEdit::doHighlightExtraSelections);
connect(document(), &QTextDocument::modificationChanged, connect(document(), &QTextDocument::modificationChanged,
(VFile *)m_file, &VFile::setModified); (VFile *)m_file, &VFile::setModified);
@ -47,9 +48,10 @@ VEdit::VEdit(VFile *p_file, QWidget *p_parent)
updateFontAndPalette(); updateFontAndPalette();
connect(this, &VEdit::cursorPositionChanged, connect(this, &VEdit::cursorPositionChanged,
this, &VEdit::highlightCurrentLine); this, &VEdit::handleCursorPositionChanged);
connect(this, &VEdit::selectionChanged, connect(this, &VEdit::selectionChanged,
this, &VEdit::triggerHighlightSelectedWord); this, &VEdit::highlightSelectedWord);
} }
VEdit::~VEdit() VEdit::~VEdit()
@ -374,7 +376,17 @@ void VEdit::updateFontAndPalette()
setPalette(vconfig.getBaseEditPalette()); setPalette(vconfig.getBaseEditPalette());
} }
void VEdit::highlightExtraSelections() void VEdit::highlightExtraSelections(bool p_now)
{
m_highlightTimer->stop();
if (p_now) {
doHighlightExtraSelections();
} else {
m_highlightTimer->start();
}
}
void VEdit::doHighlightExtraSelections()
{ {
int nrExtra = m_extraSelections.size(); int nrExtra = m_extraSelections.size();
Q_ASSERT(nrExtra == (int)SelectionId::MaxSelection); Q_ASSERT(nrExtra == (int)SelectionId::MaxSelection);
@ -382,6 +394,7 @@ void VEdit::highlightExtraSelections()
for (int i = 0; i < nrExtra; ++i) { for (int i = 0; i < nrExtra; ++i) {
extraSelects.append(m_extraSelections[i]); extraSelects.append(m_extraSelections[i]);
} }
setExtraSelections(extraSelects); setExtraSelections(extraSelects);
} }
@ -390,23 +403,24 @@ void VEdit::highlightCurrentLine()
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::CurrentLine]; QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::CurrentLine];
if (vconfig.getHighlightCursorLine() && !isReadOnly()) { if (vconfig.getHighlightCursorLine() && !isReadOnly()) {
// Need to highlight current line. // Need to highlight current line.
selects.clear();
QTextEdit::ExtraSelection select; QTextEdit::ExtraSelection select;
select.format.setBackground(m_cursorLineColor); select.format.setBackground(m_cursorLineColor);
select.format.setProperty(QTextFormat::FullWidthSelection, true); select.format.setProperty(QTextFormat::FullWidthSelection, true);
select.cursor = textCursor(); select.cursor = textCursor();
select.cursor.clearSelection(); select.cursor.clearSelection();
selects.clear();
selects.append(select); selects.append(select);
} else { } else {
// Need to clear current line highlight. // Need to clear current line highlight.
if (selects.isEmpty()) { if (selects.isEmpty()) {
return; return;
} }
selects.clear(); selects.clear();
} }
highlightExtraSelections(); highlightExtraSelections(true);
} }
void VEdit::setReadOnly(bool p_ro) void VEdit::setReadOnly(bool p_ro)
@ -417,20 +431,67 @@ void VEdit::setReadOnly(bool p_ro)
void VEdit::highlightSelectedWord() void VEdit::highlightSelectedWord()
{ {
QString text; QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::SelectedWord];
if (vconfig.getHighlightSelectedWord()) { if (!vconfig.getHighlightSelectedWord()) {
text = textCursor().selectedText().trimmed(); if (!selects.isEmpty()) {
if (wordInSearchedSelection(text)) { selects.clear();
qDebug() << "select searched word, just skip"; highlightExtraSelections(true);
text = "";
} }
return;
} }
QString text = textCursor().selectedText().trimmed();
if (text.isEmpty() || wordInSearchedSelection(text)) {
selects.clear();
highlightExtraSelections(true);
return;
}
QTextCharFormat format; QTextCharFormat format;
format.setBackground(m_selectedWordColor); format.setBackground(m_selectedWordColor);
highlightTextAll(text, FindOption::CaseSensitive, SelectionId::SelectedWord, highlightTextAll(text, FindOption::CaseSensitive, SelectionId::SelectedWord,
format); format);
} }
// Do not highlight trailing spaces with current cursor right behind.
static void trailingSpaceFilter(VEdit *p_editor, QList<QTextEdit::ExtraSelection> &p_result)
{
QTextCursor cursor = p_editor->textCursor();
if (!cursor.atBlockEnd()) {
return;
}
int cursorPos = cursor.position();
for (auto it = p_result.begin(); it != p_result.end(); ++it) {
if (it->cursor.selectionEnd() == cursorPos) {
p_result.erase(it);
// There will be only one.
return;
}
}
}
void VEdit::highlightTrailingSpace()
{
if (!vconfig.getEnableTrailingSpaceHighlight()) {
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::TrailingSapce];
if (!selects.isEmpty()) {
selects.clear();
highlightExtraSelections(true);
}
return;
}
QTextCharFormat format;
format.setBackground(m_trailingSpaceColor);
QString text("\\s+$");
highlightTextAll(text, FindOption::RegularExpression,
SelectionId::TrailingSapce, format,
trailingSpaceFilter);
}
bool VEdit::wordInSearchedSelection(const QString &p_text) bool VEdit::wordInSearchedSelection(const QString &p_text)
{ {
QString text = p_text.trimmed(); QString text = p_text.trimmed();
@ -444,24 +505,9 @@ bool VEdit::wordInSearchedSelection(const QString &p_text)
return false; return false;
} }
void VEdit::triggerHighlightSelectedWord()
{
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::SelectedWord];
if (!vconfig.getHighlightSelectedWord() && selects.isEmpty()) {
return;
}
m_selectedWordTimer->stop();
QString text = textCursor().selectedText().trimmed();
if (text.isEmpty()) {
// Clear previous selection right now.
highlightSelectedWord();
} else {
m_selectedWordTimer->start();
}
}
void VEdit::highlightTextAll(const QString &p_text, uint p_options, void VEdit::highlightTextAll(const QString &p_text, uint p_options,
SelectionId p_id, QTextCharFormat p_format) SelectionId p_id, QTextCharFormat p_format,
void (*p_filter)(VEdit *, QList<QTextEdit::ExtraSelection> &))
{ {
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)p_id]; QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)p_id];
if (!p_text.isEmpty()) { if (!p_text.isEmpty()) {
@ -474,32 +520,42 @@ void VEdit::highlightTextAll(const QString &p_text, uint p_options,
select.cursor = occurs[i]; select.cursor = occurs[i];
selects.append(select); selects.append(select);
} }
qDebug() << "highlight" << selects.size() << "occurences of" << p_text;
} else { } else {
if (selects.isEmpty()) { if (selects.isEmpty()) {
return; return;
} }
selects.clear(); selects.clear();
} }
if (p_filter) {
p_filter(this, selects);
}
highlightExtraSelections(); highlightExtraSelections();
} }
void VEdit::highlightSearchedWord(const QString &p_text, uint p_options) void VEdit::highlightSearchedWord(const QString &p_text, uint p_options)
{ {
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::SearchedKeyword];
if (!vconfig.getHighlightSearchedWord() || p_text.isEmpty()) {
if (!selects.isEmpty()) {
selects.clear();
highlightExtraSelections(true);
}
return;
}
QTextCharFormat format; QTextCharFormat format;
format.setBackground(m_searchedWordColor); format.setBackground(m_searchedWordColor);
QString text; highlightTextAll(p_text, p_options, SelectionId::SearchedKeyword, format);
if (vconfig.getHighlightSearchedWord()) {
text = p_text;
}
highlightTextAll(text, p_options, SelectionId::SearchedKeyword, format);
} }
void VEdit::clearSearchedWordHighlight() void VEdit::clearSearchedWordHighlight()
{ {
QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::SearchedKeyword]; QList<QTextEdit::ExtraSelection> &selects = m_extraSelections[(int)SelectionId::SearchedKeyword];
selects.clear(); selects.clear();
highlightExtraSelections(); highlightExtraSelections(true);
} }
void VEdit::contextMenuEvent(QContextMenuEvent *p_event) void VEdit::contextMenuEvent(QContextMenuEvent *p_event)
@ -569,3 +625,29 @@ VFile *VEdit::getFile() const
return m_file; return m_file;
} }
void VEdit::handleCursorPositionChanged()
{
static QTextCursor lastCursor;
QTextCursor cursor = textCursor();
if (lastCursor.isNull() || cursor.blockNumber() != lastCursor.blockNumber()) {
highlightCurrentLine();
highlightTrailingSpace();
} else {
// Judge whether we have trailing space at current line.
QString text = cursor.block().text();
if (text.rbegin()->isSpace()) {
highlightTrailingSpace();
}
// Handle word-wrap in one block.
// Highlight current line if in different visual line.
if ((lastCursor.positionInBlock() - lastCursor.columnNumber()) !=
(cursor.positionInBlock() - cursor.columnNumber())) {
highlightCurrentLine();
}
}
lastCursor = cursor;
}

View File

@ -19,6 +19,7 @@ enum class SelectionId {
CurrentLine = 0, CurrentLine = 0,
SelectedWord, SelectedWord,
SearchedKeyword, SearchedKeyword,
TrailingSapce,
MaxSelection MaxSelection
}; };
@ -57,11 +58,12 @@ signals:
private slots: private slots:
void labelTimerTimeout(); void labelTimerTimeout();
void triggerHighlightSelectedWord();
void highlightSelectedWord(); void highlightSelectedWord();
void handleSaveExitAct(); void handleSaveExitAct();
void handleDiscardExitAct(); void handleDiscardExitAct();
void handleEditAct(); void handleEditAct();
void highlightTrailingSpace();
void handleCursorPositionChanged();
protected slots: protected slots:
virtual void highlightCurrentLine(); virtual void highlightCurrentLine();
@ -77,19 +79,35 @@ protected:
private: private:
QLabel *m_wrapLabel; QLabel *m_wrapLabel;
QTimer *m_labelTimer; QTimer *m_labelTimer;
// highlightExtraSelections() will highlight these selections.
// doHighlightExtraSelections() will highlight these selections.
// Selections are indexed by SelectionId. // Selections are indexed by SelectionId.
QVector<QList<QTextEdit::ExtraSelection> > m_extraSelections; QVector<QList<QTextEdit::ExtraSelection> > m_extraSelections;
QTimer *m_selectedWordTimer;
QColor m_selectedWordColor; QColor m_selectedWordColor;
QColor m_searchedWordColor; QColor m_searchedWordColor;
QColor m_trailingSpaceColor;
// Timer for extra selections highlight.
QTimer *m_highlightTimer;
void showWrapLabel(); void showWrapLabel();
void highlightExtraSelections();
// Trigger the timer to request highlight.
// If @p_now is true, stop the timer and highlight immediately.
void highlightExtraSelections(bool p_now = false);
// Do the real work to highlight extra selections.
void doHighlightExtraSelections();
// Find all the occurences of @p_text. // Find all the occurences of @p_text.
QList<QTextCursor> findTextAll(const QString &p_text, uint p_options); QList<QTextCursor> findTextAll(const QString &p_text, uint p_options);
// @p_fileter: a function to filter out highlight results.
void highlightTextAll(const QString &p_text, uint p_options, void highlightTextAll(const QString &p_text, uint p_options,
SelectionId p_id, QTextCharFormat p_format); SelectionId p_id, QTextCharFormat p_format,
void (*p_filter)(VEdit *, QList<QTextEdit::ExtraSelection> &) = NULL);
void highlightSearchedWord(const QString &p_text, uint p_options); void highlightSearchedWord(const QString &p_text, uint p_options);
bool wordInSearchedSelection(const QString &p_text); bool wordInSearchedSelection(const QString &p_text);
}; };

View File

@ -600,6 +600,13 @@ void VMainWindow::initEditMenu()
connect(selectedWordAct, &QAction::triggered, connect(selectedWordAct, &QAction::triggered,
this, &VMainWindow::changeHighlightSelectedWord); this, &VMainWindow::changeHighlightSelectedWord);
// Highlight trailing space.
QAction *trailingSapceAct = new QAction(tr("Highlight Trailing Sapces"), this);
trailingSapceAct->setToolTip(tr("Highlight all the spaces at the end of a line"));
trailingSapceAct->setCheckable(true);
connect(trailingSapceAct, &QAction::triggered,
this, &VMainWindow::changeHighlightTrailingSapce);
editMenu->addAction(m_insertImageAct); editMenu->addAction(m_insertImageAct);
editMenu->addSeparator(); editMenu->addSeparator();
m_insertImageAct->setEnabled(false); m_insertImageAct->setEnabled(false);
@ -672,6 +679,9 @@ void VMainWindow::initEditMenu()
editMenu->addAction(selectedWordAct); editMenu->addAction(selectedWordAct);
selectedWordAct->setChecked(vconfig.getHighlightSelectedWord()); selectedWordAct->setChecked(vconfig.getHighlightSelectedWord());
editMenu->addAction(trailingSapceAct);
trailingSapceAct->setChecked(vconfig.getEnableTrailingSpaceHighlight());
} }
void VMainWindow::initDockWindows() void VMainWindow::initDockWindows()
@ -784,6 +794,11 @@ void VMainWindow::changeHighlightSearchedWord(bool p_checked)
vconfig.setHighlightSearchedWord(p_checked); vconfig.setHighlightSearchedWord(p_checked);
} }
void VMainWindow::changeHighlightTrailingSapce(bool p_checked)
{
vconfig.setEnableTrailingSapceHighlight(p_checked);
}
void VMainWindow::setTabStopWidth(QAction *action) void VMainWindow::setTabStopWidth(QAction *action)
{ {
if (!action) { if (!action) {

View File

@ -59,6 +59,7 @@ private slots:
void changeHighlightCursorLine(bool p_checked); void changeHighlightCursorLine(bool p_checked);
void changeHighlightSelectedWord(bool p_checked); void changeHighlightSelectedWord(bool p_checked);
void changeHighlightSearchedWord(bool p_checked); void changeHighlightSearchedWord(bool p_checked);
void changeHighlightTrailingSapce(bool p_checked);
void handleCurTabStatusChanged(const VFile *p_file, const VEditTab *p_editTab, bool p_editMode); void handleCurTabStatusChanged(const VFile *p_file, const VEditTab *p_editTab, bool p_editMode);
void onePanelView(); void onePanelView();
void twoPanelView(); void twoPanelView();

View File

@ -186,8 +186,10 @@ void VStyleParser::fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
QMap<QString, QMap<QString, QString>> &styles) const QMap<QString, QMap<QString, QString>> &styles) const
{ {
QString ruleKey; QString ruleKey;
// editor // editor
pmh_style_attribute *editorStyles = markdownStyles->editor_styles; pmh_style_attribute *editorStyles = markdownStyles->editor_styles;
ruleKey = "editor";
while (editorStyles) { while (editorStyles) {
switch (editorStyles->type) { switch (editorStyles->type) {
case pmh_attr_type_foreground_color: case pmh_attr_type_foreground_color:
@ -210,6 +212,16 @@ void VStyleParser::fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
break; break;
} }
// Get custom styles:
// trailing-space.
case pmh_attr_type_other:
{
QString attrName(editorStyles->name);
QString value(editorStyles->value->string);
styles[ruleKey][attrName] = value;
break;
}
default: default:
qWarning() << "unimplemented editor attr type:" << editorStyles->type; qWarning() << "unimplemented editor attr type:" << editorStyles->type;
} }
@ -229,6 +241,8 @@ void VStyleParser::fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
break; break;
} }
// Get custom styles:
// vim-background.
case pmh_attr_type_other: case pmh_attr_type_other:
{ {
QString attrName(curLineStyles->name); QString attrName(curLineStyles->name);