From: Daniel Carl <danielcarl@gmx.de>
Date: Sat, 18 Apr 2015 21:52:04 +0000 (+0200)
Subject: Moved default hint css from js to config.def.h file (#199).
X-Git-Url: https://git.owens.tech/assets/dummy.html/assets/dummy.html/git?a=commitdiff_plain;h=476b624b704f4d74d17a304c18129fce0dca4dcf;p=vimb.git

Moved default hint css from js to config.def.h file (#199).

This makes it easier for user to adapt the hinting theme without the need to
overrule the style by style.css file or to patch the hints.js file.
---

diff --git a/src/config.def.h b/src/config.def.h
index fe9a2df..a74ce73 100644
--- a/src/config.def.h
+++ b/src/config.def.h
@@ -83,4 +83,30 @@
 #define PROGRESS_BAR_LEN            20
 #endif
 
+/* CSS style use on creating hints. This might also be averrules by css out of
+ * $XDG_CONFIG_HOME/vimb/style.css file. */
+#define HINT_CSS "._hintLabel{\
+-webkit-transform:translate(-4px,-4px);\
+position:absolute;\
+z-index:100000;\
+font:bold .8em monospace;\
+color:#000;\
+background-color:#fff;\
+margin:0;\
+padding:0px 1px;\
+border:1px solid #444;\
+opacity:0.7\
+}\
+._hintElem{\
+background-color:#ff0 !important;\
+color:#000 !important\
+}\
+._hintElem._hintFocus{\
+background-color:#8f0 !important\
+}\
+._hintLabel._hintFocus{\
+z-index:100001;\
+opacity:1\
+}"
+
 #endif /* end of include guard: _CONFIG_H */
diff --git a/src/hints.js b/src/hints.js
index c7db2ec..075af23 100644
--- a/src/hints.js
+++ b/src/hints.js
@@ -14,32 +14,7 @@ Object.freeze((function(){
         lClass   = "_hintLabel",       /* class used on the hint labels with the hint numbers */
         hClass   = "_hintElem",        /* marks hinted elements */
         fClass   = "_hintFocus",       /* marks focused element and focussed hint */
-        config,
-        style    = "." + lClass + "{" +
-            "-webkit-transform:translate(-4px,-4px);" +
-            "position:absolute;" +
-            "z-index:100000;" +
-            "font:bold\x20.8em\x20monospace;" +
-            "color:#000;" +
-            "background-color:#fff;" +
-            "margin:0;" +
-            "padding:0px 1px;" +
-            "border:1px solid #444;" +
-            "opacity:0.7" +
-            "}" +
-            "." + hClass + "{" +
-            "background-color:#ff0 !important;" +
-            "color:#000 !important" +
-            "}" +
-            "." + hClass + "." + fClass + "{" +
-            "background-color:#8f0 !important" +
-            "}" +
-            "." + lClass + "." + fClass + "{" +
-            /* use higher z-index to show the active label if it's overlapped by other labels */
-            "z-index:100001;" +
-            "opacity:1" +
-            "}";
-
+        config;
     /* the hint class used to maintain hinted element and labels */
     function Hint() {
         /* hide hint label and remove coloring from hinted element */
@@ -330,7 +305,8 @@ Object.freeze((function(){
             return;
         }
         var e = doc.createElement("style");
-        e.innerHTML = style;
+        /* HINT_CSS is replaces by the contents of the HINT_CSS constant from config.h */
+        e.innerHTML = "HINT_CSS";
         doc.head.appendChild(e);
         /* prevent us from adding the style multiple times */
         doc.hasStyle = true;
diff --git a/src/js2h.sh b/src/js2h.sh
index 871401e..d4d1f1a 100755
--- a/src/js2h.sh
+++ b/src/js2h.sh
@@ -10,5 +10,6 @@ cat $1 | \
     -e 's|\\x20| |g' \
     -e 's|\\|\\\\|g' \
     -e 's|"|\\"|g' \
+    -e 's|HINT_CSS|" HINT_CSS "|' \
     -e '$s/$/"/'
 echo ""