mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
enable font-size in editor section in MDHL file
This commit is contained in:
parent
11f06bf617
commit
eeaeb0b567
@ -46,7 +46,12 @@ void VLogger(QtMsgType type, const QMessageLogContext &context, const QString &m
|
|||||||
Q_UNUSED(context);
|
Q_UNUSED(context);
|
||||||
|
|
||||||
QTextStream stream(&g_logFile);
|
QTextStream stream(&g_logFile);
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
stream << header << localMsg << "\r\n";
|
||||||
|
#else
|
||||||
stream << header << localMsg << "\n";
|
stream << header << localMsg << "\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (type == QtFatalMsg) {
|
if (type == QtFatalMsg) {
|
||||||
g_logFile.close();
|
g_logFile.close();
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
# This is the default markdown styles used for Peg-Markdown-Highlight
|
# This is the default markdown styles used for Peg-Markdown-Highlight
|
||||||
# Created by Le Tan (tamlokveer@gmail.com)
|
# created by Le Tan(tamlokveer@gmail.com).
|
||||||
|
# For a complete description of the syntax, please refer to the original
|
||||||
|
# documentation of the style parser
|
||||||
|
# [The Syntax of PEG Markdown Highlight Stylesheets](http://hasseg.org/peg-markdown-highlight/docs/stylesheet_syntax.html).
|
||||||
|
# VNote adds some styles in the syntax which will be marked [VNote] in the comment.
|
||||||
|
#
|
||||||
|
# Note: Empty lines within a section is NOT allowed.
|
||||||
|
# Note: Do NOT modify this file directly. Copy it and tune your own style!
|
||||||
|
|
||||||
editor
|
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
|
# [VNote] Style for trailing space
|
||||||
trailing-space: ffebee
|
trailing-space: ffebee
|
||||||
|
font-size: 12
|
||||||
|
|
||||||
editor-selection
|
editor-selection
|
||||||
foreground: eeeeee
|
foreground: eeeeee
|
||||||
@ -14,9 +22,13 @@ background: 005fff
|
|||||||
|
|
||||||
editor-current-line
|
editor-current-line
|
||||||
background: c5cae9
|
background: c5cae9
|
||||||
|
# [VNote] Vim insert mode cursor line background
|
||||||
vim-insert-background: cdc0b0
|
vim-insert-background: cdc0b0
|
||||||
|
# [VNote] Vim normal mode cursor line background
|
||||||
vim-normal-background: b0bec5
|
vim-normal-background: b0bec5
|
||||||
|
# [VNote] Vim visual mode cursor line background
|
||||||
vim-visual-background: 90caf9
|
vim-visual-background: 90caf9
|
||||||
|
# [VNote] Vim replace mode cursor line background
|
||||||
vim-replace-background: f8bbd0
|
vim-replace-background: f8bbd0
|
||||||
|
|
||||||
H1
|
H1
|
||||||
@ -97,7 +109,7 @@ foreground: 93a1a1
|
|||||||
VERBATIM
|
VERBATIM
|
||||||
foreground: 551a8b
|
foreground: 551a8b
|
||||||
font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
|
font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
|
||||||
# Codeblock sylte from HighlightJS (bold, italic, underlined, color)
|
# [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, color)
|
||||||
# The last occurence of the same attribute takes effect
|
# The last occurence of the same attribute takes effect
|
||||||
hljs-comment: 6c6c6c
|
hljs-comment: 6c6c6c
|
||||||
hljs-keyword: 0000ee
|
hljs-keyword: 0000ee
|
||||||
@ -114,6 +126,7 @@ hljs-selector-class: 880000
|
|||||||
hljs-quote: 880000
|
hljs-quote: 880000
|
||||||
hljs-template-tag: 880000
|
hljs-template-tag: 880000
|
||||||
hljs-deletion: 880000
|
hljs-deletion: 880000
|
||||||
|
# Could specify multiple attribute in one line
|
||||||
hljs-title: bold, 880000
|
hljs-title: bold, 880000
|
||||||
hljs-section: bold, 880000
|
hljs-section: bold, 880000
|
||||||
hljs-regexp: bc6060
|
hljs-regexp: bc6060
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
# Styles using 'Solarized' color scheme
|
# Styles using 'Solarized' color scheme
|
||||||
# by Ethan Schoonover: http://ethanschoonover.com/solarized
|
# by Ethan Schoonover: http://ethanschoonover.com/solarized
|
||||||
#
|
#
|
||||||
# (dark background version)
|
# (dark background version)
|
||||||
|
|
||||||
editor
|
editor
|
||||||
foreground: 93a1a1 # base1
|
foreground: 93a1a1 # base1
|
||||||
background: 002b36 # base03
|
background: 002b36 # base03
|
||||||
caret: ffffff
|
caret: ffffff
|
||||||
|
font-size: 12
|
||||||
|
|
||||||
editor-current-line
|
editor-current-line
|
||||||
background: 37474f
|
background: 37474f
|
||||||
vim-background: 004d40
|
vim-insert-background: 004d40
|
||||||
|
vim-normal-background: 004d40
|
||||||
|
vim-visual-background: 004d40
|
||||||
|
vim-replace-background: 004d40
|
||||||
|
|
||||||
H1
|
H1
|
||||||
foreground: 6c71c4 # violet
|
foreground: 6c71c4 # violet
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
# Styles using 'Solarized' color scheme
|
# Styles using 'Solarized' color scheme
|
||||||
# by Ethan Schoonover: http://ethanschoonover.com/solarized
|
# by Ethan Schoonover: http://ethanschoonover.com/solarized
|
||||||
#
|
#
|
||||||
# (light background version)
|
# (light background version)
|
||||||
|
|
||||||
editor
|
editor
|
||||||
foreground: 586e75 # base01
|
foreground: 586e75 # base01
|
||||||
background: fdf6e3 # base3
|
background: fdf6e3 # base3
|
||||||
caret: 000000
|
caret: 000000
|
||||||
|
font-size: 12
|
||||||
|
|
||||||
editor-current-line
|
editor-current-line
|
||||||
background: c5cae9
|
background: c5cae9
|
||||||
vim-background: a5d6a7
|
vim-insert-background: a5d6a7
|
||||||
|
vim-normal-background: a5d6a7
|
||||||
|
vim-visual-background: a5d6a7
|
||||||
|
vim-replace-background: a5d6a7
|
||||||
|
|
||||||
H1
|
H1
|
||||||
foreground: 6c71c4 # violet
|
foreground: 6c71c4 # violet
|
||||||
|
@ -13,7 +13,6 @@ auto_list=true
|
|||||||
current_background_color=System
|
current_background_color=System
|
||||||
current_render_background_color=System
|
current_render_background_color=System
|
||||||
language=System
|
language=System
|
||||||
editor_font_size=12
|
|
||||||
|
|
||||||
; 0 - Hoedown, 1 - Marked, 2 - Markdown-it, 3 - Showdown
|
; 0 - Hoedown, 1 - Marked, 2 - Markdown-it, 3 - Showdown
|
||||||
markdown_converter=2
|
markdown_converter=2
|
||||||
|
@ -66,12 +66,7 @@ void VConfigManager::initialize()
|
|||||||
outputDefaultCssStyle();
|
outputDefaultCssStyle();
|
||||||
outputDefaultEditorStyle();
|
outputDefaultEditorStyle();
|
||||||
|
|
||||||
m_editorFontSize = getConfigFromSettings("global", "editor_font_size").toInt();
|
m_defaultEditPalette = QTextEdit().palette();
|
||||||
if (m_editorFontSize <= 0) {
|
|
||||||
m_editorFontSize = 12;
|
|
||||||
}
|
|
||||||
baseEditFont.setPointSize(m_editorFontSize);
|
|
||||||
baseEditPalette = QTextEdit().palette();
|
|
||||||
|
|
||||||
m_editorStyle = getConfigFromSettings("global", "editor_style").toString();
|
m_editorStyle = getConfigFromSettings("global", "editor_style").toString();
|
||||||
|
|
||||||
@ -345,15 +340,18 @@ void VConfigManager::updateMarkdownEditStyle()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VStyleParser parser;
|
|
||||||
parser.parseMarkdownStyle(styleStr);
|
|
||||||
mdHighlightingStyles = parser.fetchMarkdownStyles(baseEditFont);
|
|
||||||
m_codeBlockStyles = parser.fetchCodeBlockStyles(baseEditFont);
|
|
||||||
mdEditPalette = baseEditPalette;
|
mdEditPalette = baseEditPalette;
|
||||||
mdEditFont = baseEditFont;
|
mdEditFont = baseEditFont;
|
||||||
|
|
||||||
|
VStyleParser parser;
|
||||||
|
parser.parseMarkdownStyle(styleStr);
|
||||||
|
|
||||||
QMap<QString, QMap<QString, QString>> styles;
|
QMap<QString, QMap<QString, QString>> styles;
|
||||||
parser.fetchMarkdownEditorStyles(mdEditPalette, mdEditFont, styles);
|
parser.fetchMarkdownEditorStyles(mdEditPalette, mdEditFont, styles);
|
||||||
|
|
||||||
|
mdHighlightingStyles = parser.fetchMarkdownStyles(mdEditFont);
|
||||||
|
m_codeBlockStyles = parser.fetchCodeBlockStyles(mdEditFont);
|
||||||
|
|
||||||
m_editorCurrentLineBg = defaultCurrentLineBackground;
|
m_editorCurrentLineBg = defaultCurrentLineBackground;
|
||||||
m_editorVimInsertBg = defaultVimInsertBg;
|
m_editorVimInsertBg = defaultVimInsertBg;
|
||||||
m_editorVimNormalBg = defaultVimNormalBg;
|
m_editorVimNormalBg = defaultVimNormalBg;
|
||||||
@ -400,7 +398,11 @@ void VConfigManager::updateMarkdownEditStyle()
|
|||||||
|
|
||||||
void VConfigManager::updateEditStyle()
|
void VConfigManager::updateEditStyle()
|
||||||
{
|
{
|
||||||
static const QColor defaultColor = baseEditPalette.color(QPalette::Base);
|
// Reset font and palette.
|
||||||
|
baseEditFont = mdEditFont = m_defaultEditFont;
|
||||||
|
baseEditPalette = mdEditPalette = m_defaultEditPalette;
|
||||||
|
|
||||||
|
static const QColor defaultColor = m_defaultEditPalette.color(QPalette::Base);
|
||||||
QColor newColor = defaultColor;
|
QColor newColor = defaultColor;
|
||||||
bool force = false;
|
bool force = false;
|
||||||
if (curBackgroundColor != "System") {
|
if (curBackgroundColor != "System") {
|
||||||
@ -411,6 +413,7 @@ void VConfigManager::updateEditStyle()
|
|||||||
newColor = QColor(VUtils::QRgbFromString(rgb));
|
newColor = QColor(VUtils::QRgbFromString(rgb));
|
||||||
force = true;
|
force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,6 +424,11 @@ void VConfigManager::updateEditStyle()
|
|||||||
// Update markdown editor palette
|
// Update markdown editor palette
|
||||||
updateMarkdownEditStyle();
|
updateMarkdownEditStyle();
|
||||||
|
|
||||||
|
// Base editor will use the same font size as the markdown editor by now.
|
||||||
|
if (mdEditFont.pointSize() > -1) {
|
||||||
|
baseEditFont.setPointSize(mdEditFont.pointSize());
|
||||||
|
}
|
||||||
|
|
||||||
if (force) {
|
if (force) {
|
||||||
mdEditPalette.setColor(QPalette::Base, newColor);
|
mdEditPalette.setColor(QPalette::Base, newColor);
|
||||||
}
|
}
|
||||||
|
@ -236,13 +236,21 @@ private:
|
|||||||
// the new one; if not, use the c_dirConfigFile.
|
// the new one; if not, use the c_dirConfigFile.
|
||||||
static QString fetchDirConfigFilePath(const QString &p_path);
|
static QString fetchDirConfigFilePath(const QString &p_path);
|
||||||
|
|
||||||
int m_editorFontSize;
|
// Default font and palette.
|
||||||
|
QFont m_defaultEditFont;
|
||||||
|
QPalette m_defaultEditPalette;
|
||||||
|
|
||||||
|
// Font and palette used for non-markdown editor.
|
||||||
QFont baseEditFont;
|
QFont baseEditFont;
|
||||||
QPalette baseEditPalette;
|
QPalette baseEditPalette;
|
||||||
|
|
||||||
|
// Font and palette used for markdown editor.
|
||||||
QFont mdEditFont;
|
QFont mdEditFont;
|
||||||
QPalette mdEditPalette;
|
QPalette mdEditPalette;
|
||||||
|
|
||||||
QVector<HighlightingStyle> mdHighlightingStyles;
|
QVector<HighlightingStyle> mdHighlightingStyles;
|
||||||
QHash<QString, QTextCharFormat> m_codeBlockStyles;
|
QHash<QString, QTextCharFormat> m_codeBlockStyles;
|
||||||
|
|
||||||
QString welcomePagePath;
|
QString welcomePagePath;
|
||||||
QString m_templateCss;
|
QString m_templateCss;
|
||||||
QString m_editorStyle;
|
QString m_editorStyle;
|
||||||
|
@ -187,6 +187,12 @@ void VStyleParser::fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
|
|||||||
{
|
{
|
||||||
QString ruleKey;
|
QString ruleKey;
|
||||||
|
|
||||||
|
int basePointSize = font.pointSize();
|
||||||
|
if (basePointSize == -1) {
|
||||||
|
// The size is specified in pixel. Use 11 pt by default.
|
||||||
|
basePointSize = 11;
|
||||||
|
}
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
pmh_style_attribute *editorStyles = markdownStyles->editor_styles;
|
pmh_style_attribute *editorStyles = markdownStyles->editor_styles;
|
||||||
ruleKey = "editor";
|
ruleKey = "editor";
|
||||||
@ -212,6 +218,21 @@ void VStyleParser::fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case pmh_attr_type_font_size_pt:
|
||||||
|
{
|
||||||
|
pmh_attr_font_size *fontSize = editorStyles->value->font_size;
|
||||||
|
int ptSize = fontSize->size_pt;
|
||||||
|
if (fontSize->is_relative) {
|
||||||
|
ptSize += basePointSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ptSize > 0) {
|
||||||
|
font.setPointSize(ptSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Get custom styles:
|
// Get custom styles:
|
||||||
// trailing-space.
|
// trailing-space.
|
||||||
case pmh_attr_type_other:
|
case pmh_attr_type_other:
|
||||||
|
@ -23,9 +23,12 @@ public:
|
|||||||
|
|
||||||
void parseMarkdownStyle(const QString &styleStr);
|
void parseMarkdownStyle(const QString &styleStr);
|
||||||
QVector<HighlightingStyle> fetchMarkdownStyles(const QFont &baseFont) const;
|
QVector<HighlightingStyle> fetchMarkdownStyles(const QFont &baseFont) const;
|
||||||
|
|
||||||
|
// Fetch style sections: editor, editor-selection, editor-current-line.
|
||||||
// @styles: [rule] -> ([attr] -> value).
|
// @styles: [rule] -> ([attr] -> value).
|
||||||
void fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
|
void fetchMarkdownEditorStyles(QPalette &palette, QFont &font,
|
||||||
QMap<QString, QMap<QString, QString>> &styles) const;
|
QMap<QString, QMap<QString, QString>> &styles) const;
|
||||||
|
|
||||||
QHash<QString, QTextCharFormat> fetchCodeBlockStyles(const QFont &p_baseFont) const;
|
QHash<QString, QTextCharFormat> fetchCodeBlockStyles(const QFont &p_baseFont) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user