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) {
|
if (charsRemoved == 0 && charsAdded == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
timer->stop();
|
timer->stop();
|
||||||
timer->start();
|
timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HGMarkdownHighlighter::timerTimeout()
|
void HGMarkdownHighlighter::timerTimeout()
|
||||||
{
|
{
|
||||||
|
qDebug() << "HGMarkdownHighlighter start a new parse";
|
||||||
parse();
|
parse();
|
||||||
if (!updateCodeBlocks()) {
|
if (!updateCodeBlocks()) {
|
||||||
rehighlight();
|
rehighlight();
|
||||||
|
@ -70,6 +70,9 @@ minimize_to_system_tray=-1
|
|||||||
; Case-insensitive
|
; Case-insensitive
|
||||||
markdown_suffix=md:markdown:mkd
|
markdown_suffix=md:markdown:mkd
|
||||||
|
|
||||||
|
; Markdown highlight timer interval (milliseconds)
|
||||||
|
markdown_highlight_interval=400
|
||||||
|
|
||||||
[session]
|
[session]
|
||||||
tools_dock_checked=true
|
tools_dock_checked=true
|
||||||
|
|
||||||
|
@ -157,6 +157,9 @@ void VConfigManager::initialize()
|
|||||||
readShortcutsFromSettings();
|
readShortcutsFromSettings();
|
||||||
|
|
||||||
initDocSuffixes();
|
initDocSuffixes();
|
||||||
|
|
||||||
|
m_markdownHighlightInterval = getConfigFromSettings("global",
|
||||||
|
"markdown_highlight_interval").toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VConfigManager::readPredefinedColorsFromSettings()
|
void VConfigManager::readPredefinedColorsFromSettings()
|
||||||
|
@ -221,6 +221,8 @@ public:
|
|||||||
void initDocSuffixes();
|
void initDocSuffixes();
|
||||||
const QHash<int, QList<QString>> &getDocSuffixes() const;
|
const QHash<int, QList<QString>> &getDocSuffixes() const;
|
||||||
|
|
||||||
|
int getMarkdownHighlightInterval() const;
|
||||||
|
|
||||||
// Return the configured key sequence of @p_operation.
|
// Return the configured key sequence of @p_operation.
|
||||||
// Return empty if there is no corresponding config.
|
// Return empty if there is no corresponding config.
|
||||||
QString getShortcutKeySequence(const QString &p_operation) const;
|
QString getShortcutKeySequence(const QString &p_operation) const;
|
||||||
@ -446,6 +448,9 @@ private:
|
|||||||
// [DocType] -> { Suffixes }.
|
// [DocType] -> { Suffixes }.
|
||||||
QHash<int, QList<QString>> m_docSuffixes;
|
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.
|
// 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;
|
||||||
@ -1138,4 +1143,10 @@ inline const QHash<int, QList<QString>> &VConfigManager::getDocSuffixes() const
|
|||||||
{
|
{
|
||||||
return m_docSuffixes;
|
return m_docSuffixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int VConfigManager::getMarkdownHighlightInterval() const
|
||||||
|
{
|
||||||
|
return m_markdownHighlightInterval;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VCONFIGMANAGER_H
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -25,7 +25,8 @@ VMdEdit::VMdEdit(VFile *p_file, VDocument *p_vdoc, MarkdownConverterType p_type,
|
|||||||
setAcceptRichText(false);
|
setAcceptRichText(false);
|
||||||
m_mdHighlighter = new HGMarkdownHighlighter(g_config->getMdHighlightingStyles(),
|
m_mdHighlighter = new HGMarkdownHighlighter(g_config->getMdHighlightingStyles(),
|
||||||
g_config->getCodeBlockStyles(),
|
g_config->getCodeBlockStyles(),
|
||||||
700, document());
|
g_config->getMarkdownHighlightInterval(),
|
||||||
|
document());
|
||||||
connect(m_mdHighlighter, &HGMarkdownHighlighter::highlightCompleted,
|
connect(m_mdHighlighter, &HGMarkdownHighlighter::highlightCompleted,
|
||||||
this, &VMdEdit::generateEditOutline);
|
this, &VMdEdit::generateEditOutline);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user