mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
make markdown highlight interval configurable via markdown_highlight_interval
This commit is contained in:
parent
639d1cb9e9
commit
bb7e6e196c
@ -414,12 +414,14 @@ void HGMarkdownHighlighter::handleContentChange(int /* position */, int charsRem
|
||||
if (charsRemoved == 0 && charsAdded == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
timer->stop();
|
||||
timer->start();
|
||||
}
|
||||
|
||||
void HGMarkdownHighlighter::timerTimeout()
|
||||
{
|
||||
qDebug() << "HGMarkdownHighlighter start a new parse";
|
||||
parse();
|
||||
if (!updateCodeBlocks()) {
|
||||
rehighlight();
|
||||
|
@ -70,6 +70,9 @@ minimize_to_system_tray=-1
|
||||
; Case-insensitive
|
||||
markdown_suffix=md:markdown:mkd
|
||||
|
||||
; Markdown highlight timer interval (milliseconds)
|
||||
markdown_highlight_interval=400
|
||||
|
||||
[session]
|
||||
tools_dock_checked=true
|
||||
|
||||
|
@ -157,6 +157,9 @@ void VConfigManager::initialize()
|
||||
readShortcutsFromSettings();
|
||||
|
||||
initDocSuffixes();
|
||||
|
||||
m_markdownHighlightInterval = getConfigFromSettings("global",
|
||||
"markdown_highlight_interval").toInt();
|
||||
}
|
||||
|
||||
void VConfigManager::readPredefinedColorsFromSettings()
|
||||
|
@ -221,6 +221,8 @@ public:
|
||||
void initDocSuffixes();
|
||||
const QHash<int, QList<QString>> &getDocSuffixes() const;
|
||||
|
||||
int getMarkdownHighlightInterval() const;
|
||||
|
||||
// Return the configured key sequence of @p_operation.
|
||||
// Return empty if there is no corresponding config.
|
||||
QString getShortcutKeySequence(const QString &p_operation) const;
|
||||
@ -446,6 +448,9 @@ private:
|
||||
// [DocType] -> { Suffixes }.
|
||||
QHash<int, QList<QString>> m_docSuffixes;
|
||||
|
||||
// Interval for HGMarkdownHighlighter highlight timer (milliseconds).
|
||||
int m_markdownHighlightInterval;
|
||||
|
||||
// The name of the config file in each directory, obsolete.
|
||||
// Use c_dirConfigFile instead.
|
||||
static const QString c_obsoleteDirConfigFile;
|
||||
@ -1138,4 +1143,10 @@ inline const QHash<int, QList<QString>> &VConfigManager::getDocSuffixes() const
|
||||
{
|
||||
return m_docSuffixes;
|
||||
}
|
||||
|
||||
inline int VConfigManager::getMarkdownHighlightInterval() const
|
||||
{
|
||||
return m_markdownHighlightInterval;
|
||||
}
|
||||
|
||||
#endif // VCONFIGMANAGER_H
|
||||
|
@ -25,7 +25,8 @@ VMdEdit::VMdEdit(VFile *p_file, VDocument *p_vdoc, MarkdownConverterType p_type,
|
||||
setAcceptRichText(false);
|
||||
m_mdHighlighter = new HGMarkdownHighlighter(g_config->getMdHighlightingStyles(),
|
||||
g_config->getCodeBlockStyles(),
|
||||
700, document());
|
||||
g_config->getMarkdownHighlightInterval(),
|
||||
document());
|
||||
connect(m_mdHighlighter, &HGMarkdownHighlighter::highlightCompleted,
|
||||
this, &VMdEdit::generateEditOutline);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user