fix tab stop width temporarily

This commit is contained in:
Le Tan 2018-11-29 21:26:42 +08:00
parent 05a42bd2bb
commit 7928874936
11 changed files with 40 additions and 12 deletions

View File

@ -90,6 +90,9 @@ pre {
display: block; display: block;
overflow-y: hidden; overflow-y: hidden;
overflow-x: auto; overflow-x: auto;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
code { code {
@ -108,6 +111,9 @@ pre code {
line-height: 1.5; line-height: 1.5;
font-family: Consolas, Monaco, Monospace, Courier; font-family: Consolas, Monaco, Monospace, Courier;
white-space: pre; white-space: pre;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
pre code.markdown-metadata { pre code.markdown-metadata {
@ -337,6 +343,6 @@ table.hljs-ln tr td.hljs-ln-code {
} }
::selection { ::selection {
background: #1976D2; background: #8CBAE8;
color: #DADADA; color: #DADADA;
} }

View File

@ -9,7 +9,7 @@ mdhl_file=v_detorte.mdhl
css_file=v_detorte.css css_file=v_detorte.css
codeblock_css_file=v_detorte_codeblock.css codeblock_css_file=v_detorte_codeblock.css
mermaid_css_file=v_detorte_mermaid.css mermaid_css_file=v_detorte_mermaid.css
version=13 version=14
; This mapping will be used to translate colors when the content of HTML is copied ; This mapping will be used to translate colors when the content of HTML is copied
; without background. You could just specify the foreground colors mapping here. ; without background. You could just specify the foreground colors mapping here.

View File

@ -90,6 +90,9 @@ pre {
display: block; display: block;
overflow-y: hidden; overflow-y: hidden;
overflow-x: auto; overflow-x: auto;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
code { code {
@ -107,6 +110,9 @@ pre code {
line-height: 1.5; line-height: 1.5;
font-family: Consolas, Monaco, Monospace, Courier; font-family: Consolas, Monaco, Monospace, Courier;
white-space: pre; white-space: pre;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
pre code.markdown-metadata { pre code.markdown-metadata {
@ -335,6 +341,6 @@ table.hljs-ln tr td.hljs-ln-code {
} }
::selection { ::selection {
background: #1976D2; background: #8CBAE8;
color: #BCBCBC; color: #D0D0D0;
} }

View File

@ -7,7 +7,7 @@ mdhl_file=v_moonlight.mdhl
css_file=v_moonlight.css css_file=v_moonlight.css
codeblock_css_file=v_moonlight_codeblock.css codeblock_css_file=v_moonlight_codeblock.css
mermaid_css_file=v_moonlight_mermaid.css mermaid_css_file=v_moonlight_mermaid.css
version=24 version=25
; This mapping will be used to translate colors when the content of HTML is copied ; This mapping will be used to translate colors when the content of HTML is copied
; without background. You could just specify the foreground colors mapping here. ; without background. You could just specify the foreground colors mapping here.

View File

@ -85,6 +85,9 @@ pre {
display: block; display: block;
overflow-y: hidden; overflow-y: hidden;
overflow-x: auto; overflow-x: auto;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
code { code {
@ -102,6 +105,9 @@ pre code {
line-height: 1.5; line-height: 1.5;
font-family: Consolas, Monaco, Monospace, Courier; font-family: Consolas, Monaco, Monospace, Courier;
white-space: pre; white-space: pre;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
pre code.markdown-metadata { pre code.markdown-metadata {

View File

@ -7,7 +7,7 @@ mdhl_file=v_native.mdhl
css_file=v_native.css css_file=v_native.css
codeblock_css_file=v_native_codeblock.css codeblock_css_file=v_native_codeblock.css
mermaid_css_file=v_native_mermaid.css mermaid_css_file=v_native_mermaid.css
version=22 version=23
[phony] [phony]
; Abstract color attributes. ; Abstract color attributes.

View File

@ -86,6 +86,9 @@ pre {
display: block; display: block;
overflow-y: hidden; overflow-y: hidden;
overflow-x: auto; overflow-x: auto;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
code { code {
@ -104,6 +107,9 @@ pre code {
line-height: 1.5; line-height: 1.5;
font-family: Consolas, Monaco, Monospace, Courier; font-family: Consolas, Monaco, Monospace, Courier;
white-space: pre; white-space: pre;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
} }
pre code.markdown-metadata { pre code.markdown-metadata {

View File

@ -7,7 +7,7 @@ mdhl_file=v_pure.mdhl
css_file=v_pure.css css_file=v_pure.css
codeblock_css_file=v_pure_codeblock.css codeblock_css_file=v_pure_codeblock.css
mermaid_css_file=v_pure_mermaid.css mermaid_css_file=v_pure_mermaid.css
version=24 version=25
[phony] [phony]
; Abstract color attributes. ; Abstract color attributes.

View File

@ -10,6 +10,7 @@
#include "dialog/vinsertlinkdialog.h" #include "dialog/vinsertlinkdialog.h"
#include "utils/vmetawordmanager.h" #include "utils/vmetawordmanager.h"
#include "utils/vvim.h" #include "utils/vvim.h"
#include "vnote.h"
extern VConfigManager *g_config; extern VConfigManager *g_config;
@ -217,7 +218,10 @@ void VEditor::doUpdateTrailingSpaceAndTabHighlights()
void VEditor::updateEditConfig() void VEditor::updateEditConfig()
{ {
m_config.update(QFontMetrics(m_editor->font())); // FIXME: we need to use font of the code block here.
QFont font(m_editor->font());
font.setFamily(VNote::getMonospaceFont());
m_config.update(QFontMetrics(font));
if (m_config.m_tabStopWidth > 0) { if (m_config.m_tabStopWidth > 0) {
setTabStopWidthW(m_config.m_tabStopWidth); setTabStopWidthW(m_config.m_tabStopWidth);

View File

@ -222,7 +222,7 @@ QString VNote::getNavigationLabelStyle(const QString &p_str, bool p_small) const
static int pxHeight = 24; static int pxHeight = 24;
const int fontPt = p_small ? 12 : 15; const int fontPt = p_small ? 12 : 15;
QString fontFamily = getMonospacedFont(); QString fontFamily = getMonospaceFont();
if (p_str.size() != lastLen) { if (p_str.size() != lastLen) {
QFont font(fontFamily, fontPt); QFont font(fontFamily, fontPt);
@ -261,7 +261,7 @@ QString VNote::getNavigationLabelStyle(const QString &p_str, bool p_small) const
return style; return style;
} }
const QString &VNote::getMonospacedFont() const const QString &VNote::getMonospaceFont()
{ {
static QString font; static QString font;
if (font.isNull()) { if (font.isNull()) {

View File

@ -120,14 +120,14 @@ public:
static QString generateMathJaxPreviewTemplate(); static QString generateMathJaxPreviewTemplate();
static const QString &getMonospaceFont();
public slots: public slots:
void updateTemplate(); void updateTemplate();
void updateSimpletHtmlTemplate(); void updateSimpletHtmlTemplate();
private: private:
const QString &getMonospacedFont() const;
// Given the path of an external file, create a VOrphanFile struct. // Given the path of an external file, create a VOrphanFile struct.
VOrphanFile *getOrphanFile(const QString &p_path, VOrphanFile *getOrphanFile(const QString &p_path,
bool p_modifiable, bool p_modifiable,