Browse Source

fix tab stop width temporarily

Le Tan 7 years ago
parent
commit
7928874936

+ 7 - 1
src/resources/themes/v_detorte/v_detorte.css

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

+ 1 - 1
src/resources/themes/v_detorte/v_detorte.palette

@@ -9,7 +9,7 @@ mdhl_file=v_detorte.mdhl
 css_file=v_detorte.css
 codeblock_css_file=v_detorte_codeblock.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
 ; without background. You could just specify the foreground colors mapping here.

+ 8 - 2
src/resources/themes/v_moonlight/v_moonlight.css

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

+ 1 - 1
src/resources/themes/v_moonlight/v_moonlight.palette

@@ -7,7 +7,7 @@ mdhl_file=v_moonlight.mdhl
 css_file=v_moonlight.css
 codeblock_css_file=v_moonlight_codeblock.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
 ; without background. You could just specify the foreground colors mapping here.

+ 6 - 0
src/resources/themes/v_native/v_native.css

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

+ 1 - 1
src/resources/themes/v_native/v_native.palette

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

+ 6 - 0
src/resources/themes/v_pure/v_pure.css

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

+ 1 - 1
src/resources/themes/v_pure/v_pure.palette

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

+ 5 - 1
src/veditor.cpp

@@ -10,6 +10,7 @@
 #include "dialog/vinsertlinkdialog.h"
 #include "utils/vmetawordmanager.h"
 #include "utils/vvim.h"
+#include "vnote.h"
 
 extern VConfigManager *g_config;
 
@@ -217,7 +218,10 @@ void VEditor::doUpdateTrailingSpaceAndTabHighlights()
 
 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) {
         setTabStopWidthW(m_config.m_tabStopWidth);

+ 2 - 2
src/vnote.cpp

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

+ 2 - 2
src/vnote.h

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